/usr/include/root/TMVA/Factory.h is in libroot-tmva-dev 5.34.14-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | // @(#)root/tmva $Id$
// Author: Andreas Hoecker, Peter Speckmayer, Joerg Stelzer, Helge Voss, Kai Voss, Eckhard von Toerne, Jan Therhaag
/**********************************************************************************
* Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
* Package: TMVA *
* Class : Factory *
* Web : http://tmva.sourceforge.net *
* *
* Description: *
* This is the main MVA steering class: it creates (books) all MVA methods, *
* and guides them through the training, testing and evaluation phases. *
* *
* Authors (alphabetical): *
* Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
* Joerg Stelzer <stelzer@cern.ch> - DESY, Germany *
* Peter Speckmayer <peter.speckmayer@cern.ch> - CERN, Switzerland *
* Jan Therhaag <Jan.Therhaag@cern.ch> - U of Bonn, Germany *
* Eckhard v. Toerne <evt@uni-bonn.de> - U of Bonn, Germany *
* Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
* Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada *
* *
* Copyright (c) 2005-2011: *
* CERN, Switzerland *
* U. of Victoria, Canada *
* MPI-K Heidelberg, Germany *
* U. of Bonn, 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_Factory
#define ROOT_TMVA_Factory
//////////////////////////////////////////////////////////////////////////
// //
// Factory //
// //
// This is the main MVA steering class: it creates all MVA methods, //
// and guides them through the training, testing and evaluation //
// phases //
// //
//////////////////////////////////////////////////////////////////////////
#include <string>
#include <vector>
#include <map>
#ifndef ROOT_TCut
#include "TCut.h"
#endif
#ifndef ROOT_TMVA_Configurable
#include "TMVA/Configurable.h"
#endif
#ifndef ROOT_TMVA_Types
#include "TMVA/Types.h"
#endif
#ifndef ROOT_TMVA_DataSet
#include "TMVA/DataSet.h"
#endif
class TFile;
class TTree;
class TDirectory;
namespace TMVA {
class IMethod;
class MethodBase;
class DataInputHandler;
class DataSetInfo;
class DataSetManager;
class VariableTransformBase;
class Factory : public Configurable {
public:
typedef std::vector<IMethod*> MVector;
// no default constructor
Factory( TString theJobName, TFile* theTargetFile, TString theOption = "" );
// default destructor
virtual ~Factory();
virtual const char* GetName() const { return "Factory"; }
// add events to training and testing trees
void AddSignalTrainingEvent ( const std::vector<Double_t>& event, Double_t weight = 1.0 );
void AddBackgroundTrainingEvent( const std::vector<Double_t>& event, Double_t weight = 1.0 );
void AddSignalTestEvent ( const std::vector<Double_t>& event, Double_t weight = 1.0 );
void AddBackgroundTestEvent ( const std::vector<Double_t>& event, Double_t weight = 1.0 );
void AddTrainingEvent( const TString& className, const std::vector<Double_t>& event, Double_t weight );
void AddTestEvent ( const TString& className, const std::vector<Double_t>& event, Double_t weight );
void AddEvent ( const TString& className, Types::ETreeType tt, const std::vector<Double_t>& event, Double_t weight );
Bool_t UserAssignEvents(UInt_t clIndex);
TTree* CreateEventAssignTrees( const TString& name );
DataSetInfo& AddDataSet( DataSetInfo& );
DataSetInfo& AddDataSet( const TString& );
// special case: signal/background
// Data input related
void SetInputTrees( const TString& signalFileName, const TString& backgroundFileName,
Double_t signalWeight=1.0, Double_t backgroundWeight=1.0 );
void SetInputTrees( TTree* inputTree, const TCut& SigCut, const TCut& BgCut );
// Set input trees at once
void SetInputTrees( TTree* signal, TTree* background,
Double_t signalWeight=1.0, Double_t backgroundWeight=1.0) ;
void AddSignalTree( TTree* signal, Double_t weight=1.0, Types::ETreeType treetype = Types::kMaxTreeType );
void AddSignalTree( TString datFileS, Double_t weight=1.0, Types::ETreeType treetype = Types::kMaxTreeType );
void AddSignalTree( TTree* signal, Double_t weight, const TString& treetype );
// ... depreciated, kept for backwards compatibility
void SetSignalTree( TTree* signal, Double_t weight=1.0);
void AddBackgroundTree( TTree* background, Double_t weight=1.0, Types::ETreeType treetype = Types::kMaxTreeType );
void AddBackgroundTree( TString datFileB, Double_t weight=1.0, Types::ETreeType treetype = Types::kMaxTreeType );
void AddBackgroundTree( TTree* background, Double_t weight, const TString & treetype );
// ... depreciated, kept for backwards compatibility
void SetBackgroundTree( TTree* background, Double_t weight=1.0 );
void SetSignalWeightExpression( const TString& variable );
void SetBackgroundWeightExpression( const TString& variable );
// special case: regression
void AddRegressionTree( TTree* tree, Double_t weight = 1.0,
Types::ETreeType treetype = Types::kMaxTreeType ) {
AddTree( tree, "Regression", weight, "", treetype );
}
// general
// Data input related
void SetTree( TTree* tree, const TString& className, Double_t weight ); // depreciated
void AddTree( TTree* tree, const TString& className, Double_t weight=1.0,
const TCut& cut = "",
Types::ETreeType tt = Types::kMaxTreeType );
void AddTree( TTree* tree, const TString& className, Double_t weight, const TCut& cut, const TString& treeType );
// set input variable
void SetInputVariables ( std::vector<TString>* theVariables ); // depreciated
void AddVariable ( const TString& expression, const TString& title, const TString& unit,
char type='F', Double_t min = 0, Double_t max = 0 );
void AddVariable ( const TString& expression, char type='F',
Double_t min = 0, Double_t max = 0 );
void AddTarget ( const TString& expression, const TString& title = "", const TString& unit = "",
Double_t min = 0, Double_t max = 0 );
void AddRegressionTarget( const TString& expression, const TString& title = "", const TString& unit = "",
Double_t min = 0, Double_t max = 0 )
{
AddTarget( expression, title, unit, min, max );
}
void AddSpectator ( const TString& expression, const TString& title = "", const TString& unit = "",
Double_t min = 0, Double_t max = 0 );
// set weight for class
void SetWeightExpression( const TString& variable, const TString& className = "" );
// set cut for class
void SetCut( const TString& cut, const TString& className = "" );
void SetCut( const TCut& cut, const TString& className = "" );
void AddCut( const TString& cut, const TString& className = "" );
void AddCut( const TCut& cut, const TString& className = "" );
// prepare input tree for training
void PrepareTrainingAndTestTree( const TCut& cut, const TString& splitOpt );
void PrepareTrainingAndTestTree( TCut sigcut, TCut bkgcut, const TString& splitOpt );
// ... deprecated, kept for backwards compatibility
void PrepareTrainingAndTestTree( const TCut& cut, Int_t Ntrain, Int_t Ntest = -1 );
void PrepareTrainingAndTestTree( const TCut& cut, Int_t NsigTrain, Int_t NbkgTrain, Int_t NsigTest, Int_t NbkgTest,
const TString& otherOpt="SplitMode=Random:!V" );
MethodBase* BookMethod( TString theMethodName, TString methodTitle, TString theOption = "" );
MethodBase* BookMethod( Types::EMVA theMethod, TString methodTitle, TString theOption = "" );
MethodBase* BookMethod( TMVA::Types::EMVA /*theMethod*/,
TString /*methodTitle*/,
TString /*methodOption*/,
TMVA::Types::EMVA /*theComposite*/,
TString /*compositeOption = ""*/ ) { return 0; }
// optimize all booked methods (well, if desired by the method)
void OptimizeAllMethods (TString fomType="ROCIntegral", TString fitType="FitGA");
void OptimizeAllMethodsForClassification(TString fomType="ROCIntegral", TString fitType="FitGA") { OptimizeAllMethods(fomType,fitType); }
void OptimizeAllMethodsForRegression (TString fomType="ROCIntegral", TString fitType="FitGA") { OptimizeAllMethods(fomType,fitType); }
// training for all booked methods
void TrainAllMethods ();
void TrainAllMethodsForClassification( void ) { TrainAllMethods(); }
void TrainAllMethodsForRegression ( void ) { TrainAllMethods(); }
// testing
void TestAllMethods();
// performance evaluation
void EvaluateAllMethods( void );
void EvaluateAllVariables( TString options = "" );
// delete all methods and reset the method vector
void DeleteAllMethods( void );
// accessors
IMethod* GetMethod( const TString& title ) const;
Bool_t Verbose( void ) const { return fVerbose; }
void SetVerbose( Bool_t v=kTRUE );
// make ROOT-independent C++ class for classifier response
// (classifier-specific implementation)
// If no classifier name is given, help messages for all booked
// classifiers are printed
virtual void MakeClass( const TString& methodTitle = "" ) const;
// prints classifier-specific hepl messages, dedicated to
// help with the optimisation and configuration options tuning.
// If no classifier name is given, help messages for all booked
// classifiers are printed
void PrintHelpMessage( const TString& methodTitle = "" ) const;
static TDirectory* RootBaseDir() { return (TDirectory*)fgTargetFile; }
private:
// the beautiful greeting message
void Greetings();
void WriteDataInformation();
DataInputHandler& DataInput() { return *fDataInputHandler; }
DataSetInfo& DefaultDataSetInfo();
void SetInputTreesFromEventAssignTrees();
private:
// data members
DataSetManager* fDataSetManager; // DSMTEST
static TFile* fgTargetFile; //! ROOT output file
DataInputHandler* fDataInputHandler;
std::vector<TMVA::VariableTransformBase*> fDefaultTrfs; //! list of transformations on default DataSet
// cd to local directory
TString fOptions; //! option string given by construction (presently only "V")
TString fTransformations; //! List of transformations to test
Bool_t fVerbose; //! verbose mode
MVector fMethods; //! all MVA methods
TString fJobName; //! jobname, used as extension in weight file names
// flag determining the way training and test data are assigned to Factory
enum DataAssignType { kUndefined = 0,
kAssignTrees,
kAssignEvents };
DataAssignType fDataAssignType; //! flags for data assigning
std::vector<TTree*> fTrainAssignTree; //! for each class: tmp tree if user wants to assign the events directly
std::vector<TTree*> fTestAssignTree; //! for each class: tmp tree if user wants to assign the events directly
Int_t fATreeType; // type of event (=classIndex)
Float_t fATreeWeight; // weight of the event
Float_t* fATreeEvent; // event variables
Types::EAnalysisType fAnalysisType; //! the training type
protected:
ClassDef(Factory,0) // The factory creates all MVA methods, and performs their training and testing
};
} // namespace TMVA
#endif
|