LEMAmbyE50S591 Class Reference

#include <LEMAmbyE50S591.h>

List of all members.

Public Member Functions

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


Constructor & Destructor Documentation

LEMAmbyE50S591::LEMAmbyE50S591 (  ) 

Definition at line 5 of file LEMAmbyE50S591.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 
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 
00029       // initialize constants
00030       Initialize();
00031 
00032       // initialize transformation
00033       InitTransform();
00034 }//LEMAmbyE50S591

LEMAmbyE50S591::~LEMAmbyE50S591 (  )  [inline]

Definition at line 19 of file LEMAmbyE50S591.h.

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


Member Function Documentation

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

Definition at line 150 of file LEMAmbyE50S591.cxx.

Referenced by GetMvaValue__().

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

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

Definition at line 158 of file LEMAmbyE50S591.cxx.

00159 {
00160    // nothing to clear
00161 }

Double_t LEMAmbyE50S591::GetLEMAmbyE50S591 ( NueAnaReader nueana  ) 

Definition at line 325 of file LEMAmbyE50S591.cxx.

References GetLEMAmbyE50S591(), and NueAnaReader::nuerecord.

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

Double_t LEMAmbyE50S591::GetLEMAmbyE50S591 ( NueRecord nr  ) 

Definition at line 266 of file LEMAmbyE50S591.cxx.

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

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

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

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

Definition at line 162 of file LEMAmbyE50S591.cxx.

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

Referenced by GetLEMAmbyE50S591().

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

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

Definition at line 115 of file LEMAmbyE50S591.cxx.

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

Referenced by GetMvaValue().

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

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

Definition at line 49 of file LEMAmbyE50S591.h.

References fType.

00049 { return fType[ivar]; }

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

Definition at line 37 of file LEMAmbyE50S591.cxx.

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

Referenced by LEMAmbyE50S591().

00038 {
00039 
00040    // build network structure
00041    fLayers = 3;
00042    fLayerSize[0] = 6; fWeights[0] = new double[6]; 
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.0197627571899156;
00047    fWeightMatrix0to1[1][0] = -0.0771838415682967;
00048    fWeightMatrix0to1[2][0] = -0.00290357039843015;
00049    fWeightMatrix0to1[3][0] = -0.45185554065689;
00050    fWeightMatrix0to1[4][0] = -0.0110569061753419;
00051    fWeightMatrix0to1[5][0] = -0.0793052146394144;
00052    fWeightMatrix0to1[6][0] = 0.0162554484180977;
00053    fWeightMatrix0to1[7][0] = -9.5957296104167e-05;
00054    fWeightMatrix0to1[8][0] = -0.0215817098466821;
00055    fWeightMatrix0to1[0][1] = -0.0848956461119597;
00056    fWeightMatrix0to1[1][1] = 0.0967451150643266;
00057    fWeightMatrix0to1[2][1] = -0.0811402296689578;
00058    fWeightMatrix0to1[3][1] = -3.27974702632489;
00059    fWeightMatrix0to1[4][1] = -0.0800122012640142;
00060    fWeightMatrix0to1[5][1] = 0.0972126959436241;
00061    fWeightMatrix0to1[6][1] = -0.0842641272160589;
00062    fWeightMatrix0to1[7][1] = 0.0815883026058802;
00063    fWeightMatrix0to1[8][1] = 0.0852293402392174;
00064    fWeightMatrix0to1[0][2] = -0.149145691169929;
00065    fWeightMatrix0to1[1][2] = 0.208741197248913;
00066    fWeightMatrix0to1[2][2] = -0.125625478449109;
00067    fWeightMatrix0to1[3][2] = -1.22287176566633;
00068    fWeightMatrix0to1[4][2] = -0.117222434529494;
00069    fWeightMatrix0to1[5][2] = 0.210928382380868;
00070    fWeightMatrix0to1[6][2] = -0.145497721274375;
00071    fWeightMatrix0to1[7][2] = 0.128727339252025;
00072    fWeightMatrix0to1[8][2] = 0.151038160396743;
00073    fWeightMatrix0to1[0][3] = 0.0429877219436064;
00074    fWeightMatrix0to1[1][3] = -0.0824076575266441;
00075    fWeightMatrix0to1[2][3] = 0.0266927180620729;
00076    fWeightMatrix0to1[3][3] = 0.184833783460169;
00077    fWeightMatrix0to1[4][3] = 0.020763648700558;
00078    fWeightMatrix0to1[5][3] = -0.0838085518751932;
00079    fWeightMatrix0to1[6][3] = 0.0404894260211396;
00080    fWeightMatrix0to1[7][3] = -0.0288671697564681;
00081    fWeightMatrix0to1[8][3] = -0.0442796247087708;
00082    fWeightMatrix0to1[0][4] = -0.0623034459577372;
00083    fWeightMatrix0to1[1][4] = 0.0348661920708074;
00084    fWeightMatrix0to1[2][4] = -0.0762956621360704;
00085    fWeightMatrix0to1[3][4] = 0.620867164235401;
00086    fWeightMatrix0to1[4][4] = -0.0819266765879942;
00087    fWeightMatrix0to1[5][4] = 0.0340078821126698;
00088    fWeightMatrix0to1[6][4] = -0.0643226116827852;
00089    fWeightMatrix0to1[7][4] = 0.0743086396139491;
00090    fWeightMatrix0to1[8][4] = 0.0612755167988081;
00091    fWeightMatrix0to1[0][5] = -0.0180320453261113;
00092    fWeightMatrix0to1[1][5] = 0.0546324220685092;
00093    fWeightMatrix0to1[2][5] = -0.00616098101347837;
00094    fWeightMatrix0to1[3][5] = 2.65650356218864;
00095    fWeightMatrix0to1[4][5] = -0.00254841146113071;
00096    fWeightMatrix0to1[5][5] = 0.0560571288309702;
00097    fWeightMatrix0to1[6][5] = -0.0160483208892952;
00098    fWeightMatrix0to1[7][5] = 0.00758839517739168;
00099    fWeightMatrix0to1[8][5] = 0.0190785593742402;
00100    // weight matrix from layer 1 to 2
00101    fWeightMatrix1to2[0][0] = -0.115368162249954;
00102    fWeightMatrix1to2[0][1] = 0.136042987122931;
00103    fWeightMatrix1to2[0][2] = -0.117565890401788;
00104    fWeightMatrix1to2[0][3] = -0.334781934940441;
00105    fWeightMatrix1to2[0][4] = -0.120076481301276;
00106    fWeightMatrix1to2[0][5] = 0.137339249333805;
00107    fWeightMatrix1to2[0][6] = -0.115260755666553;
00108    fWeightMatrix1to2[0][7] = 0.116874229336062;
00109    fWeightMatrix1to2[0][8] = 0.115485728743423;
00110    fWeightMatrix1to2[0][9] = 0.445629254599882;
00111 
00112 
00113 }//L4Init

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

Definition at line 250 of file LEMAmbyE50S591.cxx.

References InitTransform_1().

Referenced by LEMAmbyE50S591().

00251 {
00252    InitTransform_1();
00253 }

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

Definition at line 198 of file LEMAmbyE50S591.cxx.

References fMax_1, and fMin_1.

Referenced by InitTransform().

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

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

Definition at line 54 of file LEMAmbyE50S591.h.

Referenced by GetMvaValue().

00054 { return false; }

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

Definition at line 57 of file LEMAmbyE50S591.h.

Referenced by GetMvaValue().

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

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

Definition at line 256 of file LEMAmbyE50S591.cxx.

References Transform_1().

Referenced by GetMvaValue().

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

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

Definition at line 236 of file LEMAmbyE50S591.cxx.

References fMax_1, and fMin_1.

Referenced by Transform().

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


Member Data Documentation

const char* LEMAmbyE50S591::fClassName [private]

Definition at line 47 of file LEMAmbyE50S591.h.

int LEMAmbyE50S591::fLayers [private]

Definition at line 73 of file LEMAmbyE50S591.h.

Referenced by GetMvaValue__(), and Initialize().

int LEMAmbyE50S591::fLayerSize[3] [private]

Definition at line 74 of file LEMAmbyE50S591.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 40 of file LEMAmbyE50S591.h.

Referenced by InitTransform_1(), and Transform_1().

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

Definition at line 39 of file LEMAmbyE50S591.h.

Referenced by InitTransform_1(), and Transform_1().

char LEMAmbyE50S591::fType[5] [private]

Definition at line 63 of file LEMAmbyE50S591.h.

Referenced by GetType(), and LEMAmbyE50S591().

double LEMAmbyE50S591::fVmax[5] [private]

Definition at line 56 of file LEMAmbyE50S591.h.

Referenced by GetMvaValue(), and LEMAmbyE50S591().

double LEMAmbyE50S591::fVmin[5] [private]

Definition at line 55 of file LEMAmbyE50S591.h.

Referenced by GetMvaValue(), and LEMAmbyE50S591().

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

Definition at line 75 of file LEMAmbyE50S591.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 76 of file LEMAmbyE50S591.h.

Referenced by GetMvaValue__(), and Initialize().

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

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