67#ifndef IClassifierReader__def
68#define IClassifierReader__def
70class IClassifierReader {
75 IClassifierReader() : fStatusIsClean(
true ) {}
76 virtual ~IClassifierReader() {}
79 virtual double GetMvaValue(
const std::vector<double>& inputValues )
const = 0;
82 bool IsStatusClean()
const {
return fStatusIsClean; }
91class ReadCutsD :
public IClassifierReader {
96 ReadCutsD( std::vector<std::string>& theInputVars )
97 : IClassifierReader(),
98 fClassName(
"ReadCutsD" ),
102 const char* inputVars[] = {
"var1+var2",
"var1-var2",
"var3",
"var4" };
105 if (theInputVars.size() <= 0) {
106 std::cout <<
"Problem in class \"" << fClassName <<
"\": empty input vector" << std::endl;
107 fStatusIsClean =
false;
110 if (theInputVars.size() != fNvars) {
111 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in number of input values: "
112 << theInputVars.size() <<
" != " << fNvars << std::endl;
113 fStatusIsClean =
false;
117 for (
size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
118 if (theInputVars[ivar] != inputVars[ivar]) {
119 std::cout <<
"Problem in class \"" << fClassName <<
"\": mismatch in input variable names" << std::endl
120 <<
" for variable [" << ivar <<
"]: " << theInputVars[ivar].c_str() <<
" != " << inputVars[ivar] << std::endl;
121 fStatusIsClean =
false;
126 fVmin[0] = -5.64005947113037;
127 fVmax[0] = 4.8529167175293;
128 fVmin[1] = -2.92915463447571;
129 fVmax[1] = 3.70650386810303;
130 fVmin[2] = -4.17918729782104;
131 fVmax[2] = 3.51799082756042;
132 fVmin[3] = -3.33631753921509;
133 fVmax[3] = 3.39626932144165;
149 virtual ~ReadCutsD() {
156 double GetMvaValue(
const std::vector<double>& inputValues )
const override;
165 double fDecTF_1[3][4][4];
166 void InitTransform_1();
167 void Transform_1( std::vector<double> & iv,
int sigOrBgd )
const;
168 void InitTransform();
169 void Transform( std::vector<double> & iv,
int sigOrBgd )
const;
172 const char* fClassName;
175 size_t GetNvar()
const {
return fNvars; }
181 double NormVariable(
double x,
double xmin,
double xmax )
const {
191 double GetMvaValue__(
const std::vector<double>& inputValues )
const;
196 inline double ReadCutsD::GetMvaValue(
const std::vector<double>& inputValues )
const
202 if (!IsStatusClean()) {
203 std::cout <<
"Problem in class \"" << fClassName <<
"\": cannot return classifier response"
204 <<
" because status is dirty" << std::endl;
208 std::vector<double> iV(inputValues);
210 retval = GetMvaValue__( iV );
217inline void ReadCutsD::InitTransform_1()
220 fDecTF_1[0][0][0] = 1.2722714631;
221 fDecTF_1[0][0][1] = 0.0686064444285;
222 fDecTF_1[0][0][2] = -0.12911102307;
223 fDecTF_1[0][0][3] = -1.09274831745;
224 fDecTF_1[0][1][0] = 0.0686064444285;
225 fDecTF_1[0][1][1] = 0.955508716631;
226 fDecTF_1[0][1][2] = 0.160135175699;
227 fDecTF_1[0][1][3] = -0.260395275481;
228 fDecTF_1[0][2][0] = -0.12911102307;
229 fDecTF_1[0][2][1] = 0.160135175699;
230 fDecTF_1[0][2][2] = 1.82502263962;
231 fDecTF_1[0][2][3] = -0.851610263797;
232 fDecTF_1[0][3][0] = -1.09274831745;
233 fDecTF_1[0][3][1] = -0.260395275481;
234 fDecTF_1[0][3][2] = -0.851610263797;
235 fDecTF_1[0][3][3] = 2.83594069875;
236 fDecTF_1[1][0][0] = 1.25494894161;
237 fDecTF_1[1][0][1] = 0.0623620720116;
238 fDecTF_1[1][0][2] = -0.196685390931;
239 fDecTF_1[1][0][3] = -1.08407302428;
240 fDecTF_1[1][1][0] = 0.0623620720116;
241 fDecTF_1[1][1][1] = 0.989421920502;
242 fDecTF_1[1][1][2] = 0.225698355104;
243 fDecTF_1[1][1][3] = -0.268869598248;
244 fDecTF_1[1][2][0] = -0.196685390931;
245 fDecTF_1[1][2][1] = 0.225698355104;
246 fDecTF_1[1][2][2] = 1.81274154375;
247 fDecTF_1[1][2][3] = -0.812605958671;
248 fDecTF_1[1][3][0] = -1.08407302428;
249 fDecTF_1[1][3][1] = -0.268869598248;
250 fDecTF_1[1][3][2] = -0.812605958671;
251 fDecTF_1[1][3][3] = 2.87018256874;
252 fDecTF_1[2][0][0] = 1.14762966212;
253 fDecTF_1[2][0][1] = 0.0279230119711;
254 fDecTF_1[2][0][2] = -0.199814116336;
255 fDecTF_1[2][0][3] = -0.828429139126;
256 fDecTF_1[2][1][0] = 0.0279230119711;
257 fDecTF_1[2][1][1] = 0.95469118273;
258 fDecTF_1[2][1][2] = 0.185805400506;
259 fDecTF_1[2][1][3] = -0.162300136235;
260 fDecTF_1[2][2][0] = -0.199814116336;
261 fDecTF_1[2][2][1] = 0.185805400506;
262 fDecTF_1[2][2][2] = 1.79132300554;
263 fDecTF_1[2][2][3] = -0.772313501682;
264 fDecTF_1[2][3][0] = -0.828429139126;
265 fDecTF_1[2][3][1] = -0.162300136235;
266 fDecTF_1[2][3][2] = -0.772313501682;
267 fDecTF_1[2][3][3] = 2.19181433911;
271inline void ReadCutsD::Transform_1( std::vector<double>& iv,
int cls)
const
274 if (cls < 0 || cls > 2) {
280 static std::vector<int> indicesGet;
281 static std::vector<int> indicesPut;
283 if ( indicesGet.empty() ) {
284 indicesGet.reserve(fNvars);
285 indicesGet.push_back( 0);
286 indicesGet.push_back( 1);
287 indicesGet.push_back( 2);
288 indicesGet.push_back( 3);
290 if ( indicesPut.empty() ) {
291 indicesPut.reserve(fNvars);
292 indicesPut.push_back( 0);
293 indicesPut.push_back( 1);
294 indicesPut.push_back( 2);
295 indicesPut.push_back( 3);
298 std::vector<double> tv;
299 for (
int i=0; i<4;i++) {
301 for (
int j=0; j<4; j++)
302 v += iv[indicesGet.at(j)] * fDecTF_1[cls][i][j];
305 for (
int i=0; i<4;i++) iv[indicesPut.at(i)] = tv[i];
309inline void ReadCutsD::InitTransform()
315inline void ReadCutsD::Transform( std::vector<double>& iv,
int sigOrBgd )
const
317 Transform_1( iv, sigOrBgd );
Type GetType(const std::string &Name)
void Initialize(Bool_t useTMVAStyle=kTRUE)