108 std::vector<TTreeFormula*>::iterator formIt =
fCatFormulas.begin();
109 std::vector<TTreeFormula*>::iterator lastF =
fCatFormulas.end();
110 for(;formIt!=lastF; ++formIt)
delete *formIt;
120 std::vector<IMethod*>::iterator itrMethod =
fMethods.begin();
123 for(; itrMethod !=
fMethods.end(); ++itrMethod ) {
124 if ( !(*itrMethod)->HasAnalysisType(type, numberClasses, numberTargets) )
148 Log() <<
kINFO <<
"Adding sub-classifier: " << addedMethodName <<
"::" << theTitle <<
Endl;
155 if(method==0)
return 0;
185 fVars.push_back(theVariables);
207 TString dsiName=theTitle+
"_dsi";
216 std::vector<VariableInfo>::iterator itrVarInfo;
228 std::vector<UInt_t> varMap;
232 std::vector<TString>::iterator itrVariables;
236 for (itrVariables = variables.begin(); itrVariables != variables.end(); itrVariables++) {
241 if((*itrVariables==itrVarInfo->GetLabel()) ) {
245 varMap.push_back(counter);
253 if((*itrVariables==itrVarInfo->GetLabel()) ) {
257 varMap.push_back(counter);
265 Log() <<
kFATAL <<
"The variable " << itrVariables->Data() <<
" was not found and could not be added " <<
Endl;
271 if (theVariables==
"") {
285 for (
UInt_t i=0; i<nClasses; i++) {
289 dsi->
AddCut(theCut,className);
318 std::vector<VariableInfo>::const_iterator viIt;
323 for (viIt = vars.begin(); viIt != vars.end(); ++viIt)
324 if( viIt->GetExternalLink() == 0 ) {
325 hasAllExternalLinks =
kFALSE;
328 for (viIt = specs.begin(); viIt != specs.end(); ++viIt)
329 if( viIt->GetExternalLink() == 0 ) {
330 hasAllExternalLinks =
kFALSE;
334 if(!hasAllExternalLinks)
return;
346 for (viIt = vars.begin(); viIt != vars.end(); ++viIt) {
350 for (viIt = specs.begin(); viIt != specs.end(); ++viIt) {
372 Log() <<
kINFO <<
"Train all sub-classifiers for " 381 std::vector<IMethod*>::iterator itrMethod;
384 for (itrMethod =
fMethods.begin(); itrMethod !=
fMethods.end(); ++itrMethod ) {
397 itrMethod =
fMethods.erase( itrMethod );
410 <<
" not trained (training tree has less entries [" 412 <<
"] than required [" << MinNoTrainingEvents <<
"]" <<
Endl;
414 Log() <<
kERROR <<
" w/o training/test events for that category, I better stop here and let you fix " <<
Endl;
415 Log() <<
kFATAL <<
"that one first, otherwise things get too messy later ... " <<
Endl;
423 Log() <<
kINFO <<
"Begin ranking of input variables..." <<
Endl;
424 for (itrMethod =
fMethods.begin(); itrMethod !=
fMethods.end(); itrMethod++) {
427 const Ranking* ranking = (*itrMethod)->CreateRanking();
431 Log() <<
kINFO <<
"No variable ranking supplied by classifier: " 447 std::vector<IMethod*>::iterator itrMethod;
476 Log() <<
kINFO <<
"Recreating sub-classifiers from XML-file " <<
Endl;
479 for (
UInt_t i=0; i<nSubMethods; i++) {
485 methodType = fullMethodName(0,fullMethodName.
Index(
"::"));
486 if (methodType.
Contains(
" ")) methodType = methodType(methodType.
Last(
' ')+1,methodType.
Length());
489 titleLength = fullMethodName.
Length()-fullMethodName.
Index(
"::")-2;
490 methodTitle = fullMethodName(fullMethodName.
Index(
"::")+2,titleLength);
499 Log() <<
kFATAL <<
"Could not create sub-method " << method <<
" from XML." <<
Endl;
506 fVars.push_back(theVariables);
510 UInt_t spectatorIdx = 10000;
515 std::vector<VariableInfo>::iterator itrVarInfo;
518 for (itrVarInfo = spectators.begin(); itrVarInfo != spectators.end(); ++itrVarInfo, ++counter) {
519 if((specName==itrVarInfo->GetLabel()) || (specName==itrVarInfo->GetExpression())) {
520 spectatorIdx=counter;
551 Log() <<
"This method allows to define different categories of events. The" <<
Endl;
552 Log() <<
"categories are defined via cuts on the variables. For each" <<
Endl;
553 Log() <<
"category, a different classifier and set of variables can be" <<
Endl;
554 Log() <<
"specified. The categories which are defined for this method must" <<
Endl;
555 Log() <<
"be disjoint." <<
Endl;
575 Log() <<
kFATAL <<
"Large method index " << methodIdx <<
", number of category formulas = " 586 Log() <<
kFATAL <<
"Unknown method index " << methodIdx <<
" maximum allowed index=" 591 Bool_t pass = (specVal>0.5);
607 Int_t suitableCutsN = 0;
616 if (suitableCutsN == 0) {
617 Log() <<
kWARNING <<
"Event does not lie within the cut of any sub-classifier." <<
Endl;
621 if (suitableCutsN > 1) {
622 Log() <<
kFATAL <<
"The defined categories are not disjoint." <<
Endl;
647 Int_t suitableCutsN = 0;
656 if (suitableCutsN == 0) {
657 Log() <<
kWARNING <<
"Event does not lie within the cut of any sub-classifier." <<
Endl;
661 if (suitableCutsN > 1) {
662 Log() <<
kFATAL <<
"The defined categories are not disjoint." <<
Endl;
667 Log() <<
kFATAL <<
"method not found in Category Regression method" <<
Endl;
IMethod * Create(const std::string &name, const TString &job, const TString &title, DataSetInfo &dsi, const TString &option)
creates the method if needed based on the method name using the creator function the factory has stor...
static ClassifierFactory & Instance()
access to the ClassifierFactory singleton creates the instance if needed
Types::EAnalysisType fAnalysisType
std::vector< IMethod * > fMethods
void SetModelPersistence(Bool_t status)
virtual const char * GetName() const
Returns name of object.
void Init()
initialize the method
void WriteStateToXML(void *parent) const
general method used in writing the header of the weight files where the used variables, variable transformation type etc.
TMVA::IMethod * AddMethod(const TCut &, const TString &theVariables, Types::EMVA theMethod, const TString &theTitle, const TString &theOptions)
adds sub-classifier for a category
MsgLogger & Endl(MsgLogger &ml)
VariableInfo & AddTarget(const TString &expression, const TString &title, const TString &unit, Double_t min, Double_t max, Bool_t normalized=kTRUE, void *external=0)
add a variable (can be a complex expression) to the set of variables used in the MV analysis ...
void ReadStateFromXML(void *parent)
std::vector< VariableInfo > & GetSpectatorInfos()
void SetCut(const TCut &cut, const TString &className)
set the cut for the classes
void InitCircularTree(const DataSetInfo &dsi)
initialize the circular tree
static Types & Instance()
the the single instance of "Types" if existin already, or create it (Signleton)
void SetMethodBaseDir(TDirectory *methodDir)
std::vector< TCut > fCategoryCuts
const std::vector< Float_t > & GetRegressionValues(const TMVA::Event *const ev)
std::vector< UInt_t > fCategorySpecIdx
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual const std::vector< Float_t > & GetRegressionValues()
UInt_t GetNClasses() const
virtual ~MethodCategory(void)
destructor
void AddCut(const TCut &cut, const TString &className)
set the cut for the classes
void SetSilentFile(Bool_t status)
virtual Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)=0
const TString & GetExpression() const
VariableInfo & AddSpectator(const TString &expression, const TString &title, const TString &unit, Double_t min, Double_t max, char type='F', Bool_t normalized=kTRUE, void *external=0)
add a spectator (can be a complex expression) to the set of spectator variables used in the MV analys...
const TString & GetNormalization() const
std::vector< std::vector< UInt_t > > fVarMaps
void DeclareOptions()
options for this method
const Event * GetEvent() const
void SetVariableArrangement(std::vector< UInt_t > *const m) const
set the variable arrangement
virtual void ParseOptions()
options parser
void SetupMethod()
setup of methods
DataSetInfo & DataInfo() const
Long64_t GetNTrainingEvents() const
std::vector< VariableInfo > & GetTargetInfos()
TDirectory * GetRootDir() const
A specialized string object used for TTree selections.
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 Int_t MinNoTrainingEvents
void SetSplitOptions(const TString &so)
const Ranking * CreateRanking()
no ranking
void * GetExternalLink() const
UInt_t GetNTargets() const
TMVA::DataSetInfo & CreateCategoryDSI(const TCut &, const TString &, const TString &)
create a DataSetInfo object for a sub-classifier
const char * GetName() const
ClassInfo * GetClassInfo(Int_t clNum) const
void SetWeightExpression(const TString &exp, const TString &className="")
set the weight expressions for the classes if class name is specified, set only for this class if cla...
DataSetInfo & AddDataSetInfo(DataSetInfo &dsi)
stores a copy of the dataset info object
char * Form(const char *fmt,...)
DataSetManager * fDataSetManager
const TString & GetJobName() const
const TString & GetMethodName() const
void Train(void)
train all sub-classifiers
virtual void Print() const
get maximum length of variable names
virtual void CheckSetup()
check may be overridden by derived class (sometimes, eg, fitters are used which can only be implement...
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Describe directory structure in memory.
void SetFile(TFile *file)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
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...
ClassInfo * AddClass(const TString &className)
void ProcessSetup()
process all options the "CheckForUnusedOptions" is done in an independent call, since it may be overr...
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
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Create one branch for each element in the collection.
#define REGISTER_METHOD(CLASS)
for example
Abstract ClassifierFactory template that handles arbitrary types.
const TString & GetSplitOptions() const
TDirectory * BaseDir() const
returns the ROOT directory where info/histograms etc of the corresponding MVA method instance are sto...
TString GetMethodTypeName() const
const TCut & GetCut(Int_t i) const
void SetWeightFileDir(TString fileDir)
set directory of weight file
void AddWeightsXMLTo(void *parent) const
create XML description of Category classifier
virtual TDirectory * GetDirectory(const char *namecycle, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory using apath.
virtual void SetCircular(Long64_t maxEntries)
Enable/Disable circularity for this tree.
VariableInfo & AddVariable(const TString &expression, const TString &title="", const TString &unit="", Double_t min=0, Double_t max=0, char varType='F', Bool_t normalized=kTRUE, void *external=0)
add a variable (can be a complex expression) to the set of variables used in the MV analysis ...
void DisableWriting(Bool_t setter)
Types::EAnalysisType GetAnalysisType() const
A TTree object has a header with a name and a title.
void ReadWeightsFromXML(void *wghtnode)
read weights of sub-classifiers of MethodCategory from xml weight file
Bool_t PassesCut(const Event *ev, UInt_t methodIdx)
Float_t GetSpectator(UInt_t ivar) const
return spectator content
const TString GetWeightExpression(Int_t i) const
double norm(double *x, double *p)
void SetNormalization(const TString &norm)
void SetRootDir(TDirectory *d)
virtual const std::vector< Float_t > & GetRegressionValues()
returns the mva value of the right sub-classifier
std::vector< VariableInfo > & GetVariableInfos()
void variables(TString dataset, TString fin="TMVA.root", TString dirName="InputVariables_Id", TString title="TMVA Input Variables", Bool_t isRegression=kFALSE, Bool_t useTMVAStyle=kTRUE)
virtual void SetAnalysisType(Types::EAnalysisType type)
virtual const char * GetTitle() const
Returns title of object.
void ProcessOptions()
process user options
const char * Data() const