63 fDataSetManager(NULL),
66 fNeedsRebuilding(
kTRUE ),
71 fNormalization(
"NONE" ),
73 fTrainingSumSignalWeights(-1),
74 fTrainingSumBackgrWeights(-1),
75 fTestingSumSignalWeights (-1),
76 fTestingSumBackgrWeights (-1),
80 fTargetsForMulticlass(0),
81 fLogger( new
MsgLogger(
"DataSetInfo", kINFO) )
83 std::cout <<
"create data set info " <<
name << std::endl;
93 for(
UInt_t i=0, iEnd = fClasses.size(); i<iEnd; ++i) {
97 delete fTargetsForMulticlass;
106 if(fDataSet!=0) {
delete fDataSet; fDataSet=0; }
114 fLogger->SetMinType(t);
121 ClassInfo* theClass = GetClassInfo(className);
122 if (theClass)
return theClass;
125 fClasses.push_back(
new ClassInfo(className) );
126 fClasses.back()->
SetNumber(fClasses.size()-1);
130 Log() << kHEADER <<
Form(
"[%s] : ",fName.Data()) <<
"Added class \"" << className <<
"\""<<
Endl;
132 Log() << kDEBUG <<
"\t with internal class number " << fClasses.back()->GetNumber() <<
Endl;
135 if (className ==
"Signal") fSignalClass = fClasses.size()-1;
137 return fClasses.back();
144 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); ++it) {
145 if ((*it)->GetName() ==
name)
return (*it);
155 return fClasses.at(cls);
166 for (
UInt_t cls = 0; cls < GetNClasses() ; cls++) {
167 Log() << kINFO <<
Form(
"Dataset[%s] : ",fName.Data()) <<
"Class index : " << cls <<
" name : " << GetClassInfo(cls)->GetName() <<
Endl;
175 return (ev->
GetClass() == fSignalClass);
182 if( !fTargetsForMulticlass ) fTargetsForMulticlass =
new std::vector<Float_t>( GetNClasses() );
184 fTargetsForMulticlass->assign( GetNClasses(), 0.0 );
185 fTargetsForMulticlass->at( ev->
GetClass() ) = 1.0;
186 return fTargetsForMulticlass;
195 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); ++it) {
205 ClassInfo* ptr = GetClassInfo(className);
223 fVariables.push_back(
VariableInfo( regexpr, title, unit,
224 fVariables.size()+1, varType, external, min, max, normalized ));
225 fNeedsRebuilding =
kTRUE;
226 return fVariables.back();
234 fNeedsRebuilding =
kTRUE;
235 return fVariables.back();
247 fVariables.reserve(fVariables.size() + size);
248 for (
int i = 0; i < size; ++i) {
251 fVariables.emplace_back(regexpr, newTitle, unit, fVariables.size() + 1, varType, external, min, max, normalized);
253 fVariables.back().SetBit(kIsArrayVariable);
255 fVariables.back().SetInternalName(newVarName);
257 fVarArrays[regexpr] = size;
258 fNeedsRebuilding =
kTRUE;
276 fTargets.size()+1,
type, external, min,
278 fNeedsRebuilding =
kTRUE;
279 return fTargets.back();
287 fNeedsRebuilding =
kTRUE;
288 return fTargets.back();
299 Bool_t normalized,
void* external )
303 fSpectators.push_back(
VariableInfo( regexpr, title, unit,
304 fSpectators.size()+1,
type, external, min, max, normalized ));
305 fNeedsRebuilding =
kTRUE;
306 return fSpectators.back();
314 fNeedsRebuilding =
kTRUE;
315 return fSpectators.back();
323 for (
UInt_t ivar=0; ivar<GetNVariables(); ivar++)
324 if (var == GetVariableInfo(ivar).GetInternalName())
return ivar;
326 for (
UInt_t ivar=0; ivar<GetNVariables(); ivar++)
327 Log() << kINFO <<
Form(
"Dataset[%s] : ",fName.Data()) << GetVariableInfo(ivar).GetInternalName() <<
Endl;
329 Log() << kFATAL <<
Form(
"Dataset[%s] : ",fName.Data()) <<
"<FindVarIndex> Variable \'" << var <<
"\' not found." <<
Endl;
341 if (className !=
"") {
347 if (fClasses.empty()) {
348 Log() << kWARNING <<
Form(
"Dataset[%s] : ",fName.Data()) <<
"No classes registered yet, cannot specify weight expression!" <<
Endl;
350 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); ++it) {
351 (*it)->SetWeight( expr );
360 GetClassInfo(className)->SetCorrelationMatrix(matrix);
368 if (className ==
"") {
369 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); ++it) {
370 (*it)->SetCut( cut );
384 if (className ==
"") {
385 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); ++it) {
386 const TCut& oldCut = (*it)->GetCut();
387 (*it)->SetCut( oldCut+cut );
401 std::vector<TString> vNames;
402 std::vector<TMVA::VariableInfo>::const_iterator viIt = GetVariableInfos().begin();
403 for(;viIt != GetVariableInfos().end(); ++viIt) vNames.push_back( (*viIt).GetInternalName() );
416 <<
"Correlation matrix (" << className <<
"):" <<
Endl;
428 const UInt_t nvar = GetNVariables();
433 for (
UInt_t ivar=0; ivar<nvar; ivar++) {
434 for (
UInt_t jvar=0; jvar<nvar; jvar++) {
435 (*tm)(ivar, jvar) = (*
m)(ivar,jvar);
442 for (
UInt_t ivar=0; ivar<nvar; ivar++) {
450 for (
UInt_t ibin=1; ibin<=nvar; ibin++) {
451 for (
UInt_t jbin=1; jbin<=nvar; jbin++) {
457 const Float_t labelSize = 0.055;
478 Log() << kDEBUG <<
Form(
"Dataset[%s] : ",fName.Data()) <<
"Created correlation matrix as 2D histogram: " << h2->
GetName() <<
Endl;
488 if (fDataSet==0 || fNeedsRebuilding) {
489 if(fDataSet!=0) ClearDataSet();
491 if( !fDataSetManager )
492 Log() << kFATAL <<
Form(
"Dataset[%s] : ",fName.Data()) <<
"DataSetManager has not been set in DataSetInfo (GetDataSet() )." <<
Endl;
493 fDataSet = fDataSetManager->CreateDataSet(
GetName());
495 fNeedsRebuilding =
kFALSE;
505 return fSpectators.size();
507 for(std::vector<VariableInfo>::const_iterator spit=fSpectators.begin(); spit!=fSpectators.end(); ++spit) {
508 if(spit->GetVarType()!=
'C') nsp++;
518 for (
UInt_t cl = 0; cl < GetNClasses(); cl++) {
530 for (
UInt_t i = 0; i < GetNVariables(); i++) {
531 if (
TString(GetVariableInfo(i).GetExpression()).
Length() > maxL) maxL =
TString(GetVariableInfo(i).GetExpression()).Length();
542 for (
UInt_t i = 0; i < GetNTargets(); i++) {
543 if (
TString(GetTargetInfo(i).GetExpression()).
Length() > maxL) maxL =
TString(GetTargetInfo(i).GetExpression()).Length();
552 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;
553 return fTrainingSumSignalWeights;
559 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;
560 return fTrainingSumBackgrWeights;
566 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;
567 return fTestingSumSignalWeights ;
573 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;
574 return fTestingSumBackgrWeights ;
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")
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-Dim 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.
std::string GetName(const std::string &scope_name)
void AddClass(const char *cname, Version_t id, const std::type_info &info, DictFuncPtr_t dict, Int_t pragmabits)
Global function called by the ctor of a class's init class (see the ClassImp macro).
MsgLogger & Endl(MsgLogger &ml)