28 #ifndef ROOT_TMVA_DataInputHandler
29 #define ROOT_TMVA_DataInputHandler
53 class TreeInfo:
public TObject {
57 TreeInfo( TTree* tr,
const TString& className, Double_t weight=1.0, Types::ETreeType tt = Types::kMaxTreeType, Bool_t own=kFALSE )
58 : fTree(tr), fClassName(className), fWeight(weight), fTreeType(tt), fOwner(own) {}
59 TreeInfo():fTree(0),fClassName(
""),fWeight(1.0), fTreeType(Types::kMaxTreeType), fOwner(kFALSE) {}
60 ~TreeInfo() {
if (fOwner)
delete fTree; }
62 TTree* GetTree()
const {
return fTree; }
63 Double_t GetWeight()
const {
return fWeight; }
64 UInt_t GetEntries()
const {
if( !fTree )
return 0;
else return fTree->GetEntries(); }
65 Types::ETreeType GetTreeType()
const {
return fTreeType; }
66 const TString& GetClassName()
const {
return fClassName; }
73 Types::ETreeType fTreeType;
79 class DataInputHandler :
public TObject {
87 void AddSignalTree ( TTree* tr, Double_t weight=1.0, Types::ETreeType tt = Types::kMaxTreeType );
88 void AddBackgroundTree( TTree* tr, Double_t weight=1.0, Types::ETreeType tt = Types::kMaxTreeType );
89 void AddSignalTree (
const TString& tr, Double_t weight=1.0, Types::ETreeType tt = Types::kMaxTreeType );
90 void AddBackgroundTree(
const TString& tr, Double_t weight=1.0, Types::ETreeType tt = Types::kMaxTreeType );
91 void AddInputTrees ( TTree* inputTree,
const TCut& SigCut,
const TCut& BgCut);
93 void AddTree ( TTree* tree,
const TString& className, Double_t weight=1.0,
94 const TCut& cut =
"", Types::ETreeType tt = Types::kMaxTreeType );
95 void AddTree (
const TString& tr,
const TString& className, Double_t weight=1.0,
96 const TCut& cut =
"", Types::ETreeType tt = Types::kMaxTreeType );
99 std::vector< TString >* GetClassList()
const;
101 UInt_t GetEntries(
const TString& name )
const {
return GetEntries( fInputTrees[name] ); }
102 UInt_t GetNTrees (
const TString& name )
const {
return fInputTrees[name].size(); }
104 UInt_t GetNSignalTrees()
const {
return fInputTrees[
"Signal"].size(); }
105 UInt_t GetNBackgroundTrees()
const {
return fInputTrees[
"Background"].size(); }
106 UInt_t GetSignalEntries()
const {
return GetEntries(fInputTrees[
"Signal"]); }
107 UInt_t GetBackgroundEntries()
const {
return GetEntries(fInputTrees[
"Background"]); }
108 UInt_t GetEntries()
const;
109 const TreeInfo& SignalTreeInfo(Int_t i)
const {
return fInputTrees[
"Signal"][i]; }
110 const TreeInfo& BackgroundTreeInfo(Int_t i)
const {
return fInputTrees[
"Background"][i]; }
112 std::vector<TreeInfo>::const_iterator begin(
const TString& className )
const {
return fInputTrees[className].begin(); }
113 std::vector<TreeInfo>::const_iterator end(
const TString& className )
const {
return fInputTrees[className].end(); }
114 std::vector<TreeInfo>::const_iterator Sbegin()
const {
return begin(
"Signal"); }
115 std::vector<TreeInfo>::const_iterator Send()
const {
return end (
"Signal"); }
116 std::vector<TreeInfo>::const_iterator Bbegin()
const {
return begin(
"Background"); }
117 std::vector<TreeInfo>::const_iterator Bend()
const {
return end (
"Background"); }
120 void ClearSignalTreeList() { ClearTreeList(
"Signal"); }
121 void ClearBackgroundTreeList() { ClearTreeList(
"Background"); }
122 void ClearTreeList(
const TString& className );
126 UInt_t GetEntries(
const std::vector<TreeInfo>& tiV)
const;
128 TTree * ReadInputTree(
const TString& dataFile );
130 mutable std::map< TString, std::vector<TreeInfo> > fInputTrees;
131 std::map< std::string, Bool_t > fExplicitTrainTest;
132 mutable MsgLogger* fLogger;
133 MsgLogger& Log()
const {
return *fLogger; }
135 ClassDef(DataInputHandler,1);