77 #ifndef IClassifierReader__def
78 #define IClassifierReader__def
89 virtual double GetMvaValue(
const std::vector<double>& inputValues )
const = 0;
112 const char* inputVars[] = {
"max(track_1_IP,track_2_IP)",
"max(abs(track_1_IP_xy),abs(track_2_IP_xy))",
"track_1_track_2_DCA",
"INTT_meanHits" };
115 if (theInputVars.size() <= 0) {
116 std::cout <<
"Problem in class \"" <<
fClassName <<
"\": empty input vector" << std::endl;
120 if (theInputVars.size() !=
fNvars) {
121 std::cout <<
"Problem in class \"" <<
fClassName <<
"\": mismatch in number of input values: "
122 << theInputVars.size() <<
" != " <<
fNvars << std::endl;
127 for (
size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
128 if (theInputVars[ivar] != inputVars[ivar]) {
129 std::cout <<
"Problem in class \"" <<
fClassName <<
"\": mismatch in input variable names" << std::endl
130 <<
" for variable [" << ivar <<
"]: " << theInputVars[ivar].c_str() <<
" != " << inputVars[ivar] << std::endl;
166 double GetMvaValue(
const std::vector<double>& inputValues )
const override;
178 void Transform_1( std::vector<double> & iv,
int sigOrBgd )
const;
180 void Transform( std::vector<double> & iv,
int sigOrBgd )
const;
194 return 2*(x -
xmin)/(xmax - xmin) - 1.0;
202 double GetMvaValue__(
const std::vector<double>& inputValues )
const;
308 if (inputValues.size() != (
unsigned int)4) {
309 std::cout <<
"Input vector needs to be of size " << 4 << std::endl;
313 std::array<double, 15> fWeights1 {{}};
314 std::array<double, 1> fWeights2 {{}};
315 fWeights1.back() = 1.;
318 for (
int o=0; o<14; o++) {
319 std::array<double, 5>
buffer;
320 for (
int i = 0;
i<5 - 1;
i++) {
324 for (
int i=0;
i<5;
i++) {
325 fWeights1[o] += buffer[
i];
328 for (
int o=0; o<14; o++) {
332 for (
int o=0; o<1; o++) {
333 std::array<double, 15>
buffer;
334 for (
int i=0;
i<15;
i++) {
337 for (
int i=0;
i<15;
i++) {
338 fWeights2[o] += buffer[
i];
341 for (
int o=0; o<1; o++) {
350 if (x > 4.97)
return 1;
351 if (x < -4.97)
return -1;
353 float a = x * (135135.0f + x2 * (17325.0f + x2 * (378.0f + x2)));
354 float b = 135135.0f + x2 * (62370.0f + x2 * (3150.0f + x2 * 28.0f));
359 return 1.0/(1.0+exp(-x));
373 std::cout <<
"Problem in class \"" <<
fClassName <<
"\": cannot return classifier response"
374 <<
" because status is dirty" << std::endl;
377 std::vector<double> iV(inputValues);
391 fMin_1[0][0] = 0.0262883696705;
392 fMax_1[0][0] = 4.92083930969;
393 fScal_1[0][0] = 2.0/(fMax_1[0][0]-fMin_1[0][0]);
395 fMin_1[1][0] = 0.00383873376995;
396 fMax_1[1][0] = 4.99581956863;
397 fScal_1[1][0] = 2.0/(fMax_1[1][0]-fMin_1[1][0]);
399 fMin_1[2][0] = 0.00383873376995;
400 fMax_1[2][0] = 4.99581956863;
401 fScal_1[2][0] = 2.0/(fMax_1[2][0]-fMin_1[2][0]);
403 fMin_1[0][1] = 0.00748753221706;
404 fMax_1[0][1] = 4.8996257782;
405 fScal_1[0][1] = 2.0/(fMax_1[0][1]-fMin_1[0][1]);
407 fMin_1[1][1] = 9.33057162911e-05;
408 fMax_1[1][1] = 4.55496644974;
409 fScal_1[1][1] = 2.0/(fMax_1[1][1]-fMin_1[1][1]);
411 fMin_1[2][1] = 9.33057162911e-05;
412 fMax_1[2][1] = 4.8996257782;
413 fScal_1[2][1] = 2.0/(fMax_1[2][1]-fMin_1[2][1]);
415 fMin_1[0][2] = 3.39120670105e-05;
416 fMax_1[0][2] = 0.0499259270728;
417 fScal_1[0][2] = 2.0/(fMax_1[0][2]-fMin_1[0][2]);
419 fMin_1[1][2] = 1.57269468559e-07;
420 fMax_1[1][2] = 0.0499997623265;
421 fScal_1[1][2] = 2.0/(fMax_1[1][2]-fMin_1[1][2]);
423 fMin_1[2][2] = 1.57269468559e-07;
424 fMax_1[2][2] = 0.0499997623265;
425 fScal_1[2][2] = 2.0/(fMax_1[2][2]-fMin_1[2][2]);
429 fScal_1[0][3] = 2.0/(fMax_1[0][3]-fMin_1[0][3]);
433 fScal_1[1][3] = 2.0/(fMax_1[1][3]-fMin_1[1][3]);
437 fScal_1[2][3] = 2.0/(fMax_1[2][3]-fMin_1[2][3]);
445 if (cls < 0 || cls > 2) {
454 static std::vector<int> indicesGet;
455 static std::vector<int> indicesPut;
457 if ( indicesGet.empty() ) {
458 indicesGet.reserve(
fNvars);
459 indicesGet.push_back( 0);
460 indicesGet.push_back( 1);
461 indicesGet.push_back( 2);
462 indicesGet.push_back( 3);
464 if ( indicesPut.empty() ) {
465 indicesPut.reserve(
fNvars);
466 indicesPut.push_back( 0);
467 indicesPut.push_back( 1);
468 indicesPut.push_back( 2);
469 indicesPut.push_back( 3);
472 static std::vector<double> dv;
474 for (
int ivar=0; ivar<nVar; ivar++) dv[ivar] = iv[indicesGet.at(ivar)];
475 for (
int ivar=0;ivar<4;ivar++) {
477 double scale =
fScal_1[cls][ivar];
478 iv[indicesPut.at(ivar)] = scale*dv[ivar]-
offset;