125 fDataSetManager( NULL ),
132 fMvaEventErrorUpper( 0 ),
150 fDataSetManager( NULL ),
157 fMvaEventErrorUpper( 0 ),
169 for (std::vector<TString>::iterator ivar = inputVars.begin(); ivar != inputVars.end(); ++ivar)
180 fDataSetManager( NULL ),
187 fMvaEventErrorUpper( 0 ),
199 for (std::vector<std::string>::iterator ivar = inputVars.begin(); ivar != inputVars.end(); ++ivar)
210 fDataSetManager( NULL ),
217 fMvaEventErrorUpper( 0 ),
238 fDataSetManager( NULL ),
245 fMvaEventErrorUpper( 0 ),
266 if (
gTools().CheckForSilentOption( GetOptions() )) Log().InhibitOutput();
268 DeclareOptionRef( fVerbose,
"V",
"Verbose flag" );
269 DeclareOptionRef( fColor,
"Color",
"Color flag (default True)" );
270 DeclareOptionRef( fSilent,
"Silent",
"Boolean silent flag (default False)" );
271 DeclareOptionRef( fCalculateError,
"Error",
"Calculates errors (default False)" );
279 delete fDataSetManager;
283 for (
auto it=fMethodMap.begin(); it!=fMethodMap.end(); it++){
294 if (Verbose()) fLogger->SetMinType( kVERBOSE );
305 DataInfo().AddVariable( expression,
"",
"", 0, 0,
'F',
kFALSE ,(
void*)datalink );
312 Log() << kFATAL <<
"Reader::AddVariable( const TString& expression, Int_t* datalink ), this function is deprecated, please provide all variables to the reader as floats" <<
Endl;
314 Log() << kFATAL <<
"Reader::AddVariable( const TString& expression, Int_t* datalink ), this function is deprecated, please provide all variables to the reader as floats" <<
Endl;
315 DataInfo().AddVariable(expression,
"",
"", 0, 0,
'I',
kFALSE, (
void*)datalink );
323 DataInfo().AddSpectator( expression,
"",
"", 0, 0,
'F',
kFALSE ,(
void*)datalink );
331 DataInfo().AddSpectator(expression,
"",
"", 0, 0,
'I',
kFALSE, (
void*)datalink );
341 Log() << kFATAL <<
"<BookMVA> fatal error: "
342 <<
"unable to open input weight file: " <<
filename <<
Endl;
355 fin.getline(buf,512);
356 while (!
TString(buf).BeginsWith(
"Method")) fin.getline(buf,512);
360 TString methodType = fullMethodName(0,fullMethodName.
Index(
"::"));
361 if (methodType.
Contains(
" ")) methodType = methodType(methodType.
Last(
' ')+1,methodType.
Length());
371 if (fMethodMap.find( methodTag ) != fMethodMap.end())
372 Log() << kFATAL <<
"<BookMVA> method tag \"" << methodTag <<
"\" already exists!" <<
Endl;
374 TString methodType(GetMethodTypeFromFile(weightfile));
376 Log() << kINFO <<
"Booking \"" << methodTag <<
"\" of type \"" << methodType <<
"\" from " << weightfile <<
"." <<
Endl;
383 Log() << kFATAL <<
"Method with type kCategory cannot be casted to MethodCategory. /Reader" <<
Endl;
387 return fMethodMap[methodTag] = method;
400 if (method==0)
return im;
405 Log() << kERROR <<
"Method with type kCategory cannot be casted to MethodCategory. /Reader" <<
Endl;
421 Log() << kINFO <<
"Booked classifier \"" << method->
GetMethodName()
437 if(!method)
return 0;
442 Log() << kFATAL <<
"Method with type kCategory cannot be casted to MethodCategory. /Reader" <<
Endl;
458 Log() << kINFO <<
"Booked classifier \"" << method->
GetMethodName()
471 IMethod* imeth = FindMVA( methodTag );
473 if(meth==0)
return 0;
476 Event* tmpEvent=
new Event(inputVec, DataInfo().GetNVariables());
477 for (
UInt_t i=0; i<inputVec.size(); i++){
479 Log() << kERROR << i <<
"-th variable of the event is NaN --> return MVA value -999, \n that's all I can do, please fix or remove this event." <<
Endl;
502 if(fTmpEvalVec.size() != inputVec.size())
503 fTmpEvalVec.resize(inputVec.size());
505 for (
UInt_t idx=0; idx!=inputVec.size(); idx++ )
506 fTmpEvalVec[idx]=inputVec[idx];
508 return EvaluateMVA( fTmpEvalVec, methodTag, aux );
518 std::map<TString, IMethod*>::iterator it = fMethodMap.find( methodTag );
519 if (it == fMethodMap.end()) {
520 Log() << kINFO <<
"<EvaluateMVA> unknown classifier in map; "
521 <<
"you looked for \"" << methodTag <<
"\" within available methods: " <<
Endl;
522 for (it = fMethodMap.begin(); it!=fMethodMap.end(); ++it) Log() <<
"--> " << it->first <<
Endl;
523 Log() <<
"Check calling string" << kFATAL <<
Endl;
526 else method = it->second;
531 Log() << kFATAL << methodTag <<
" is not a method" <<
Endl;
538 Log() << kERROR << i <<
"-th variable of the event is NaN --> return MVA value -999, \n that's all I can do, please fix or remove this event." <<
Endl;
542 return this->EvaluateMVA( kl, aux );
558 return method->
GetMvaValue( (fCalculateError?&fMvaEventError:0),
559 (fCalculateError?&fMvaEventErrorUpper:0) );
569 std::map<TString, IMethod*>::iterator it = fMethodMap.find( methodTag );
570 if (it == fMethodMap.end()) {
571 Log() << kINFO <<
"<EvaluateMVA> unknown method in map; "
572 <<
"you looked for \"" << methodTag <<
"\" within available methods: " <<
Endl;
573 for (it = fMethodMap.begin(); it!=fMethodMap.end(); ++it) Log() <<
"--> " << it->first <<
Endl;
574 Log() <<
"Check calling string" << kFATAL <<
Endl;
576 else method = it->second;
581 Log() << kFATAL << methodTag <<
" is not a method" <<
Endl;
587 Log() << kERROR << i <<
"-th variable of the event is NaN, \n regression values might evaluate to .. what do I know. \n sorry this warning is all I can do, please fix or remove this event." <<
Endl;
591 return this->EvaluateRegression( kl, aux );
604 Log() << kERROR << i <<
"-th variable of the event is NaN, \n regression values might evaluate to .. what do I know. \n sorry this warning is all I can do, please fix or remove this event." <<
Endl;
617 return EvaluateRegression(methodTag, aux).at(tgtNumber);
619 catch (std::out_of_range &) {
620 Log() << kWARNING <<
"Regression could not be evaluated for target-number " << tgtNumber <<
Endl;
634 std::map<TString, IMethod*>::iterator it = fMethodMap.find( methodTag );
635 if (it == fMethodMap.end()) {
636 Log() << kINFO <<
"<EvaluateMVA> unknown method in map; "
637 <<
"you looked for \"" << methodTag <<
"\" within available methods: " <<
Endl;
638 for (it = fMethodMap.begin(); it!=fMethodMap.end(); ++it) Log() <<
"--> " << it->first <<
Endl;
639 Log() <<
"Check calling string" << kFATAL <<
Endl;
641 else method = it->second;
646 Log() << kFATAL << methodTag <<
" is not a method" <<
Endl;
653 Log() << kERROR << i <<
"-th variable of the event is NaN, \n regression values might evaluate to .. what do I know. \n sorry this warning is all I can do, please fix or remove this event." <<
Endl;
657 return this->EvaluateMulticlass( kl, aux );
670 Log() << kERROR << i <<
"-th variable of the event is NaN, \n regression values might evaluate to .. what do I know. \n sorry this warning is all I can do, please fix or remove this event." <<
Endl;
683 return EvaluateMulticlass(methodTag, aux).at(clsNumber);
685 catch (std::out_of_range &) {
686 Log() << kWARNING <<
"Multiclass could not be evaluated for class-number " << clsNumber <<
Endl;
697 std::map<TString, IMethod*>::iterator it = fMethodMap.find( methodTag );
698 if (it != fMethodMap.end())
return it->second;
699 Log() << kERROR <<
"Method " << methodTag <<
" not found!" <<
Endl;
709 return dynamic_cast<MethodCuts*
>(FindMVA(methodTag));
718 std::map<TString, IMethod*>::iterator it = fMethodMap.find( methodTag );
719 if (it == fMethodMap.end()) {
720 for (it = fMethodMap.begin(); it!=fMethodMap.end(); ++it) Log() <<
"M" << it->first <<
Endl;
721 Log() << kFATAL <<
"<EvaluateMVA> unknown classifier in map: " << method <<
"; "
722 <<
"you looked for " << methodTag<<
" while the available methods are : " <<
Endl;
724 else method = it->second;
733 Log() << kERROR << i <<
"-th variable of the event is NaN --> return MVA value -999, \n that's all I can do, please fix or remove this event." <<
Endl;
738 if (mvaVal == -9999999) mvaVal = kl->
GetMvaValue();
740 return kl->
GetProba( mvaVal, ap_sig );
749 std::map<TString, IMethod*>::iterator it = fMethodMap.find( methodTag );
750 if (it == fMethodMap.end()) {
751 for (it = fMethodMap.begin(); it!=fMethodMap.end(); ++it) Log() <<
"M" << it->first <<
Endl;
752 Log() << kFATAL <<
"<EvaluateMVA> unknown classifier in map: \"" << method <<
"\"; "
753 <<
"you looked for \"" << methodTag<<
"\" while the available methods are : " <<
Endl;
755 else method = it->second;
764 Log() << kERROR << i <<
"-th variable of the event is NaN --> return MVA value -999, \n that's all I can do, please fix or remove this event." <<
Endl;
769 if (mvaVal == -9999999) mvaVal = kl->
GetMvaValue();
783 size_t ipos = 0,
f = 0;
784 while (
f != varNames.length()) {
785 f = varNames.find(
':', ipos );
786 if (
f > varNames.length())
f = varNames.length();
787 std::string subs = varNames.substr( ipos,
f-ipos ); ipos =
f+1;
788 DataInfo().AddVariable( subs.c_str() );
801 for (
int i=0; i<
n+1 ; i++) {
802 format.Append(varNames(i));
803 if (varNames(i) ==
':' || i ==
n) {
807 DataInfo().AddVariable( format_obj );
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
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
void SetUseColor(Bool_t uc)
void SetConfigName(const char *n)
virtual void ParseOptions()
options parser
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=nullptr)
add a variable (can be a complex expression) to the set of variables used in the MV analysis
Class that contains all the data information.
DataSetInfo & AddDataSetInfo(DataSetInfo &dsi)
stores a copy of the dataset info object
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
UInt_t GetNVariables() const
accessor to the number of variables
Interface for all concrete MVA method implementations.
Virtual base Class for all MVA method.
const std::vector< Float_t > & GetRegressionValues(const TMVA::Event *const ev)
virtual Double_t GetMvaValue(Double_t *errLower=nullptr, Double_t *errUpper=nullptr)=0
virtual void DeclareCompatibilityOptions()
options that are used ONLY for the READER to ensure backward compatibility they are hence without any...
TString GetMethodTypeName() const
virtual Double_t GetProba(const Event *ev)
virtual const std::vector< Float_t > & GetMulticlassValues()
void SetupMethod()
setup of methods
const TString & GetMethodName() const
const Event * GetEvent() const
void ReadStateFromXMLString(const char *xmlstr)
for reading from memory
void ReadStateFromFile()
Function to write options and weights to file.
virtual Double_t GetRarity(Double_t mvaVal, Types::ESBType reftype=Types::kBackground) const
compute rarity:
Types::EMVA GetMethodType() const
virtual void CheckSetup()
check may be overridden by derived class (sometimes, eg, fitters are used which can only be implement...
Class for categorizing the phase space.
DataSetManager * fDataSetManager
Multivariate optimisation of signal efficiency for given background efficiency, applying rectangular ...
void SetTestSignalEfficiency(Double_t effS)
ostringstream derivative to redirect and format output
const std::vector< Float_t > & EvaluateRegression(const TString &methodTag, Double_t aux=0)
evaluates MVA for given set of input variables
virtual const char * GetName() const
Returns name of object.
Double_t EvaluateMVA(const std::vector< Float_t > &, const TString &methodTag, Double_t aux=0)
Evaluate a std::vector<float> of input data for a given method The parameter aux is obligatory for th...
Double_t GetRarity(const TString &methodTag, Double_t mvaVal=-9999999)
evaluates the MVA's rarity
IMethod * FindMVA(const TString &methodTag)
return pointer to method with tag "methodTag"
void Init(void)
default initialisation (no member variables)
Double_t GetProba(const TString &methodTag, Double_t ap_sig=0.5, Double_t mvaVal=-9999999)
evaluates probability of MVA for given set of input variables
MethodCuts * FindCutsMVA(const TString &methodTag)
special function for Cuts to avoid dynamic_casts in ROOT macros, which are not properly handled by CI...
TString GetMethodTypeFromFile(const TString &filename)
read the method type from the file
DataSetManager * fDataSetManager
IMethod * BookMVA(const TString &methodTag, const TString &weightfile)
read method name from weight file
Reader(const TString &theOption="", Bool_t verbose=0)
constructor
const std::vector< Float_t > & EvaluateMulticlass(const TString &methodTag, Double_t aux=0)
evaluates MVA for given set of input variables
DataInputHandler fDataInputHandler
void DecodeVarNames(const std::string &varNames)
decodes "name1:name2:..." form
void DeclareOptions()
declaration of configuration options
void AddSpectator(const TString &expression, Float_t *)
Add a float spectator or expression to the reader.
void AddVariable(const TString &expression, Float_t *)
Add a float variable or expression to the reader.
virtual ~Reader(void)
destructor
MsgLogger * fLogger
message logger
const DataSetInfo & DataInfo() const
static Types & Instance()
The single instance of "Types" if existing already, or create it (Singleton)
TString & ReplaceAll(const TString &s1, const TString &s2)
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
void FreeDoc(XMLDocPointer_t xmldoc)
frees allocated document data and deletes document itself
XMLNodePointer_t DocGetRootElement(XMLDocPointer_t xmldoc)
returns root node of document
XMLDocPointer_t ParseFile(const char *filename, Int_t maxbuf=100000)
Parses content of file and tries to produce xml structures.
MsgLogger & Endl(MsgLogger &ml)