80 #ifndef IClassifierReader__def
81 #define IClassifierReader__def
92 virtual double GetMvaValue(
const std::vector<double>& inputValues )
const = 0;
111 fClassName(
"DNeutralShower_FCALQualityMLP" ),
116 const char* inputVars[] = {
"nHits",
"e9e25Sh",
"e1e9Sh",
"sumUSh",
"sumVSh",
"asymUVSh",
"speedSh",
"dtTrSh" };
119 if (theInputVars.size() <= 0) {
120 std::cout <<
"Problem in class \"" <<
fClassName <<
"\": empty input vector" << std::endl;
124 if (theInputVars.size() !=
fNvars) {
125 std::cout <<
"Problem in class \"" <<
fClassName <<
"\": mismatch in number of input values: "
126 << theInputVars.size() <<
" != " <<
fNvars << std::endl;
131 for (
size_t ivar = 0; ivar < theInputVars.size(); ivar++) {
132 if (theInputVars[ivar] != inputVars[ivar]) {
133 std::cout <<
"Problem in class \"" <<
fClassName <<
"\": mismatch in input variable names" << std::endl
134 <<
" for variable [" << ivar <<
"]: " << theInputVars[ivar].c_str() <<
" != " << inputVars[ivar] << std::endl;
145 fVmax[2] = 0.99999988079071;
147 fVmax[3] = 0.99999988079071;
149 fVmax[4] = 0.99999988079071;
182 double GetMvaValue(
const std::vector<double>& inputValues )
const;
194 void Transform_1( std::vector<double> & iv,
int sigOrBgd )
const;
196 void Transform( std::vector<double> & iv,
int sigOrBgd )
const;
212 return 2*(x - xmin)/(xmax - xmin) - 1.0;
220 double GetMvaValue__(
const std::vector<double>& inputValues )
const;
359 if (inputValues.size() != (
unsigned int)
fLayerSize[0]-1) {
360 std::cout <<
"Input vector needs to be of size " <<
fLayerSize[0]-1 << std::endl;
367 for (
int l=0; l<fLayers-1; l++)
370 for (
int i=0; i<fLayerSize[0]-1; i++)
374 for (
int o=0; o<fLayerSize[1]-1; o++) {
375 for (
int i=0; i<fLayerSize[0]; i++) {
377 fWeights[1][o] += inputVal;
382 for (
int o=0; o<fLayerSize[2]; o++) {
383 for (
int i=0; i<fLayerSize[1]; i++) {
385 fWeights[2][o] += inputVal;
395 return exp(-x*x/2.0);
399 return 1.0/(1.0+exp(-x));
406 for (
int lIdx = 0; lIdx < 3; lIdx++) {
417 std::cout <<
"Problem in class \"" <<
fClassName <<
"\": cannot return classifier response"
418 <<
" because status is dirty" << std::endl;
424 std::vector<double> iV;
425 iV.reserve(inputValues.size());
427 for (std::vector<double>::const_iterator varIt = inputValues.begin();
428 varIt != inputValues.end(); varIt++, ivar++) {
435 std::vector<double> iV;
437 for (std::vector<double>::const_iterator varIt = inputValues.begin();
438 varIt != inputValues.end(); varIt++, ivar++) {
439 iV.push_back(*varIt);
459 fMin_1[0][1] = 0.323900818825;
461 fMin_1[1][1] = 0.223209112883;
463 fMin_1[2][1] = 0.223209112883;
465 fMin_1[0][2] = 0.196359068155;
467 fMin_1[1][2] = 0.159292444587;
469 fMin_1[2][2] = 0.159292444587;
471 fMin_1[0][3] = 3.04391463146e-08;
472 fMax_1[0][3] = 123.788467407;
473 fMin_1[1][3] = 2.02385636028e-10;
474 fMax_1[1][3] = 251.844528198;
475 fMin_1[2][3] = 2.02385636028e-10;
476 fMax_1[2][3] = 251.844528198;
477 fMin_1[0][4] = 1.07598518984e-09;
478 fMax_1[0][4] = 32.411315918;
479 fMin_1[1][4] = 2.56061630233e-11;
480 fMax_1[1][4] = 174.307571411;
481 fMin_1[2][4] = 2.56061630233e-11;
482 fMax_1[2][4] = 174.307571411;
489 fMin_1[0][6] = -1266.28295898;
490 fMax_1[0][6] = 202.097763062;
491 fMin_1[1][6] = -98087.1953125;
492 fMax_1[1][6] = 479840.125;
493 fMin_1[2][6] = -98087.1953125;
494 fMax_1[2][6] = 479840.125;
495 fMin_1[0][7] = -999975.1875;
496 fMax_1[0][7] = 127.996780396;
497 fMin_1[1][7] = -999973.375;
498 fMax_1[1][7] = 164.864715576;
499 fMin_1[2][7] = -999975.1875;
500 fMax_1[2][7] = 164.864715576;
507 if (cls < 0 || cls > 2) {
516 static std::vector<int> indicesGet;
517 static std::vector<int> indicesPut;
519 if ( indicesGet.empty() ) {
520 indicesGet.reserve(
fNvars);
521 indicesGet.push_back( 0);
522 indicesGet.push_back( 1);
523 indicesGet.push_back( 2);
524 indicesGet.push_back( 3);
525 indicesGet.push_back( 4);
526 indicesGet.push_back( 5);
527 indicesGet.push_back( 6);
528 indicesGet.push_back( 7);
530 if ( indicesPut.empty() ) {
531 indicesPut.reserve(
fNvars);
532 indicesPut.push_back( 0);
533 indicesPut.push_back( 1);
534 indicesPut.push_back( 2);
535 indicesPut.push_back( 3);
536 indicesPut.push_back( 4);
537 indicesPut.push_back( 5);
538 indicesPut.push_back( 6);
539 indicesPut.push_back( 7);
542 static std::vector<double> dv;
544 for (
int ivar=0; ivar<nVar; ivar++) dv[ivar] = iv[indicesGet.at(ivar)];
545 for (
int ivar=0;ivar<8;ivar++) {
546 double offset =
fMin_1[cls][ivar];
547 double scale = 1.0/(
fMax_1[cls][ivar]-
fMin_1[cls][ivar]);
548 iv[indicesPut.at(ivar)] = (dv[ivar]-offset)*scale * 2 - 1;
bool IsNormalised() const
double fWeightMatrix0to1[12][9]
double OutputActivationFnc(double x) const
void Transform(std::vector< double > &iv, int sigOrBgd) const
double GetMvaValue(const std::vector< double > &inputValues) const
bool IsStatusClean() const
double GetMvaValue__(const std::vector< double > &inputValues) const
double fWeightMatrix1to2[1][12]
void Transform_1(std::vector< double > &iv, int sigOrBgd) const
char GetType(int ivar) const
virtual ~DNeutralShower_FCALQualityMLP()
double ActivationFnc(double x) const
double NormVariable(double x, double xmin, double xmax) const
DNeutralShower_FCALQualityMLP(std::vector< std::string > &theInputVars)
virtual ~IClassifierReader()
virtual double GetMvaValue(const std::vector< double > &inputValues) const =0