LEMAmbyE50S691 Class Reference

#include <LEMAmbyE50S691.h>

List of all members.

Public Member Functions

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


Constructor & Destructor Documentation

LEMAmbyE50S691::LEMAmbyE50S691 (  ) 

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

LEMAmbyE50S691::~LEMAmbyE50S691 (  )  [inline]

Definition at line 19 of file LEMAmbyE50S691.h.

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


Member Function Documentation

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

Definition at line 158 of file LEMAmbyE50S691.cxx.

Referenced by GetMvaValue__().

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

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

Definition at line 166 of file LEMAmbyE50S691.cxx.

00167 {
00168    // nothing to clear
00169 }

Double_t LEMAmbyE50S691::GetLEMAmbyE50S691 ( NueAnaReader nueana  ) 

Definition at line 342 of file LEMAmbyE50S691.cxx.

References GetLEMAmbyE50S691(), and NueAnaReader::nuerecord.

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

Double_t LEMAmbyE50S691::GetLEMAmbyE50S691 ( NueRecord nr  ) 

Definition at line 280 of file LEMAmbyE50S691.cxx.

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

Referenced by GetLEMAmbyE50S691(), 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 = LEMAmbyE50S691::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   //E50S691 -0.177654--1.19281
00325 
00326    Double_t lowval=-0.177654;
00327    Double_t highval=1.19281;
00328    Double_t midpoint=(lowval+highval)/2.0;
00329    Double_t denom=(highval-lowval)*1.001; //prev 1.022mod
00330    //lemAmby = (( lemAmby - midpoint) / denom) + 0.5;
00331    lemAmby = (( lemAmby - lowval ) / denom); 
00332  
00333  
00334 
00335   }
00336   //return the PID:
00337   return lemAmby;
00338 
00339 }

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

Definition at line 170 of file LEMAmbyE50S691.cxx.

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

Referenced by GetLEMAmbyE50S691().

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

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

Definition at line 49 of file LEMAmbyE50S691.h.

References fType.

00049 { return fType[ivar]; }

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

Definition at line 38 of file LEMAmbyE50S691.cxx.

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

Referenced by LEMAmbyE50S691().

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] = 1.17032456953156;
00047    fWeightMatrix0to1[1][0] = -0.214971034962123;
00048    fWeightMatrix0to1[2][0] = 0.681909364104436;
00049    fWeightMatrix0to1[3][0] = -0.122173525425133;
00050    fWeightMatrix0to1[4][0] = -0.214739330026887;
00051    fWeightMatrix0to1[5][0] = 1.29465076331257;
00052    fWeightMatrix0to1[6][0] = -0.751227762182554;
00053    fWeightMatrix0to1[7][0] = 0.594079242209473;
00054    fWeightMatrix0to1[8][0] = 0.1387858163438;
00055    fWeightMatrix0to1[0][1] = 0.032755561876095;
00056    fWeightMatrix0to1[1][1] = -0.0891599517016012;
00057    fWeightMatrix0to1[2][1] = -0.263859799335819;
00058    fWeightMatrix0to1[3][1] = -1.62850981462308;
00059    fWeightMatrix0to1[4][1] = -0.134581383638538;
00060    fWeightMatrix0to1[5][1] = 0.0171390043111249;
00061    fWeightMatrix0to1[6][1] = 0.450116970365314;
00062    fWeightMatrix0to1[7][1] = -3.19837934746939;
00063    fWeightMatrix0to1[8][1] = -0.48382921563251;
00064    fWeightMatrix0to1[0][2] = 0.467328150426411;
00065    fWeightMatrix0to1[1][2] = -0.118128714254956;
00066    fWeightMatrix0to1[2][2] = 0.113297478129158;
00067    fWeightMatrix0to1[3][2] = -1.52641565330932;
00068    fWeightMatrix0to1[4][2] = -0.120355853730778;
00069    fWeightMatrix0to1[5][2] = -0.00893715155483434;
00070    fWeightMatrix0to1[6][2] = -0.604722148129965;
00071    fWeightMatrix0to1[7][2] = -1.57256104211101;
00072    fWeightMatrix0to1[8][2] = 0.795880132777089;
00073    fWeightMatrix0to1[0][3] = -0.0486636193097568;
00074    fWeightMatrix0to1[1][3] = -0.276757491762409;
00075    fWeightMatrix0to1[2][3] = -0.672829754683943;
00076    fWeightMatrix0to1[3][3] = 0.867080946143594;
00077    fWeightMatrix0to1[4][3] = -0.276175216147174;
00078    fWeightMatrix0to1[5][3] = 0.0218376133535347;
00079    fWeightMatrix0to1[6][3] = -0.2373179269355;
00080    fWeightMatrix0to1[7][3] = 0.196057097315705;
00081    fWeightMatrix0to1[8][3] = 0.776287006156817;
00082    fWeightMatrix0to1[0][4] = -0.273736503712209;
00083    fWeightMatrix0to1[1][4] = -0.0403691191647449;
00084    fWeightMatrix0to1[2][4] = -0.358179122825371;
00085    fWeightMatrix0to1[3][4] = 0.724539633107615;
00086    fWeightMatrix0to1[4][4] = -0.0357173455783099;
00087    fWeightMatrix0to1[5][4] = -0.538006128553566;
00088    fWeightMatrix0to1[6][4] = 0.217008784127368;
00089    fWeightMatrix0to1[7][4] = -0.908350892638779;
00090    fWeightMatrix0to1[8][4] = 0.362115292399976;
00091    fWeightMatrix0to1[0][5] = 0.125517439736942;
00092    fWeightMatrix0to1[1][5] = 0.351464529236773;
00093    fWeightMatrix0to1[2][5] = 0.0259623004034322;
00094    fWeightMatrix0to1[3][5] = -0.411356909528232;
00095    fWeightMatrix0to1[4][5] = 0.399503904630572;
00096    fWeightMatrix0to1[5][5] = -0.144769316877144;
00097    fWeightMatrix0to1[6][5] = 0.546047017414606;
00098    fWeightMatrix0to1[7][5] = 0.748805280168415;
00099    fWeightMatrix0to1[8][5] = -0.798308789271752;
00100    fWeightMatrix0to1[0][6] = 0.124356916047483;
00101    fWeightMatrix0to1[1][6] = -0.274213827840265;
00102    fWeightMatrix0to1[2][6] = 0.95043186437119;
00103    fWeightMatrix0to1[3][6] = 2.08048494356371;
00104    fWeightMatrix0to1[4][6] = -0.267228152957903;
00105    fWeightMatrix0to1[5][6] = -0.400676180543149;
00106    fWeightMatrix0to1[6][6] = -0.0945498029923083;
00107    fWeightMatrix0to1[7][6] = 4.29205559153195;
00108    fWeightMatrix0to1[8][6] = 0.640473495678827;
00109    // weight matrix from layer 1 to 2
00110    fWeightMatrix1to2[0][0] = 0.429857587289225;
00111    fWeightMatrix1to2[0][1] = -0.177493815366158;
00112    fWeightMatrix1to2[0][2] = -0.552490466414419;
00113    fWeightMatrix1to2[0][3] = -0.305443179769104;
00114    fWeightMatrix1to2[0][4] = -0.168596147909891;
00115    fWeightMatrix1to2[0][5] = -0.52364817856011;
00116    fWeightMatrix1to2[0][6] = -0.423503882681838;
00117    fWeightMatrix1to2[0][7] = -0.227525640222766;
00118    fWeightMatrix1to2[0][8] = -0.470946602471872;
00119    fWeightMatrix1to2[0][9] = 0.91195476196393;
00120 
00121 }//L4Init

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

Definition at line 264 of file LEMAmbyE50S691.cxx.

References InitTransform_1().

Referenced by LEMAmbyE50S691().

00265 {
00266    InitTransform_1();
00267 }

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

Definition at line 206 of file LEMAmbyE50S691.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 LEMAmbyE50S691::IsNormalised (  )  const [inline, private]

Definition at line 54 of file LEMAmbyE50S691.h.

Referenced by GetMvaValue().

00054 { return false; }

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

Definition at line 57 of file LEMAmbyE50S691.h.

Referenced by GetMvaValue().

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

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

Definition at line 270 of file LEMAmbyE50S691.cxx.

References Transform_1().

Referenced by GetMvaValue().

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

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

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

Definition at line 47 of file LEMAmbyE50S691.h.

int LEMAmbyE50S691::fLayers [private]

Definition at line 73 of file LEMAmbyE50S691.h.

Referenced by GetMvaValue__(), and Initialize().

int LEMAmbyE50S691::fLayerSize[3] [private]

Definition at line 74 of file LEMAmbyE50S691.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 40 of file LEMAmbyE50S691.h.

Referenced by InitTransform_1(), and Transform_1().

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

Definition at line 39 of file LEMAmbyE50S691.h.

Referenced by InitTransform_1(), and Transform_1().

char LEMAmbyE50S691::fType[6] [private]

Definition at line 63 of file LEMAmbyE50S691.h.

Referenced by GetType(), and LEMAmbyE50S691().

double LEMAmbyE50S691::fVmax[6] [private]

Definition at line 56 of file LEMAmbyE50S691.h.

Referenced by GetMvaValue(), and LEMAmbyE50S691().

double LEMAmbyE50S691::fVmin[6] [private]

Definition at line 55 of file LEMAmbyE50S691.h.

Referenced by GetMvaValue(), and LEMAmbyE50S691().

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

Definition at line 75 of file LEMAmbyE50S691.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 76 of file LEMAmbyE50S691.h.

Referenced by GetMvaValue__(), and Initialize().

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

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