#ifndef ROOT_TMVA_MethodBase
#define ROOT_TMVA_MethodBase
#include "Riostream.h"
#include <sstream>
#include <vector>
#include <iostream>
#ifndef ROOT_TMVA_DataSet
#include "TMVA/DataSet.h"
#endif
#ifndef ROOT_TMVA_IMethod
#include "TMVA/IMethod.h"
#endif
#ifndef ROOT_TMVA_PDF
#include "TMVA/PDF.h"
#endif
#ifndef ROOT_TMVA_TSpline1
#include "TMVA/TSpline1.h"
#endif
#ifndef ROOT_TMVA_Option
#include "TMVA/Option.h"
#endif
#ifndef ROOT_TMVA_Types
#include "TMVA/Types.h"
#endif
#ifndef ROOT_TMVA_MsgLogger
#include "TMVA/MsgLogger.h"
#endif
class TTree;
class TDirectory;
namespace TMVA {
class Ranking;
class MethodBase : public IMethod {
public:
enum EWeightFileType { kROOT=0, kTEXT };
MethodBase( TString jobName,
TString methodTitle,
DataSet& theData,
TString theOption = "",
TDirectory* theBaseDir = 0 );
MethodBase( DataSet& theData,
TString weightFile,
TDirectory* theBaseDir = 0 );
virtual ~MethodBase( void );
virtual void PrepareEvaluationTree( TTree* theTestTree );
void TrainMethod();
void WriteStateToFile() const;
void WriteStateToStream( std::ostream& o ) const;
void ReadStateFromFile();
virtual void WriteMonitoringHistosToFile( void ) const;
virtual void WriteWeightsToStream ( std::ostream& o ) const = 0;
virtual void ReadWeightsFromStream( std::istream& i ) = 0;
virtual void ReadStateFromStream ( std::istream& i );
virtual Bool_t IsSignalLike() { return GetMvaValue() > GetSignalReferenceCut() ? kTRUE : kFALSE; }
virtual void TestInit( TTree* theTestTree = 0 );
virtual Double_t GetMvaValue() = 0;
virtual void Test( TTree* theTestTree = 0 );
const TString& GetJobName ( void ) const { return fJobName; }
const TString& GetMethodName ( void ) const { return fMethodName; }
const char* GetName ( void ) const { return GetMethodName().Data(); }
const TString& GetMethodTitle( void ) const { return fMethodTitle; }
const Types::EMVA GetMethodType ( void ) const { return fMethodType; }
void SetJobName ( TString jobName ) { fJobName = jobName; }
void SetMethodName ( TString methodName ) { fMethodName = methodName; }
void SetMethodTitle( TString methodTitle ) { fMethodTitle = methodTitle; }
void SetMethodType ( Types::EMVA methodType ) { fMethodType = methodType; }
TString GetOptions ( void ) const { return fOptions; }
TString GetWeightFileExtension( void ) const { return fFileExtension; }
void SetWeightFileExtension( TString fileExtension ) { fFileExtension = fileExtension; }
void SetWeightFileType( EWeightFileType w ) { fWeightFileType = w; }
EWeightFileType GetWeightFileType() const { return fWeightFileType; }
TString GetWeightFileDir( void ) const { return fFileDir; }
void SetWeightFileDir( TString fileDir );
const TString& GetInputVar( int i ) const { return Data().GetInternalVarName(i); }
const TString& GetInputExp( int i ) const { return Data().GetExpression(i); }
void SetWeightFileName( TString );
TString GetWeightFileName() const;
Bool_t HasTrainingTree() const { return Data().GetTrainingTree() != 0; }
TTree* GetTrainingTree() const {
if (GetPreprocessingMethod()!=Types::kNone) {
fLogger << kFATAL << "Trying to access correlated Training tree in method "
<< GetMethodName() << endl;
}
return Data().GetTrainingTree();
}
TTree* GetTestTree() const {
if (GetPreprocessingMethod()!=Types::kNone) {
fLogger << kFATAL << "Trying to access correlated Training tree in method "
<< GetMethodName() << endl;
}
return Data().GetTestTree();
}
Int_t GetNvar( void ) const { return fNvar; }
void SetNvar( Int_t n) { fNvar = n; }
virtual Double_t GetEfficiency ( TString , TTree*);
virtual Double_t GetTrainingEfficiency ( TString );
virtual Double_t GetSignificance ( void );
virtual Double_t GetOptimalSignificance( Double_t SignalEvents, Double_t BackgroundEvents,
Double_t& optimal_significance_value ) const;
virtual Double_t GetSeparation ( void );
virtual Double_t GetmuTransform ( TTree* );
Double_t GetXmin( Int_t ivar, Types::EPreprocessingMethod corr = Types::kNone ) const { return fXminNorm[(Int_t) corr][ivar]; }
Double_t GetXmax( Int_t ivar, Types::EPreprocessingMethod corr = Types::kNone ) const { return fXmaxNorm[(Int_t) corr][ivar]; }
Double_t GetXmin( const TString& var, Types::EPreprocessingMethod corr = Types::kNone ) const { return GetXmin(Data().FindVar(var), corr); }
Double_t GetXmax( const TString& var, Types::EPreprocessingMethod corr = Types::kNone ) const { return GetXmax(Data().FindVar(var), corr); }
void SetXmin( Int_t ivar, Double_t x, Types::EPreprocessingMethod corr = Types::kNone ) { fXminNorm[(Int_t) corr][ivar] = x; }
void SetXmax( Int_t ivar, Double_t x, Types::EPreprocessingMethod corr = Types::kNone ) { fXmaxNorm[(Int_t) corr][ivar] = x; }
void SetXmin( const TString& var, Double_t x, Types::EPreprocessingMethod corr = Types::kNone ) { SetXmin(Data().FindVar(var), x, corr); }
void SetXmax( const TString& var, Double_t x, Types::EPreprocessingMethod corr = Types::kNone ) { SetXmax(Data().FindVar(var), x, corr); }
Double_t Norm ( Int_t ivar, Double_t x ) const;
Double_t Norm ( TString var, Double_t x ) const;
Bool_t IsOK ( void ) const { return fIsOK; }
void WriteEvaluationHistosToFile( TDirectory* targetDir );
Types::EPreprocessingMethod GetPreprocessingMethod() const { return fPreprocessingMethod; }
void SetPreprocessingMethod ( Types::EPreprocessingMethod m ) { fPreprocessingMethod = m; }
Bool_t Verbose( void ) const { return fVerbose; }
void SetVerbose( Bool_t v = kTRUE ) { fVerbose = v; }
DataSet& Data() const { return fData; }
Bool_t ReadTrainingEvent( UInt_t ievt, Types::ESBType type = Types::kMaxSBType ) {
return Data().ReadTrainingEvent( ievt, GetPreprocessingMethod(),
(type == Types::kMaxSBType) ? GetPreprocessingType() : type );
}
virtual Bool_t ReadTestEvent( UInt_t ievt, Types::ESBType type = Types::kMaxSBType ) {
return Data().ReadTestEvent( ievt, GetPreprocessingMethod(),
(type == Types::kMaxSBType) ? GetPreprocessingType() : type );
}
Double_t GetEventVal( Int_t ivar ) const { return Data().Event().GetVal(ivar); }
Double_t GetEventValNormalized(Int_t ivar) const;
Double_t GetEventWeight() const { return Data().Event().GetWeight(); }
virtual void DeclareOptions();
virtual void ProcessOptions();
public:
static MethodBase* GetThisBase( void ) { return fgThisBase; }
protected:
enum ECutOrientation { kNegative = -1, kPositive = +1 };
ECutOrientation GetCutOrientation() const { return fCutOrientation; }
void ResetThisBase( void ) { fgThisBase = this; }
Double_t GetSignalReferenceCut() const { return fSignalReferenceCut; }
void SetSignalReferenceCut( Double_t cut ) { fSignalReferenceCut = cut; }
void Statistics( TMVA::Types::ETreeType treeType, const TString& theVarName,
Double_t&, Double_t&, Double_t&,
Double_t&, Double_t&, Double_t&, Bool_t norm = kFALSE );
Types::ESBType GetPreprocessingType() const { return fPreprocessingType; }
void SetPreprocessingType( Types::ESBType t ) { fPreprocessingType = t; }
private:
Double_t fSignalReferenceCut;
Types::ESBType fPreprocessingType;
private:
DataSet& fData;
Double_t* fXminNorm[3];
Double_t* fXmaxNorm[3];
protected:
TDirectory* BaseDir() const;
TDirectory* LocalTDir() const { return Data().LocalRootDir(); }
const TString& GetTestvarName() const { return fTestvar; }
void SetTestvarName( void ) { fTestvar = fTestvarPrefix + GetMethodTitle(); }
void SetTestvarName( TString v ) { fTestvar = v; }
const TString& GetTestvarPrefix() const { return fTestvarPrefix; }
void SetTestvarPrefix( TString prefix ) { fTestvarPrefix = prefix; }
Bool_t CheckSanity( TTree* theTree = 0 );
void EnableLooseOptions( Bool_t b = kTRUE ) { fLooseOptionCheckingEnabled = b; }
Ranking* fRanking;
vector<TString>* fInputVars;
private:
TString fJobName;
TString fMethodName;
Types::EMVA fMethodType;
TString fMethodTitle;
TString fTestvar;
TString fTestvarPrefix;
TString fOptions;
private:
void SetBaseDir( TDirectory* d ) { fBaseDir = d; }
Int_t fNvar;
TDirectory* fBaseDir;
TString fFileExtension;
TString fFileDir;
TString fWeightFile;
EWeightFileType fWeightFileType;
protected:
Bool_t fIsOK;
TH1* fHistS_plotbin;
TH1* fHistB_plotbin;
TH1* fHistS_highbin;
TH1* fHistB_highbin;
TH1* fEffS;
TH1* fEffB;
TH1* fEffBvsS;
TH1* fRejBvsS;
TH1* fHistBhatS;
TH1* fHistBhatB;
TH1* fHistMuS;
TH1* fHistMuB;
TH1* fTrainEffS;
TH1* fTrainEffB;
TH1* fTrainEffBvsS;
TH1* fTrainRejBvsS;
Double_t fX;
Double_t fMode;
TGraph* fGraphS;
TGraph* fGraphB;
TGraph* fGrapheffBvsS;
PDF* fSplS;
PDF* fSplB;
TSpline* fSpleffBvsS;
TGraph* fGraphTrainS;
TGraph* fGraphTrainB;
TGraph* fGraphTrainEffBvsS;
PDF* fSplTrainS;
PDF* fSplTrainB;
TSpline* fSplTrainEffBvsS;
private:
Double_t fMeanS;
Double_t fMeanB;
Double_t fRmsS;
Double_t fRmsB;
Double_t fXmin;
Double_t fXmax;
Bool_t fUseDecorr;
Types::EPreprocessingMethod fPreprocessingMethod;
TString fPreprocessingString;
TString fPreprocessingTypeString;
Bool_t fVerbose;
Bool_t fHelp;
Bool_t LooseOptionCheckingEnabled() const { return fLooseOptionCheckingEnabled; }
Bool_t fLooseOptionCheckingEnabled;
protected:
Int_t fNbins;
Int_t fNbinsH;
ECutOrientation fCutOrientation;
TSpline1* fSplRefS;
TSpline1* fSplRefB;
TSpline1* fSplTrainRefS;
TSpline1* fSplTrainRefB;
public:
static Double_t IGetEffForRoot( Double_t );
Double_t GetEffForRoot( Double_t );
private:
static MethodBase* fgThisBase;
void Init( void );
protected:
OptionBase* fLastDeclaredOption;
TList fListOfOptions;
const TList& ListOfOptions() const { return fListOfOptions; }
template <class T>
void AssignOpt( const TString& name, T& valAssign ) const;
protected:
template<class T>
OptionBase* DeclareOption( const TString& name, const TString& desc = "" );
template<class T>
OptionBase* DeclareOptionRef( T& ref, const TString& name, const TString& desc = "" );
template<class T>
void AddPreDefVal(const T&);
void ParseOptions( Bool_t verbose = kTRUE);
void PrintOptions() const;
void WriteOptionsToStream(ostream& o) const;
void ReadOptionsFromStream(istream& istr);
mutable MsgLogger fLogger;
ClassDef(MethodBase,0)
;
};
}
template <class T>
TMVA::OptionBase* TMVA::MethodBase::DeclareOption( const TString& name, const TString& desc)
{
OptionBase* o = new Option<T>(name,desc);
fListOfOptions.Add(o);
fLastDeclaredOption = o;
return o;
}
template <class T>
TMVA::OptionBase* TMVA::MethodBase::DeclareOptionRef( T& ref, const TString& name, const TString& desc)
{
OptionBase* o = new Option<T>(ref, name, desc);
fListOfOptions.Add(o);
fLastDeclaredOption = o;
return o;
}
template<class T>
void TMVA::MethodBase::AddPreDefVal(const T& val)
{
Option<T>* oc = dynamic_cast<Option<T>*>(fLastDeclaredOption);
if(oc!=0) oc->AddPreDefVal(val);
}
template <class T>
void TMVA::MethodBase::AssignOpt(const TString& name, T& valAssign) const
{
TObject* opt = fListOfOptions.FindObject(name);
if (opt!=0) valAssign = ((Option<T>*)opt)->Value();
else
fLogger << kFATAL << "Option \"" << name
<< "\" not declared, please check the syntax of your option string" << endl;
}
#endif
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.