Logo ROOT   6.08/07
Reference Guide
MethodCategory.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss,Or Cohen
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : MethodCompositeBase *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Virtual base class for all MVA method *
12  * *
13  * Authors (alphabetical): *
14  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15  * Joerg Stelzer <Joerg.Stelzer@cern.ch> - CERN, Switzerland *
16  * Peter Speckmayer <Peter.Speckmayer@cern.ch> - CERN, Switzerland *
17  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
18  * Eckhard v. Toerne <evt@uni-bonn.de> - U of Bonn, Germany *
19  * *
20  * Copyright (c) 2005: *
21  * CERN, Switzerland *
22  * U. of Victoria, Canada *
23  * MPI-K Heidelberg, Germany *
24  * LAPP, Annecy, France *
25  * *
26  * Redistribution and use in source and binary forms, with or without *
27  * modification, are permitted according to the terms listed in LICENSE *
28  * (http://tmva.sourceforge.net/LICENSE) *
29  **********************************************************************************/
30 
31 #ifndef ROOT_TMVA_MethodCategory
32 #define ROOT_TMVA_MethodCategory
33 
34 //////////////////////////////////////////////////////////////////////////
35 // //
36 // MethodCategory //
37 // //
38 // Class for categorizing the phase space //
39 // //
40 //////////////////////////////////////////////////////////////////////////
41 
42 #include <iosfwd>
43 #include <vector>
44 
45 #ifndef ROOT_TMVA_MethodBase
46 #include "TMVA/MethodBase.h"
47 #endif
48 
49 #ifndef ROOT_TMVA_MethodCompositeBase
51 #endif
52 
53 namespace TMVA {
54 
55  class Factory; // DSMTEST
56  class Reader; // DSMTEST
57  class MethodBoost; // DSMTEST
58  class DataSetManager; // DSMTEST
59 
61 
62  public :
63 
64  // constructors
65  MethodCategory( const TString& jobName,
66  const TString& methodTitle,
67  DataSetInfo& theData,
68  const TString& theOption = "" );
69 
71  const TString& theWeightFile );
72 
73  virtual ~MethodCategory( void );
74 
75  virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t /*numberTargets*/ );
76  // training and boosting all the classifiers
77  void Train( void );
78 
79  // ranking of input variables
80  const Ranking* CreateRanking();
81 
82  // saves the name and options string of the boosted classifier
84  const TString& theVariables,
85  Types::EMVA theMethod,
86  const TString& theTitle,
87  const TString& theOptions);
88 
89  void AddWeightsXMLTo( void* parent ) const;
90  void ReadWeightsFromXML( void* wghtnode );
91 
92  Double_t GetMvaValue( Double_t* err=0, Double_t* errUpper = 0 );
93 
94  // regression response
95  virtual const std::vector<Float_t>& GetRegressionValues();
96 
97  virtual void MakeClass( const TString& = TString("") ) const {};
98 
99  private :
100 
101  // initializing mostly monitoring tools of the category process
102  void Init();
103 
104  // the option handling methods
105  void DeclareOptions();
106  void ProcessOptions();
107 
108  // build the cut formula for event categorization
109  Bool_t PassesCut( const Event* ev, UInt_t methodIdx );
110 
111  protected:
112 
113  // vectors that contain the added methods and the cuts on which they are to be called
114  std::vector<IMethod*> fMethods;
115  std::vector<TCut> fCategoryCuts;
116  std::vector<UInt_t> fCategorySpecIdx;
117  std::vector<TString> fVars;
118  std::vector <std::vector <UInt_t> > fVarMaps;
119 
120  // get help message text
121  void GetHelpMessage() const;
122 
123  TMVA::DataSetInfo& CreateCategoryDSI(const TCut&, const TString&, const TString&);
124 
125  private:
126 
127  void InitCircularTree(const DataSetInfo& dsi);
128 
129  TTree * fCatTree; //! needed in conjunction with TTreeFormulas for evaluation category expressions
130  std::vector<TTreeFormula*> fCatFormulas;
131 
133  friend class Factory; // DSMTEST
134  friend class Reader; // DSMTEST
135  friend class MethodBoost; // DSMTEST
136 
138  };
139 }
140 
141 #endif
std::vector< IMethod * > fMethods
void Init()
initialize the method
TMVA::IMethod * AddMethod(const TCut &, const TString &theVariables, Types::EMVA theMethod, const TString &theTitle, const TString &theOptions)
adds sub-classifier for a category
virtual void MakeClass(const TString &=TString("")) const
create reader class for method (classification only at present)
void InitCircularTree(const DataSetInfo &dsi)
initialize the circular tree
EAnalysisType
Definition: Types.h:129
std::vector< TCut > fCategoryCuts
std::vector< UInt_t > fCategorySpecIdx
Basic string class.
Definition: TString.h:137
bool Bool_t
Definition: RtypesCore.h:59
virtual ~MethodCategory(void)
destructor
std::vector< std::vector< UInt_t > > fVarMaps
#define ClassDef(name, id)
Definition: Rtypes.h:254
void DeclareOptions()
options for this method
A specialized string object used for TTree selections.
Definition: TCut.h:27
std::vector< TTreeFormula * > fCatFormulas
needed in conjunction with TTreeFormulas for evaluation category expressions
MethodCategory(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="")
standard constructor
const Ranking * CreateRanking()
no ranking
TMVA::DataSetInfo & CreateCategoryDSI(const TCut &, const TString &, const TString &)
create a DataSetInfo object for a sub-classifier
unsigned int UInt_t
Definition: RtypesCore.h:42
DataSetManager * fDataSetManager
void Train(void)
train all sub-classifiers
double Double_t
Definition: RtypesCore.h:55
int type
Definition: TGX11.cxx:120
virtual Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t)
check whether method category has analysis type the method type has to be the same for all sub-method...
std::vector< TString > fVars
void GetHelpMessage() const
Get help message text.
Double_t GetMvaValue(Double_t *err=0, Double_t *errUpper=0)
returns the mva value of the right sub-classifier
Abstract ClassifierFactory template that handles arbitrary types.
void AddWeightsXMLTo(void *parent) const
create XML description of Category classifier
A TTree object has a header with a name and a title.
Definition: TTree.h:98
void ReadWeightsFromXML(void *wghtnode)
read weights of sub-classifiers of MethodCategory from xml weight file
Bool_t PassesCut(const Event *ev, UInt_t methodIdx)
virtual const std::vector< Float_t > & GetRegressionValues()
returns the mva value of the right sub-classifier
void ProcessOptions()
process user options