82 fDataSetManager ( NULL ),
84 fTransformations (
"I" ),
86 fDataAssignType ( kAssignEvents ),
100 std::vector<TMVA::VariableTransformBase*>::iterator trfIt = fDefaultTrfs.begin();
101 for (;trfIt != fDefaultTrfs.end(); ++trfIt)
delete (*trfIt);
103 delete fDataInputHandler;
107 delete fDataSetManager;
121 return fDataSetManager->AddDataSetInfo(dsi);
128 DataSetInfo* dsi = fDataSetManager->GetDataSetInfo(dsiName);
130 if (dsi!=0)
return *dsi;
132 return fDataSetManager->AddDataSetInfo(*(
new DataSetInfo(dsiName)));
139 return DefaultDataSetInfo();
150 if (trafoDefinition.
Contains(
"(")) {
154 Ssiz_t parLen = trafoDefinition.
Index(
")", parStart )-parStart+1;
156 trName = trafoDefinition(0,parStart);
157 trOptions = trafoDefinition(parStart,parLen);
158 trOptions.
Remove(parLen-1,1);
162 trName = trafoDefinition;
166 if (trName ==
"VT") {
171 Log() << kFATAL <<
" VT transformation must be passed a floating threshold value" <<
Endl;
176 threshold = trOptions.
Atof();
179 return transformedLoader;
183 Log() << kFATAL <<
"Incorrect transformation string provided, please check" <<
Endl;
185 Log() << kINFO <<
"No transformation applied, returning original loader" <<
Endl;
199 assignTree->
Branch(
"type", &fATreeType,
"ATreeType/I" );
200 assignTree->
Branch(
"weight", &fATreeWeight,
"ATreeWeight/F" );
202 std::vector<VariableInfo>& vars = DefaultDataSetInfo().GetVariableInfos();
203 std::vector<VariableInfo>& tgts = DefaultDataSetInfo().GetTargetInfos();
204 std::vector<VariableInfo>& spec = DefaultDataSetInfo().GetSpectatorInfos();
206 if (fATreeEvent.size()==0) fATreeEvent.resize(vars.size()+tgts.size()+spec.size());
208 for (
UInt_t ivar=0; ivar<vars.size(); ivar++) {
209 TString vname = vars[ivar].GetExpression();
210 assignTree->
Branch( vname, &fATreeEvent[ivar], vname +
"/F" );
213 for (
UInt_t itgt=0; itgt<tgts.size(); itgt++) {
214 TString vname = tgts[itgt].GetExpression();
215 assignTree->
Branch( vname, &fATreeEvent[vars.size()+itgt], vname +
"/F" );
218 for (
UInt_t ispc=0; ispc<spec.size(); ispc++) {
219 TString vname = spec[ispc].GetExpression();
220 assignTree->
Branch( vname, &fATreeEvent[vars.size()+tgts.size()+ispc], vname +
"/F" );
280 ClassInfo* theClass = DefaultDataSetInfo().AddClass(className);
289 if (clIndex>=fTrainAssignTree.size()) {
290 fTrainAssignTree.resize(clIndex+1, 0);
291 fTestAssignTree.resize(clIndex+1, 0);
294 if (fTrainAssignTree[clIndex]==0) {
295 fTrainAssignTree[clIndex] = CreateEventAssignTrees(
Form(
"TrainAssignTree_%s", className.
Data()) );
296 fTestAssignTree[clIndex] = CreateEventAssignTrees(
Form(
"TestAssignTree_%s", className.
Data()) );
299 fATreeType = clIndex;
300 fATreeWeight = weight;
301 for (
UInt_t ivar=0; ivar<
event.size(); ivar++) fATreeEvent[ivar] =
event[ivar];
304 else fTestAssignTree[clIndex]->Fill();
313 return fTrainAssignTree[clIndex]!=0;
323 if(!UserAssignEvents(i))
continue;
324 const TString& className = DefaultDataSetInfo().GetClassInfo(i)->GetName();
325 SetWeightExpression(
"weight", className );
343 Log() << kFATAL <<
"<AddTree> cannot interpret tree type: \"" << treetype
344 <<
"\" should be \"Training\" or \"Test\" or \"Training and Testing\"" <<
Endl;
346 AddTree(
tree, className, weight, cut,
tt );
355 Log() << kFATAL <<
"Tree does not exist (empty pointer)." <<
Endl;
357 DefaultDataSetInfo().AddClass( className );
363 Log() << kINFO<<
"Add Tree " <<
tree->GetName() <<
" of type " << className
364 <<
" with " <<
tree->GetEntries() <<
" events" <<
Endl;
365 DataInput().AddTree(
tree, className, weight, cut,
tt );
373 AddTree( signal,
"Signal", weight,
TCut(
""), treetype );
382 TTree* signalTree =
new TTree(
"TreeS",
"Tree (S)" );
385 Log() << kINFO <<
"Create TTree objects from ASCII input files ... \n- Signal file : \""
389 AddTree( signalTree,
"Signal", weight,
TCut(
""), treetype );
396 AddTree( signal,
"Signal", weight,
TCut(
""), treetype );
404 AddTree( signal,
"Background", weight,
TCut(
""), treetype );
413 TTree* bkgTree =
new TTree(
"TreeB",
"Tree (B)" );
416 Log() << kINFO <<
"Create TTree objects from ASCII input files ... \n- Background file : \""
420 AddTree( bkgTree,
"Background", weight,
TCut(
""), treetype );
427 AddTree( signal,
"Background", weight,
TCut(
""), treetype );
434 AddTree(
tree,
"Signal", weight );
441 AddTree(
tree,
"Background", weight );
467 DataInput().AddTree( datFileS,
"Signal", signalWeight );
468 DataInput().AddTree( datFileB,
"Background", backgroundWeight );
488 DefaultDataSetInfo().AddVariable( expression, title, unit, min, max,
type );
497 DefaultDataSetInfo().AddVariable( expression,
"",
"", min, max,
type );
507 DefaultDataSetInfo().AddVariablesArray(expression,
size,
"",
"", min, max,
type);
518 DefaultDataSetInfo().AddTarget( expression, title, unit, min, max );
527 DefaultDataSetInfo().AddSpectator( expression, title, unit, min, max );
535 return AddDataSet( fName );
543 for (std::vector<TString>::iterator it=theVariables->begin();
544 it!=theVariables->end(); ++it) AddVariable(*it);
551 DefaultDataSetInfo().SetWeightExpression(variable,
"Signal");
558 DefaultDataSetInfo().SetWeightExpression(variable,
"Background");
567 SetSignalWeightExpression(variable);
568 SetBackgroundWeightExpression(variable);
570 else DefaultDataSetInfo().SetWeightExpression( variable, className );
576 SetCut(
TCut(cut), className );
583 DefaultDataSetInfo().SetCut( cut, className );
590 AddCut(
TCut(cut), className );
596 DefaultDataSetInfo().AddCut( cut, className );
606 SetInputTreesFromEventAssignTrees();
610 DefaultDataSetInfo().SetSplitOptions(
Form(
"nTrain_Signal=%i:nTrain_Background=%i:nTest_Signal=%i:nTest_Background=%i:%s",
611 NsigTrain, NbkgTrain, NsigTest, NbkgTest, otherOpt.
Data()) );
620 SetInputTreesFromEventAssignTrees();
624 DefaultDataSetInfo().SetSplitOptions(
Form(
"nTrain_Signal=%i:nTrain_Background=%i:nTest_Signal=%i:nTest_Background=%i:SplitMode=Random:EqualTrainSample:!V",
625 Ntrain, Ntrain, Ntest, Ntest) );
634 SetInputTreesFromEventAssignTrees();
636 DefaultDataSetInfo().PrintClasses();
638 DefaultDataSetInfo().SetSplitOptions( opt );
647 SetInputTreesFromEventAssignTrees();
650 AddCut( sigcut,
"Signal" );
651 AddCut( bkgcut,
"Background" );
653 DefaultDataSetInfo().SetSplitOptions( splitOpt );
705 des->
AddSignalTree( (*treeinfo).GetTree(), (*treeinfo).GetWeight(),(*treeinfo).GetTreeType());
710 des->
AddBackgroundTree( (*treeinfo).GetTree(), (*treeinfo).GetWeight(),(*treeinfo).GetTreeType());
719 const TMatrixD *
m = DefaultDataSetInfo().CorrelationMatrix(className);
720 return DefaultDataSetInfo().CreateCorrelationMatrixHist(
m,
721 "CorrelationMatrix"+className,
"Correlation Matrix ("+className+
")");
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
char * Form(const char *fmt,...)
A specialized string object used for TTree selections.
Service class for 2-D histogram classes.
Class that contains all the information of a class.
virtual void RecombineKFoldDataSet(DataSetInfo &dsi, Types::ETreeType tt=Types::kTraining)
virtual void MakeKFoldDataSet(DataSetInfo &dsi)=0
virtual void PrepareFoldDataSet(DataSetInfo &dsi, UInt_t foldNumber, Types::ETreeType tt)
Set training and test set vectors of dataset described by dsi.
DataInputHandler * fDataInputHandler
TTree * CreateEventAssignTrees(const TString &name)
create the data assignment tree (for event-wise data assignment by user)
void AddVariablesArray(const TString &expression, int size, char type='F', Double_t min=0, Double_t max=0)
user inserts discriminating array of variables in data set info in case input tree provides an array ...
void SetBackgroundTree(TTree *background, Double_t weight=1.0)
void AddSignalTree(TTree *signal, Double_t weight=1.0, Types::ETreeType treetype=Types::kMaxTreeType)
number of signal events (used to compute significance)
DataSetInfo & AddDataSet(DataSetInfo &)
void AddSpectator(const TString &expression, const TString &title="", const TString &unit="", Double_t min=0, Double_t max=0)
user inserts target in data set info
void SetInputTreesFromEventAssignTrees()
assign event-wise local trees to data set
void AddTrainingEvent(const TString &className, const std::vector< Double_t > &event, Double_t weight)
add signal training event
void SetTree(TTree *tree, const TString &className, Double_t weight)
set background tree
void AddSignalTestEvent(const std::vector< Double_t > &event, Double_t weight=1.0)
add signal testing event
DataSetInfo & DefaultDataSetInfo()
default creation
void AddBackgroundTestEvent(const std::vector< Double_t > &event, Double_t weight=1.0)
add signal training event
DataSetManager * fDataSetManager
DataLoader * MakeCopy(TString name)
Copy method use in VI and CV.
void SetSignalWeightExpression(const TString &variable)
void MakeKFoldDataSet(CvSplit &s)
Function required to split the training and testing datasets into a number of folds.
void SetWeightExpression(const TString &variable, const TString &className="")
void AddBackgroundTrainingEvent(const std::vector< Double_t > &event, Double_t weight=1.0)
add signal training event
void RecombineKFoldDataSet(CvSplit &s, Types::ETreeType tt=Types::kTraining)
Recombines the dataset.
DataLoader * VarTransform(TString trafoDefinition)
Transforms the variables and return a new DataLoader with the transformed variables.
void SetBackgroundWeightExpression(const TString &variable)
void AddCut(const TString &cut, const TString &className="")
void AddEvent(const TString &className, Types::ETreeType tt, const std::vector< Double_t > &event, Double_t weight)
add event vector event : the order of values is: variables + targets + spectators
DataLoader(TString thedlName="default")
void PrepareTrainingAndTestTree(const TCut &cut, const TString &splitOpt)
prepare the training and test trees -> same cuts for signal and background
DataInputHandler & DataInput()
void AddBackgroundTree(TTree *background, Double_t weight=1.0, Types::ETreeType treetype=Types::kMaxTreeType)
number of signal events (used to compute significance)
DataSetInfo & GetDataSetInfo()
void AddTarget(const TString &expression, const TString &title="", const TString &unit="", Double_t min=0, Double_t max=0)
user inserts target in data set info
TH2 * GetCorrelationMatrix(const TString &className)
returns the correlation matrix of datasets
Bool_t UserAssignEvents(UInt_t clIndex)
void AddSignalTrainingEvent(const std::vector< Double_t > &event, Double_t weight=1.0)
add signal training event
void AddTestEvent(const TString &className, const std::vector< Double_t > &event, Double_t weight)
add signal test event
void SetSignalTree(TTree *signal, Double_t weight=1.0)
void SetInputTrees(const TString &signalFileName, const TString &backgroundFileName, Double_t signalWeight=1.0, Double_t backgroundWeight=1.0)
void AddTree(TTree *tree, const TString &className, Double_t weight=1.0, const TCut &cut="", Types::ETreeType tt=Types::kMaxTreeType)
void SetInputVariables(std::vector< TString > *theVariables)
fill input variables in data set
void SetCut(const TString &cut, const TString &className="")
void AddVariable(const TString &expression, const TString &title, const TString &unit, char type='F', Double_t min=0, Double_t max=0)
user inserts discriminating variable in data set info
void PrepareFoldDataSet(CvSplit &s, UInt_t foldNumber, Types::ETreeType tt=Types::kTraining)
Function for assigning the correct folds to the testing or training set.
Class that contains all the data information.
Class that contains all the data information.
void SetSource(const std::string &source)
virtual void SetName(const char *name)
Set the name of the TNamed.
void ToLower()
Change string to lower-case.
Double_t Atof() const
Return floating-point value contained in string.
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
const char * Data() const
TString & Remove(Ssiz_t pos)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
A TTree represents a columnar dataset.
virtual void SetDirectory(TDirectory *dir)
Change the tree's directory.
TBranch * Branch(const char *name, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
Add a new branch, and infer the data type from the type of obj being passed.
virtual Long64_t ReadFile(const char *filename, const char *branchDescriptor="", char delimiter=' ')
Create or simply read branches from filename.
void DataLoaderCopy(TMVA::DataLoader *des, TMVA::DataLoader *src)
MsgLogger & Endl(MsgLogger &ml)