LEMAmbyE50N6111 Class Reference

#include <LEMAmbyE50N6111.h>

List of all members.

Public Member Functions

 LEMAmbyE50N6111 ()
 ~LEMAmbyE50N6111 ()
double GetMvaValue (const std::vector< double > &inputValues) const
Double_t GetLEMAmbyE50N6111 (NueRecord *nr)
Double_t GetLEMAmbyE50N6111 (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 [12][7]
double fWeightMatrix1to2 [1][12]
double * fWeights [3]

Detailed Description

Definition at line 13 of file LEMAmbyE50N6111.h.


Constructor & Destructor Documentation

LEMAmbyE50N6111::LEMAmbyE50N6111 (  ) 

Definition at line 5 of file LEMAmbyE50N6111.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 }//LEMAmbyE50N6111

LEMAmbyE50N6111::~LEMAmbyE50N6111 (  )  [inline]

Definition at line 19 of file LEMAmbyE50N6111.h.

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


Member Function Documentation

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

Definition at line 174 of file LEMAmbyE50N6111.cxx.

Referenced by GetMvaValue__().

00174                                                     {
00175    // hyperbolic tan
00176    return tanh(x);
00177 }

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

Definition at line 182 of file LEMAmbyE50N6111.cxx.

00183 {
00184    // nothing to clear
00185 }

Double_t LEMAmbyE50N6111::GetLEMAmbyE50N6111 ( NueAnaReader nueana  ) 

Definition at line 358 of file LEMAmbyE50N6111.cxx.

References GetLEMAmbyE50N6111(), and NueAnaReader::nuerecord.

00358                                                                 {
00359 
00360   Double_t lemAmby=-1;
00361   lemAmby = GetLEMAmbyE50N6111(nueana->nuerecord);
00362   return lemAmby;
00363 
00364 }

Double_t LEMAmbyE50N6111::GetLEMAmbyE50N6111 ( NueRecord nr  ) 

Definition at line 296 of file LEMAmbyE50N6111.cxx.

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

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

00296                                                          {
00297 
00298   //LEM4 PID value
00299   Double_t lemAmby=-1;
00300 
00301   //Input variables
00302   Double_t val_mny=-1;
00303   Double_t val_mfqm=-1;
00304   Double_t val_fcc=-1;
00305   Double_t val_recoe=-1;
00306   Double_t val_ncmny=-1;
00307   Double_t val_ncmfqm=-1;
00308 
00309   //Define the variables (y_cut = 1.0 = no y cut)
00310   val_mny = LEMStandard::Getymean(nr,1.0);
00311   val_mfqm = LEMStandard::GetMeanFracQMatched(nr,1.0);
00312   val_fcc = LEMStandard::GetfracCCy(nr,1.0);
00313   val_recoe = nr->srevent.phNueGeV;
00314   val_ncmfqm = LEMStandard::GetNCMeanFracQMatched(nr,1.0);
00315   val_ncmny = LEMStandard::GetNCymean(nr,1.0);
00316 
00317   //Preselection: return automatic -1 for out of range events.
00318   if (val_ncmny<0||val_ncmfqm<0||val_mny<0||val_mfqm<0||val_fcc<0||val_recoe<0) {
00319     lemAmby=-1;
00320   } else {
00321     //Define an input vector with the cariable names.
00322     std::vector<double> inputVec( 6 );
00323 
00324     inputVec[0]=val_mny;
00325     inputVec[1]=val_mfqm;
00326     inputVec[2]=val_fcc;
00327     inputVec[3]=val_recoe;
00328     inputVec[4]=val_ncmny;
00329     inputVec[5]=val_ncmfqm;
00330       
00331     //Calculate the LEM discriminant!
00332    lemAmby = LEMAmbyE50N6111::GetMvaValue(inputVec);
00333 
00334   
00335   //Transform so that the PID value is between 0.0 to 1.0.
00336   //A1Testrun showed spread from -0.10 to 1.13
00337   //A2lemAmby = (lemAmby + 0.029)/1.170;
00338   //A3lemAmby -0.071 -- 1.134
00339   //A5(A3_9) -0.0598634--1.13229
00340   //E50N6111 -0.203401 -- 1.19919
00341 
00342    Double_t lowval=-0.203401;
00343    Double_t highval=1.19919;
00344    Double_t midpoint=(lowval+highval)/2.0;
00345    Double_t denom=(highval-lowval)*1.001; //prev 1.022mod
00346    //lemAmby = (( lemAmby - midpoint) / denom) + 0.5;
00347    lemAmby = (( lemAmby - lowval ) / denom); 
00348  
00349   
00350 
00351   }
00352   //return the PID:
00353   return lemAmby;
00354 
00355 }

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

Definition at line 186 of file LEMAmbyE50N6111.cxx.

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

Referenced by GetLEMAmbyE50N6111().

00187    {
00188       // classifier response value
00189       double retval = 0;
00190 
00191       // classifier response, sanity check first
00192    
00193          if (IsNormalised()) {
00194             // normalise variables
00195             std::vector<double> iV;
00196             int ivar = 0;
00197             for (std::vector<double>::const_iterator varIt = inputValues.begin();
00198                  varIt != inputValues.end(); varIt++, ivar++) {
00199                iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));
00200             }
00201             Transform( iV, -1 );
00202             retval = GetMvaValue__( iV );
00203          }
00204          else {
00205             std::vector<double> iV;
00206             int ivar = 0;
00207             for (std::vector<double>::const_iterator varIt = inputValues.begin();
00208                  varIt != inputValues.end(); varIt++, ivar++) {
00209                iV.push_back(*varIt);
00210             }
00211             Transform( iV, -1 );
00212             retval = GetMvaValue__( iV );
00213          }
00214      
00215 
00216       return retval;
00217    }//cleanup

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

Definition at line 139 of file LEMAmbyE50N6111.cxx.

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

Referenced by GetMvaValue().

00140 {
00141    if (inputValues.size() != (unsigned int)fLayerSize[0]-1) {
00142       std::cout << "Input vector needs to be of size " << fLayerSize[0]-1 << std::endl;
00143       return 0;
00144    }
00145 
00146    for (int l=0; l<fLayers; l++)
00147       for (int i=0; i<fLayerSize[l]; i++) fWeights[l][i]=0;
00148 
00149    for (int l=0; l<fLayers-1; l++)
00150       fWeights[l][fLayerSize[l]-1]=1;
00151 
00152    for (int i=0; i<fLayerSize[0]-1; i++)
00153       fWeights[0][i]=inputValues[i];
00154 
00155    // layer 0 to 1
00156    for (int o=0; o<fLayerSize[1]-1; o++) {
00157       for (int i=0; i<fLayerSize[0]; i++) {
00158          double inputVal = fWeightMatrix0to1[o][i] * fWeights[0][i];
00159          fWeights[1][o] += inputVal;
00160       }
00161       fWeights[1][o] = ActivationFnc(fWeights[1][o]);
00162    }
00163    // layer 1 to 2
00164    for (int o=0; o<fLayerSize[2]; o++) {
00165       for (int i=0; i<fLayerSize[1]; i++) {
00166          double inputVal = fWeightMatrix1to2[o][i] * fWeights[1][i];
00167          fWeights[2][o] += inputVal;
00168       }
00169    }
00170 
00171    return fWeights[2][0];
00172 }//GetMVAvalue

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

Definition at line 49 of file LEMAmbyE50N6111.h.

References fType.

00049 { return fType[ivar]; }

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

Definition at line 38 of file LEMAmbyE50N6111.cxx.

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

Referenced by LEMAmbyE50N6111().

00039 {
00040   // build network structure
00041    fLayers = 3;
00042    fLayerSize[0] = 7; fWeights[0] = new double[7]; 
00043    fLayerSize[1] = 12; fWeights[1] = new double[12]; 
00044    fLayerSize[2] = 1; fWeights[2] = new double[1]; 
00045    // weight matrix from layer 0 to 1
00046    fWeightMatrix0to1[0][0] = -0.0216764188225851;
00047    fWeightMatrix0to1[1][0] = 0.00129778593099998;
00048    fWeightMatrix0to1[2][0] = -0.106066829142817;
00049    fWeightMatrix0to1[3][0] = 1.53188387581955;
00050    fWeightMatrix0to1[4][0] = -0.21726382561719;
00051    fWeightMatrix0to1[5][0] = 0.101390923438033;
00052    fWeightMatrix0to1[6][0] = 2.04038537761505;
00053    fWeightMatrix0to1[7][0] = 0.0302317276288896;
00054    fWeightMatrix0to1[8][0] = 0.412396371601389;
00055    fWeightMatrix0to1[9][0] = -1.02942101891681;
00056    fWeightMatrix0to1[10][0] = 0.213136539004101;
00057    fWeightMatrix0to1[0][1] = -0.0170774742173185;
00058    fWeightMatrix0to1[1][1] = 0.00507246445067779;
00059    fWeightMatrix0to1[2][1] = -2.75254112059097;
00060    fWeightMatrix0to1[3][1] = 0.342154102295813;
00061    fWeightMatrix0to1[4][1] = -0.124345683760814;
00062    fWeightMatrix0to1[5][1] = 3.47098675419681;
00063    fWeightMatrix0to1[6][1] = -0.105470323246353;
00064    fWeightMatrix0to1[7][1] = 0.0365627672162702;
00065    fWeightMatrix0to1[8][1] = 0.20733396157655;
00066    fWeightMatrix0to1[9][1] = -1.93259997617255;
00067    fWeightMatrix0to1[10][1] = 1.4637288681527;
00068    fWeightMatrix0to1[0][2] = -0.0257442679059718;
00069    fWeightMatrix0to1[1][2] = 0.00261693730104791;
00070    fWeightMatrix0to1[2][2] = -2.33466213470668;
00071    fWeightMatrix0to1[3][2] = -0.800592671774557;
00072    fWeightMatrix0to1[4][2] = -0.168528640896397;
00073    fWeightMatrix0to1[5][2] = 0.961331041100472;
00074    fWeightMatrix0to1[6][2] = 0.146550455695123;
00075    fWeightMatrix0to1[7][2] = 0.0391272324677198;
00076    fWeightMatrix0to1[8][2] = 0.142847579524241;
00077    fWeightMatrix0to1[9][2] = -0.43097654382663;
00078    fWeightMatrix0to1[10][2] = -1.39396076018431;
00079    fWeightMatrix0to1[0][3] = 0.00101150652407453;
00080    fWeightMatrix0to1[1][3] = 0.0006256048025007;
00081    fWeightMatrix0to1[2][3] = -0.904885728711334;
00082    fWeightMatrix0to1[3][3] = 1.10966066034035;
00083    fWeightMatrix0to1[4][3] = 0.046731521705973;
00084    fWeightMatrix0to1[5][3] = -1.83371821833513;
00085    fWeightMatrix0to1[6][3] = 0.159629297195171;
00086    fWeightMatrix0to1[7][3] = 0.000685140274535195;
00087    fWeightMatrix0to1[8][3] = -0.137667830027321;
00088    fWeightMatrix0to1[9][3] = 1.16954302489771;
00089    fWeightMatrix0to1[10][3] = -1.47540047598019;
00090    fWeightMatrix0to1[0][4] = 0.00916388928667644;
00091    fWeightMatrix0to1[1][4] = -0.000814107271620006;
00092    fWeightMatrix0to1[2][4] = -0.9328499022689;
00093    fWeightMatrix0to1[3][4] = 0.67975761061333;
00094    fWeightMatrix0to1[4][4] = 0.0916379807963843;
00095    fWeightMatrix0to1[5][4] = -0.657852587152271;
00096    fWeightMatrix0to1[6][4] = -0.0325923742082239;
00097    fWeightMatrix0to1[7][4] = -0.0135734750425883;
00098    fWeightMatrix0to1[8][4] = -0.231556131848749;
00099    fWeightMatrix0to1[9][4] = 0.805541677522287;
00100    fWeightMatrix0to1[10][4] = -1.52789170980641;
00101    fWeightMatrix0to1[0][5] = 0.000765665857140273;
00102    fWeightMatrix0to1[1][5] = -0.0026797938861823;
00103    fWeightMatrix0to1[2][5] = 0.906533877713082;
00104    fWeightMatrix0to1[3][5] = 0.758849346400918;
00105    fWeightMatrix0to1[4][5] = 0.0309665515971484;
00106    fWeightMatrix0to1[5][5] = 0.0616028730624263;
00107    fWeightMatrix0to1[6][5] = -0.445552879951528;
00108    fWeightMatrix0to1[7][5] = -0.00956920898430812;
00109    fWeightMatrix0to1[8][5] = -0.0840096828764973;
00110    fWeightMatrix0to1[9][5] = -1.8629173219283;
00111    fWeightMatrix0to1[10][5] = -0.271455954594812;
00112    fWeightMatrix0to1[0][6] = -0.00228219560328892;
00113    fWeightMatrix0to1[1][6] = 0.000227090035594474;
00114    fWeightMatrix0to1[2][6] = 4.3903405848734;
00115    fWeightMatrix0to1[3][6] = -0.0335289768578641;
00116    fWeightMatrix0to1[4][6] = -0.0150983841725151;
00117    fWeightMatrix0to1[5][6] = -3.43230634585143;
00118    fWeightMatrix0to1[6][6] = 0.882611257836678;
00119    fWeightMatrix0to1[7][6] = 0.00340083236652871;
00120    fWeightMatrix0to1[8][6] = 0.0166685173332766;
00121    fWeightMatrix0to1[9][6] = 2.23346518317369;
00122    fWeightMatrix0to1[10][6] = -4.28804081487549;
00123    // weight matrix from layer 1 to 2
00124    fWeightMatrix1to2[0][0] = 0.0182502707669697;
00125    fWeightMatrix1to2[0][1] = -0.00263095435962451;
00126    fWeightMatrix1to2[0][2] = -0.377876712848166;
00127    fWeightMatrix1to2[0][3] = -0.224916675589221;
00128    fWeightMatrix1to2[0][4] = 0.10497762886895;
00129    fWeightMatrix1to2[0][5] = 0.280053113993149;
00130    fWeightMatrix1to2[0][6] = 0.21443681460688;
00131    fWeightMatrix1to2[0][7] = -0.0301286097781128;
00132    fWeightMatrix1to2[0][8] = -0.142128562091066;
00133    fWeightMatrix1to2[0][9] = -0.166129213215818;
00134    fWeightMatrix1to2[0][10] = -0.529536584133866;
00135    fWeightMatrix1to2[0][11] = 0.344416578158908;
00136 
00137 }//L4Init

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

Definition at line 280 of file LEMAmbyE50N6111.cxx.

References InitTransform_1().

Referenced by LEMAmbyE50N6111().

00281 {
00282    InitTransform_1();
00283 }

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

Definition at line 222 of file LEMAmbyE50N6111.cxx.

References fMax_1, and fMin_1.

Referenced by InitTransform().

00223 {
00224 
00225    // Normalization transformation, initialisation
00226    fMin_1[0][0] = 0.0228846855462;
00227    fMax_1[0][0] = 0.98898011446;
00228    fMin_1[1][0] = 0.00716135371476;
00229    fMax_1[1][0] = 0.998298585415;
00230    fMin_1[2][0] = 0.00716135371476;
00231    fMax_1[2][0] = 0.998298585415;
00232    fMin_1[0][1] = 0.0475189238787;
00233    fMax_1[0][1] = 1;
00234    fMin_1[1][1] = 0;
00235    fMax_1[1][1] = 1;
00236    fMin_1[2][1] = 0;
00237    fMax_1[2][1] = 1;
00238    fMin_1[0][2] = 0.019999999553;
00239    fMax_1[0][2] = 0.980000019073;
00240    fMin_1[1][2] = 0.019999999553;
00241    fMax_1[1][2] = 0.980000019073;
00242    fMin_1[2][2] = 0.019999999553;
00243    fMax_1[2][2] = 0.980000019073;
00244    fMin_1[0][3] = 0.665335953236;
00245    fMax_1[0][3] = 15.999958992;
00246    fMin_1[1][3] = 0.632570564747;
00247    fMax_1[1][3] = 15.9997463226;
00248    fMin_1[2][3] = 0.632570564747;
00249    fMax_1[2][3] = 15.999958992;
00250    fMin_1[0][4] = 0;
00251    fMax_1[0][4] = 0.998935520649;
00252    fMin_1[1][4] = 0;
00253    fMax_1[1][4] = 0.997940421104;
00254    fMin_1[2][4] = 0;
00255    fMax_1[2][4] = 0.998935520649;
00256    fMin_1[0][5] = 0.0351097136736;
00257    fMax_1[0][5] = 0.987394332886;
00258    fMin_1[1][5] = 0;
00259    fMax_1[1][5] = 0.991289019585;
00260    fMin_1[2][5] = 0;
00261    fMax_1[2][5] = 0.991289019585;
00262 
00263 }

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

Definition at line 54 of file LEMAmbyE50N6111.h.

Referenced by GetMvaValue().

00054 { return false; }

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

Definition at line 57 of file LEMAmbyE50N6111.h.

Referenced by GetMvaValue().

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

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

Definition at line 286 of file LEMAmbyE50N6111.cxx.

References Transform_1().

Referenced by GetMvaValue().

00287 {
00288    Transform_1( iv, sigOrBgd );
00289 }

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

Definition at line 266 of file LEMAmbyE50N6111.cxx.

References fMax_1, and fMin_1.

Referenced by Transform().

00267 {
00268 if (cls < 0 || cls > 2) {
00269    if (2 > 1 ) cls = 2;
00270    else cls = 2;
00271 }
00272    for (int ivar=0;ivar<6;ivar++) {
00273       double offset = fMin_1[cls][ivar];
00274       double scale  = 1.0/(fMax_1[cls][ivar]-fMin_1[cls][ivar]);
00275       iv[ivar] = (iv[ivar]-offset)*scale * 2 - 1;
00276    }
00277 }


Member Data Documentation

const char* LEMAmbyE50N6111::fClassName [private]

Definition at line 47 of file LEMAmbyE50N6111.h.

int LEMAmbyE50N6111::fLayers [private]

Definition at line 73 of file LEMAmbyE50N6111.h.

Referenced by GetMvaValue__(), and Initialize().

int LEMAmbyE50N6111::fLayerSize[3] [private]

Definition at line 74 of file LEMAmbyE50N6111.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 40 of file LEMAmbyE50N6111.h.

Referenced by InitTransform_1(), and Transform_1().

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

Definition at line 39 of file LEMAmbyE50N6111.h.

Referenced by InitTransform_1(), and Transform_1().

char LEMAmbyE50N6111::fType[6] [private]

Definition at line 63 of file LEMAmbyE50N6111.h.

Referenced by GetType(), and LEMAmbyE50N6111().

double LEMAmbyE50N6111::fVmax[6] [private]

Definition at line 56 of file LEMAmbyE50N6111.h.

Referenced by GetMvaValue(), and LEMAmbyE50N6111().

double LEMAmbyE50N6111::fVmin[6] [private]

Definition at line 55 of file LEMAmbyE50N6111.h.

Referenced by GetMvaValue(), and LEMAmbyE50N6111().

double LEMAmbyE50N6111::fWeightMatrix0to1[12][7] [private]

Definition at line 75 of file LEMAmbyE50N6111.h.

Referenced by GetMvaValue__(), and Initialize().

double LEMAmbyE50N6111::fWeightMatrix1to2[1][12] [private]

Definition at line 76 of file LEMAmbyE50N6111.h.

Referenced by GetMvaValue__(), and Initialize().

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

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