LEMAmbyE50N691 Class Reference

#include <LEMAmbyE50N691.h>

List of all members.

Public Member Functions

 LEMAmbyE50N691 ()
 ~LEMAmbyE50N691 ()
double GetMvaValue (const std::vector< double > &inputValues) const
Double_t GetLEMAmbyE50N691 (NueRecord *nr)
Double_t GetLEMAmbyE50N691 (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][6]
double fMax_1 [3][6]
const char * fClassName
double fVmin [6]
double fVmax [6]
char fType [6]
int fLayers
int fLayerSize [3]
double fWeightMatrix0to1 [10][7]
double fWeightMatrix1to2 [1][10]
double * fWeights [3]

Detailed Description

Definition at line 13 of file LEMAmbyE50N691.h.


Constructor & Destructor Documentation

LEMAmbyE50N691::LEMAmbyE50N691 (  ) 

Definition at line 5 of file LEMAmbyE50N691.cxx.

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

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

LEMAmbyE50N691::~LEMAmbyE50N691 (  )  [inline]

Definition at line 19 of file LEMAmbyE50N691.h.

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


Member Function Documentation

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

Definition at line 158 of file LEMAmbyE50N691.cxx.

Referenced by GetMvaValue__().

00158                                                    {
00159    // hyperbolic tan
00160    return tanh(x);
00161 }

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

Definition at line 166 of file LEMAmbyE50N691.cxx.

00167 {
00168    // nothing to clear
00169 }

Double_t LEMAmbyE50N691::GetLEMAmbyE50N691 ( NueAnaReader nueana  ) 

Definition at line 342 of file LEMAmbyE50N691.cxx.

References GetLEMAmbyE50N691(), and NueAnaReader::nuerecord.

00342                                                               {
00343 
00344   Double_t lemAmby=-1;
00345   lemAmby = GetLEMAmbyE50N691(nueana->nuerecord);
00346   return lemAmby;
00347 
00348 }

Double_t LEMAmbyE50N691::GetLEMAmbyE50N691 ( NueRecord nr  ) 

Definition at line 280 of file LEMAmbyE50N691.cxx.

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

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

00280                                                        {
00281 
00282   //LEM4 PID value
00283   Double_t lemAmby=-1;
00284 
00285   //Input variables
00286   Double_t val_mny=-1;
00287   Double_t val_mfqm=-1;
00288   Double_t val_fcc=-1;
00289   Double_t val_recoe=-1;
00290   Double_t val_ncmny=-1;
00291   Double_t val_ncmfqm=-1;
00292 
00293   //Define the variables (y_cut = 1.0 = no y cut)
00294   val_mny = LEMStandard::Getymean(nr,1.0);
00295   val_mfqm = LEMStandard::GetMeanFracQMatched(nr,1.0);
00296   val_fcc = LEMStandard::GetfracCCy(nr,1.0);
00297   val_recoe = nr->srevent.phNueGeV;
00298   val_ncmfqm = LEMStandard::GetNCMeanFracQMatched(nr,1.0);
00299   val_ncmny = LEMStandard::GetNCymean(nr,1.0);
00300 
00301   //Preselection: return automatic -1 for out of range events.
00302   if (val_ncmny<0||val_ncmfqm<0||val_mny<0||val_mfqm<0||val_fcc<0||val_recoe<0) {
00303     lemAmby=-1;
00304   } else {
00305     //Define an input vector with the cariable names.
00306     std::vector<double> inputVec( 6 );
00307 
00308     inputVec[0]=val_mny;
00309     inputVec[1]=val_mfqm;
00310     inputVec[2]=val_fcc;
00311     inputVec[3]=val_recoe;
00312     inputVec[4]=val_ncmny;
00313     inputVec[5]=val_ncmfqm;
00314       
00315     //Calculate the LEM discriminant!
00316    lemAmby = LEMAmbyE50N691::GetMvaValue(inputVec);
00317 
00318   
00319   //Transform so that the PID value is between 0.0 to 1.0.
00320   //A1Testrun showed spread from -0.10 to 1.13
00321   //A2lemAmby = (lemAmby + 0.029)/1.170;
00322   //A3lemAmby -0.071 -- 1.134
00323   //A5(A3_9) -0.0598634--1.13229
00324   //E50N691  -0.234354--1.20513
00325 
00326 
00327    Double_t lowval=-0.234354;
00328    Double_t highval=1.20513;
00329    Double_t midpoint=(lowval+highval)/2.0;
00330    Double_t denom=(highval-lowval)*1.001; //prev 1.022mod
00331    //lemAmby = (( lemAmby - midpoint) / denom) + 0.5;
00332    lemAmby = (( lemAmby - lowval ) / denom); 
00333 
00334 
00335   }
00336   //return the PID:
00337   return lemAmby;
00338 
00339 }

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

Definition at line 170 of file LEMAmbyE50N691.cxx.

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

Referenced by GetLEMAmbyE50N691().

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

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

Definition at line 123 of file LEMAmbyE50N691.cxx.

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

Referenced by GetMvaValue().

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

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

Definition at line 49 of file LEMAmbyE50N691.h.

References fType.

00049 { return fType[ivar]; }

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

Definition at line 38 of file LEMAmbyE50N691.cxx.

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

Referenced by LEMAmbyE50N691().

00039 {
00040   // build network structure
00041    fLayers = 3;
00042    fLayerSize[0] = 7; fWeights[0] = new double[7]; 
00043    fLayerSize[1] = 10; fWeights[1] = new double[10]; 
00044    fLayerSize[2] = 1; fWeights[2] = new double[1]; 
00045    // weight matrix from layer 0 to 1
00046    fWeightMatrix0to1[0][0] = 0.270755352001138;
00047    fWeightMatrix0to1[1][0] = 0.124851301085762;
00048    fWeightMatrix0to1[2][0] = 0.228165000584316;
00049    fWeightMatrix0to1[3][0] = -0.804302350968627;
00050    fWeightMatrix0to1[4][0] = 1.40482228605609;
00051    fWeightMatrix0to1[5][0] = -1.59824969701617;
00052    fWeightMatrix0to1[6][0] = -0.120264048984722;
00053    fWeightMatrix0to1[7][0] = -0.127034043557079;
00054    fWeightMatrix0to1[8][0] = 0.284203292578543;
00055    fWeightMatrix0to1[0][1] = 0.182667883567616;
00056    fWeightMatrix0to1[1][1] = 3.34786150885716;
00057    fWeightMatrix0to1[2][1] = 1.39749746353061;
00058    fWeightMatrix0to1[3][1] = -1.77466962947428;
00059    fWeightMatrix0to1[4][1] = 0.292086756417874;
00060    fWeightMatrix0to1[5][1] = 0.0100812301361321;
00061    fWeightMatrix0to1[6][1] = -0.0827330645482468;
00062    fWeightMatrix0to1[7][1] = -2.82522262543631;
00063    fWeightMatrix0to1[8][1] = 0.190830459529022;
00064    fWeightMatrix0to1[0][2] = 0.0637887823189096;
00065    fWeightMatrix0to1[1][2] = 1.05472725295233;
00066    fWeightMatrix0to1[2][2] = -1.34581565860913;
00067    fWeightMatrix0to1[3][2] = -0.19489301187994;
00068    fWeightMatrix0to1[4][2] = -0.797255146700641;
00069    fWeightMatrix0to1[5][2] = -0.0848833324097296;
00070    fWeightMatrix0to1[6][2] = -0.0386468266217164;
00071    fWeightMatrix0to1[7][2] = -2.31935702080177;
00072    fWeightMatrix0to1[8][2] = 0.0638466076865949;
00073    fWeightMatrix0to1[0][3] = -0.0748476467304008;
00074    fWeightMatrix0to1[1][3] = -1.89081485375151;
00075    fWeightMatrix0to1[2][3] = -1.54822569576917;
00076    fWeightMatrix0to1[3][3] = 0.967818311146661;
00077    fWeightMatrix0to1[4][3] = 1.07973298142773;
00078    fWeightMatrix0to1[5][3] = -0.121778160500955;
00079    fWeightMatrix0to1[6][3] = 0.0315526857734212;
00080    fWeightMatrix0to1[7][3] = -0.889280867922996;
00081    fWeightMatrix0to1[8][3] = -0.0791961157414961;
00082    fWeightMatrix0to1[0][4] = -0.0896431355723157;
00083    fWeightMatrix0to1[1][4] = -0.787742655840307;
00084    fWeightMatrix0to1[2][4] = -1.57601147535322;
00085    fWeightMatrix0to1[3][4] = 0.550236947342049;
00086    fWeightMatrix0to1[4][4] = 0.82729038066998;
00087    fWeightMatrix0to1[5][4] = -0.157480195962658;
00088    fWeightMatrix0to1[6][4] = 0.0318100556797228;
00089    fWeightMatrix0to1[7][4] = -0.965561350242499;
00090    fWeightMatrix0to1[8][4] = -0.0964465676929348;
00091    fWeightMatrix0to1[0][5] = -0.126988721013905;
00092    fWeightMatrix0to1[1][5] = 0.120160629748694;
00093    fWeightMatrix0to1[2][5] = -0.275215566265995;
00094    fWeightMatrix0to1[3][5] = -1.7146260068946;
00095    fWeightMatrix0to1[4][5] = 0.776919659548909;
00096    fWeightMatrix0to1[5][5] = 0.655163624780459;
00097    fWeightMatrix0to1[6][5] = 0.0567902055934061;
00098    fWeightMatrix0to1[7][5] = 0.88443281505962;
00099    fWeightMatrix0to1[8][5] = -0.132855647771769;
00100    fWeightMatrix0to1[0][6] = -0.00787122974401658;
00101    fWeightMatrix0to1[1][6] = -3.37811149125262;
00102    fWeightMatrix0to1[2][6] = -4.28195385475786;
00103    fWeightMatrix0to1[3][6] = 2.07236274506228;
00104    fWeightMatrix0to1[4][6] = -0.121522541781733;
00105    fWeightMatrix0to1[5][6] = -0.767677651327477;
00106    fWeightMatrix0to1[6][6] = 0.00555908089925202;
00107    fWeightMatrix0to1[7][6] = 4.46144552904799;
00108    fWeightMatrix0to1[8][6] = -0.00826185365026335;
00109    // weight matrix from layer 1 to 2
00110    fWeightMatrix1to2[0][0] = -0.167499910998796;
00111    fWeightMatrix1to2[0][1] = 0.275404884636255;
00112    fWeightMatrix1to2[0][2] = -0.530247767078582;
00113    fWeightMatrix1to2[0][3] = -0.186954704601141;
00114    fWeightMatrix1to2[0][4] = -0.222556311774063;
00115    fWeightMatrix1to2[0][5] = -0.253915115167186;
00116    fWeightMatrix1to2[0][6] = 0.074755968203667;
00117    fWeightMatrix1to2[0][7] = -0.379456850444989;
00118    fWeightMatrix1to2[0][8] = -0.175752270716442;
00119    fWeightMatrix1to2[0][9] = 0.32494417995557;
00120 
00121 }//L4Init

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

Definition at line 264 of file LEMAmbyE50N691.cxx.

References InitTransform_1().

Referenced by LEMAmbyE50N691().

00265 {
00266    InitTransform_1();
00267 }

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

Definition at line 206 of file LEMAmbyE50N691.cxx.

References fMax_1, and fMin_1.

Referenced by InitTransform().

00207 {
00208 
00209  // Normalization transformation, initialisation
00210    fMin_1[0][0] = 0.0228846855462;
00211    fMax_1[0][0] = 0.98898011446;
00212    fMin_1[1][0] = 0.00716135371476;
00213    fMax_1[1][0] = 0.998298585415;
00214    fMin_1[2][0] = 0.00716135371476;
00215    fMax_1[2][0] = 0.998298585415;
00216    fMin_1[0][1] = 0.0475189238787;
00217    fMax_1[0][1] = 1;
00218    fMin_1[1][1] = 0;
00219    fMax_1[1][1] = 1;
00220    fMin_1[2][1] = 0;
00221    fMax_1[2][1] = 1;
00222    fMin_1[0][2] = 0.019999999553;
00223    fMax_1[0][2] = 0.980000019073;
00224    fMin_1[1][2] = 0.019999999553;
00225    fMax_1[1][2] = 0.980000019073;
00226    fMin_1[2][2] = 0.019999999553;
00227    fMax_1[2][2] = 0.980000019073;
00228    fMin_1[0][3] = 0.665335953236;
00229    fMax_1[0][3] = 15.999958992;
00230    fMin_1[1][3] = 0.632570564747;
00231    fMax_1[1][3] = 15.9997463226;
00232    fMin_1[2][3] = 0.632570564747;
00233    fMax_1[2][3] = 15.999958992;
00234    fMin_1[0][4] = 0;
00235    fMax_1[0][4] = 0.998935520649;
00236    fMin_1[1][4] = 0;
00237    fMax_1[1][4] = 0.997940421104;
00238    fMin_1[2][4] = 0;
00239    fMax_1[2][4] = 0.998935520649;
00240    fMin_1[0][5] = 0.0351097136736;
00241    fMax_1[0][5] = 0.987394332886;
00242    fMin_1[1][5] = 0;
00243    fMax_1[1][5] = 0.991289019585;
00244    fMin_1[2][5] = 0;
00245    fMax_1[2][5] = 0.991289019585;
00246 
00247 }

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

Definition at line 54 of file LEMAmbyE50N691.h.

Referenced by GetMvaValue().

00054 { return false; }

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

Definition at line 57 of file LEMAmbyE50N691.h.

Referenced by GetMvaValue().

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

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

Definition at line 270 of file LEMAmbyE50N691.cxx.

References Transform_1().

Referenced by GetMvaValue().

00271 {
00272    Transform_1( iv, sigOrBgd );
00273 }

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

Definition at line 250 of file LEMAmbyE50N691.cxx.

References fMax_1, and fMin_1.

Referenced by Transform().

00251 {
00252 if (cls < 0 || cls > 2) {
00253    if (2 > 1 ) cls = 2;
00254    else cls = 2;
00255 }
00256    for (int ivar=0;ivar<6;ivar++) {
00257       double offset = fMin_1[cls][ivar];
00258       double scale  = 1.0/(fMax_1[cls][ivar]-fMin_1[cls][ivar]);
00259       iv[ivar] = (iv[ivar]-offset)*scale * 2 - 1;
00260    }
00261 }


Member Data Documentation

const char* LEMAmbyE50N691::fClassName [private]

Definition at line 47 of file LEMAmbyE50N691.h.

int LEMAmbyE50N691::fLayers [private]

Definition at line 73 of file LEMAmbyE50N691.h.

Referenced by GetMvaValue__(), and Initialize().

int LEMAmbyE50N691::fLayerSize[3] [private]

Definition at line 74 of file LEMAmbyE50N691.h.

Referenced by GetMvaValue__(), and Initialize().

double LEMAmbyE50N691::fMax_1[3][6] [private]

Definition at line 40 of file LEMAmbyE50N691.h.

Referenced by InitTransform_1(), and Transform_1().

double LEMAmbyE50N691::fMin_1[3][6] [private]

Definition at line 39 of file LEMAmbyE50N691.h.

Referenced by InitTransform_1(), and Transform_1().

char LEMAmbyE50N691::fType[6] [private]

Definition at line 63 of file LEMAmbyE50N691.h.

Referenced by GetType(), and LEMAmbyE50N691().

double LEMAmbyE50N691::fVmax[6] [private]

Definition at line 56 of file LEMAmbyE50N691.h.

Referenced by GetMvaValue(), and LEMAmbyE50N691().

double LEMAmbyE50N691::fVmin[6] [private]

Definition at line 55 of file LEMAmbyE50N691.h.

Referenced by GetMvaValue(), and LEMAmbyE50N691().

double LEMAmbyE50N691::fWeightMatrix0to1[10][7] [private]

Definition at line 75 of file LEMAmbyE50N691.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 76 of file LEMAmbyE50N691.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 78 of file LEMAmbyE50N691.h.

Referenced by GetMvaValue__(), and Initialize().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1