Logo ROOT   6.16/01
Reference Guide
TMVAClassification_PDERS.class.C
Go to the documentation of this file.
1// Class: ReadPDERS
2// Automatically generated by MethodBase::MakeClass
3//
4
5/* configuration options =====================================================
6
7#GEN -*-*-*-*-*-*-*-*-*-*-*- general info -*-*-*-*-*-*-*-*-*-*-*-
8
9Method : PDERS::PDERS
10TMVA Release : 4.2.1 [262657]
11ROOT Release : 6.16/01 [397313]
12Creator : sftnight
13Date : Sun Dec 19 22:13:31 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]
25VolumeRangeMode: "Adaptive" [Method to determine volume size]
26KernelEstimator: "Gauss" [Kernel estimation function]
27NEventsMin: "4.000000e+02" [nEventsMin for adaptive volume range]
28NEventsMax: "6.000000e+02" [nEventsMax for adaptive volume range]
29GaussSigma: "3.000000e-01" [Width (wrt volume size) of Gaussian kernel estimator]
30NormTree: "True" [Normalize binary search tree]
31# Default:
32VerbosityLevel: "Default" [Verbosity level]
33VarTransform: "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)"]
34CreateMVAPdfs: "False" [Create PDFs for classifier outputs (signal and background)]
35IgnoreNegWeightsInTraining: "False" [Events with negative weights are ignored in the training (but are included for testing and performance evaluation)]
36DeltaFrac: "3.000000e+00" [nEventsMin/Max for minmax and rms volume range]
37MaxVIterations: "1.500000e+02" [MaxVIterations for adaptive volume range]
38InitialScale: "9.900000e-01" [InitialScale for adaptive volume range]
39##
40
41
42#VAR -*-*-*-*-*-*-*-*-*-*-*-* variables *-*-*-*-*-*-*-*-*-*-*-*-
43
44NVar 4
45var1+var2 myvar1 myvar1 myvar1 'F' [-9.33803939819,7.69307804108]
46var1-var2 myvar2 myvar2 Expression 2 'F' [-3.25508260727,4.02912044525]
47var3 var3 var3 Variable 3 units 'F' [-5.2777428627,4.64297914505]
48var4 var4 var4 Variable 4 units 'F' [-5.6007027626,4.67435789108]
49NSpec 2
50var1*2 spec1 spec1 Spectator 1 units 'F' [-9.91655540466,8.7030172348]
51var1*3 spec2 spec2 Spectator 2 units 'F' [-14.874833107,13.0545253754]
52
53
54============================================================================ */
55
56#include <array>
57#include <vector>
58#include <cmath>
59#include <string>
60#include <iostream>
61
62#ifndef IClassifierReader__def
63#define IClassifierReader__def
64
65class IClassifierReader {
66
67 public:
68
69 // constructor
70 IClassifierReader() : fStatusIsClean( true ) {}
71 virtual ~IClassifierReader() {}
72
73 // return classifier response
74 virtual double GetMvaValue( const std::vector<double>& inputValues ) const = 0;
75
76 // returns classifier status
77 bool IsStatusClean() const { return fStatusIsClean; }
78
79 protected:
80
81 bool fStatusIsClean;
82};
83
84#endif
85
86class ReadPDERS : public IClassifierReader {
87
88 public:
89
90 // constructor
91 ReadPDERS( std::vector<std::string>& theInputVars )
92 : IClassifierReader(),
93 fClassName( "ReadPDERS" ),
94 fNvars( 4 )
95 {
96 // the training input variables
97 const char* inputVars[] = { "var1+var2", "var1-var2", "var3", "var4" };
98
99 // sanity checks
100 if (theInputVars.size() <= 0) {
101 std::cout << "Problem in class \"" << fClassName << "\": empty input vector" << std::endl;
102 fStatusIsClean = false;
103 }
104
105 if (theInputVars.size() != fNvars) {
106 std::cout << "Problem in class \"" << fClassName << "\": mismatch in number of input values: "
107 << theInputVars.size() << " != " << fNvars << std::endl;
108 fStatusIsClean = false;
109 }
110
111 // validate input variables
112 for (size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
113 if (theInputVars[ivar] != inputVars[ivar]) {
114 std::cout << "Problem in class \"" << fClassName << "\": mismatch in input variable names" << std::endl
115 << " for variable [" << ivar << "]: " << theInputVars[ivar].c_str() << " != " << inputVars[ivar] << std::endl;
116 fStatusIsClean = false;
117 }
118 }
119
120 // initialize min and max vectors (for normalisation)
121 fVmin[0] = 0;
122 fVmax[0] = 0;
123 fVmin[1] = 0;
124 fVmax[1] = 0;
125 fVmin[2] = 0;
126 fVmax[2] = 0;
127 fVmin[3] = 0;
128 fVmax[3] = 0;
129
130 // initialize input variable types
131 fType[0] = 'F';
132 fType[1] = 'F';
133 fType[2] = 'F';
134 fType[3] = 'F';
135
136 // initialize constants
137 Initialize();
138
139 }
140
141 // destructor
142 virtual ~ReadPDERS() {
143 Clear(); // method-specific
144 }
145
146 // the classifier response
147 // "inputValues" is a vector of input values in the same order as the
148 // variables given to the constructor
149 double GetMvaValue( const std::vector<double>& inputValues ) const override;
150
151 private:
152
153 // method-specific destructor
154 void Clear();
155
156 // common member variables
157 const char* fClassName;
158
159 const size_t fNvars;
160 size_t GetNvar() const { return fNvars; }
161 char GetType( int ivar ) const { return fType[ivar]; }
162
163 // normalisation of input variables
164 double fVmin[4];
165 double fVmax[4];
166 double NormVariable( double x, double xmin, double xmax ) const {
167 // normalise to output range: [-1, 1]
168 return 2*(x - xmin)/(xmax - xmin) - 1.0;
169 }
170
171 // type of input variable: 'F' or 'I'
172 char fType[4];
173
174 // initialize internal variables
175 void Initialize();
176 double GetMvaValue__( const std::vector<double>& inputValues ) const;
177
178 // private members (method specific)
179 // not implemented for class: "ReadPDERS"
180};
181 inline double ReadPDERS::GetMvaValue( const std::vector<double>& inputValues ) const
182 {
183 // classifier response value
184 double retval = 0;
185
186 // classifier response, sanity check first
187 if (!IsStatusClean()) {
188 std::cout << "Problem in class \"" << fClassName << "\": cannot return classifier response"
189 << " because status is dirty" << std::endl;
190 retval = 0;
191 }
192 else {
193 retval = GetMvaValue__( inputValues );
194 }
195
196 return retval;
197 }
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