ROOT logo
ROOT » TMVA » TMVA::Reader

class TMVA::Reader: public TMVA::Configurable


  The Reader class serves to use the MVAs in a specific analysis context.
  Within an event loop, a vector is filled that corresponds to the variables
  that were used to train the MVA(s) during the training stage. This vector
  is transfered to the Reader, who takes care of interpreting the weight
  file of the MVA of choice, and to return the MVA's output. This is then
  used by the user for further analysis.


  Usage:

    // ------ before starting the event loop (eg, in the initialisation step)


    // create TMVA::Reader object

    TMVA::Reader *reader = new TMVA::Reader();

    // create a set of variables and declare them to the reader
    // - the variable names must corresponds in name and type to
    // those given in the weight file(s) that you use
    Float_t var1, var2, var3, var4;
    reader->AddVariable( "var1", &var1 );
    reader->AddVariable( "var2", &var2 );
    reader->AddVariable( "var3", &var3 );
    reader->AddVariable( "var4", &var4 );

    // book the MVA of your choice (prior training of these methods, ie,
    // existence of the weight files is required)
    reader->BookMVA( "Fisher method",  "weights/Fisher.weights.txt"   );
    reader->BookMVA( "MLP method",     "weights/MLP.weights.txt" );
    // ... etc

    // ------- start your event loop

    for (Long64_t ievt=0; ievt<myTree->GetEntries();ievt++) {

      // fill vector with values of variables computed from those in the tree
      var1 = myvar1;
      var2 = myvar2;
      var3 = myvar3;
      var4 = myvar4;

      // retrieve the corresponding MVA output
      double mvaFi = reader->EvaluateMVA( "Fisher method" );
      double mvaNN = reader->EvaluateMVA( "MLP method"    );

      // do something with these ...., e.g., fill them into your ntuple

    } // end of event loop

    delete reader;


  An example application of the Reader can be found in TMVA/macros/TMVApplication.C.

Function Members (Methods)

public:
virtual~Reader()
voidTObject::AbstractMethod(const char* method) const
voidTMVA::Configurable::AddOptionsXMLTo(void* parent) const
voidAddSpectator(const TString& expression, Float_t*)
voidAddSpectator(const TString& expression, Int_t*)
voidAddVariable(const TString& expression, Float_t*)
voidAddVariable(const TString& expression, Int_t*)
virtual voidTObject::AppendPad(Option_t* option = "")
TMVA::IMethod*BookMVA(const TString& methodTag, const TString& weightfile)
TMVA::IMethod*BookMVA(TMVA::Types::EMVA methodType, const char* xmlstr)
virtual voidTObject::Browse(TBrowser* b)
voidTMVA::Configurable::CheckForUnusedOptions() const
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTObject::Clear(Option_t* = "")
virtual TObject*TObject::Clone(const char* newname = "") const
virtual Int_tTObject::Compare(const TObject* obj) const
TMVA::ConfigurableTMVA::Configurable::Configurable(const TString& theOption = "")
virtual voidTObject::Copy(TObject& object) const
const TMVA::DataSetInfo&DataInfo() const
TMVA::DataSetInfo&DataInfo()
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
const vector<Float_t>&EvaluateMulticlass(const TString& methodTag, Double_t aux = 0)
const vector<Float_t>&EvaluateMulticlass(TMVA::MethodBase* method, Double_t aux = 0)
Float_tEvaluateMulticlass(UInt_t clsNumber, const TString& methodTag, Double_t aux = 0)
Double_tEvaluateMVA(TMVA::MethodBase* method, Double_t aux = 0)
Double_tEvaluateMVA(const TString& methodTag, Double_t aux = 0)
Double_tEvaluateMVA(const vector<Float_t>&, const TString& methodTag, Double_t aux = 0)
Double_tEvaluateMVA(const vector<Double_t>&, const TString& methodTag, Double_t aux = 0)
const vector<Float_t>&EvaluateRegression(const TString& methodTag, Double_t aux = 0)
const vector<Float_t>&EvaluateRegression(TMVA::MethodBase* method, Double_t aux = 0)
Float_tEvaluateRegression(UInt_t tgtNumber, const TString& methodTag, Double_t aux = 0)
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
TMVA::MethodCuts*FindCutsMVA(const TString& methodTag)
TMVA::IMethod*FindMVA(const TString& methodTag)
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
const char*TMVA::Configurable::GetConfigDescription() const
const char*TMVA::Configurable::GetConfigName() const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual const char*TObject::GetIconName() const
Double_tGetMVAError() const
Double_tGetMVAErrorLower() const
Double_tGetMVAErrorUpper() const
virtual const char*GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
const TString&TMVA::Configurable::GetOptions() const
Double_tGetProba(const TString& methodTag, Double_t ap_sig = 0.5, Double_t mvaVal = -9999999)
Double_tGetRarity(const TString& methodTag, Double_t mvaVal = -9999999)
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTObject::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTObject::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTObject::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
TObject&TObject::operator=(const TObject& rhs)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTMVA::Configurable::ParseOptions()
virtual voidTObject::Pop()
virtual voidTObject::Print(Option_t* option = "") const
voidTMVA::Configurable::PrintOptions() const
virtual Int_tTObject::Read(const char* name)
TMVA::ReaderReader(const TString& theOption = "", Bool_t verbose = 0)
TMVA::ReaderReader(vector<std::string>& varNames, const TString& theOption = "", Bool_t verbose = 0)
TMVA::ReaderReader(const string& varNames, const TString& theOption, Bool_t verbose = 0)
TMVA::ReaderReader(vector<TString>& varNames, const TString& theOption = "", Bool_t verbose = 0)
TMVA::ReaderReader(const TString& varNames, const TString& theOption, Bool_t verbose = 0)
voidTMVA::Configurable::ReadOptionsFromStream(istream& istr)
voidTMVA::Configurable::ReadOptionsFromXML(void* node)
virtual voidTObject::RecursiveRemove(TObject* obj)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(ostream& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
voidTMVA::Configurable::SetConfigDescription(const char* d)
voidTMVA::Configurable::SetConfigName(const char* n)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
voidTMVA::Configurable::SetMsgType(TMVA::EMsgType t)
static voidTObject::SetObjectStat(Bool_t stat)
voidTMVA::Configurable::SetOptions(const TString& s)
virtual voidTObject::SetUniqueID(UInt_t uid)
voidSetVerbose(Bool_t v)
virtual voidShowMembers(TMemberInspector&)
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
Bool_tVerbose() const
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
voidTMVA::Configurable::WriteOptionsToStream(ostream& o, const TString& prefix) const
private:
TMVA::IMethod*BookMVA(TMVA::Types::EMVA method, const TString& weightfile)
voidDeclareOptions()
voidDecodeVarNames(const string& varNames)
voidDecodeVarNames(const TString& varNames)
TStringGetMethodTypeFromFile(const TString& filename)
voidInit()
TMVA::MsgLogger&Log() const

Data Members

private:
Bool_tfCalculateErrorerror calculation mode
Bool_tfColorcolor mode
TMVA::DataInputHandlerfDataInputHandler
TMVA::DataSetInfofDataSetInfothe data set
TMVA::DataSetManager*fDataSetManagerDSMTEST
TMVA::MsgLogger*fLoggermessage logger
map<TString,IMethod*>fMethodMapmap of methods
Double_tfMvaEventErrorper-event error returned by MVA
Double_tfMvaEventErrorUpperper-event error returned by MVA
Bool_tfSilentsilent mode
vector<Float_t>fTmpEvalVectemporary evaluation vector (if user input is v<double>)
Bool_tfVerboseverbosity

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

Reader(const TString& theOption = "", Bool_t verbose = 0)
 constructor
Reader(vector<TString>& varNames, const TString& theOption = "", Bool_t verbose = 0)
 constructor
Reader(vector<std::string>& varNames, const TString& theOption = "", Bool_t verbose = 0)
 constructor
Reader( const std::string& varNames, const TString& theOption, Bool_t verbose )
 constructor
Reader(const TString& varNames, const TString& theOption, Bool_t verbose = 0)
 constructor
void DeclareOptions()
 declaration of configuration options
~Reader( void )
 destructor
void Init( void )
 default initialisation (no member variables)
 default initialisation (no member variables)
void AddVariable(const TString& expression, Float_t* )
 Add a float variable or expression to the reader
void AddVariable(const TString& expression, Int_t* )
void AddSpectator(const TString& expression, Float_t* )
 Add a float spectator or expression to the reader
void AddSpectator(const TString& expression, Int_t* )
 Add an integer spectator or expression to the reader
TString GetMethodTypeFromFile(const TString& filename)
 read the method type from the file
TMVA::IMethod* BookMVA(const TString& methodTag, const TString& weightfile)
 read method name from weight file
TMVA::IMethod* BookMVA(TMVA::Types::EMVA method, const TString& weightfile)
 books MVA method from weightfile
TMVA::IMethod* BookMVA(TMVA::Types::EMVA methodType, const char* xmlstr)
Double_t EvaluateMVA( const std::vector<Float_t>& inputVec, const TString& methodTag, Double_t aux )
 Evaluate a std::vector<float> of input data for a given method
 The parameter aux is obligatory for the cuts method where it represents the efficiency cutoff
Double_t EvaluateMVA( const std::vector<Double_t>& inputVec, const TString& methodTag, Double_t aux )
 Evaluate a std::vector<double> of input data for a given method
 The parameter aux is obligatory for the cuts method where it represents the efficiency cutoff
Double_t EvaluateMVA(const TString& methodTag, Double_t aux = 0)
 evaluates MVA for given set of input variables
Double_t EvaluateMVA(TMVA::MethodBase* method, Double_t aux = 0)
 evaluates the MVA
const std::vector< Float_t >& EvaluateRegression(const TString& methodTag, Double_t aux = 0)
 evaluates MVA for given set of input variables
const std::vector< Float_t >& EvaluateRegression(TMVA::MethodBase* method, Double_t aux = 0)
 evaluates the regression MVA
 check for NaN in event data:  (note: in the factory, this check was done already at the creation of the datasets, hence
 it is not again checked in each of these subsequet calls..
Float_t EvaluateRegression(UInt_t tgtNumber, const TString& methodTag, Double_t aux = 0)
 evaluates the regression MVA
const std::vector< Float_t >& EvaluateMulticlass(const TString& methodTag, Double_t aux = 0)
 evaluates MVA for given set of input variables
const std::vector< Float_t >& EvaluateMulticlass(TMVA::MethodBase* method, Double_t aux = 0)
 evaluates the multiclass MVA
 check for NaN in event data:  (note: in the factory, this check was done already at the creation of the datasets, hence
 it is not again checked in each of these subsequet calls..
Float_t EvaluateMulticlass(UInt_t clsNumber, const TString& methodTag, Double_t aux = 0)
 evaluates the multiclass MVA
TMVA::IMethod* FindMVA(const TString& methodTag)
 return pointer to method with tag "methodTag"
TMVA::MethodCuts* FindCutsMVA(const TString& methodTag)
 special function for Cuts to avoid dynamic_casts in ROOT macros,
 which are not properly handled by CINT
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
Double_t GetRarity(const TString& methodTag, Double_t mvaVal = -9999999)
 evaluates the MVA's rarity
void DecodeVarNames( const std::string& varNames )
 decodes "name1:name2:..." form
void DecodeVarNames(const TString& varNames)
 decodes "name1:name2:..." form
Double_t GetMVAError() const
 returns error on MVA response for given event
 NOTE: must be called AFTER "EvaluateMVA(...)" call !
{ return fMvaEventError; }
Double_t GetMVAErrorLower() const
{ return fMvaEventError; }
Double_t GetMVAErrorUpper() const
const char* GetName() const
 accessors
{ return "Reader"; }
Bool_t Verbose( void )
{ return fVerbose; }
void SetVerbose(Bool_t v)
{ fVerbose = v; }
const DataSetInfo& DataInfo() const
{ return fDataSetInfo; }
DataSetInfo& DataInfo()
{ return fDataSetInfo; }