Logo ROOT   6.16/01
Reference Guide
TMVAClassification_PDEFoam.class.C
Go to the documentation of this file.
1// Class: ReadPDEFoam
2// Automatically generated by MethodBase::MakeClass
3//
4
5/* configuration options =====================================================
6
7#GEN -*-*-*-*-*-*-*-*-*-*-*- general info -*-*-*-*-*-*-*-*-*-*-*-
8
9Method : PDEFoam::PDEFoam
10TMVA Release : 4.2.1 [262657]
11ROOT Release : 6.16/01 [397313]
12Creator : sftnight
13Date : Sun Dec 19 22:13:32 2021
14Host : Linux root-ubuntu-2004-3 5.4.0-73-generic #82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
15Dir : /home/sftnight/build/workspace/root-makedoc-v616/rootspi/rdoc/src/v6-16-00-patches/documentation/doxygen
16Training events: 2000
17Analysis type : [Classification]
18
19
20#OPT -*-*-*-*-*-*-*-*-*-*-*-*- options -*-*-*-*-*-*-*-*-*-*-*-*-
21
22# Set by User:
23V: "False" [Verbose output (short form of "VerbosityLevel" below - overrides the latter one)]
24H: "False" [Print method-specific help message]
25SigBgSeparate: "False" [Separate foams for signal and background]
26TailCut: "1.000000e-03" [Fraction of outlier events that are excluded from the foam in each dimension]
27VolFrac: "6.660000e-02" [Size of sampling box, used for density calculation during foam build-up (maximum value: 1.0 is equivalent to volume of entire foam)]
28nActiveCells: "500" [Maximum number of active cells to be created by the foam]
29nSampl: "2000" [Number of generated MC events per cell]
30nBin: "5" [Number of bins in edge histograms]
31Compress: "True" [Compress foam output file]
32Nmin: "100" [Number of events in cell required to split cell]
33Kernel: "None" [Kernel type used]
34# Default:
35VerbosityLevel: "Default" [Verbosity level]
36VarTransform: "None" [List of variable transformations performed before training, e.g., "D_Background,P_Signal,G,N_AllClasses" for: "Decorrelation, PCA-transformation, Gaussianisation, Normalisation, each for the given class of events ('AllClasses' denotes all events of all classes, if no class indication is given, 'All' is assumed)"]
37CreateMVAPdfs: "False" [Create PDFs for classifier outputs (signal and background)]
38IgnoreNegWeightsInTraining: "False" [Events with negative weights are ignored in the training (but are included for testing and performance evaluation)]
39MultiTargetRegression: "False" [Do regression with multiple targets]
40MaxDepth: "0" [Maximum depth of cell tree (0=unlimited)]
41FillFoamWithOrigWeights: "False" [Fill foam with original or boost weights]
42UseYesNoCell: "False" [Return -1 or 1 for bkg or signal like events]
43DTLogic: "None" [Use decision tree algorithm to split cells]
44TargetSelection: "Mean" [Target selection method]
45##
46
47
48#VAR -*-*-*-*-*-*-*-*-*-*-*-* variables *-*-*-*-*-*-*-*-*-*-*-*-
49
50NVar 4
51var1+var2 myvar1 myvar1 myvar1 'F' [-9.33803939819,7.69307804108]
52var1-var2 myvar2 myvar2 Expression 2 'F' [-3.25508260727,4.02912044525]
53var3 var3 var3 Variable 3 units 'F' [-5.2777428627,4.64297914505]
54var4 var4 var4 Variable 4 units 'F' [-5.6007027626,4.67435789108]
55NSpec 2
56var1*2 spec1 spec1 Spectator 1 units 'F' [-9.91655540466,8.7030172348]
57var1*3 spec2 spec2 Spectator 2 units 'F' [-14.874833107,13.0545253754]
58
59
60============================================================================ */
61
62#include <array>
63#include <vector>
64#include <cmath>
65#include <string>
66#include <iostream>
67
68#ifndef IClassifierReader__def
69#define IClassifierReader__def
70
71class IClassifierReader {
72
73 public:
74
75 // constructor
76 IClassifierReader() : fStatusIsClean( true ) {}
77 virtual ~IClassifierReader() {}
78
79 // return classifier response
80 virtual double GetMvaValue( const std::vector<double>& inputValues ) const = 0;
81
82 // returns classifier status
83 bool IsStatusClean() const { return fStatusIsClean; }
84
85 protected:
86
87 bool fStatusIsClean;
88};
89
90#endif
91
92class ReadPDEFoam : public IClassifierReader {
93
94 public:
95
96 // constructor
97 ReadPDEFoam( std::vector<std::string>& theInputVars )
98 : IClassifierReader(),
99 fClassName( "ReadPDEFoam" ),
100 fNvars( 4 )
101 {
102 // the training input variables
103 const char* inputVars[] = { "var1+var2", "var1-var2", "var3", "var4" };
104
105 // sanity checks
106 if (theInputVars.size() <= 0) {
107 std::cout << "Problem in class \"" << fClassName << "\": empty input vector" << std::endl;
108 fStatusIsClean = false;
109 }
110
111 if (theInputVars.size() != fNvars) {
112 std::cout << "Problem in class \"" << fClassName << "\": mismatch in number of input values: "
113 << theInputVars.size() << " != " << fNvars << std::endl;
114 fStatusIsClean = false;
115 }
116
117 // validate input variables
118 for (size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
119 if (theInputVars[ivar] != inputVars[ivar]) {
120 std::cout << "Problem in class \"" << fClassName << "\": mismatch in input variable names" << std::endl
121 << " for variable [" << ivar << "]: " << theInputVars[ivar].c_str() << " != " << inputVars[ivar] << std::endl;
122 fStatusIsClean = false;
123 }
124 }
125
126 // initialize min and max vectors (for normalisation)
127 fVmin[0] = 0;
128 fVmax[0] = 0;
129 fVmin[1] = 0;
130 fVmax[1] = 0;
131 fVmin[2] = 0;
132 fVmax[2] = 0;
133 fVmin[3] = 0;
134 fVmax[3] = 0;
135
136 // initialize input variable types
137 fType[0] = 'F';
138 fType[1] = 'F';
139 fType[2] = 'F';
140 fType[3] = 'F';
141
142 // initialize constants
143 Initialize();
144
145 }
146
147 // destructor
148 virtual ~ReadPDEFoam() {
149 Clear(); // method-specific
150 }
151
152 // the classifier response
153 // "inputValues" is a vector of input values in the same order as the
154 // variables given to the constructor
155 double GetMvaValue( const std::vector<double>& inputValues ) const override;
156
157 private:
158
159 // method-specific destructor
160 void Clear();
161
162 // common member variables
163 const char* fClassName;
164
165 const size_t fNvars;
166 size_t GetNvar() const { return fNvars; }
167 char GetType( int ivar ) const { return fType[ivar]; }
168
169 // normalisation of input variables
170 double fVmin[4];
171 double fVmax[4];
172 double NormVariable( double x, double xmin, double xmax ) const {
173 // normalise to output range: [-1, 1]
174 return 2*(x - xmin)/(xmax - xmin) - 1.0;
175 }
176
177 // type of input variable: 'F' or 'I'
178 char fType[4];
179
180 // initialize internal variables
181 void Initialize();
182 double GetMvaValue__( const std::vector<double>& inputValues ) const;
183
184 // private members (method specific)
185 inline double ReadPDEFoam::GetMvaValue( const std::vector<double>& inputValues ) const
186 {
187 // classifier response value
188 double retval = 0;
189
190 // classifier response, sanity check first
191 if (!IsStatusClean()) {
192 std::cout << "Problem in class \"" << fClassName << "\": cannot return classifier response"
193 << " because status is dirty" << std::endl;
194 retval = 0;
195 }
196 else {
197 retval = GetMvaValue__( inputValues );
198 }
199
200 return retval;
201 }
PyObject * fType
float xmin
Definition: THbookFile.cxx:93
float xmax
Definition: THbookFile.cxx:93
Double_t x[n]
Definition: legend1.C:17
Type GetType(const std::string &Name)
Definition: Systematics.cxx:34
void Initialize(Bool_t useTMVAStyle=kTRUE)
Definition: tmvaglob.cxx:176