LEMAmbyE50N591 Class Reference

#include <LEMAmbyE50N591.h>

List of all members.

Public Member Functions

 LEMAmbyE50N591 ()
 ~LEMAmbyE50N591 ()
double GetMvaValue (const std::vector< double > &inputValues) const
Double_t GetLEMAmbyE50N591 (NueRecord *nr)
Double_t GetLEMAmbyE50N591 (NueAnaReader *nueana)

Private Member Functions

void Clear ()
void InitTransform_1 ()
void Transform_1 (std::vector< double > &iv, int sigOrBgd) const
void InitTransform ()
void Transform (std::vector< double > &iv, int sigOrBgd) const
char GetType (int ivar) const
Bool_t IsNormalised () const
double NormVariable (double x, double xmin, double xmax) const
void Initialize ()
double GetMvaValue__ (const std::vector< double > &inputValues) const
double ActivationFnc (double x) const

Private Attributes

double fMin_1 [3][5]
double fMax_1 [3][5]
const char * fClassName
double fVmin [5]
double fVmax [5]
char fType [5]
int fLayers
int fLayerSize [3]
double fWeightMatrix0to1 [10][6]
double fWeightMatrix1to2 [1][10]
double * fWeights [3]

Detailed Description

Definition at line 13 of file LEMAmbyE50N591.h.


Constructor & Destructor Documentation

LEMAmbyE50N591::LEMAmbyE50N591 (  ) 

Definition at line 5 of file LEMAmbyE50N591.cxx.

References fType, fVmax, fVmin, Initialize(), and InitTransform().

00006 {
00007 
00008 
00009       // initialize min and max vectors (for normalisation)
00010       fVmin[0] = -1;
00011       fVmax[0] = 1;
00012       fVmin[1] = -1;
00013       fVmax[1] = 1;
00014       fVmin[2] = -1;
00015       fVmax[2] = 0.999999940395355;
00016       fVmin[3] = -1;
00017       fVmax[3] = 0.999999940395355;
00018       fVmin[4] = -1;
00019       fVmax[4] = 1;
00020 
00021       // initialize input variable types
00022       fType[0] = 'F';
00023       fType[1] = 'F';
00024       fType[2] = 'F';
00025       fType[3] = 'F';
00026       fType[4] = 'F';
00027 
00028       // initialize constants
00029       Initialize();
00030 
00031       // initialize transformation
00032       InitTransform();
00033 }//LEMAmbyE50N591

LEMAmbyE50N591::~LEMAmbyE50N591 (  )  [inline]

Definition at line 19 of file LEMAmbyE50N591.h.

00019                     {
00020      //Clear(); // method-specific
00021   }


Member Function Documentation

double LEMAmbyE50N591::ActivationFnc ( double  x  )  const [private]

Definition at line 149 of file LEMAmbyE50N591.cxx.

Referenced by GetMvaValue__().

00149                                                    {
00150    // hyperbolic tan
00151    return tanh(x);
00152 }

void LEMAmbyE50N591::Clear ( void   )  [inline, private]

Definition at line 157 of file LEMAmbyE50N591.cxx.

00158 {
00159    // nothing to clear
00160 }

Double_t LEMAmbyE50N591::GetLEMAmbyE50N591 ( NueAnaReader nueana  ) 

Definition at line 324 of file LEMAmbyE50N591.cxx.

References GetLEMAmbyE50N591(), and NueAnaReader::nuerecord.

00324                                                               {
00325 
00326   Double_t lemAmby=-1;
00327   lemAmby = GetLEMAmbyE50N591(nueana->nuerecord);
00328   return lemAmby;
00329 
00330 }

Double_t LEMAmbyE50N591::GetLEMAmbyE50N591 ( NueRecord nr  ) 

Definition at line 265 of file LEMAmbyE50N591.cxx.

References LEMStandard::GetfracCCy(), LEMStandard::GetMeanFracQMatched(), GetMvaValue(), LEMStandard::GetNCymean(), LEMStandard::Getymean(), ANtpEventInfoNue::phNueGeV, and NueRecord::srevent.

Referenced by GetLEMAmbyE50N591(), and NueStandard::GetPIDValue().

00265                                                        {
00266 
00267   //LEM4 PID value
00268   Double_t lemAmby=-1;
00269 
00270   //Input variables
00271   Double_t val_mny=-1;
00272   Double_t val_mfqm=-1;
00273   Double_t val_fcc=-1;
00274   Double_t val_recoe=-1;
00275   Double_t val_ncmny=-1;
00276 
00277   //Define the variables (y_cut = 1.0 = no y cut)
00278   val_mny = LEMStandard::Getymean(nr,1.0);
00279   val_mfqm = LEMStandard::GetMeanFracQMatched(nr,1.0);
00280   val_fcc = LEMStandard::GetfracCCy(nr,1.0);
00281   val_recoe = nr->srevent.phNueGeV;
00282   val_ncmny = LEMStandard::GetNCymean(nr,1.0);
00283 
00284   //Preselection: return automatic -1 for out of range events.
00285   if (val_ncmny<0||val_mny<0||val_mfqm<0||val_fcc<0||val_recoe<0) {
00286     lemAmby=-1;
00287   } else {
00288     //Define an input vector with the cariable names.
00289     std::vector<double> inputVec( 5 );
00290 
00291     inputVec[0]=val_mny;
00292     inputVec[1]=val_mfqm;
00293     inputVec[2]=val_fcc;
00294     inputVec[3]=val_recoe;
00295     inputVec[4]=val_ncmny;
00296       
00297     //Calculate the LEM discriminant!
00298    lemAmby = LEMAmbyE50N591::GetMvaValue(inputVec);
00299 
00300   
00301   //Transform so that the PID value is between 0.0 to 1.0.
00302   //A1Testrun showed spread from -0.10 to 1.13
00303   //A2lemAmby = (lemAmby + 0.029)/1.170;
00304   //A3lemAmby -0.071 -- 1.134
00305   //A5(A3_9) -0.0598634--1.13229
00306   //E50N591 -0.156096 -- 1.24958
00307  
00308    Double_t lowval=-0.156096;
00309    Double_t highval=1.24958;
00310    Double_t midpoint=(lowval+highval)/2.0;
00311    Double_t denom=(highval-lowval)*1.001; //prev 1.022mod
00312    //lemAmby = (( lemAmby - midpoint) / denom) + 0.5;
00313    lemAmby = (( lemAmby - lowval ) / denom); 
00314 
00315 
00316 
00317   }
00318   //return the PID:
00319   return lemAmby;
00320 
00321 }

double LEMAmbyE50N591::GetMvaValue ( const std::vector< double > &  inputValues  )  const [inline]

Definition at line 161 of file LEMAmbyE50N591.cxx.

References fVmax, fVmin, GetMvaValue__(), IsNormalised(), NormVariable(), and Transform().

Referenced by GetLEMAmbyE50N591().

00162    {
00163       // classifier response value
00164       double retval = 0;
00165 
00166       // classifier response, sanity check first
00167    
00168          if (IsNormalised()) {
00169             // normalise variables
00170             std::vector<double> iV;
00171             int ivar = 0;
00172             for (std::vector<double>::const_iterator varIt = inputValues.begin();
00173                  varIt != inputValues.end(); varIt++, ivar++) {
00174                iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));
00175             }
00176             Transform( iV, -1 );
00177             retval = GetMvaValue__( iV );
00178          }
00179          else {
00180             std::vector<double> iV;
00181             int ivar = 0;
00182             for (std::vector<double>::const_iterator varIt = inputValues.begin();
00183                  varIt != inputValues.end(); varIt++, ivar++) {
00184                iV.push_back(*varIt);
00185             }
00186             Transform( iV, -1 );
00187             retval = GetMvaValue__( iV );
00188          }
00189      
00190 
00191       return retval;
00192    }//cleanup

double LEMAmbyE50N591::GetMvaValue__ ( const std::vector< double > &  inputValues  )  const [inline, private]

Definition at line 114 of file LEMAmbyE50N591.cxx.

References ActivationFnc(), fLayers, fLayerSize, fWeightMatrix0to1, fWeightMatrix1to2, and fWeights.

Referenced by GetMvaValue().

00115 {
00116    if (inputValues.size() != (unsigned int)fLayerSize[0]-1) {
00117       std::cout << "Input vector needs to be of size " << fLayerSize[0]-1 << std::endl;
00118       return 0;
00119    }
00120 
00121    for (int l=0; l<fLayers; l++)
00122       for (int i=0; i<fLayerSize[l]; i++) fWeights[l][i]=0;
00123 
00124    for (int l=0; l<fLayers-1; l++)
00125       fWeights[l][fLayerSize[l]-1]=1;
00126 
00127    for (int i=0; i<fLayerSize[0]-1; i++)
00128       fWeights[0][i]=inputValues[i];
00129 
00130    // layer 0 to 1
00131    for (int o=0; o<fLayerSize[1]-1; o++) {
00132       for (int i=0; i<fLayerSize[0]; i++) {
00133          double inputVal = fWeightMatrix0to1[o][i] * fWeights[0][i];
00134          fWeights[1][o] += inputVal;
00135       }
00136       fWeights[1][o] = ActivationFnc(fWeights[1][o]);
00137    }
00138    // layer 1 to 2
00139    for (int o=0; o<fLayerSize[2]; o++) {
00140       for (int i=0; i<fLayerSize[1]; i++) {
00141          double inputVal = fWeightMatrix1to2[o][i] * fWeights[1][i];
00142          fWeights[2][o] += inputVal;
00143       }
00144    }
00145 
00146    return fWeights[2][0];
00147 }//GetMVAvalue

char LEMAmbyE50N591::GetType ( int  ivar  )  const [inline, private]

Definition at line 49 of file LEMAmbyE50N591.h.

References fType.

00049 { return fType[ivar]; }

void LEMAmbyE50N591::Initialize (  )  [inline, private]

Definition at line 36 of file LEMAmbyE50N591.cxx.

References fLayers, fLayerSize, fWeightMatrix0to1, fWeightMatrix1to2, and fWeights.

Referenced by LEMAmbyE50N591().

00037 {
00038 
00039    // build network structure
00040    fLayers = 3;
00041    fLayerSize[0] = 6; fWeights[0] = new double[6]; 
00042    fLayerSize[1] = 10; fWeights[1] = new double[10]; 
00043    fLayerSize[2] = 1; fWeights[2] = new double[1]; 
00044    // weight matrix from layer 0 to 1
00045    fWeightMatrix0to1[0][0] = 0.297042790422506;
00046    fWeightMatrix0to1[1][0] = 0.324937049596202;
00047    fWeightMatrix0to1[2][0] = -0.634103004016969;
00048    fWeightMatrix0to1[3][0] = -0.0867315300832394;
00049    fWeightMatrix0to1[4][0] = -0.329318066404884;
00050    fWeightMatrix0to1[5][0] = -0.212398349840982;
00051    fWeightMatrix0to1[6][0] = 1.3656015466073;
00052    fWeightMatrix0to1[7][0] = 1.68708129235172;
00053    fWeightMatrix0to1[8][0] = -0.0214842870351359;
00054    fWeightMatrix0to1[0][1] = 1.17879401164422;
00055    fWeightMatrix0to1[1][1] = 2.73888623729239;
00056    fWeightMatrix0to1[2][1] = 0.0488847850010252;
00057    fWeightMatrix0to1[3][1] = -2.1481674873969;
00058    fWeightMatrix0to1[4][1] = -3.29924026528054;
00059    fWeightMatrix0to1[5][1] = 0.0267339396222459;
00060    fWeightMatrix0to1[6][1] = 1.18012208477585;
00061    fWeightMatrix0to1[7][1] = -0.297802777516577;
00062    fWeightMatrix0to1[8][1] = 0.00318605078342812;
00063    fWeightMatrix0to1[0][2] = -1.32983160910878;
00064    fWeightMatrix0to1[1][2] = -0.336404229849725;
00065    fWeightMatrix0to1[2][2] = 0.0112458114060587;
00066    fWeightMatrix0to1[3][2] = -2.17400378410413;
00067    fWeightMatrix0to1[4][2] = -1.21576751607541;
00068    fWeightMatrix0to1[5][2] = -0.0537889264347545;
00069    fWeightMatrix0to1[6][2] = -0.563121005763723;
00070    fWeightMatrix0to1[7][2] = 0.405112704424101;
00071    fWeightMatrix0to1[8][2] = -0.00748170924223895;
00072    fWeightMatrix0to1[0][3] = -1.5950173683208;
00073    fWeightMatrix0to1[1][3] = -0.840413492251815;
00074    fWeightMatrix0to1[2][3] = 0.148996772340629;
00075    fWeightMatrix0to1[3][3] = -0.751073171809522;
00076    fWeightMatrix0to1[4][3] = 1.87544620031947;
00077    fWeightMatrix0to1[5][3] = 0.0986856860948806;
00078    fWeightMatrix0to1[6][3] = 1.0633801168158;
00079    fWeightMatrix0to1[7][3] = 0.109189331729661;
00080    fWeightMatrix0to1[8][3] = 0.00985382047517701;
00081    fWeightMatrix0to1[0][4] = -1.52850163211498;
00082    fWeightMatrix0to1[1][4] = -0.272655903692163;
00083    fWeightMatrix0to1[2][4] = 0.433454133381912;
00084    fWeightMatrix0to1[3][4] = -0.887845626851596;
00085    fWeightMatrix0to1[4][4] = 0.900329053739832;
00086    fWeightMatrix0to1[5][4] = 0.0732901379892319;
00087    fWeightMatrix0to1[6][4] = 0.689687694420149;
00088    fWeightMatrix0to1[7][4] = -0.271469510312583;
00089    fWeightMatrix0to1[8][4] = 0.00505481479446288;
00090    fWeightMatrix0to1[0][5] = -4.33472363245986;
00091    fWeightMatrix0to1[1][5] = -1.8657372483017;
00092    fWeightMatrix0to1[2][5] = 0.0688997673475049;
00093    fWeightMatrix0to1[3][5] = 4.5094012789039;
00094    fWeightMatrix0to1[4][5] = 3.10003970161723;
00095    fWeightMatrix0to1[5][5] = -0.0013689489591694;
00096    fWeightMatrix0to1[6][5] = -0.197683779599887;
00097    fWeightMatrix0to1[7][5] = 0.514477944600947;
00098    fWeightMatrix0to1[8][5] = -0.000235853371267831;
00099    // weight matrix from layer 1 to 2
00100    fWeightMatrix1to2[0][0] = -0.521350948546773;
00101    fWeightMatrix1to2[0][1] = 0.204922984988432;
00102    fWeightMatrix1to2[0][2] = 0.219453136000861;
00103    fWeightMatrix1to2[0][3] = -0.416173678486907;
00104    fWeightMatrix1to2[0][4] = -0.262346903727061;
00105    fWeightMatrix1to2[0][5] = 0.0218748561901953;
00106    fWeightMatrix1to2[0][6] = -0.222025299852116;
00107    fWeightMatrix1to2[0][7] = 0.269256265081341;
00108    fWeightMatrix1to2[0][8] = 0.00248334183771965;
00109    fWeightMatrix1to2[0][9] = 0.349886767839481;
00110 
00111 
00112 }//L4Init

void LEMAmbyE50N591::InitTransform (  )  [inline, private]

Definition at line 249 of file LEMAmbyE50N591.cxx.

References InitTransform_1().

Referenced by LEMAmbyE50N591().

00250 {
00251    InitTransform_1();
00252 }

void LEMAmbyE50N591::InitTransform_1 (  )  [inline, private]

Definition at line 197 of file LEMAmbyE50N591.cxx.

References fMax_1, and fMin_1.

Referenced by InitTransform().

00198 {
00199 
00200    // Normalization transformation, initialisation
00201    fMin_1[0][0] = 0.0228846855462;
00202    fMax_1[0][0] = 0.98898011446;
00203    fMin_1[1][0] = 0.00716135371476;
00204    fMax_1[1][0] = 0.998298585415;
00205    fMin_1[2][0] = 0.00716135371476;
00206    fMax_1[2][0] = 0.998298585415;
00207    fMin_1[0][1] = 0.0475189238787;
00208    fMax_1[0][1] = 1;
00209    fMin_1[1][1] = 0;
00210    fMax_1[1][1] = 1;
00211    fMin_1[2][1] = 0;
00212    fMax_1[2][1] = 1;
00213    fMin_1[0][2] = 0.019999999553;
00214    fMax_1[0][2] = 0.980000019073;
00215    fMin_1[1][2] = 0.019999999553;
00216    fMax_1[1][2] = 0.980000019073;
00217    fMin_1[2][2] = 0.019999999553;
00218    fMax_1[2][2] = 0.980000019073;
00219    fMin_1[0][3] = 0.665335953236;
00220    fMax_1[0][3] = 15.999958992;
00221    fMin_1[1][3] = 0.632570564747;
00222    fMax_1[1][3] = 15.9997463226;
00223    fMin_1[2][3] = 0.632570564747;
00224    fMax_1[2][3] = 15.999958992;
00225    fMin_1[0][4] = 0;
00226    fMax_1[0][4] = 0.998935520649;
00227    fMin_1[1][4] = 0;
00228    fMax_1[1][4] = 0.997940421104;
00229    fMin_1[2][4] = 0;
00230    fMax_1[2][4] = 0.998935520649;
00231 
00232 }

Bool_t LEMAmbyE50N591::IsNormalised (  )  const [inline, private]

Definition at line 54 of file LEMAmbyE50N591.h.

Referenced by GetMvaValue().

00054 { return false; }

double LEMAmbyE50N591::NormVariable ( double  x,
double  xmin,
double  xmax 
) const [inline, private]

Definition at line 57 of file LEMAmbyE50N591.h.

Referenced by GetMvaValue().

00057                                                                    {
00058       // normalise to output range: [-1, 1]
00059       return 2*(x - xmin)/(xmax - xmin) - 1.0;
00060    }

void LEMAmbyE50N591::Transform ( std::vector< double > &  iv,
int  sigOrBgd 
) const [inline, private]

Definition at line 255 of file LEMAmbyE50N591.cxx.

References Transform_1().

Referenced by GetMvaValue().

00256 {
00257    Transform_1( iv, sigOrBgd );
00258 }

void LEMAmbyE50N591::Transform_1 ( std::vector< double > &  iv,
int  sigOrBgd 
) const [inline, private]

Definition at line 235 of file LEMAmbyE50N591.cxx.

References fMax_1, and fMin_1.

Referenced by Transform().

00236 {
00237 if (cls < 0 || cls > 2) {
00238    if (2 > 1 ) cls = 2;
00239    else cls = 2;
00240 }
00241    for (int ivar=0;ivar<5;ivar++) {
00242       double offset = fMin_1[cls][ivar];
00243       double scale  = 1.0/(fMax_1[cls][ivar]-fMin_1[cls][ivar]);
00244       iv[ivar] = (iv[ivar]-offset)*scale * 2 - 1;
00245    }
00246 }


Member Data Documentation

const char* LEMAmbyE50N591::fClassName [private]

Definition at line 47 of file LEMAmbyE50N591.h.

int LEMAmbyE50N591::fLayers [private]

Definition at line 73 of file LEMAmbyE50N591.h.

Referenced by GetMvaValue__(), and Initialize().

int LEMAmbyE50N591::fLayerSize[3] [private]

Definition at line 74 of file LEMAmbyE50N591.h.

Referenced by GetMvaValue__(), and Initialize().

double LEMAmbyE50N591::fMax_1[3][5] [private]

Definition at line 40 of file LEMAmbyE50N591.h.

Referenced by InitTransform_1(), and Transform_1().

double LEMAmbyE50N591::fMin_1[3][5] [private]

Definition at line 39 of file LEMAmbyE50N591.h.

Referenced by InitTransform_1(), and Transform_1().

char LEMAmbyE50N591::fType[5] [private]

Definition at line 63 of file LEMAmbyE50N591.h.

Referenced by GetType(), and LEMAmbyE50N591().

double LEMAmbyE50N591::fVmax[5] [private]

Definition at line 56 of file LEMAmbyE50N591.h.

Referenced by GetMvaValue(), and LEMAmbyE50N591().

double LEMAmbyE50N591::fVmin[5] [private]

Definition at line 55 of file LEMAmbyE50N591.h.

Referenced by GetMvaValue(), and LEMAmbyE50N591().

double LEMAmbyE50N591::fWeightMatrix0to1[10][6] [private]

Definition at line 75 of file LEMAmbyE50N591.h.

Referenced by GetMvaValue__(), and Initialize().

double LEMAmbyE50N591::fWeightMatrix1to2[1][10] [private]

Definition at line 76 of file LEMAmbyE50N591.h.

Referenced by GetMvaValue__(), and Initialize().

double* LEMAmbyE50N591::fWeights[3] [private]

Definition at line 78 of file LEMAmbyE50N591.h.

Referenced by GetMvaValue__(), and Initialize().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1