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
40#include "TObject.h"
41#include "TString.h"
42#include "TTree.h"
43#include "TCut.h"
44#include "TMatrixDfwd.h"
45
46#include "TMVA/Types.h"
47#include "TMVA/VariableInfo.h"
48#include "TMVA/ClassInfo.h"
49#include "TMVA/Event.h"
50
51class TH2;
52
53namespace TMVA {
54
55 class DataSet;
56 class VariableTransformBase;
57 class MsgLogger;
58 class DataSetManager;
59
60 class DataSetInfo : public TObject {
61
62 public:
63
64 enum { kIsArrayVariable = BIT(15) };
65
66 DataSetInfo(const TString& name = "Default");
67 virtual ~DataSetInfo();
68
69 virtual const char* GetName() const { return fName.Data(); }
70
71 // the data set
72 void ClearDataSet() const;
73 DataSet* GetDataSet() const;
74
75 // ---
76 // the variable data
77 // ---
78 VariableInfo& AddVariable( const TString& expression, const TString& title = "", const TString& unit = "",
79 Double_t min = 0, Double_t max = 0, char varType='F',
80 Bool_t normalized = kTRUE, void* external = 0 );
81 VariableInfo& AddVariable( const VariableInfo& varInfo );
82
83 // NEW: add an array of variables (e.g. for image data)
84 void AddVariablesArray(const TString &expression, Int_t size, const TString &title = "", const TString &unit = "",
85 Double_t min = 0, Double_t max = 0, char type = 'F', Bool_t normalized = kTRUE,
86 void *external = 0 );
87
88 VariableInfo& AddTarget ( const TString& expression, const TString& title, const TString& unit,
89 Double_t min, Double_t max, Bool_t normalized = kTRUE, void* external = 0 );
90 VariableInfo& AddTarget ( const VariableInfo& varInfo );
91
92 VariableInfo& AddSpectator ( const TString& expression, const TString& title, const TString& unit,
93 Double_t min, Double_t max, char type = 'F', Bool_t normalized = kTRUE, void* external = 0 );
94 VariableInfo& AddSpectator ( const VariableInfo& varInfo );
95
96 ClassInfo* AddClass ( const TString& className );
97
98 // accessors
99
100 // general
101 std::vector<VariableInfo>& GetVariableInfos() { return fVariables; }
102 const std::vector<VariableInfo>& GetVariableInfos() const { return fVariables; }
104 const VariableInfo& GetVariableInfo( Int_t i ) const { return fVariables.at(i); }
105
106 Int_t GetVarArraySize(const TString &expression) const {
107 auto element = fVarArrays.find(expression);
108 return (element != fVarArrays.end()) ? element->second : -1;
109 }
111
112 std::vector<VariableInfo> &GetTargetInfos()
113 {
114 return fTargets;
115 }
116 const std::vector<VariableInfo> &GetTargetInfos() const { return fTargets; }
118 const VariableInfo &GetTargetInfo(Int_t i) const { return fTargets.at(i); }
119
120 std::vector<VariableInfo> &GetSpectatorInfos() { return fSpectators; }
121 const std::vector<VariableInfo> &GetSpectatorInfos() const { return fSpectators; }
123 const VariableInfo &GetSpectatorInfo(Int_t i) const { return fSpectators.at(i); }
124
125 UInt_t GetNVariables() const { return fVariables.size(); }
126 UInt_t GetNTargets() const { return fTargets.size(); }
127 UInt_t GetNSpectators(bool all = kTRUE) const;
128
129 const TString &GetNormalization() const { return fNormalization; }
130 void SetNormalization(const TString &norm) { fNormalization = norm; }
131
132 void SetTrainingSumSignalWeights(Double_t trainingSumSignalWeights)
133 {
134 fTrainingSumSignalWeights = trainingSumSignalWeights;}
135 void SetTrainingSumBackgrWeights(Double_t trainingSumBackgrWeights){fTrainingSumBackgrWeights = trainingSumBackgrWeights;}
136 void SetTestingSumSignalWeights (Double_t testingSumSignalWeights ){fTestingSumSignalWeights = testingSumSignalWeights ;}
137 void SetTestingSumBackgrWeights (Double_t testingSumBackgrWeights ){fTestingSumBackgrWeights = testingSumBackgrWeights ;}
138
143
144
145
146 // classification information
150 ClassInfo* GetClassInfo( Int_t clNum ) const;
151 ClassInfo* GetClassInfo( const TString& name ) const;
152 void PrintClasses() const;
153 UInt_t GetNClasses() const { return fClasses.size(); }
154 Bool_t IsSignal( const Event* ev ) const;
155 std::vector<Float_t>* GetTargetsForMulticlass( const Event* ev );
157
158 // by variable
159 Int_t FindVarIndex( const TString& ) const;
160
161 // weights
162 const TString GetWeightExpression(Int_t i) const { return GetClassInfo(i)->GetWeight(); }
163 void SetWeightExpression( const TString& exp, const TString& className = "" );
164
165 // cuts
166 const TCut& GetCut (Int_t i) const { return GetClassInfo(i)->GetCut(); }
167 const TCut& GetCut ( const TString& className ) const { return GetClassInfo(className)->GetCut(); }
168 void SetCut ( const TCut& cut, const TString& className );
169 void AddCut ( const TCut& cut, const TString& className );
170 Bool_t HasCuts() const;
171
172 std::vector<TString> GetListOfVariables() const;
173
174 // correlation matrix
175 const TMatrixD* CorrelationMatrix ( const TString& className ) const;
176 void SetCorrelationMatrix ( const TString& className, TMatrixD* matrix );
177 void PrintCorrelationMatrix( const TString& className );
179 const TString& hName,
180 const TString& hTitle ) const;
181
182 // options
184 const TString& GetSplitOptions() const { return fSplitOptions; }
185
186 // root dir
188 TDirectory* GetRootDir() const { return fOwnRootDir; }
189
190 void SetMsgType( EMsgType t ) const;
191
193 private:
194
196 void SetDataSetManager( DataSetManager* dsm ) { fDataSetManager = dsm; } // DSMTEST
197 friend class DataSetManager; // DSMTEST (datasetmanager test)
198
200
202
203 TString fName; // name of the dataset info object
204
205 mutable DataSet* fDataSet; // dataset, owned by this datasetinfo object
206 mutable Bool_t fNeedsRebuilding; // flag if rebuilding of dataset is needed (after change of cuts, vars, etc.)
207
208 // expressions/formulas
209 std::vector<VariableInfo> fVariables; // list of variable expressions/internal names
210 std::vector<VariableInfo> fTargets; // list of targets expressions/internal names
211 std::vector<VariableInfo> fSpectators; // list of spectators expressions/internal names
212
213 // variable arrays
214 std::map<TString, int> fVarArrays;
215
216 // the classes
217 mutable std::vector<ClassInfo*> fClasses; // name and other infos of the classes
218
221
226
227
228
229 TDirectory* fOwnRootDir; // ROOT output dir
230 Bool_t fVerbose; // Verbosity
231
232 UInt_t fSignalClass; // index of the class with the name signal
233
234 std::vector<Float_t>* fTargetsForMulticlass;//-> all targets 0 except the one with index==classNumber
235
236 mutable MsgLogger* fLogger; //! message logger
237 MsgLogger& Log() const { return *fLogger; }
238
239 public:
240
242 };
243}
244
245#endif
#define d(i)
Definition: RSha256.hxx:102
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:326
#define BIT(n)
Definition: Rtypes.h:83
char name[80]
Definition: TGX11.cxx:109
int type
Definition: TGX11.cxx:120
double exp(double)
A specialized string object used for TTree selections.
Definition: TCut.h:25
Describe directory structure in memory.
Definition: TDirectory.h:34
Service class for 2-Dim 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:60
const TString GetWeightExpression(Int_t i) const
Definition: DataSetInfo.h:162
std::vector< VariableInfo > & GetVariableInfos()
Definition: DataSetInfo.h:101
const std::vector< VariableInfo > & GetSpectatorInfos() const
Definition: DataSetInfo.h:121
Bool_t HasCuts() const
UInt_t GetNVariables() const
Definition: DataSetInfo.h:125
const std::vector< VariableInfo > & GetVariableInfos() const
Definition: DataSetInfo.h:102
UInt_t GetNSpectators(bool all=kTRUE) const
const VariableInfo & GetVariableInfo(Int_t i) const
Definition: DataSetInfo.h:104
Int_t GetVarArraySize(const TString &expression) const
Definition: DataSetInfo.h:106
void SetSplitOptions(const TString &so)
Definition: DataSetInfo.h:183
DataSetInfo(const DataSetInfo &)
Definition: DataSetInfo.h:199
TDirectory * fOwnRootDir
Definition: DataSetInfo.h:229
std::map< TString, int > fVarArrays
Definition: DataSetInfo.h:214
ClassInfo * AddClass(const TString &className)
virtual const char * GetName() const
Returns name of object.
Definition: DataSetInfo.h:69
const TString & GetNormalization() const
Definition: DataSetInfo.h:129
const TMatrixD * CorrelationMatrix(const TString &className) const
TString fNormalization
Definition: DataSetInfo.h:219
Bool_t IsVariableFromArray(Int_t i) const
Definition: DataSetInfo.h:110
std::vector< VariableInfo > & GetSpectatorInfos()
Definition: DataSetInfo.h:120
const VariableInfo & GetTargetInfo(Int_t i) const
Definition: DataSetInfo.h:118
TDirectory * GetRootDir() const
Definition: DataSetInfo.h:188
std::vector< ClassInfo * > fClasses
Definition: DataSetInfo.h:217
Double_t fTrainingSumBackgrWeights
Definition: DataSetInfo.h:223
void SetNormalization(const TString &norm)
Definition: DataSetInfo.h:130
Int_t GetTargetNameMaxLength() const
virtual ~DataSetInfo()
destructor
Definition: DataSetInfo.cxx:89
MsgLogger & Log() const
message logger
Definition: DataSetInfo.h:237
Double_t fTestingSumSignalWeights
Definition: DataSetInfo.h:224
Double_t GetTestingSumBackgrWeights()
void SetMsgType(EMsgType t) const
UInt_t GetNClasses() const
Definition: DataSetInfo.h:153
TString fSplitOptions
Definition: DataSetInfo.h:220
const TString & GetSplitOptions() const
Definition: DataSetInfo.h:184
UInt_t GetNTargets() const
Definition: DataSetInfo.h:126
Bool_t fNeedsRebuilding
Definition: DataSetInfo.h:206
const TCut & GetCut(const TString &className) const
Definition: DataSetInfo.h:167
void SetTestingSumSignalWeights(Double_t testingSumSignalWeights)
Definition: DataSetInfo.h:136
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:211
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:61
MsgLogger * fLogger
Definition: DataSetInfo.h:236
TH2 * CreateCorrelationMatrixHist(const TMatrixD *m, const TString &hName, const TString &hTitle) const
UInt_t GetSignalClassIndex()
Definition: DataSetInfo.h:156
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:116
void SetTrainingSumSignalWeights(Double_t trainingSumSignalWeights)
Definition: DataSetInfo.h:132
std::vector< TString > GetListOfVariables() const
returns list of variables
DataSet * fDataSet
Definition: DataSetInfo.h:205
ClassInfo * GetClassInfo(Int_t clNum) const
void SetTestingSumBackgrWeights(Double_t testingSumBackgrWeights)
Definition: DataSetInfo.h:137
void SetDataSetManager(DataSetManager *dsm)
Definition: DataSetInfo.h:196
Double_t GetTrainingSumSignalWeights()
Double_t fTrainingSumSignalWeights
Definition: DataSetInfo.h:222
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:210
const TCut & GetCut(Int_t i) const
Definition: DataSetInfo.h:166
const VariableInfo & GetSpectatorInfo(Int_t i) const
Definition: DataSetInfo.h:123
std::vector< Float_t > * fTargetsForMulticlass
Definition: DataSetInfo.h:234
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:103
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:112
void SetTrainingSumBackgrWeights(Double_t trainingSumBackgrWeights)
Definition: DataSetInfo.h:135
std::vector< VariableInfo > fVariables
Definition: DataSetInfo.h:209
void SetRootDir(TDirectory *d)
Definition: DataSetInfo.h:187
Int_t GetVariableNameMaxLength() const
Double_t fTestingSumBackgrWeights
Definition: DataSetInfo.h:225
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:192
VariableInfo & GetTargetInfo(Int_t i)
Definition: DataSetInfo.h:117
TMVA::DataSetManager * fDataSetManager
Definition: DataSetInfo.h:195
VariableInfo & GetSpectatorInfo(Int_t i)
Definition: DataSetInfo.h:122
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.
Class that contains all the data information.
Definition: DataSet.h:69
ostringstream derivative to redirect and format output
Definition: MsgLogger.h:59
Class for type info of MVA input variable.
Definition: VariableInfo.h:47
Mother of all ROOT objects.
Definition: TObject.h:37
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
Basic string class.
Definition: TString.h:131
const char * Data() const
Definition: TString.h:364
A TTree represents a columnar dataset.
Definition: TTree.h:72
create variable transformations
auto * m
Definition: textangle.C:8