LEMAmby Class Reference

#include <LEMAmby.h>

List of all members.

Public Member Functions

 LEMAmby ()
 ~LEMAmby ()
double GetMvaValue (const std::vector< double > &inputValues) const
Double_t GetLEMAmby (NueRecord *nr)
Double_t GetLEMAmby (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 LEMAmby.h.


Constructor & Destructor Documentation

LEMAmby::LEMAmby (  ) 

Definition at line 5 of file LEMAmby.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] = 0.99999988079071;
00011       fVmin[1] = -1;
00012       fVmax[1] = 1;
00013       fVmin[2] = -1;
00014       fVmax[2] = 0.999999940395355;
00015       fVmin[3] = -1;
00016       fVmax[3] = 1;
00017       fVmin[4] = -1;
00018       fVmax[4] = 0.999999940395355;
00019       fVmin[5] = -1;
00020       fVmax[5] = 1;
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 }//LEMAmby

LEMAmby::~LEMAmby (  )  [inline]

Definition at line 19 of file LEMAmby.h.

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


Member Function Documentation

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

Definition at line 158 of file LEMAmby.cxx.

Referenced by GetMvaValue__().

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

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

Definition at line 166 of file LEMAmby.cxx.

00167 {
00168    // nothing to clear
00169 }

Double_t LEMAmby::GetLEMAmby ( NueAnaReader nueana  ) 

Definition at line 335 of file LEMAmby.cxx.

References GetLEMAmby(), and NueAnaReader::nuerecord.

00335                                                 {
00336 
00337   Double_t lemAmby=-1;
00338   lemAmby = GetLEMAmby(nueana->nuerecord);
00339   return lemAmby;
00340 
00341 }

Double_t LEMAmby::GetLEMAmby ( NueRecord nr  ) 

Definition at line 280 of file LEMAmby.cxx.

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

Referenced by GetLEMAmby(), 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 = LEMAmby::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  
00325  
00326    lemAmby = ( lemAmby + 0.060 ) / 1.193;
00327 
00328   }
00329   //return the PID:
00330   return lemAmby;
00331 
00332 }

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

Definition at line 170 of file LEMAmby.cxx.

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

Referenced by GetLEMAmby().

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 LEMAmby::GetMvaValue__ ( const std::vector< double > &  inputValues  )  const [inline, private]

Definition at line 123 of file LEMAmby.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 LEMAmby::GetType ( int  ivar  )  const [inline, private]

Definition at line 49 of file LEMAmby.h.

References fType.

00049 { return fType[ivar]; }

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

Definition at line 38 of file LEMAmby.cxx.

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

Referenced by LEMAmby().

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.288602503865829;
00047    fWeightMatrix0to1[1][0] = -0.0639052774575577;
00048    fWeightMatrix0to1[2][0] = 0.171199098902505;
00049    fWeightMatrix0to1[3][0] = -0.38796773161626;
00050    fWeightMatrix0to1[4][0] = 0.168192317609668;
00051    fWeightMatrix0to1[5][0] = -0.00413000347794458;
00052    fWeightMatrix0to1[6][0] = 0.0159118745578133;
00053    fWeightMatrix0to1[7][0] = -0.642500696717762;
00054    fWeightMatrix0to1[8][0] = 0.00566479150574775;
00055    fWeightMatrix0to1[0][1] = 0.387330213071385;
00056    fWeightMatrix0to1[1][1] = -0.941537700422439;
00057    fWeightMatrix0to1[2][1] = -0.189616405095457;
00058    fWeightMatrix0to1[3][1] = -0.965683767556327;
00059    fWeightMatrix0to1[4][1] = -1.47354601362537;
00060    fWeightMatrix0to1[5][1] = -1.02381377352135;
00061    fWeightMatrix0to1[6][1] = -0.624329949840168;
00062    fWeightMatrix0to1[7][1] = -3.41073337677381;
00063    fWeightMatrix0to1[8][1] = 0.325906476369478;
00064    fWeightMatrix0to1[0][2] = -0.21580089573703;
00065    fWeightMatrix0to1[1][2] = 0.0904330221501802;
00066    fWeightMatrix0to1[2][2] = 0.0127978905779944;
00067    fWeightMatrix0to1[3][2] = -1.00290847352419;
00068    fWeightMatrix0to1[4][2] = 1.19816350341141;
00069    fWeightMatrix0to1[5][2] = 0.0985923951011257;
00070    fWeightMatrix0to1[6][2] = 0.228128596368305;
00071    fWeightMatrix0to1[7][2] = -1.59986881353021;
00072    fWeightMatrix0to1[8][2] = -0.158084354170617;
00073    fWeightMatrix0to1[0][3] = 0.583920514564217;
00074    fWeightMatrix0to1[1][3] = -0.274468406833023;
00075    fWeightMatrix0to1[2][3] = 0.156973223890315;
00076    fWeightMatrix0to1[3][3] = 0.417516515350461;
00077    fWeightMatrix0to1[4][3] = 2.89692682703697;
00078    fWeightMatrix0to1[5][3] = -0.207177182409577;
00079    fWeightMatrix0to1[6][3] = -1.17635961233761;
00080    fWeightMatrix0to1[7][3] = 0.544447552610365;
00081    fWeightMatrix0to1[8][3] = 1.6828637282739;
00082    fWeightMatrix0to1[0][4] = -0.214254469585384;
00083    fWeightMatrix0to1[1][4] = 0.109292451212849;
00084    fWeightMatrix0to1[2][4] = -0.00649750078462596;
00085    fWeightMatrix0to1[3][4] = 0.935470499989475;
00086    fWeightMatrix0to1[4][4] = 0.078539812967966;
00087    fWeightMatrix0to1[5][4] = 0.109303173199281;
00088    fWeightMatrix0to1[6][4] = 0.730231634440694;
00089    fWeightMatrix0to1[7][4] = 0.048551854574118;
00090    fWeightMatrix0to1[8][4] = -0.265977609070951;
00091    fWeightMatrix0to1[0][5] = 0.00103110902413979;
00092    fWeightMatrix0to1[1][5] = 0.750144122394641;
00093    fWeightMatrix0to1[2][5] = 0.273301235547354;
00094    fWeightMatrix0to1[3][5] = -0.446034162921574;
00095    fWeightMatrix0to1[4][5] = 0.0190114969173711;
00096    fWeightMatrix0to1[5][5] = 0.880096820753151;
00097    fWeightMatrix0to1[6][5] = -0.373134256314892;
00098    fWeightMatrix0to1[7][5] = 0.234099893171368;
00099    fWeightMatrix0to1[8][5] = -0.0157102952173098;
00100    fWeightMatrix0to1[0][6] = -0.0866179197272484;
00101    fWeightMatrix0to1[1][6] = -0.0509223816405669;
00102    fWeightMatrix0to1[2][6] = 0.0170106252386197;
00103    fWeightMatrix0to1[3][6] = 0.857559013411603;
00104    fWeightMatrix0to1[4][6] = 2.05217178062504;
00105    fWeightMatrix0to1[5][6] = -0.0443163937504046;
00106    fWeightMatrix0to1[6][6] = -0.23013095588947;
00107    fWeightMatrix0to1[7][6] = 3.33925342706143;
00108    fWeightMatrix0to1[8][6] = 0.482847620592836;
00109    // weight matrix from layer 1 to 2
00110    fWeightMatrix1to2[0][0] = -0.203596222002034;
00111    fWeightMatrix1to2[0][1] = 0.0442108652476931;
00112    fWeightMatrix1to2[0][2] = -0.11300806842137;
00113    fWeightMatrix1to2[0][3] = -0.319797166888924;
00114    fWeightMatrix1to2[0][4] = -0.174436620712367;
00115    fWeightMatrix1to2[0][5] = 0.00107911914389487;
00116    fWeightMatrix1to2[0][6] = 0.417899394919336;
00117    fWeightMatrix1to2[0][7] = -0.324160439530401;
00118    fWeightMatrix1to2[0][8] = 0.641943059242995;
00119    fWeightMatrix1to2[0][9] = 0.698088853773151;
00120 
00121 }//L4Init

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

Definition at line 264 of file LEMAmby.cxx.

References InitTransform_1().

Referenced by LEMAmby().

00265 {
00266    InitTransform_1();
00267 }

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

Definition at line 206 of file LEMAmby.cxx.

References fMax_1, and fMin_1.

Referenced by InitTransform().

00207 {
00208 
00209    // Normalization transformation, initialisation
00210    fMin_1[0][0] = 0.0234358664602;
00211    fMax_1[0][0] = 0.963169395924;
00212    fMin_1[1][0] = 0.00440045911819;
00213    fMax_1[1][0] = 0.996161162853;
00214    fMin_1[2][0] = 0.00440045911819;
00215    fMax_1[2][0] = 0.996161162853;
00216    fMin_1[0][1] = 0.103901900351;
00217    fMax_1[0][1] = 0.988250792027;
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.503064274788;
00229    fMax_1[0][3] = 11.9998617172;
00230    fMin_1[1][3] = 0.500009179115;
00231    fMax_1[1][3] = 11.9999990463;
00232    fMin_1[2][3] = 0.500009179115;
00233    fMax_1[2][3] = 11.9999990463;
00234    fMin_1[0][4] = 0.041999027133;
00235    fMax_1[0][4] = 0.997338533401;
00236    fMin_1[1][4] = 0.0386520028114;
00237    fMax_1[1][4] = 0.996083319187;
00238    fMin_1[2][4] = 0.0386520028114;
00239    fMax_1[2][4] = 0.997338533401;
00240    fMin_1[0][5] = 0.088061593473;
00241    fMax_1[0][5] = 0.981214880943;
00242    fMin_1[1][5] = 0;
00243    fMax_1[1][5] = 1;
00244    fMin_1[2][5] = 0;
00245    fMax_1[2][5] = 1;
00246 
00247 }

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

Definition at line 54 of file LEMAmby.h.

Referenced by GetMvaValue().

00054 { return false; }

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

Definition at line 57 of file LEMAmby.h.

Referenced by GetMvaValue().

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

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

Definition at line 270 of file LEMAmby.cxx.

References Transform_1().

Referenced by GetMvaValue().

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

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

Definition at line 250 of file LEMAmby.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* LEMAmby::fClassName [private]

Definition at line 47 of file LEMAmby.h.

int LEMAmby::fLayers [private]

Definition at line 73 of file LEMAmby.h.

Referenced by GetMvaValue__(), and Initialize().

int LEMAmby::fLayerSize[3] [private]

Definition at line 74 of file LEMAmby.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 40 of file LEMAmby.h.

Referenced by InitTransform_1(), and Transform_1().

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

Definition at line 39 of file LEMAmby.h.

Referenced by InitTransform_1(), and Transform_1().

char LEMAmby::fType[6] [private]

Definition at line 63 of file LEMAmby.h.

Referenced by GetType(), and LEMAmby().

double LEMAmby::fVmax[6] [private]

Definition at line 56 of file LEMAmby.h.

Referenced by GetMvaValue(), and LEMAmby().

double LEMAmby::fVmin[6] [private]

Definition at line 55 of file LEMAmby.h.

Referenced by GetMvaValue(), and LEMAmby().

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

Definition at line 75 of file LEMAmby.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 76 of file LEMAmby.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 78 of file LEMAmby.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