#ifndef ROOT_TMVA_DataSet
#define ROOT_TMVA_DataSet
#include "TObject.h"
#include "TString.h"
#include "TTree.h"
#include "TCut.h"
#include "TTreeFormula.h"
#include "TMatrixD.h"
#include "TPrincipal.h"
#ifndef ROOT_TMVA_Types
#include "TMVA/Types.h"
#endif
#ifndef ROOT_TMVA_VariableInfo
#include "TMVA/VariableInfo.h"
#endif
#ifndef ROOT_TMVA_Event
#include "TMVA/Event.h"
#endif
#ifndef ROOT_TMVA_MsgLogger
#include "TMVA/MsgLogger.h"
#endif
#ifndef ROOT_TMVA_VariableTransformBase
#include "TMVA/VariableTransformBase.h"
#endif
namespace TMVA {
class TreeInfo {
public:
TreeInfo( TTree* tr, Double_t weight=1.0, Types::ETreeType tt = Types::kMaxTreeType )
: fTree(tr), fWeight(weight), fTreeType(tt) {}
~TreeInfo() {}
TTree* GetTree() const { return fTree; }
Double_t GetWeight() const { return fWeight; }
Types::ETreeType GettreeType() const { return fTreeType; }
private:
TTree* fTree;
Double_t fWeight;
Types::ETreeType fTreeType;
};
class DataSet {
public:
DataSet();
virtual ~DataSet();
const char* GetName() const { return "DataSet"; }
void AddSignalTree ( TTree* tr, Double_t weight=1.0, Types::ETreeType tt = Types::kMaxTreeType );
void AddBackgroundTree( TTree* tr, Double_t weight=1.0, Types::ETreeType tt = Types::kMaxTreeType );
UInt_t NSignalTrees() const { return fTreeCollection[Types::kSignal].size(); }
UInt_t NBackgroundTrees() const { return fTreeCollection[Types::kBackground].size(); }
const TreeInfo& SignalTreeInfo(Int_t i) const { return fTreeCollection[Types::kSignal][i]; }
const TreeInfo& BackgroundTreeInfo(Int_t i) const { return fTreeCollection[Types::kBackground][i]; }
void ClearSignalTreeList() { fTreeCollection[Types::kSignal].clear(); }
void ClearBackgroundTreeList() { fTreeCollection[Types::kBackground].clear(); }
void AddVariable( const TString& expression, char varType='F', void* external = 0 );
void AddVariable( const TString& expression, Double_t min, Double_t max, char varType, void* external = 0 );
std::vector<VariableInfo>& GetVariableInfos() { return fVariables; }
UInt_t GetNVariables() const { return fVariables.size(); }
char GetVarType(Int_t i) const { return fVariables[i].GetVarType(); }
Int_t FindVar(const TString& var) const;
const TString& GetExpression(Int_t i) const { return fVariables[i].GetExpression(); }
const TString& GetInternalVarName(Int_t i) const { return fVariables[i].GetInternalVarName(); }
void SetCuts( const TString& scut, const TString& bcut ) { SetCuts(TCut(scut), TCut(bcut)); }
void SetCuts( const TCut& scut, const TCut& bcut ) { fCutSig = scut; fCutBkg = bcut; }
void SetMultiCut( const TString& cut ) { SetMultiCut(TCut(cut)); }
void SetMultiCut( const TCut& cut ) { fMultiCut = cut; }
const TCut& CutSig() const { return fCutSig; }
const TCut& CutBkg() const { return fCutBkg; }
const char* CutSigS() const { return fCutSig.GetTitle(); }
const char* CutBkgS() const { return fCutBkg.GetTitle(); }
Bool_t HasCuts() const { return TString(CutSig()) != "" || TString(CutBkg()) != ""; }
TTree* GetTrainingTree() const { return fTrainingTree; }
TTree* GetTestTree() const { return fTestTree; }
TTree* GetMultiCutTestTree() const { return fMultiCutTestTree; }
void SetTrainingTree (TTree* tr) { fTrainingTree = tr; }
void SetTestTree (TTree* tr) { fTestTree = tr; }
void SetMultiCutTestTree(TTree* tr) { fMultiCutTestTree = tr; }
TDirectory* LocalRootDir() const { return fLocalRootDir; }
TDirectory* BaseRootDir() const { return fBaseRootDir; }
void SetBaseRootDir(TDirectory* dir) { fBaseRootDir = dir; }
void SetLocalRootDir(TDirectory* dir) { fLocalRootDir = dir; }
void PrepareForTrainingAndTesting( const TString & splitOpt );
void GetCorrelationMatrix( Bool_t isSignal, TMatrixDBase* mat );
void GetCovarianceMatrix ( Bool_t isSignal, TMatrixDBase*, Bool_t norm = kFALSE );
void SetVerbose( Bool_t v=kTRUE ) { fVerbose = v; }
VariableTransformBase* FindTransform( Types::EVariableTransform transform ) const;
VariableTransformBase* GetTransform( Types::EVariableTransform transform );
Bool_t ReadEvent ( TTree* tr, Long64_t evidx ) const;
Bool_t ReadTrainingEvent( Long64_t evidx ) const { return ReadEvent(GetTrainingTree(), evidx ); }
Bool_t ReadTestEvent ( Long64_t evidx ) const { return ReadEvent(GetTestTree(), evidx ); }
TMVA::Event& GetEvent() { if (fEvent==0) fEvent = new TMVA::Event(fVariables); return *fEvent; }
UInt_t GetCurrentEvtIdx() const { return fCurrentEvtIdx; }
const TMVA::Event& GetEvent() const { return *fEvent; }
const TMatrixD* CorrelationMatrix( Types::ESBType sigbgd ) const { return fDecorrMatrix[sigbgd]; }
void SetSignalWeightExpression ( const TString& expr ) { fWeightExp[Types::kSignal] = expr; }
void SetBackgroundWeightExpression( const TString& expr ) { fWeightExp[Types::kBackground] = expr; }
Bool_t HasNegativeEventWeights() const { return fHasNegativeEventWeights; }
Int_t GetNEvtTrain() const { return fDataStats[Types::kTraining][Types::kSBBoth]; }
Int_t GetNEvtSigTrain() const { return fDataStats[Types::kTraining][Types::kSignal]; }
Int_t GetNEvtBkgdTrain() const { return fDataStats[Types::kTraining][Types::kBackground]; }
Int_t GetNEvtTest() const { return fDataStats[Types::kTesting][Types::kSBBoth]; }
Int_t GetNEvtSigTest() const { return fDataStats[Types::kTesting][Types::kSignal]; }
Int_t GetNEvtBkgdTest() const { return fDataStats[Types::kTesting][Types::kBackground]; }
void ResetBranchAndEventAddresses( TTree* );
void ResetCurrentTree() { fCurrentTree = 0; }
private:
void ChangeToNewTree( TTree* tr, Int_t sb );
void PrintCorrelationMatrix( TTree* theTree );
Bool_t Verbose() { return fVerbose; }
TDirectory* fLocalRootDir;
TDirectory* fBaseRootDir;
std::vector<TMVA::TreeInfo> fTreeCollection[2];
std::vector<TMVA::VariableInfo> fVariables;
std::vector<TString> fVariableStrings;
std::vector<TTreeFormula*> fInputVarFormulas;
TCut fCutSig;
TCut fCutBkg;
TCut fMultiCut;
TTreeFormula* fCutSigF;
TTreeFormula* fCutBkgF;
TTree* fTrainingTree;
TTree* fTestTree;
TTree* fMultiCutTestTree;
UInt_t fDataStats[Types::kMaxTreeType][Types::kMaxSBType];
TMatrixD* fDecorrMatrix[2];
std::map<TMVA::Types::EVariableTransform,TMVA::VariableTransformBase*> fVarTransforms;
Bool_t fVerbose;
mutable TMVA::Event* fEvent;
mutable TTree* fCurrentTree;
mutable UInt_t fCurrentEvtIdx;
TString fWeightExp[2];
TTreeFormula* fWeightFormula[2];
Bool_t fExplicitTrainTest[2];
Bool_t fHasNegativeEventWeights;
mutable MsgLogger fLogger;
};
}
#endif
Last change: Sat Nov 1 10:21:33 2008
Last generated: 2008-11-01 10:21
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.