LEMAmbyE50S5111 Class Reference

#include <LEMAmbyE50S5111.h>

List of all members.

Public Member Functions

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

Detailed Description

Definition at line 13 of file LEMAmbyE50S5111.h.


Constructor & Destructor Documentation

LEMAmbyE50S5111::LEMAmbyE50S5111 (  ) 

Definition at line 5 of file LEMAmbyE50S5111.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 
00020       // initialize input variable types
00021       fType[0] = 'F';
00022       fType[1] = 'F';
00023       fType[2] = 'F';
00024       fType[3] = 'F';
00025       fType[4] = 'F';
00026 
00027       // initialize constants
00028       Initialize();
00029 
00030       // initialize transformation
00031       InitTransform();
00032 }//LEMAmbyE50S5111

LEMAmbyE50S5111::~LEMAmbyE50S5111 (  )  [inline]

Definition at line 19 of file LEMAmbyE50S5111.h.

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


Member Function Documentation

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

Definition at line 162 of file LEMAmbyE50S5111.cxx.

Referenced by GetMvaValue__().

00162                                                     {
00163    // hyperbolic tan
00164    return tanh(x);
00165 }

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

Definition at line 170 of file LEMAmbyE50S5111.cxx.

00171 {
00172    // nothing to clear
00173 }

Double_t LEMAmbyE50S5111::GetLEMAmbyE50S5111 ( NueAnaReader nueana  ) 

Definition at line 339 of file LEMAmbyE50S5111.cxx.

References GetLEMAmbyE50S5111(), and NueAnaReader::nuerecord.

00339                                                                 {
00340 
00341   Double_t lemAmby=-1;
00342   lemAmby = GetLEMAmbyE50S5111(nueana->nuerecord);
00343   return lemAmby;
00344 
00345 }

Double_t LEMAmbyE50S5111::GetLEMAmbyE50S5111 ( NueRecord nr  ) 

Definition at line 278 of file LEMAmbyE50S5111.cxx.

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

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

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

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

Definition at line 174 of file LEMAmbyE50S5111.cxx.

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

Referenced by GetLEMAmbyE50S5111().

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

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

Definition at line 127 of file LEMAmbyE50S5111.cxx.

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

Referenced by GetMvaValue().

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

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

Definition at line 49 of file LEMAmbyE50S5111.h.

References fType.

00049 { return fType[ivar]; }

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

Definition at line 35 of file LEMAmbyE50S5111.cxx.

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

Referenced by LEMAmbyE50S5111().

00036 {
00037 
00038   // build network structure
00039    fLayers = 3;
00040    fLayerSize[0] = 6; fWeights[0] = new double[6]; 
00041    fLayerSize[1] = 12; fWeights[1] = new double[12]; 
00042    fLayerSize[2] = 1; fWeights[2] = new double[1]; 
00043    // weight matrix from layer 0 to 1
00044    fWeightMatrix0to1[0][0] = 0.457164863943827;
00045    fWeightMatrix0to1[1][0] = 0.0220928136491208;
00046    fWeightMatrix0to1[2][0] = -0.0220155740490428;
00047    fWeightMatrix0to1[3][0] = 0.0219686579306614;
00048    fWeightMatrix0to1[4][0] = 0.0220231333381128;
00049    fWeightMatrix0to1[5][0] = -0.0220049047643356;
00050    fWeightMatrix0to1[6][0] = 0.0221341437418853;
00051    fWeightMatrix0to1[7][0] = -0.0219962650033325;
00052    fWeightMatrix0to1[8][0] = 0.0220472731270565;
00053    fWeightMatrix0to1[9][0] = 0.0219508308069218;
00054    fWeightMatrix0to1[10][0] = 0.0220989327625126;
00055    fWeightMatrix0to1[0][1] = 3.28101780366812;
00056    fWeightMatrix0to1[1][1] = -0.0776435671584362;
00057    fWeightMatrix0to1[2][1] = 0.0776263099380779;
00058    fWeightMatrix0to1[3][1] = -0.0776158321238156;
00059    fWeightMatrix0to1[4][1] = -0.0776279984708945;
00060    fWeightMatrix0to1[5][1] = 0.0776239268662966;
00061    fWeightMatrix0to1[6][1] = -0.0776528050093853;
00062    fWeightMatrix0to1[7][1] = 0.0776219972306231;
00063    fWeightMatrix0to1[8][1] = -0.0776333912002757;
00064    fWeightMatrix0to1[9][1] = -0.0776118516500025;
00065    fWeightMatrix0to1[10][1] = -0.0776449347033747;
00066    fWeightMatrix0to1[0][2] = 1.23693441152423;
00067    fWeightMatrix0to1[1][2] = -0.13057738176211;
00068    fWeightMatrix0to1[2][2] = 0.130496678670272;
00069    fWeightMatrix0to1[3][2] = -0.130447662171314;
00070    fWeightMatrix0to1[4][2] = -0.130504576619991;
00071    fWeightMatrix0to1[5][2] = 0.13048553150881;
00072    fWeightMatrix0to1[6][2] = -0.130620567960954;
00073    fWeightMatrix0to1[7][2] = 0.130476504870904;
00074    fWeightMatrix0to1[8][2] = -0.130529798327316;
00075    fWeightMatrix0to1[9][2] = -0.130429037619701;
00076    fWeightMatrix0to1[10][2] = -0.130583775555715;
00077    fWeightMatrix0to1[0][3] = -0.199013184025842;
00078    fWeightMatrix0to1[1][3] = 0.0361593634871003;
00079    fWeightMatrix0to1[2][3] = -0.0361047740517259;
00080    fWeightMatrix0to1[3][3] = 0.0360716192096197;
00081    fWeightMatrix0to1[4][3] = 0.0361101163128128;
00082    fWeightMatrix0to1[5][3] = -0.0360972340227785;
00083    fWeightMatrix0to1[6][3] = 0.0361885765061547;
00084    fWeightMatrix0to1[7][3] = -0.0360911283636637;
00085    fWeightMatrix0to1[8][3] = 0.0361271766934121;
00086    fWeightMatrix0to1[9][3] = 0.0360590217410728;
00087    fWeightMatrix0to1[10][3] = 0.0361636884876753;
00088    fWeightMatrix0to1[0][4] = -0.639962278203516;
00089    fWeightMatrix0to1[1][4] = -0.0519357491034027;
00090    fWeightMatrix0to1[2][4] = 0.0519940946882203;
00091    fWeightMatrix0to1[3][4] = -0.0520295581992349;
00092    fWeightMatrix0to1[4][4] = -0.0519883823676268;
00093    fWeightMatrix0to1[5][4] = 0.0520021579314653;
00094    fWeightMatrix0to1[6][4] = -0.0519045490115962;
00095    fWeightMatrix0to1[7][4] = 0.0520086880586148;
00096    fWeightMatrix0to1[8][4] = -0.0519701438024577;
00097    fWeightMatrix0to1[9][4] = -0.0520430382975507;
00098    fWeightMatrix0to1[10][4] = -0.0519311289034354;
00099    fWeightMatrix0to1[0][5] = -2.65616566273247;
00100    fWeightMatrix0to1[1][5] = 0.0242893162510659;
00101    fWeightMatrix0to1[2][5] = -0.0243270284656713;
00102    fWeightMatrix0to1[3][5] = 0.0243499119561036;
00103    fWeightMatrix0to1[4][5] = 0.0243233397486465;
00104    fWeightMatrix0to1[5][5] = -0.0243322339928733;
00105    fWeightMatrix0to1[6][5] = 0.0242691172849299;
00106    fWeightMatrix0to1[7][5] = -0.0243364486492918;
00107    fWeightMatrix0to1[8][5] = 0.0243115571667766;
00108    fWeightMatrix0to1[9][5] = 0.0243586025722464;
00109    fWeightMatrix0to1[10][5] = 0.0242863265606441;
00110    // weight matrix from layer 1 to 2
00111    fWeightMatrix1to2[0][0] = 0.331026185122903;
00112    fWeightMatrix1to2[0][1] = -0.114384460634508;
00113    fWeightMatrix1to2[0][2] = 0.114382212447269;
00114    fWeightMatrix1to2[0][3] = -0.114380892573337;
00115    fWeightMatrix1to2[0][4] = -0.114382428341914;
00116    fWeightMatrix1to2[0][5] = 0.114381909256857;
00117    fWeightMatrix1to2[0][6] = -0.114385702040211;
00118    fWeightMatrix1to2[0][7] = 0.114381665049863;
00119    fWeightMatrix1to2[0][8] = -0.114383123779133;
00120    fWeightMatrix1to2[0][9] = -0.114380400108112;
00121    fWeightMatrix1to2[0][10] = -0.114384642740348;
00122    fWeightMatrix1to2[0][11] = 0.491114735426463;
00123 
00124 
00125 }//L4Init

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

Definition at line 262 of file LEMAmbyE50S5111.cxx.

References InitTransform_1().

Referenced by LEMAmbyE50S5111().

00263 {
00264    InitTransform_1();
00265 }

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

Definition at line 210 of file LEMAmbyE50S5111.cxx.

References fMax_1, and fMin_1.

Referenced by InitTransform().

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

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

Definition at line 54 of file LEMAmbyE50S5111.h.

Referenced by GetMvaValue().

00054 { return false; }

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

Definition at line 57 of file LEMAmbyE50S5111.h.

Referenced by GetMvaValue().

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

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

Definition at line 268 of file LEMAmbyE50S5111.cxx.

References Transform_1().

Referenced by GetMvaValue().

00269 {
00270    Transform_1( iv, sigOrBgd );
00271 }

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

Definition at line 248 of file LEMAmbyE50S5111.cxx.

References fMax_1, and fMin_1.

Referenced by Transform().

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


Member Data Documentation

const char* LEMAmbyE50S5111::fClassName [private]

Definition at line 47 of file LEMAmbyE50S5111.h.

int LEMAmbyE50S5111::fLayers [private]

Definition at line 73 of file LEMAmbyE50S5111.h.

Referenced by GetMvaValue__(), and Initialize().

int LEMAmbyE50S5111::fLayerSize[3] [private]

Definition at line 74 of file LEMAmbyE50S5111.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 40 of file LEMAmbyE50S5111.h.

Referenced by InitTransform_1(), and Transform_1().

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

Definition at line 39 of file LEMAmbyE50S5111.h.

Referenced by InitTransform_1(), and Transform_1().

char LEMAmbyE50S5111::fType[5] [private]

Definition at line 63 of file LEMAmbyE50S5111.h.

Referenced by GetType(), and LEMAmbyE50S5111().

double LEMAmbyE50S5111::fVmax[5] [private]

Definition at line 56 of file LEMAmbyE50S5111.h.

Referenced by GetMvaValue(), and LEMAmbyE50S5111().

double LEMAmbyE50S5111::fVmin[5] [private]

Definition at line 55 of file LEMAmbyE50S5111.h.

Referenced by GetMvaValue(), and LEMAmbyE50S5111().

double LEMAmbyE50S5111::fWeightMatrix0to1[12][6] [private]

Definition at line 75 of file LEMAmbyE50S5111.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 76 of file LEMAmbyE50S5111.h.

Referenced by GetMvaValue__(), and Initialize().

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

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