111 #ifndef ROOT_TMVA_Tools 128 fDataSetManager(
NULL ),
133 fCalculateError(kFALSE),
135 fMvaEventErrorUpper( 0 ),
139 fDataSetManager->AddDataSetInfo(fDataSetInfo);
141 SetConfigName( GetName() );
153 fDataSetManager(
NULL ),
160 fMvaEventErrorUpper( 0 ),
172 for (std::vector<TString>::iterator ivar = inputVars.begin(); ivar != inputVars.end(); ivar++)
202 for (std::vector<std::string>::iterator ivar = inputVars.begin(); ivar != inputVars.end(); ivar++)
311 Log() <<
kFATAL <<
"Reader::AddVariable( const TString& expression, Int_t* datalink ), this function is deprecated, please provide all variables to the reader as floats" <<
Endl;
313 Log() <<
kFATAL <<
"Reader::AddVariable( const TString& expression, Int_t* datalink ), this function is deprecated, please provide all variables to the reader as floats" <<
Endl;
338 std::ifstream fin( filename );
340 Log() <<
kFATAL <<
"<BookMVA> fatal error: " 341 <<
"unable to open input weight file: " << filename <<
Endl;
347 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,29,0) 358 fin.getline(buf,512);
363 TString methodType = fullMethodName(0,fullMethodName.
Index(
"::"));
364 if (methodType.
Contains(
" ")) methodType = methodType(methodType.
Last(
' ')+1,methodType.
Length());
375 Log() <<
kFATAL <<
"<BookMVA> method tag \"" << methodTag <<
"\" already exists!" <<
Endl;
379 Log() <<
kINFO <<
"Booking \"" << methodTag <<
"\" of type \"" << methodType <<
"\" from " << weightfile <<
"." <<
Endl;
386 Log() <<
kFATAL <<
"Method with type kCategory cannot be casted to MethodCategory. /Reader" <<
Endl;
403 if (method==0)
return im;
408 Log() <<
kERROR <<
"Method with type kCategory cannot be casted to MethodCategory. /Reader" <<
Endl;
434 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,26,00) 442 if(!method)
return 0;
447 Log() <<
kFATAL <<
"Method with type kCategory cannot be casted to MethodCategory. /Reader" <<
Endl;
468 Log() <<
kFATAL <<
"Method Reader::BookMVA(TMVA::Types::EMVA methodType = " << methodType
469 <<
", const char* xmlstr = " << xmlstr
470 <<
" ) is not available for ROOT versions prior to 5.26/00." <<
Endl;
484 if(meth==0)
return 0;
488 for (
UInt_t i=0; i<inputVec.size(); i++){
490 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;
516 for (
UInt_t idx=0; idx!=inputVec.size(); idx++ )
529 std::map<TString, IMethod*>::iterator it =
fMethodMap.find( methodTag );
531 Log() <<
kINFO <<
"<EvaluateMVA> unknown classifier in map; " 532 <<
"you looked for \"" << methodTag <<
"\" within available methods: " <<
Endl;
537 else method = it->second;
549 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;
580 std::map<TString, IMethod*>::iterator it =
fMethodMap.find( methodTag );
582 Log() <<
kINFO <<
"<EvaluateMVA> unknown method in map; " 583 <<
"you looked for \"" << methodTag <<
"\" within available methods: " <<
Endl;
587 else method = it->second;
598 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;
615 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;
630 catch (std::out_of_range e) {
631 Log() <<
kWARNING <<
"Regression could not be evaluated for target-number " << tgtNumber <<
Endl;
645 std::map<TString, IMethod*>::iterator it =
fMethodMap.find( methodTag );
647 Log() <<
kINFO <<
"<EvaluateMVA> unknown method in map; " 648 <<
"you looked for \"" << methodTag <<
"\" within available methods: " <<
Endl;
652 else method = it->second;
664 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;
681 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;
696 catch (std::out_of_range e) {
697 Log() <<
kWARNING <<
"Multiclass could not be evaluated for class-number " << clsNumber <<
Endl;
708 std::map<TString, IMethod*>::iterator it =
fMethodMap.find( methodTag );
709 if (it !=
fMethodMap.end())
return it->second;
710 Log() <<
kERROR <<
"Method " << methodTag <<
" not found!" <<
Endl;
729 std::map<TString, IMethod*>::iterator it =
fMethodMap.find( methodTag );
732 Log() <<
kFATAL <<
"<EvaluateMVA> unknown classifier in map: " << method <<
"; " 733 <<
"you looked for " << methodTag<<
" while the available methods are : " <<
Endl;
735 else method = it->second;
744 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;
749 if (mvaVal == -9999999) mvaVal = kl->
GetMvaValue();
751 return kl->
GetProba( mvaVal, ap_sig );
760 std::map<TString, IMethod*>::iterator it =
fMethodMap.find( methodTag );
763 Log() <<
kFATAL <<
"<EvaluateMVA> unknown classifier in map: \"" << method <<
"\"; " 764 <<
"you looked for \"" << methodTag<<
"\" while the available methods are : " <<
Endl;
766 else method = it->second;
775 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;
780 if (mvaVal == -9999999) mvaVal = kl->
GetMvaValue();
794 size_t ipos = 0,
f = 0;
795 while (
f != varNames.length()) {
796 f = varNames.find(
':', ipos );
797 if (
f > varNames.length())
f = varNames.length();
798 std::string subs = varNames.substr( ipos,
f-ipos ); ipos =
f+1;
812 for (
int i=0; i< n+1 ; i++) {
813 format.
Append(varNames(i));
814 if (varNames(i) ==
':' || i == n) {
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
std::map< TString, IMethod * > fMethodMap
virtual const std::vector< Float_t > & GetMulticlassValues()
MsgLogger & Endl(MsgLogger &ml)
virtual Double_t GetMvaValue(Double_t *errLower=0, Double_t *errUpper=0)=0
virtual ~Reader(void)
destructor
void AddVariable(const TString &expression, Float_t *)
Add a float variable or expression to the reader.
TString & ReplaceAll(const TString &s1, const TString &s2)
void SetTestSignalEfficiency(Double_t effS)
OptionBase * DeclareOptionRef(T &ref, const TString &name, const TString &desc="")
Double_t fMvaEventErrorUpper
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.
const std::vector< Float_t > & GetRegressionValues(const TMVA::Event *const ev)
static const char * filename()
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Double_t GetRarity(const TString &methodTag, Double_t mvaVal=-9999999)
evaluates the MVA's rarity
static std::string format(double x, double y, int digits, int width)
void FreeDoc(XMLDocPointer_t xmldoc)
frees allocated document data and deletes document itself
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...
void DecodeVarNames(const std::string &varNames)
decodes "name1:name2:..." form
static Types & Instance()
the the single instance of "Types" if existin already, or create it (Signleton)
static void InhibitOutput()
TString GetMethodTypeFromFile(const TString &filename)
read the method type from the file
const Event * GetEvent() const
DataInputHandler fDataInputHandler
void Init(TClassEdit::TInterpreterLookupHelper *helper)
void DeclareOptions()
declaration of configuration options
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: R(x) = Integrate_[-oo..x] { PDF(x') dx' } where PDF(x) is the PDF of the classifier's...
TString & Append(const char *cs)
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
virtual void ParseOptions()
options parser
void SetupMethod()
setup of methods
void SetMinType(EMsgType minType)
IMethod * BookMVA(const TString &methodTag, const TString &weightfile)
read method name from weight file
virtual Double_t GetProba(const Event *ev)
DataSetManager * fDataSetManager
void ReadStateFromXMLString(const char *xmlstr)
for reading from memory
std::vector< Float_t > fTmpEvalVec
std::string GetMethodName(TCppMethod_t)
DataSetInfo & AddDataSetInfo(DataSetInfo &dsi)
stores a copy of the dataset info object
DataSetManager * fDataSetManager
const TString & GetMethodName() const
Bool_t Verbose(void) const
UInt_t GetNVariables() const
accessor to the number of variables
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
Reader(const TString &theOption="", Bool_t verbose=0)
constructor
XMLDocPointer_t ParseFile(const char *filename, Int_t maxbuf=100000)
Parses content of file and tries to produce xml structures.
virtual void CheckSetup()
check may be overridden by derived class (sometimes, eg, fitters are used which can only be implement...
void AddSpectator(const TString &expression, Float_t *)
Add a float spectator or expression to the reader.
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
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...
void Init(void)
default initialisation (no member variables) default initialisation (no member variables) ...
const TString & GetOptions() const
void SetUseColor(Bool_t uc)
void SetConfigName(const char *n)
Abstract ClassifierFactory template that handles arbitrary types.
IMethod * FindMVA(const TString &methodTag)
return pointer to method with tag "methodTag"
TString GetMethodTypeName() const
virtual void DeclareCompatibilityOptions()
options that are used ONLY for the READER to ensure backward compatibility they are hence without any...
XMLNodePointer_t DocGetRootElement(XMLDocPointer_t xmldoc)
returns root node of document
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 ...
const DataSetInfo & DataInfo() const
Types::EMVA GetMethodType() const
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
const std::vector< Float_t > & EvaluateMulticlass(const TString &methodTag, Double_t aux=0)
evaluates MVA for given set of input variables
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
MethodCuts * FindCutsMVA(const TString &methodTag)
special function for Cuts to avoid dynamic_casts in ROOT macros, which are not properly handled by CI...