Logo ROOT   6.08/07
Reference Guide
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 #ifndef ROOT_TMVA_MethodBase
47 #include "TMVA/MethodBase.h"
48 #endif
49 #ifndef ROOT_TMVA_TMatrixDfwd
50 #ifndef ROOT_TMatrixDfwd
51 #include "TMatrixDfwd.h"
52 #endif
53 #endif
54 #ifndef ROOT_TMVA_TVectorD
55 #ifndef ROOT_TVectorD
56 #include "TVectorD.h"
57 #endif
58 #endif
59 
60 namespace TMVA {
61 
62  class MethodHMatrix : public MethodBase {
63 
64  public:
65 
66  MethodHMatrix( const TString& jobName,
67  const TString& methodTitle,
68  DataSetInfo& theData,
69  const TString& theOption = "");
70 
71  MethodHMatrix( DataSetInfo& theData,
72  const TString& theWeightFile);
73 
74  virtual ~MethodHMatrix();
75 
76  virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
77 
78  // training method
79  void Train();
80 
82 
83  // write weights to file
84  void AddWeightsXMLTo( void* parent ) const;
85 
86  // read weights from file
87  void ReadWeightsFromStream( std::istream& istr );
88  void ReadWeightsFromXML( void* wghtnode );
89  // calculate the MVA value
90  Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );
91 
92  // ranking of input variables
93  const Ranking* CreateRanking() { return 0; }
94 
95  protected:
96 
97  // make ROOT-independent C++ class for classifier response (classifier-specific implementation)
98  void MakeClassSpecific( std::ostream&, const TString& ) const;
99 
100  // get help message text
101  void GetHelpMessage() const;
102 
103  private:
104 
105  // the option handling methods
106  void DeclareOptions();
107  void ProcessOptions();
108 
109  // returns chi2 estimator for given type (signal or background)
111 
112  // compute correlation matrices
114 
115  // arrays of input evt vs. variable
116  TMatrixD* fInvHMatrixS; // inverse H-matrix (signal)
117  TMatrixD* fInvHMatrixB; // inverse H-matrix (background)
118  TVectorD* fVecMeanS; // vector of mean values (signal)
119  TVectorD* fVecMeanB; // vector of mean values (background)
120 
121  // default initialisation method called by all constructors
122  void Init();
123 
124  ClassDef(MethodHMatrix,0); // H-Matrix method, a simple comparison of chi-squared estimators for signal and background
125  };
126 
127 } // namespace TMVA
128 
129 #endif
void ReadWeightsFromXML(void *wghtnode)
read weights from XML file
void Init()
default initialization called by all constructors
Double_t GetMvaValue(Double_t *err=0, Double_t *errUpper=0)
returns the H-matrix signal estimator
void ProcessOptions()
process user options
virtual Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
FDA can handle classification with 2 classes and regression with one regression-target.
EAnalysisType
Definition: Types.h:129
void MakeClassSpecific(std::ostream &, const TString &) const
write Fisher-specific classifier response
Basic string class.
Definition: TString.h:137
bool Bool_t
Definition: RtypesCore.h:59
TMatrixD * fInvHMatrixS
void ReadWeightsFromStream(std::istream &istr)
read variable names and min/max NOTE: the latter values are mandatory for the normalisation in the re...
virtual ~MethodHMatrix()
destructor
#define ClassDef(name, id)
Definition: Rtypes.h:254
void AddWeightsXMLTo(void *parent) const
create XML description for HMatrix classification
unsigned int UInt_t
Definition: RtypesCore.h:42
void Train()
computes H-matrices for signal and background samples
MethodHMatrix(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="")
standard constructor for the H-Matrix method
double Double_t
Definition: RtypesCore.h:55
void ComputeCovariance(Bool_t, TMatrixD *)
compute covariance matrix
int type
Definition: TGX11.cxx:120
const Ranking * CreateRanking()
Definition: MethodHMatrix.h:93
void GetHelpMessage() const
get help message text
Abstract ClassifierFactory template that handles arbitrary types.
void DeclareOptions()
MethodHMatrix options: none (apart from those implemented in MethodBase)
TMatrixD * fInvHMatrixB
virtual void ReadWeightsFromStream(std::istream &)=0
Double_t GetChi2(Types::ESBType)
compute chi2-estimator for event according to type (signal/background)