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
68 fDataSetManager(
NULL),
71 fNeedsRebuilding(
kTRUE ),
76 fNormalization(
"NONE" ),
78 fTrainingSumSignalWeights(-1),
79 fTrainingSumBackgrWeights(-1),
80 fTestingSumSignalWeights (-1),
81 fTestingSumBackgrWeights (-1),
85 fTargetsForMulticlass(0),
97 for(
UInt_t i=0, iEnd = fClasses.size(); i<iEnd; ++i) {
101 delete fTargetsForMulticlass;
110 if(fDataSet!=0) {
delete fDataSet; fDataSet=0; }
116 fLogger->SetMinType(t);
123 ClassInfo* theClass = GetClassInfo(className);
124 if (theClass)
return theClass;
126 fClasses.push_back(
new ClassInfo(className) );
127 fClasses.back()->
SetNumber(fClasses.size()-1);
129 Log() <<
kINFO <<
"Added class \"" << className <<
"\"\t with internal class number "
130 << fClasses.back()->GetNumber() <<
Endl;
132 if (className ==
"Signal") fSignalClass = fClasses.size()-1;
134 return fClasses.back();
141 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); it++) {
142 if ((*it)->GetName() ==
name)
return (*it);
152 return fClasses.at(cls);
163 for (
UInt_t cls = 0; cls < GetNClasses() ; cls++) {
164 Log() <<
kINFO <<
"Class index : " << cls <<
" name : " << GetClassInfo(cls)->GetName() <<
Endl;
172 return (ev->
GetClass() == fSignalClass);
179 if( !fTargetsForMulticlass ) fTargetsForMulticlass =
new std::vector<Float_t>( GetNClasses() );
181 fTargetsForMulticlass->assign( GetNClasses(), 0.0 );
182 fTargetsForMulticlass->at( ev->
GetClass() ) = 1.0;
183 return fTargetsForMulticlass;
192 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); it++) {
202 ClassInfo* ptr = GetClassInfo(className);
220 fVariables.push_back(
VariableInfo( regexpr, title, unit,
221 fVariables.size()+1, varType, external,
min,
max, normalized ));
222 fNeedsRebuilding =
kTRUE;
223 return fVariables.back();
231 fNeedsRebuilding =
kTRUE;
232 return fVariables.back();
250 fTargets.size()+1,
type, external,
min,
252 fNeedsRebuilding =
kTRUE;
253 return fTargets.back();
261 fNeedsRebuilding =
kTRUE;
262 return fTargets.back();
273 Bool_t normalized,
void* external )
277 fSpectators.push_back(
VariableInfo( regexpr, title, unit,
278 fSpectators.size()+1,
type, external,
min,
max, normalized ));
279 fNeedsRebuilding =
kTRUE;
280 return fSpectators.back();
288 fNeedsRebuilding =
kTRUE;
289 return fSpectators.back();
297 for (
UInt_t ivar=0; ivar<GetNVariables(); ivar++)
298 if (var == GetVariableInfo(ivar).GetInternalName())
return ivar;
300 for (
UInt_t ivar=0; ivar<GetNVariables(); ivar++)
301 Log() <<
kINFO << GetVariableInfo(ivar).GetInternalName() <<
Endl;
303 Log() <<
kFATAL <<
"<FindVarIndex> Variable \'" << var <<
"\' not found." <<
Endl;
315 if (className !=
"") {
321 if (fClasses.empty()) {
322 Log() <<
kWARNING <<
"No classes registered yet, cannot specify weight expression!" <<
Endl;
324 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); it++) {
325 (*it)->SetWeight( expr );
334 GetClassInfo(className)->SetCorrelationMatrix(matrix);
342 if (className ==
"") {
343 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); it++) {
344 (*it)->SetCut( cut );
358 if (className ==
"") {
359 for (std::vector<ClassInfo*>::iterator it = fClasses.begin(); it < fClasses.end(); it++) {
360 const TCut& oldCut = (*it)->GetCut();
361 (*it)->SetCut( oldCut+cut );
375 std::vector<TString> vNames;
376 std::vector<TMVA::VariableInfo>::const_iterator viIt = GetVariableInfos().begin();
377 for(;viIt != GetVariableInfos().end(); viIt++) vNames.push_back( (*viIt).GetExpression() );
388 Log() <<
kINFO <<
"Correlation matrix (" << className <<
"):" <<
Endl;
400 const UInt_t nvar = GetNVariables();
405 for (
UInt_t ivar=0; ivar<nvar; ivar++) {
406 for (
UInt_t jvar=0; jvar<nvar; jvar++) {
407 (*tm)(ivar, jvar) = (*m)(ivar,jvar);
414 for (
UInt_t ivar=0; ivar<nvar; ivar++) {
422 for (
UInt_t ibin=1; ibin<=nvar; ibin++) {
423 for (
UInt_t jbin=1; jbin<=nvar; jbin++) {
429 const Float_t labelSize = 0.055;
460 if (fDataSet==0 || fNeedsRebuilding) {
461 if(fDataSet!=0) ClearDataSet();
463 if( !fDataSetManager )
464 Log() <<
kFATAL <<
"DataSetManager has not been set in DataSetInfo (GetDataSet() )." <<
Endl;
465 fDataSet = fDataSetManager->CreateDataSet(GetName());
467 fNeedsRebuilding =
kFALSE;
477 return fSpectators.size();
479 for(std::vector<VariableInfo>::const_iterator spit=fSpectators.begin(); spit!=fSpectators.end(); ++spit) {
480 if(spit->GetVarType()!=
'C') nsp++;
490 for (
UInt_t cl = 0; cl < GetNClasses(); cl++) {
491 if (
TString(GetClassInfo(cl)->GetName()).
Length() > maxL) maxL =
TString(GetClassInfo(cl)->GetName()).Length();
499 if (fTrainingSumSignalWeights<0)
Log() <<
kFATAL <<
" asking for the sum of training signal event weights which is not initicalised yet" <<
Endl;
500 return fTrainingSumSignalWeights;
503 if (fTrainingSumBackgrWeights<0)
Log() <<
kFATAL <<
" asking for the sum of training backgr event weights which is not initicalised yet" <<
Endl;
504 return fTrainingSumBackgrWeights;
507 if (fTestingSumSignalWeights<0)
Log() <<
kFATAL <<
" asking for the sum of testing signal event weights which is not initicalised yet" <<
Endl;
508 return fTestingSumSignalWeights ;
511 if (fTestingSumBackgrWeights<0)
Log() <<
kFATAL <<
" asking for the sum of testing backgr event weights which is not initicalised yet" <<
Endl;
512 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.
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
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.