// @(#)root/tmva $Id$    
// Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss 

/**********************************************************************************
 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
 * Package: TMVA                                                                  *
 * Class  : MethodHMatrix                                                         *
 * Web    : http://tmva.sourceforge.net                                           *
 *                                                                                *
 * Description:                                                                   *
 *      H-Matrix method, which is implemented as a simple comparison of           *
 *      chi-squared estimators for signal and background, taking into account     *
 *      the linear correlations between the input variables.                      *
 *      Method is (also) used by D0 Collaboration (FNAL) for electron             *
 *      identification; for more information, see, eg,                            *
 *      http://www-d0.fnal.gov/d0dist/dist/packages/tau_hmchisq/devel/doc/        *
 *                                                                                *
 * Authors (alphabetical):                                                        *
 *      Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland              *
 *      Helge Voss      <Helge.Voss@cern.ch>     - MPI-K Heidelberg, Germany      *
 *      Kai Voss        <Kai.Voss@cern.ch>       - U. of Victoria, Canada         *
 *                                                                                *
 * Copyright (c) 2005:                                                            *
 *      CERN, Switzerland                                                         * 
 *      U. of Victoria, Canada                                                    * 
 *      MPI-K Heidelberg, Germany                                                 * 
 *                                                                                *
 * Redistribution and use in source and binary forms, with or without             *
 * modification, are permitted according to the terms listed in LICENSE           *
 * (http://tmva.sourceforge.net/LICENSE)                                          *
 **********************************************************************************/

#ifndef ROOT_TMVA_MethodHMatrix
#define ROOT_TMVA_MethodHMatrix

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// MethodHMatrix                                                        //
//                                                                      //
// H-Matrix method, which is implemented as a simple comparison of      // 
// chi-squared estimators for signal and background, taking into        //
// account the linear correlations between the input variables          //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TMVA_MethodBase
#include "TMVA/MethodBase.h"
#endif
#ifndef ROOT_TMVA_TMatrixDfwd
#ifndef ROOT_TMatrixDfwd
#include "TMatrixDfwd.h"
#endif
#endif
#ifndef ROOT_TMVA_TVectorD
#ifndef ROOT_TVectorD
#include "TVectorD.h"
#endif
#endif

namespace TMVA {

   class MethodHMatrix : public MethodBase {

   public:

      MethodHMatrix( const TString& jobName, 
                     const TString& methodTitle, 
                     DataSetInfo& theData,
                     const TString& theOption = "",
                     TDirectory* theTargetDir = 0 );

      MethodHMatrix( DataSetInfo& theData, 
                     const TString& theWeightFile,  
                     TDirectory* theTargetDir = NULL );

      virtual ~MethodHMatrix();
    
      virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );

      // training method
      void Train();

      using MethodBase::ReadWeightsFromStream;

      // write weights to file
      void AddWeightsXMLTo( void* parent ) const;

      // read weights from file
      void ReadWeightsFromStream( std::istream& istr );
      void ReadWeightsFromXML( void* wghtnode );
      // calculate the MVA value
      Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );

      // ranking of input variables
      const Ranking* CreateRanking() { return 0; }

   protected:

      // make ROOT-independent C++ class for classifier response (classifier-specific implementation)
      void MakeClassSpecific( std::ostream&, const TString& ) const;

      // get help message text
      void GetHelpMessage() const;

   private:

      // the option handling methods
      void DeclareOptions();
      void ProcessOptions();

      // returns chi2 estimator for given type (signal or background)
      Double_t GetChi2( Types::ESBType );

      // compute correlation matrices
      void     ComputeCovariance( Bool_t, TMatrixD* );

      // arrays of input evt vs. variable 
      TMatrixD* fInvHMatrixS; // inverse H-matrix (signal)
      TMatrixD* fInvHMatrixB; // inverse H-matrix (background)
      TVectorD* fVecMeanS;    // vector of mean values (signal)
      TVectorD* fVecMeanB;    // vector of mean values (background)

      // default initialisation method called by all constructors
      void Init(); 

      ClassDef(MethodHMatrix,0) // H-Matrix method, a simple comparison of chi-squared estimators for signal and background
   }; 

} // namespace TMVA

#endif
 MethodHMatrix.h:1
 MethodHMatrix.h:2
 MethodHMatrix.h:3
 MethodHMatrix.h:4
 MethodHMatrix.h:5
 MethodHMatrix.h:6
 MethodHMatrix.h:7
 MethodHMatrix.h:8
 MethodHMatrix.h:9
 MethodHMatrix.h:10
 MethodHMatrix.h:11
 MethodHMatrix.h:12
 MethodHMatrix.h:13
 MethodHMatrix.h:14
 MethodHMatrix.h:15
 MethodHMatrix.h:16
 MethodHMatrix.h:17
 MethodHMatrix.h:18
 MethodHMatrix.h:19
 MethodHMatrix.h:20
 MethodHMatrix.h:21
 MethodHMatrix.h:22
 MethodHMatrix.h:23
 MethodHMatrix.h:24
 MethodHMatrix.h:25
 MethodHMatrix.h:26
 MethodHMatrix.h:27
 MethodHMatrix.h:28
 MethodHMatrix.h:29
 MethodHMatrix.h:30
 MethodHMatrix.h:31
 MethodHMatrix.h:32
 MethodHMatrix.h:33
 MethodHMatrix.h:34
 MethodHMatrix.h:35
 MethodHMatrix.h:36
 MethodHMatrix.h:37
 MethodHMatrix.h:38
 MethodHMatrix.h:39
 MethodHMatrix.h:40
 MethodHMatrix.h:41
 MethodHMatrix.h:42
 MethodHMatrix.h:43
 MethodHMatrix.h:44
 MethodHMatrix.h:45
 MethodHMatrix.h:46
 MethodHMatrix.h:47
 MethodHMatrix.h:48
 MethodHMatrix.h:49
 MethodHMatrix.h:50
 MethodHMatrix.h:51
 MethodHMatrix.h:52
 MethodHMatrix.h:53
 MethodHMatrix.h:54
 MethodHMatrix.h:55
 MethodHMatrix.h:56
 MethodHMatrix.h:57
 MethodHMatrix.h:58
 MethodHMatrix.h:59
 MethodHMatrix.h:60
 MethodHMatrix.h:61
 MethodHMatrix.h:62
 MethodHMatrix.h:63
 MethodHMatrix.h:64
 MethodHMatrix.h:65
 MethodHMatrix.h:66
 MethodHMatrix.h:67
 MethodHMatrix.h:68
 MethodHMatrix.h:69
 MethodHMatrix.h:70
 MethodHMatrix.h:71
 MethodHMatrix.h:72
 MethodHMatrix.h:73
 MethodHMatrix.h:74
 MethodHMatrix.h:75
 MethodHMatrix.h:76
 MethodHMatrix.h:77
 MethodHMatrix.h:78
 MethodHMatrix.h:79
 MethodHMatrix.h:80
 MethodHMatrix.h:81
 MethodHMatrix.h:82
 MethodHMatrix.h:83
 MethodHMatrix.h:84
 MethodHMatrix.h:85
 MethodHMatrix.h:86
 MethodHMatrix.h:87
 MethodHMatrix.h:88
 MethodHMatrix.h:89
 MethodHMatrix.h:90
 MethodHMatrix.h:91
 MethodHMatrix.h:92
 MethodHMatrix.h:93
 MethodHMatrix.h:94
 MethodHMatrix.h:95
 MethodHMatrix.h:96
 MethodHMatrix.h:97
 MethodHMatrix.h:98
 MethodHMatrix.h:99
 MethodHMatrix.h:100
 MethodHMatrix.h:101
 MethodHMatrix.h:102
 MethodHMatrix.h:103
 MethodHMatrix.h:104
 MethodHMatrix.h:105
 MethodHMatrix.h:106
 MethodHMatrix.h:107
 MethodHMatrix.h:108
 MethodHMatrix.h:109
 MethodHMatrix.h:110
 MethodHMatrix.h:111
 MethodHMatrix.h:112
 MethodHMatrix.h:113
 MethodHMatrix.h:114
 MethodHMatrix.h:115
 MethodHMatrix.h:116
 MethodHMatrix.h:117
 MethodHMatrix.h:118
 MethodHMatrix.h:119
 MethodHMatrix.h:120
 MethodHMatrix.h:121
 MethodHMatrix.h:122
 MethodHMatrix.h:123
 MethodHMatrix.h:124
 MethodHMatrix.h:125
 MethodHMatrix.h:126
 MethodHMatrix.h:127
 MethodHMatrix.h:128
 MethodHMatrix.h:129
 MethodHMatrix.h:130
 MethodHMatrix.h:131