Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
MethodHMatrix.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : MethodHMatrix *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * H-Matrix method, which is implemented as a simple comparison of *
12  * chi-squared estimators for signal and background, taking into account *
13  * the linear correlations between the input variables. *
14  * Method is (also) used by D0 Collaboration (FNAL) for electron *
15  * identification; for more information, see, eg, *
16  * http://www-d0.fnal.gov/d0dist/dist/packages/tau_hmchisq/devel/doc/ *
17  * *
18  * Authors (alphabetical): *
19  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
20  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
21  * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada *
22  * *
23  * Copyright (c) 2005: *
24  * CERN, Switzerland *
25  * U. of Victoria, Canada *
26  * MPI-K Heidelberg, Germany *
27  * *
28  * Redistribution and use in source and binary forms, with or without *
29  * modification, are permitted according to the terms listed in LICENSE *
30  * (http://tmva.sourceforge.net/LICENSE) *
31  **********************************************************************************/
32 
33 #ifndef ROOT_TMVA_MethodHMatrix
34 #define ROOT_TMVA_MethodHMatrix
35 
36 //////////////////////////////////////////////////////////////////////////
37 // //
38 // MethodHMatrix //
39 // //
40 // H-Matrix method, which is implemented as a simple comparison of //
41 // chi-squared estimators for signal and background, taking into //
42 // account the linear correlations between the input variables //
43 // //
44 //////////////////////////////////////////////////////////////////////////
45 
46 #include "TMVA/MethodBase.h"
47 #include "TMatrixDfwd.h"
48 #include "TVectorD.h"
49 
50 namespace TMVA {
51 
52  class MethodHMatrix : public MethodBase {
53 
54  public:
55 
56  MethodHMatrix( const TString& jobName,
57  const TString& methodTitle,
58  DataSetInfo& theData,
59  const TString& theOption = "");
60 
61  MethodHMatrix( DataSetInfo& theData,
62  const TString& theWeightFile);
63 
64  virtual ~MethodHMatrix();
65 
66  virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
67 
68  // training method
69  void Train();
70 
71  using MethodBase::ReadWeightsFromStream;
72 
73  // write weights to file
74  void AddWeightsXMLTo( void* parent ) const;
75 
76  // read weights from file
77  void ReadWeightsFromStream( std::istream& istr );
78  void ReadWeightsFromXML( void* wghtnode );
79  // calculate the MVA value
80  Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );
81 
82  // ranking of input variables
83  const Ranking* CreateRanking() { return 0; }
84 
85  protected:
86 
87  // make ROOT-independent C++ class for classifier response (classifier-specific implementation)
88  void MakeClassSpecific( std::ostream&, const TString& ) const;
89 
90  // get help message text
91  void GetHelpMessage() const;
92 
93  private:
94 
95  // the option handling methods
96  void DeclareOptions();
97  void ProcessOptions();
98 
99  // returns chi2 estimator for given type (signal or background)
100  Double_t GetChi2( Types::ESBType );
101 
102  // compute correlation matrices
103  void ComputeCovariance( Bool_t, TMatrixD* );
104 
105  // arrays of input evt vs. variable
106  TMatrixD* fInvHMatrixS; // inverse H-matrix (signal)
107  TMatrixD* fInvHMatrixB; // inverse H-matrix (background)
108  TVectorD* fVecMeanS; // vector of mean values (signal)
109  TVectorD* fVecMeanB; // vector of mean values (background)
110 
111  // default initialisation method called by all constructors
112  void Init();
113 
114  ClassDef(MethodHMatrix,0); // H-Matrix method, a simple comparison of chi-squared estimators for signal and background
115  };
116 
117 } // namespace TMVA
118 
119 #endif