58 fDataSetManager(NULL),
61 fNeedsRebuilding(
kTRUE ),
66 fNormalization(
"NONE" ),
68 fTrainingSumSignalWeights(-1),
69 fTrainingSumBackgrWeights(-1),
70 fTestingSumSignalWeights (-1),
71 fTestingSumBackgrWeights (-1),
75 fTargetsForMulticlass(0),
76 fLogger( new
MsgLogger(
"DataSetInfo", kINFO) )
87 for(
UInt_t i=0, iEnd = fClasses.size(); i<iEnd; ++i) {
91 delete fTargetsForMulticlass;
100 if(fDataSet!=0) {
delete fDataSet; fDataSet=0; }
108 fLogger->SetMinType(t);
115 ClassInfo* theClass = GetClassInfo(className);
116 if (theClass)
return theClass;
119 fClasses.push_back(
new ClassInfo(className) );
120 fClasses.back()->
SetNumber(fClasses.size()-1);
124 Log() << kHEADER <<
Form(
"[%s] : ",fName.Data()) <<
"Added class \"" << className <<
"\""<<
Endl;
126 Log() << kDEBUG <<
"\t with internal class number " << fClasses.back()->GetNumber() <<
Endl;
129 if (className ==
"Signal") fSignalClass = fClasses.size()-1;
131 return fClasses.back();
138 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); ++it) {
139 if ((*it)->GetName() ==
name)
return (*it);
149 return fClasses.at(cls);
160 for (
UInt_t cls = 0; cls < GetNClasses() ; cls++) {
161 Log() << kINFO <<
Form(
"Dataset[%s] : ",fName.Data()) <<
"Class index : " << cls <<
" name : " << GetClassInfo(cls)->GetName() <<
Endl;
169 return (ev->
GetClass() == fSignalClass);
176 if( !fTargetsForMulticlass ) fTargetsForMulticlass =
new std::vector<Float_t>( GetNClasses() );
178 fTargetsForMulticlass->assign( GetNClasses(), 0.0 );
179 fTargetsForMulticlass->at( ev->
GetClass() ) = 1.0;
180 return fTargetsForMulticlass;
189 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); ++it) {
199 ClassInfo* ptr = GetClassInfo(className);
217 fVariables.push_back(
VariableInfo( regexpr, title, unit,
218 fVariables.size()+1, varType, external, min, max, normalized ));
219 fNeedsRebuilding =
kTRUE;
220 return fVariables.back();
228 fNeedsRebuilding =
kTRUE;
229 return fVariables.back();
241 fVariables.reserve(fVariables.size() +
size);
242 for (
int i = 0; i <
size; ++i) {
245 fVariables.emplace_back(regexpr, newTitle, unit, fVariables.size() + 1, varType, external, min, max, normalized);
247 fVariables.back().SetBit(kIsArrayVariable);
249 fVariables.back().SetInternalName(newVarName);
251 fVarArrays[regexpr] =
size;
252 fNeedsRebuilding =
kTRUE;
270 fTargets.size()+1,
type, external, min,
272 fNeedsRebuilding =
kTRUE;
273 return fTargets.back();
281 fNeedsRebuilding =
kTRUE;
282 return fTargets.back();
293 Bool_t normalized,
void* external )
297 fSpectators.push_back(
VariableInfo( regexpr, title, unit,
298 fSpectators.size()+1,
type, external, min, max, normalized ));
299 fNeedsRebuilding =
kTRUE;
300 return fSpectators.back();
308 fNeedsRebuilding =
kTRUE;
309 return fSpectators.back();
317 for (
UInt_t ivar=0; ivar<GetNVariables(); ivar++)
318 if (var == GetVariableInfo(ivar).GetInternalName())
return ivar;
320 for (
UInt_t ivar=0; ivar<GetNVariables(); ivar++)
321 Log() << kINFO <<
Form(
"Dataset[%s] : ",fName.Data()) << GetVariableInfo(ivar).GetInternalName() <<
Endl;
323 Log() << kFATAL <<
Form(
"Dataset[%s] : ",fName.Data()) <<
"<FindVarIndex> Variable \'" << var <<
"\' not found." <<
Endl;
335 if (className !=
"") {
341 if (fClasses.empty()) {
342 Log() << kWARNING <<
Form(
"Dataset[%s] : ",fName.Data()) <<
"No classes registered yet, cannot specify weight expression!" <<
Endl;
344 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); ++it) {
345 (*it)->SetWeight( expr );
354 GetClassInfo(className)->SetCorrelationMatrix(matrix);
362 if (className ==
"") {
363 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); ++it) {
364 (*it)->SetCut( cut );
378 if (className ==
"") {
379 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); ++it) {
380 const TCut& oldCut = (*it)->GetCut();
381 (*it)->SetCut( oldCut+cut );
395 std::vector<TString> vNames;
396 std::vector<TMVA::VariableInfo>::const_iterator viIt = GetVariableInfos().begin();
397 for(;viIt != GetVariableInfos().end(); ++viIt) vNames.push_back( (*viIt).GetInternalName() );
410 <<
"Correlation matrix (" << className <<
"):" <<
Endl;
422 const UInt_t nvar = GetNVariables();
427 for (
UInt_t ivar=0; ivar<nvar; ivar++) {
428 for (
UInt_t jvar=0; jvar<nvar; jvar++) {
429 (*tm)(ivar, jvar) = (*
m)(ivar,jvar);
436 for (
UInt_t ivar=0; ivar<nvar; ivar++) {
444 for (
UInt_t ibin=1; ibin<=nvar; ibin++) {
445 for (
UInt_t jbin=1; jbin<=nvar; jbin++) {
451 const Float_t labelSize = 0.055;
472 Log() << kDEBUG <<
Form(
"Dataset[%s] : ",fName.Data()) <<
"Created correlation matrix as 2D histogram: " << h2->
GetName() <<
Endl;
482 if (fDataSet==0 || fNeedsRebuilding) {
483 if (fNeedsRebuilding) Log() << kINFO <<
"Rebuilding Dataset " << fName <<
Endl;
487 if( !fDataSetManager )
488 Log() << kFATAL <<
Form(
"Dataset[%s] : ",fName.Data()) <<
"DataSetManager has not been set in DataSetInfo (GetDataSet() )." <<
Endl;
489 fDataSet = fDataSetManager->CreateDataSet(GetName());
491 fNeedsRebuilding =
kFALSE;
501 return fSpectators.size();
503 for(std::vector<VariableInfo>::const_iterator spit=fSpectators.begin(); spit!=fSpectators.end(); ++spit) {
504 if(spit->GetVarType()!=
'C') nsp++;
514 for (
UInt_t cl = 0; cl < GetNClasses(); cl++) {
515 if (
TString(GetClassInfo(cl)->GetName()).
Length() > maxL) maxL =
TString(GetClassInfo(cl)->GetName()).Length();
526 for (
UInt_t i = 0; i < GetNVariables(); i++) {
527 if (
TString(GetVariableInfo(i).GetExpression()).
Length() > maxL) maxL =
TString(GetVariableInfo(i).GetExpression()).Length();
538 for (
UInt_t i = 0; i < GetNTargets(); i++) {
539 if (
TString(GetTargetInfo(i).GetExpression()).
Length() > maxL) maxL =
TString(GetTargetInfo(i).GetExpression()).Length();
548 if (fTrainingSumSignalWeights<0) Log() << kFATAL <<
Form(
"Dataset[%s] : ",fName.Data()) <<
" asking for the sum of training signal event weights which is not initialized yet" <<
Endl;
549 return fTrainingSumSignalWeights;
555 if (fTrainingSumBackgrWeights<0) Log() << kFATAL <<
Form(
"Dataset[%s] : ",fName.Data()) <<
" asking for the sum of training backgr event weights which is not initialized yet" <<
Endl;
556 return fTrainingSumBackgrWeights;
562 if (fTestingSumSignalWeights<0) Log() << kFATAL <<
Form(
"Dataset[%s] : ",fName.Data()) <<
" asking for the sum of testing signal event weights which is not initialized yet" <<
Endl;
563 return fTestingSumSignalWeights ;
569 if (fTestingSumBackgrWeights<0) Log() << kFATAL <<
Form(
"Dataset[%s] : ",fName.Data()) <<
" asking for the sum of testing backgr event weights which is not initialized yet" <<
Endl;
570 return fTestingSumBackgrWeights ;
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
TMatrixT< Float_t > TMatrixF
char * Form(const char *fmt,...)
virtual void SetLabelSize(Float_t size=0.04)
Set size of axis labels.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
A specialized string object used for TTree selections.
virtual void SetLabelOffset(Float_t offset=0.005, Option_t *axis="X")
Set offset between axis and axis' labels.
virtual void LabelsOption(Option_t *option="h", Option_t *axis="X")
Sort bins with labels or set option(s) to draw axis with labels.
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
virtual void SetMaximum(Double_t maximum=-1111)
virtual void SetMinimum(Double_t minimum=-1111)
virtual void SetNameTitle(const char *name, const char *title)
Change the name and title of this histogram.
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
2-D histogram with a float per channel (see TH1 documentation)}
Service class for 2-D histogram classes.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content.
Class that contains all the information of a class.
const TMatrixD * GetCorrelationMatrix() const
const TCut & GetCut() const
void SetCut(const TCut &cut)
void SetWeight(const TString &weight)
void SetNumber(const UInt_t index)
UInt_t GetNSpectators(bool all=kTRUE) const
ClassInfo * AddClass(const TString &className)
const TMatrixD * CorrelationMatrix(const TString &className) const
Int_t GetTargetNameMaxLength() const
virtual ~DataSetInfo()
destructor
Double_t GetTestingSumBackgrWeights()
void SetMsgType(EMsgType t) const
void AddVariablesArray(const TString &expression, Int_t size, const TString &title="", const TString &unit="", Double_t min=0, Double_t max=0, char type='F', Bool_t normalized=kTRUE, void *external=0)
add an array of variables identified by an expression corresponding to an array entry in the tree
VariableInfo & AddTarget(const TString &expression, const TString &title, const TString &unit, Double_t min, Double_t max, Bool_t normalized=kTRUE, void *external=0)
add a variable (can be a complex expression) to the set of variables used in the MV analysis
DataSet * GetDataSet() const
returns data set
DataSetInfo(const TString &name="Default")
constructor
TH2 * CreateCorrelationMatrixHist(const TMatrixD *m, const TString &hName, const TString &hTitle) const
VariableInfo & AddSpectator(const TString &expression, const TString &title, const TString &unit, Double_t min, Double_t max, char type='F', Bool_t normalized=kTRUE, void *external=0)
add a spectator (can be a complex expression) to the set of spectator variables used in the MV analys...
std::vector< TString > GetListOfVariables() const
returns list of variables
ClassInfo * GetClassInfo(Int_t clNum) const
Double_t GetTrainingSumSignalWeights()
void PrintClasses() const
Int_t GetClassNameMaxLength() const
Double_t GetTrainingSumBackgrWeights()
void PrintCorrelationMatrix(const TString &className)
calculates the correlation matrices for signal and background, prints them to standard output,...
void SetCut(const TCut &cut, const TString &className)
set the cut for the classes
Double_t GetTestingSumSignalWeights()
Int_t FindVarIndex(const TString &) const
find variable by name
VariableInfo & AddVariable(const TString &expression, const TString &title="", const TString &unit="", Double_t min=0, Double_t max=0, char varType='F', Bool_t normalized=kTRUE, void *external=0)
add a variable (can be a complex expression) to the set of variables used in the MV analysis
Int_t GetVariableNameMaxLength() const
Bool_t IsSignal(const Event *ev) const
void SetWeightExpression(const TString &exp, const TString &className="")
set the weight expressions for the classes if class name is specified, set only for this class if cla...
void AddCut(const TCut &cut, const TString &className)
set the cut for the classes
std::vector< Float_t > * GetTargetsForMulticlass(const Event *ev)
void SetCorrelationMatrix(const TString &className, TMatrixD *matrix)
void ClearDataSet() const
Class that contains all the data information.
ostringstream derivative to redirect and format output
Class for type info of MVA input variable.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
TString & ReplaceAll(const TString &s1, const TString &s2)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
MsgLogger & Endl(MsgLogger &ml)