41 #ifndef ROOT_TMVA_MsgLogger
44 #ifndef ROOT_TMVA_Tools
47 #ifndef ROOT_TMVA_DataSet
50 #ifndef ROOT_TMVA_DataSetInfo
53 #ifndef ROOT_TMVA_DataSetManager
56 #ifndef ROOT_TMVA_Event
65 fDataSetManager(
NULL),
68 fNeedsRebuilding(
kTRUE ),
73 fNormalization(
"NONE" ),
75 fTrainingSumSignalWeights(-1),
76 fTrainingSumBackgrWeights(-1),
77 fTestingSumSignalWeights (-1),
78 fTestingSumBackgrWeights (-1),
82 fTargetsForMulticlass(0),
94 for(
UInt_t i=0, iEnd = fClasses.size(); i<iEnd; ++i) {
98 delete fTargetsForMulticlass;
107 if(fDataSet!=0) {
delete fDataSet; fDataSet=0; }
113 fLogger->SetMinType(t);
120 ClassInfo* theClass = GetClassInfo(className);
121 if (theClass)
return theClass;
123 fClasses.push_back(
new ClassInfo(className) );
124 fClasses.back()->
SetNumber(fClasses.size()-1);
126 Log() <<
kINFO <<
"Added class \"" << className <<
"\"\t with internal class number "
127 << 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 <<
"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();
247 fTargets.size()+1,
type, external,
min,
249 fNeedsRebuilding =
kTRUE;
250 return fTargets.back();
258 fNeedsRebuilding =
kTRUE;
259 return fTargets.back();
270 Bool_t normalized,
void* external )
274 fSpectators.push_back(
VariableInfo( regexpr, title, unit,
275 fSpectators.size()+1,
type, external,
min,
max, normalized ));
276 fNeedsRebuilding =
kTRUE;
277 return fSpectators.back();
285 fNeedsRebuilding =
kTRUE;
286 return fSpectators.back();
294 for (
UInt_t ivar=0; ivar<GetNVariables(); ivar++)
295 if (var == GetVariableInfo(ivar).GetInternalName())
return ivar;
297 for (
UInt_t ivar=0; ivar<GetNVariables(); ivar++)
298 Log() <<
kINFO << GetVariableInfo(ivar).GetInternalName() <<
Endl;
300 Log() <<
kFATAL <<
"<FindVarIndex> Variable \'" << var <<
"\' not found." <<
Endl;
312 if (className !=
"") {
318 if (fClasses.empty()) {
319 Log() <<
kWARNING <<
"No classes registered yet, cannot specify weight expression!" <<
Endl;
321 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); it++) {
322 (*it)->SetWeight( expr );
331 GetClassInfo(className)->SetCorrelationMatrix(matrix);
339 if (className ==
"") {
340 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); it++) {
341 (*it)->SetCut( cut );
355 if (className ==
"") {
356 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); it++) {
357 const TCut& oldCut = (*it)->GetCut();
358 (*it)->SetCut( oldCut+cut );
372 std::vector<TString> vNames;
373 std::vector<TMVA::VariableInfo>::const_iterator viIt = GetVariableInfos().begin();
374 for(;viIt != GetVariableInfos().end(); viIt++) vNames.push_back( (*viIt).GetExpression() );
385 Log() <<
kINFO <<
"Correlation matrix (" << className <<
"):" <<
Endl;
397 const UInt_t nvar = GetNVariables();
402 for (
UInt_t ivar=0; ivar<nvar; ivar++) {
403 for (
UInt_t jvar=0; jvar<nvar; jvar++) {
404 (*tm)(ivar, jvar) = (*m)(ivar,jvar);
411 for (
UInt_t ivar=0; ivar<nvar; ivar++) {
419 for (
UInt_t ibin=1; ibin<=nvar; ibin++) {
420 for (
UInt_t jbin=1; jbin<=nvar; jbin++) {
426 const Float_t labelSize = 0.055;
457 if (fDataSet==0 || fNeedsRebuilding) {
458 if(fDataSet!=0) ClearDataSet();
460 if( !fDataSetManager )
461 Log() <<
kFATAL <<
"DataSetManager has not been set in DataSetInfo (GetDataSet() )." <<
Endl;
462 fDataSet = fDataSetManager->CreateDataSet(GetName());
464 fNeedsRebuilding =
kFALSE;
474 return fSpectators.size();
476 for(std::vector<VariableInfo>::const_iterator spit=fSpectators.begin(); spit!=fSpectators.end(); ++spit) {
477 if(spit->GetVarType()!=
'C') nsp++;
487 for (
UInt_t cl = 0; cl < GetNClasses(); cl++) {
488 if (
TString(GetClassInfo(cl)->GetName()).
Length() > maxL) maxL =
TString(GetClassInfo(cl)->GetName()).Length();
496 if (fTrainingSumSignalWeights<0)
Log() <<
kFATAL <<
" asking for the sum of training signal event weights which is not initicalised yet" <<
Endl;
497 return fTrainingSumSignalWeights;
500 if (fTrainingSumBackgrWeights<0)
Log() <<
kFATAL <<
" asking for the sum of training backgr event weights which is not initicalised yet" <<
Endl;
501 return fTrainingSumBackgrWeights;
504 if (fTestingSumSignalWeights<0)
Log() <<
kFATAL <<
" asking for the sum of testing signal event weights which is not initicalised yet" <<
Endl;
505 return fTestingSumSignalWeights ;
508 if (fTestingSumBackgrWeights<0)
Log() <<
kFATAL <<
" asking for the sum of testing backgr event weights which is not initicalised yet" <<
Endl;
509 return fTestingSumBackgrWeights ;
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.
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
MsgLogger & Endl(MsgLogger &ml)
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 ...
virtual void SetMaximum(Double_t maximum=-1111)
virtual void LabelsOption(Option_t *option="h", Option_t *axis="X")
Set option(s) to draw axis with labels.
void SetCut(const TCut &cut, const TString &className)
set the cut for the classes
TMatrixT< Float_t > TMatrixF
TString & ReplaceAll(const TString &s1, const TString &s2)
Int_t GetClassNameMaxLength() const
virtual void SetMinimum(Double_t minimum=-1111)
void AddClass(const char *cname, Version_t id, const 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).
void AddCut(const TCut &cut, const TString &className)
set the cut for the classes
Double_t GetTrainingSumSignalWeights()
DataSet * GetDataSet() const
returns data set
void SetWeight(const TString &weight)
Bool_t IsSignal(const Event *ev) const
virtual ~DataSetInfo()
destructor
virtual void SetMarkerColor(Color_t mcolor=1)
void PrintCorrelationMatrix(const TString &className)
calculates the correlation matrices for signal and background, prints them to standard output...
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
DataSetInfo(const TString &name="Default")
constructor
A specialized string object used for TTree selections.
void SetMsgType(EMsgType t) const
void SetCorrelationMatrix(const TString &className, TMatrixD *matrix)
Double_t GetTestingSumSignalWeights()
Service class for 2-Dim histogram classes.
2-D histogram with a float per channel (see TH1 documentation)}
ClassInfo * GetClassInfo(Int_t clNum) const
const TMatrixD * GetCorrelationMatrix() const
const TMatrixD * CorrelationMatrix(const TString &className) 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...
virtual const char * GetName() const
Returns name of object.
const TCut & GetCut() const
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 SetMarkerSize(Size_t msize=1)
void PrintClasses() const
TH2 * CreateCorrelationMatrixHist(const TMatrixD *m, const TString &hName, const TString &hTitle) const
Double_t GetTrainingSumBackgrWeights()
void SetCut(const TCut &cut)
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
void ClearDataSet() const
ClassInfo * AddClass(const TString &className)
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Mother of all ROOT objects.
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...
UInt_t GetNSpectators(bool all=kTRUE) const
void SetNumber(const UInt_t index)
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 ...
std::vector< TString > GetListOfVariables() const
returns list of variables
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content.
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Double_t GetTestingSumBackgrWeights()
std::vector< Float_t > * GetTargetsForMulticlass(const Event *ev)
virtual void SetLabelOffset(Float_t offset=0.005, Option_t *axis="X")
Set offset between axis and axis' labels.