Logo ROOT  
Reference Guide
DataSetInfo.h
Go to the documentation of this file.
1// // @(#)root/tmva $Id$
2// Author: Andreas Hoecker, Peter Speckmayer, Joerg Stelzer, Helge Voss
3
4/**********************************************************************************
5 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6 * Package: TMVA *
7 * Class : DataSetInfo *
8 * Web : http://tmva.sourceforge.net *
9 * *
10 * Description: *
11 * Contains all the data information *
12 * *
13 * Authors (alphabetical): *
14 * Peter Speckmayer <speckmay@mail.cern.ch> - CERN, Switzerland *
15 * Joerg Stelzer <Joerg.Stelzer@cern.ch> - DESY, Germany *
16 * *
17 * Copyright (c) 2008-2011: *
18 * CERN, Switzerland *
19 * MPI-K Heidelberg, Germany *
20 * DESY Hamburg, Germany *
21 * *
22 * Redistribution and use in source and binary forms, with or without *
23 * modification, are permitted according to the terms listed in LICENSE *
24 * (http://tmva.sourceforge.net/LICENSE) *
25 **********************************************************************************/
26
27#ifndef ROOT_TMVA_DataSetInfo
28#define ROOT_TMVA_DataSetInfo
29
30//////////////////////////////////////////////////////////////////////////
31// //
32// DataSetInfo //
33// //
34// Class that contains all the data information //
35// //
36//////////////////////////////////////////////////////////////////////////
37
38#include <iosfwd>
39#include <vector>
40#include <map>
41
42#include "TObject.h"
43#include "TString.h"
44#include "TTree.h"
45#include "TCut.h"
46#include "TMatrixDfwd.h"
47
48#include "TMVA/Types.h"
49#include "TMVA/VariableInfo.h"
50#include "TMVA/ClassInfo.h"
51#include "TMVA/Event.h"
52
53class TH2;
54
55namespace TMVA {
56
57 class DataSet;
58 class VariableTransformBase;
59 class MsgLogger;
60 class DataSetManager;
61
62 class DataSetInfo : public TObject {
63
64 public:
65
66 enum { kIsArrayVariable = BIT(15) };
67
68 DataSetInfo(const TString& name = "Default");
69 virtual ~DataSetInfo();
70
71 virtual const char* GetName() const { return fName.Data(); }
72
73 // the data set
74 void ClearDataSet() const;
75 DataSet* GetDataSet() const;
76
77 // ---
78 // the variable data
79 // ---
80 VariableInfo& AddVariable( const TString& expression, const TString& title = "", const TString& unit = "",
81 Double_t min = 0, Double_t max = 0, char varType='F',
82 Bool_t normalized = kTRUE, void* external = 0 );
83 VariableInfo& AddVariable( const VariableInfo& varInfo );
84
85 // NEW: add an array of variables (e.g. for image data)
86 void AddVariablesArray(const TString &expression, Int_t size, const TString &title = "", const TString &unit = "",
87 Double_t min = 0, Double_t max = 0, char type = 'F', Bool_t normalized = kTRUE,
88 void *external = 0 );
89
90 VariableInfo& AddTarget ( const TString& expression, const TString& title, const TString& unit,
91 Double_t min, Double_t max, Bool_t normalized = kTRUE, void* external = 0 );
92 VariableInfo& AddTarget ( const VariableInfo& varInfo );
93
94 VariableInfo& AddSpectator ( const TString& expression, const TString& title, const TString& unit,
95 Double_t min, Double_t max, char type = 'F', Bool_t normalized = kTRUE, void* external = 0 );
96 VariableInfo& AddSpectator ( const VariableInfo& varInfo );
97
98 ClassInfo* AddClass ( const TString& className );
99
100 // accessors
101
102 // general
103 std::vector<VariableInfo>& GetVariableInfos() { return fVariables; }
104 const std::vector<VariableInfo>& GetVariableInfos() const { return fVariables; }
106 const VariableInfo& GetVariableInfo( Int_t i ) const { return fVariables.at(i); }
107
108 Int_t GetVarArraySize(const TString &expression) const {
109 auto element = fVarArrays.find(expression);
110 return (element != fVarArrays.end()) ? element->second : -1;
111 }
113
114 std::vector<VariableInfo> &GetTargetInfos()
115 {
116 return fTargets;
117 }
118 const std::vector<VariableInfo> &GetTargetInfos() const { return fTargets; }
120 const VariableInfo &GetTargetInfo(Int_t i) const { return fTargets.at(i); }
121
122 std::vector<VariableInfo> &GetSpectatorInfos() { return fSpectators; }
123 const std::vector<VariableInfo> &GetSpectatorInfos() const { return fSpectators; }
125 const VariableInfo &GetSpectatorInfo(Int_t i) const { return fSpectators.at(i); }
126
127 UInt_t GetNVariables() const { return fVariables.size(); }
128 UInt_t GetNTargets() const { return fTargets.size(); }
129 UInt_t GetNSpectators(bool all = kTRUE) const;
130
131 const TString &GetNormalization() const { return fNormalization; }
132 void SetNormalization(const TString &norm) { fNormalization = norm; }
133
134 void SetTrainingSumSignalWeights(Double_t trainingSumSignalWeights)
135 {
136 fTrainingSumSignalWeights = trainingSumSignalWeights;}
137 void SetTrainingSumBackgrWeights(Double_t trainingSumBackgrWeights){fTrainingSumBackgrWeights = trainingSumBackgrWeights;}
138 void SetTestingSumSignalWeights (Double_t testingSumSignalWeights ){fTestingSumSignalWeights = testingSumSignalWeights ;}
139 void SetTestingSumBackgrWeights (Double_t testingSumBackgrWeights ){fTestingSumBackgrWeights = testingSumBackgrWeights ;}
140
145
146
147
148 // classification information
152 ClassInfo* GetClassInfo( Int_t clNum ) const;
153 ClassInfo* GetClassInfo( const TString& name ) const;
154 void PrintClasses() const;
155 UInt_t GetNClasses() const { return fClasses.size(); }
156 Bool_t IsSignal( const Event* ev ) const;
157 std::vector<Float_t>* GetTargetsForMulticlass( const Event* ev );
159
160 // by variable
161 Int_t FindVarIndex( const TString& ) const;
162
163 // weights
164 const TString GetWeightExpression(Int_t i) const { return GetClassInfo(i)->GetWeight(); }
165 void SetWeightExpression( const TString& exp, const TString& className = "" );
166
167 // cuts
168 const TCut& GetCut (Int_t i) const { return GetClassInfo(i)->GetCut(); }
169 const TCut& GetCut ( const TString& className ) const { return GetClassInfo(className)->GetCut(); }
170 void SetCut ( const TCut& cut, const TString& className );
171 void AddCut ( const TCut& cut, const TString& className );
172 Bool_t HasCuts() const;
173
174 std::vector<TString> GetListOfVariables() const;
175
176 // correlation matrix
177 const TMatrixD* CorrelationMatrix ( const TString& className ) const;
178 void SetCorrelationMatrix ( const TString& className, TMatrixD* matrix );
179 void PrintCorrelationMatrix( const TString& className );
181 const TString& hName,
182 const TString& hTitle ) const;
183
184 // options
186 const TString& GetSplitOptions() const { return fSplitOptions; }
187
188 // root dir
190 TDirectory* GetRootDir() const { return fOwnRootDir; }
191
192 void SetMsgType( EMsgType t ) const;
193
195 private:
196
198 void SetDataSetManager( DataSetManager* dsm ) { fDataSetManager = dsm; } // DSMTEST
199 friend class DataSetManager; // DSMTEST (datasetmanager test)
200
201 DataSetInfo(const DataSetInfo &) = delete;
202 DataSetInfo & operator= (const DataSetInfo &) = delete;
203
205
206 TString fName; // name of the dataset info object
207
208 mutable DataSet* fDataSet; // dataset, owned by this datasetinfo object
209 mutable Bool_t fNeedsRebuilding; // flag if rebuilding of dataset is needed (after change of cuts, vars, etc.)
210
211 // expressions/formulas
212 std::vector<VariableInfo> fVariables; // list of variable expressions/internal names
213 std::vector<VariableInfo> fTargets; // list of targets expressions/internal names
214 std::vector<VariableInfo> fSpectators; // list of spectators expressions/internal names
215
216 // variable arrays
217 std::map<TString, int> fVarArrays;
218
219 // the classes
220 mutable std::vector<ClassInfo*> fClasses; // name and other infos of the classes
221
224
229
230
231
232 TDirectory* fOwnRootDir; // ROOT output dir
233 Bool_t fVerbose; // Verbosity
234
235 UInt_t fSignalClass; // index of the class with the name signal
236
237 std::vector<Float_t>* fTargetsForMulticlass;//-> all targets 0 except the one with index==classNumber
238
239 mutable MsgLogger* fLogger; //! message logger
240 MsgLogger& Log() const { return *fLogger; }
241
242 public:
243
245 };
246}
247
248#endif
#define d(i)
Definition: RSha256.hxx:102
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition: RtypesCore.h:45
unsigned int UInt_t
Definition: RtypesCore.h:46
bool Bool_t
Definition: RtypesCore.h:63
double Double_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:100
#define ClassDef(name, id)
Definition: Rtypes.h:325
#define BIT(n)
Definition: Rtypes.h:85
char name[80]
Definition: TGX11.cxx:110
int type
Definition: TGX11.cxx:121
A specialized string object used for TTree selections.
Definition: TCut.h:25
Describe directory structure in memory.
Definition: TDirectory.h:45
Service class for 2-D histogram classes.
Definition: TH2.h:30
Class that contains all the information of a class.
Definition: ClassInfo.h:49
const TCut & GetCut() const
Definition: ClassInfo.h:64
const TString & GetWeight() const
Definition: ClassInfo.h:63
Class that contains all the data information.
Definition: DataSetInfo.h:62
const TString GetWeightExpression(Int_t i) const
Definition: DataSetInfo.h:164
std::vector< VariableInfo > & GetVariableInfos()
Definition: DataSetInfo.h:103
const std::vector< VariableInfo > & GetSpectatorInfos() const
Definition: DataSetInfo.h:123
Bool_t HasCuts() const
UInt_t GetNVariables() const
Definition: DataSetInfo.h:127
const std::vector< VariableInfo > & GetVariableInfos() const
Definition: DataSetInfo.h:104
UInt_t GetNSpectators(bool all=kTRUE) const
const VariableInfo & GetVariableInfo(Int_t i) const
Definition: DataSetInfo.h:106
Int_t GetVarArraySize(const TString &expression) const
Definition: DataSetInfo.h:108
void SetSplitOptions(const TString &so)
Definition: DataSetInfo.h:185
DataSetInfo & operator=(const DataSetInfo &)=delete
TDirectory * fOwnRootDir
Definition: DataSetInfo.h:232
std::map< TString, int > fVarArrays
Definition: DataSetInfo.h:217
ClassInfo * AddClass(const TString &className)
virtual const char * GetName() const
Returns name of object.
Definition: DataSetInfo.h:71
const TString & GetNormalization() const
Definition: DataSetInfo.h:131
const TMatrixD * CorrelationMatrix(const TString &className) const
TString fNormalization
Definition: DataSetInfo.h:222
Bool_t IsVariableFromArray(Int_t i) const
Definition: DataSetInfo.h:112
std::vector< VariableInfo > & GetSpectatorInfos()
Definition: DataSetInfo.h:122
const VariableInfo & GetTargetInfo(Int_t i) const
Definition: DataSetInfo.h:120
TDirectory * GetRootDir() const
Definition: DataSetInfo.h:190
std::vector< ClassInfo * > fClasses
Definition: DataSetInfo.h:220
Double_t fTrainingSumBackgrWeights
Definition: DataSetInfo.h:226
void SetNormalization(const TString &norm)
Definition: DataSetInfo.h:132
Int_t GetTargetNameMaxLength() const
virtual ~DataSetInfo()
destructor
Definition: DataSetInfo.cxx:83
MsgLogger & Log() const
message logger
Definition: DataSetInfo.h:240
Double_t fTestingSumSignalWeights
Definition: DataSetInfo.h:227
Double_t GetTestingSumBackgrWeights()
void SetMsgType(EMsgType t) const
UInt_t GetNClasses() const
Definition: DataSetInfo.h:155
TString fSplitOptions
Definition: DataSetInfo.h:223
const TString & GetSplitOptions() const
Definition: DataSetInfo.h:186
UInt_t GetNTargets() const
Definition: DataSetInfo.h:128
Bool_t fNeedsRebuilding
Definition: DataSetInfo.h:209
const TCut & GetCut(const TString &className) const
Definition: DataSetInfo.h:169
void SetTestingSumSignalWeights(Double_t testingSumSignalWeights)
Definition: DataSetInfo.h:138
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
std::vector< VariableInfo > fSpectators
Definition: DataSetInfo.h:214
void PrintCorrelationMatrix(TTree *theTree)
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
Definition: DataSetInfo.cxx:56
MsgLogger * fLogger
Definition: DataSetInfo.h:239
TH2 * CreateCorrelationMatrixHist(const TMatrixD *m, const TString &hName, const TString &hTitle) const
UInt_t GetSignalClassIndex()
Definition: DataSetInfo.h:158
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...
const std::vector< VariableInfo > & GetTargetInfos() const
Definition: DataSetInfo.h:118
void SetTrainingSumSignalWeights(Double_t trainingSumSignalWeights)
Definition: DataSetInfo.h:134
std::vector< TString > GetListOfVariables() const
returns list of variables
DataSet * fDataSet
Definition: DataSetInfo.h:208
ClassInfo * GetClassInfo(Int_t clNum) const
void SetTestingSumBackgrWeights(Double_t testingSumBackgrWeights)
Definition: DataSetInfo.h:139
void SetDataSetManager(DataSetManager *dsm)
Definition: DataSetInfo.h:198
Double_t GetTrainingSumSignalWeights()
Double_t fTrainingSumSignalWeights
Definition: DataSetInfo.h:225
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,...
std::vector< VariableInfo > fTargets
Definition: DataSetInfo.h:213
const TCut & GetCut(Int_t i) const
Definition: DataSetInfo.h:168
const VariableInfo & GetSpectatorInfo(Int_t i) const
Definition: DataSetInfo.h:125
std::vector< Float_t > * fTargetsForMulticlass
Definition: DataSetInfo.h:237
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 & GetVariableInfo(Int_t i)
Definition: DataSetInfo.h:105
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< VariableInfo > & GetTargetInfos()
Definition: DataSetInfo.h:114
void SetTrainingSumBackgrWeights(Double_t trainingSumBackgrWeights)
Definition: DataSetInfo.h:137
std::vector< VariableInfo > fVariables
Definition: DataSetInfo.h:212
void SetRootDir(TDirectory *d)
Definition: DataSetInfo.h:189
Int_t GetVariableNameMaxLength() const
Double_t fTestingSumBackgrWeights
Definition: DataSetInfo.h:228
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...
DataSetManager * GetDataSetManager()
Definition: DataSetInfo.h:194
VariableInfo & GetTargetInfo(Int_t i)
Definition: DataSetInfo.h:119
DataSetInfo(const DataSetInfo &)=delete
TMVA::DataSetManager * fDataSetManager
Definition: DataSetInfo.h:197
VariableInfo & GetSpectatorInfo(Int_t i)
Definition: DataSetInfo.h:124
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
Definition: DataSetInfo.cxx:98
Class that contains all the data information.
Class that contains all the data information.
Definition: DataSet.h:58
ostringstream derivative to redirect and format output
Definition: MsgLogger.h:57
Class for type info of MVA input variable.
Definition: VariableInfo.h:47
EMsgType
Definition: Types.h:55
Mother of all ROOT objects.
Definition: TObject.h:37
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:187
Basic string class.
Definition: TString.h:136
const char * Data() const
Definition: TString.h:369
A TTree represents a columnar dataset.
Definition: TTree.h:79
create variable transformations
auto * m
Definition: textangle.C:8