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) )
92 for(
UInt_t i=0, iEnd = fClasses.size(); i<iEnd; ++i) {
96 delete fTargetsForMulticlass;
105 if(fDataSet!=0) {
delete fDataSet; fDataSet=0; }
113 fLogger->SetMinType(t);
120 ClassInfo* theClass = GetClassInfo(className);
121 if (theClass)
return theClass;
124 fClasses.push_back(
new ClassInfo(className) );
125 fClasses.back()->
SetNumber(fClasses.size()-1);
129 Log() << kHEADER <<
Form(
"[%s] : ",fName.Data()) <<
"Added class \"" << className <<
"\""<<
Endl;
131 Log() << kDEBUG <<
"\t with internal class number " << fClasses.back()->GetNumber() <<
Endl;
134 if (className ==
"Signal") fSignalClass = fClasses.size()-1;
136 return fClasses.back();
143 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); ++it) {
144 if ((*it)->GetName() ==
name)
return (*it);
154 return fClasses.at(cls);
165 for (
UInt_t cls = 0; cls < GetNClasses() ; cls++) {
166 Log() << kINFO <<
Form(
"Dataset[%s] : ",fName.Data()) <<
"Class index : " << cls <<
" name : " << GetClassInfo(cls)->GetName() <<
Endl;
174 return (ev->
GetClass() == fSignalClass);
181 if( !fTargetsForMulticlass ) fTargetsForMulticlass =
new std::vector<Float_t>( GetNClasses() );
183 fTargetsForMulticlass->assign( GetNClasses(), 0.0 );
184 fTargetsForMulticlass->at( ev->
GetClass() ) = 1.0;
185 return fTargetsForMulticlass;
194 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); ++it) {
204 ClassInfo* ptr = GetClassInfo(className);
222 fVariables.push_back(
VariableInfo( regexpr, title, unit,
223 fVariables.size()+1, varType, external, min, max, normalized ));
224 fNeedsRebuilding =
kTRUE;
225 return fVariables.back();
233 fNeedsRebuilding =
kTRUE;
234 return fVariables.back();
252 fTargets.size()+1,
type, external, min,
254 fNeedsRebuilding =
kTRUE;
255 return fTargets.back();
263 fNeedsRebuilding =
kTRUE;
264 return fTargets.back();
275 Bool_t normalized,
void* external )
279 fSpectators.push_back(
VariableInfo( regexpr, title, unit,
280 fSpectators.size()+1,
type, external, min, max, normalized ));
281 fNeedsRebuilding =
kTRUE;
282 return fSpectators.back();
290 fNeedsRebuilding =
kTRUE;
291 return fSpectators.back();
299 for (
UInt_t ivar=0; ivar<GetNVariables(); ivar++)
300 if (var == GetVariableInfo(ivar).GetInternalName())
return ivar;
302 for (
UInt_t ivar=0; ivar<GetNVariables(); ivar++)
303 Log() << kINFO <<
Form(
"Dataset[%s] : ",fName.Data()) << GetVariableInfo(ivar).GetInternalName() <<
Endl;
305 Log() << kFATAL <<
Form(
"Dataset[%s] : ",fName.Data()) <<
"<FindVarIndex> Variable \'" << var <<
"\' not found." <<
Endl;
317 if (className !=
"") {
323 if (fClasses.empty()) {
324 Log() << kWARNING <<
Form(
"Dataset[%s] : ",fName.Data()) <<
"No classes registered yet, cannot specify weight expression!" <<
Endl;
326 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); ++it) {
327 (*it)->SetWeight( expr );
336 GetClassInfo(className)->SetCorrelationMatrix(matrix);
344 if (className ==
"") {
345 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); ++it) {
346 (*it)->SetCut( cut );
360 if (className ==
"") {
361 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); ++it) {
362 const TCut& oldCut = (*it)->GetCut();
363 (*it)->SetCut( oldCut+cut );
377 std::vector<TString> vNames;
378 std::vector<TMVA::VariableInfo>::const_iterator viIt = GetVariableInfos().begin();
379 for(;viIt != GetVariableInfos().end(); ++viIt) vNames.push_back( (*viIt).GetExpression() );
392 <<
"Correlation matrix (" << className <<
"):" <<
Endl;
404 const UInt_t nvar = GetNVariables();
409 for (
UInt_t ivar=0; ivar<nvar; ivar++) {
410 for (
UInt_t jvar=0; jvar<nvar; jvar++) {
411 (*tm)(ivar, jvar) = (*
m)(ivar,jvar);
418 for (
UInt_t ivar=0; ivar<nvar; ivar++) {
426 for (
UInt_t ibin=1; ibin<=nvar; ibin++) {
427 for (
UInt_t jbin=1; jbin<=nvar; jbin++) {
433 const Float_t labelSize = 0.055;
454 Log() << kDEBUG <<
Form(
"Dataset[%s] : ",fName.Data()) <<
"Created correlation matrix as 2D histogram: " << h2->
GetName() <<
Endl;
464 if (fDataSet==0 || fNeedsRebuilding) {
465 if(fDataSet!=0) ClearDataSet();
467 if( !fDataSetManager )
468 Log() << kFATAL <<
Form(
"Dataset[%s] : ",fName.Data()) <<
"DataSetManager has not been set in DataSetInfo (GetDataSet() )." <<
Endl;
469 fDataSet = fDataSetManager->CreateDataSet(
GetName());
471 fNeedsRebuilding =
kFALSE;
481 return fSpectators.size();
483 for(std::vector<VariableInfo>::const_iterator spit=fSpectators.begin(); spit!=fSpectators.end(); ++spit) {
484 if(spit->GetVarType()!=
'C') nsp++;
494 for (
UInt_t cl = 0; cl < GetNClasses(); cl++) {
506 for (
UInt_t i = 0; i < GetNVariables(); i++) {
507 if (
TString(GetVariableInfo(i).GetExpression()).
Length() > maxL) maxL =
TString(GetVariableInfo(i).GetExpression()).Length();
518 for (
UInt_t i = 0; i < GetNTargets(); i++) {
519 if (
TString(GetTargetInfo(i).GetExpression()).
Length() > maxL) maxL =
TString(GetTargetInfo(i).GetExpression()).Length();
528 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;
529 return fTrainingSumSignalWeights;
535 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;
536 return fTrainingSumBackgrWeights;
542 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;
543 return fTestingSumSignalWeights ;
549 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;
550 return fTestingSumBackgrWeights ;
TMatrixT< Float_t > TMatrixF
char * Form(const char *fmt,...)
virtual void SetLabelSize(Float_t size=0.04)
Set size of axis labels The size is expressed in per cent of the pad width.
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
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)
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)