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 std::map<TString, IMethod*>::iterator it = fMethodMap.find( methodTag );
710 if (it == fMethodMap.end()) {
711 for (it = fMethodMap.begin(); it!=fMethodMap.end(); ++it) Log() <<
"M" << it->first <<
Endl;
712 Log() << kFATAL <<
"<EvaluateMVA> unknown classifier in map: " << method <<
"; "
713 <<
"you looked for " << methodTag<<
" while the available methods are : " <<
Endl;
715 else method = it->second;
724 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;
729 if (mvaVal == -9999999) mvaVal = kl->
GetMvaValue();
731 return kl->
GetProba( mvaVal, ap_sig );
740 std::map<TString, IMethod*>::iterator it = fMethodMap.find( methodTag );
741 if (it == fMethodMap.end()) {
742 for (it = fMethodMap.begin(); it!=fMethodMap.end(); ++it) Log() <<
"M" << it->first <<
Endl;
743 Log() << kFATAL <<
"<EvaluateMVA> unknown classifier in map: \"" << method <<
"\"; "
744 <<
"you looked for \"" << methodTag<<
"\" while the available methods are : " <<
Endl;
746 else method = it->second;
755 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;
760 if (mvaVal == -9999999) mvaVal = kl->
GetMvaValue();
774 size_t ipos = 0,
f = 0;
775 while (
f != varNames.length()) {
776 f = varNames.find(
':', ipos );
777 if (
f > varNames.length())
f = varNames.length();
778 std::string subs = varNames.substr( ipos,
f-ipos ); ipos =
f+1;
779 DataInfo().AddVariable( subs.c_str() );
792 for (
int i=0; i<
n+1 ; i++) {
793 format.Append(varNames(i));
794 if (varNames(i) ==
':' || i ==
n) {
798 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
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)