90 fLogger->SetSource(
"DataLoader");
99 std::vector<TMVA::VariableTransformBase*>::iterator trfIt =
fDefaultTrfs.begin();
100 for (;trfIt !=
fDefaultTrfs.end(); ++trfIt)
delete (*trfIt);
129 if (dsi!=0)
return *dsi;
149 if (trafoDefinition.
Contains(
"(")) {
153 Ssiz_t parLen = trafoDefinition.
Index(
")", parStart )-parStart+1;
155 trName = trafoDefinition(0,parStart);
156 trOptions = trafoDefinition(parStart,parLen);
157 trOptions.
Remove(parLen-1,1);
161 trName = trafoDefinition;
165 if (trName ==
"VT") {
170 Log() << kFATAL <<
" VT transformation must be passed a floating threshold value" <<
Endl;
175 threshold = trOptions.
Atof();
178 return transformedLoader;
182 Log() << kFATAL <<
"Incorrect transformation string provided, please check" <<
Endl;
184 Log() << kINFO <<
"No transformation applied, returning original loader" <<
Endl;
207 for (
UInt_t ivar=0; ivar<vars.size(); ivar++) {
208 TString vname = vars[ivar].GetExpression();
212 for (
UInt_t itgt=0; itgt<tgts.size(); itgt++) {
213 TString vname = tgts[itgt].GetExpression();
217 for (
UInt_t ispc=0; ispc<spec.size(); ispc++) {
218 TString vname = spec[ispc].GetExpression();
219 assignTree->
Branch( vname, &
fATreeEvent[vars.size()+tgts.size()+ispc], vname +
"/F" );
277 const std::vector<Double_t>& event,
Double_t weight )
302 "Number of variables defined through DataLoader::AddVariable (%zu) is inconsistent"
303 " with number of variables given to DataLoader::Add*Event (%zu)."
304 " Please check your variable definitions and statement ordering."
305 " This event will not be added.",
fATreeEvent.size(), event.size());
350 Log() << kFATAL <<
"<AddTree> cannot interpret tree type: \"" << treetype
351 <<
"\" should be \"Training\" or \"Test\" or \"Training and Testing\"" <<
Endl;
353 AddTree( tree, className, weight, cut,
tt );
362 Log() << kFATAL <<
"Tree does not exist (empty pointer)." <<
Endl;
370 Log() << kINFO<<
"Add Tree " << tree->
GetName() <<
" of type " << className
372 DataInput().AddTree( tree, className, weight, cut,
tt );
380 AddTree( signal,
"Signal", weight,
TCut(
""), treetype );
389 TTree* signalTree =
new TTree(
"TreeS",
"Tree (S)" );
392 Log() << kINFO <<
"Create TTree objects from ASCII input files ... \n- Signal file : \""
396 AddTree( signalTree,
"Signal", weight,
TCut(
""), treetype );
403 AddTree( signal,
"Signal", weight,
TCut(
""), treetype );
411 AddTree( signal,
"Background", weight,
TCut(
""), treetype );
420 TTree* bkgTree =
new TTree(
"TreeB",
"Tree (B)" );
423 Log() << kINFO <<
"Create TTree objects from ASCII input files ... \n- Background file : \""
427 AddTree( bkgTree,
"Background", weight,
TCut(
""), treetype );
434 AddTree( signal,
"Background", weight,
TCut(
""), treetype );
441 AddTree( tree,
"Signal", weight );
448 AddTree( tree,
"Background", weight );
474 DataInput().AddTree( datFileS,
"Signal", signalWeight );
475 DataInput().AddTree( datFileB,
"Background", backgroundWeight );
550 for (std::vector<TString>::iterator it=theVariables->begin();
618 NsigTrain, NbkgTrain, NsigTest, NbkgTest, otherOpt.
Data()).Data() );
631 DefaultDataSetInfo().SetSplitOptions(
TString::Format(
"nTrain_Signal=%i:nTrain_Background=%i:nTest_Signal=%i:nTest_Background=%i:SplitMode=Random:EqualTrainSample:!V",
632 Ntrain, Ntrain, Ntest, Ntest).Data() );
657 AddCut( sigcut,
"Signal" );
658 AddCut( bkgcut,
"Background" );
712 des->
AddSignalTree( (*treeinfo).GetTree(), (*treeinfo).GetWeight(),(*treeinfo).GetTreeType());
717 des->
AddBackgroundTree( (*treeinfo).GetTree(), (*treeinfo).GetWeight(),(*treeinfo).GetTreeType());
728 "CorrelationMatrix"+className,
"Correlation Matrix ("+className+
")");
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
int Ssiz_t
String size (currently int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
TMatrixT< Double_t > TMatrixD
A specialized string object used for TTree selections.
Service class for 2-D histogram classes.
Class that contains all the information of a class.
Configurable(const TString &theOption="")
constructor
MsgLogger * fLogger
! message logger
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 ...
Float_t fATreeWeight
weight of the event
std::vector< TTree * > fTrainAssignTree
for each class: tmp tree if user wants to assign the events directly
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
std::vector< TMVA::VariableTransformBase * > fDefaultTrfs
list of transformations on default DataSet
DataAssignType fDataAssignType
flags for data assigning
void SetTree(TTree *tree, const TString &className, Double_t weight)
deprecated
void AddSignalTestEvent(const std::vector< Double_t > &event, Double_t weight=1.0)
add signal testing event
std::vector< Float_t > fATreeEvent
event variables
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
Bool_t fVerbose
verbose mode
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)
TString fTransformations
List of transformations to test.
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)
deprecated
Int_t fATreeType
type of event (=classIndex)
std::vector< TTree * > fTestAssignTree
for each class: tmp tree if user wants to assign the events directly
Types::EAnalysisType fAnalysisType
the training type
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.
@ kMaxTreeType
also used as temporary storage for trees not yet assigned for testing;training...
const char * GetName() const override
Returns name of object.
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)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
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.
virtual Long64_t GetEntries() const
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)