LEMLSND Class Reference

#include <LEMLSND.h>

List of all members.

Public Member Functions

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


Constructor & Destructor Documentation

LEMLSND::LEMLSND (  ) 

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

LEMLSND::~LEMLSND (  )  [inline]

Definition at line 19 of file LEMLSND.h.

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


Member Function Documentation

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

Definition at line 174 of file LEMLSND.cxx.

Referenced by GetMvaValue__().

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

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

Definition at line 182 of file LEMLSND.cxx.

00183 {
00184    // nothing to clear
00185 }

Double_t LEMLSND::GetLEMLSND ( NueAnaReader nueana  ) 

Definition at line 346 of file LEMLSND.cxx.

References GetLEMLSND(), and NueAnaReader::nuerecord.

00346                                                 {
00347 
00348   Double_t lemLSND=-1;
00349   lemLSND = GetLEMLSND(nueana->nuerecord);
00350   return lemLSND;
00351 
00352 }

Double_t LEMLSND::GetLEMLSND ( NueRecord nr  ) 

Definition at line 296 of file LEMLSND.cxx.

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

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

00296                                          {
00297 
00298   //LEM4 PID value
00299   Double_t lemLSND=-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     lemLSND=-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    lemLSND = LEMLSND::GetMvaValue(inputVec);
00333 
00334   
00335   //Transform so that the PID value is between 0.0 to 1.0.
00336   //LSND1 from -0.07085 - 1.1339
00337   lemLSND = ( lemLSND + 0.071 ) / 1.205;
00338 
00339   }
00340   //return the PID:
00341   return lemLSND;
00342 
00343 }

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

Definition at line 186 of file LEMLSND.cxx.

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

Referenced by GetLEMLSND().

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

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

Definition at line 49 of file LEMLSND.h.

References fType.

00049 { return fType[ivar]; }

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

Definition at line 38 of file LEMLSND.cxx.

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

Referenced by LEMLSND().

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.133300216139343;
00047    fWeightMatrix0to1[1][0] = 0.159662009147212;
00048    fWeightMatrix0to1[2][0] = -0.648240983223869;
00049    fWeightMatrix0to1[3][0] = -0.120002142607018;
00050    fWeightMatrix0to1[4][0] = -0.155535860348683;
00051    fWeightMatrix0to1[5][0] = 0.0178414797370245;
00052    fWeightMatrix0to1[6][0] = -0.0910990637791677;
00053    fWeightMatrix0to1[7][0] = -0.108006586579526;
00054    fWeightMatrix0to1[8][0] = 0.010162904113502;
00055    fWeightMatrix0to1[9][0] = -0.106925532098688;
00056    fWeightMatrix0to1[10][0] = -0.400022938776992;
00057    fWeightMatrix0to1[0][1] = -0.0186702655256431;
00058    fWeightMatrix0to1[1][1] = 0.150412823815657;
00059    fWeightMatrix0to1[2][1] = -3.24465895547162;
00060    fWeightMatrix0to1[3][1] = 0.0529947745413441;
00061    fWeightMatrix0to1[4][1] = -0.0587927406488098;
00062    fWeightMatrix0to1[5][1] = 0.64369039943907;
00063    fWeightMatrix0to1[6][1] = 0.357947013258939;
00064    fWeightMatrix0to1[7][1] = -0.0245540545407903;
00065    fWeightMatrix0to1[8][1] = 0.689205515396237;
00066    fWeightMatrix0to1[9][1] = -0.990286885228682;
00067    fWeightMatrix0to1[10][1] = -0.725896504376587;
00068    fWeightMatrix0to1[0][2] = -0.0766735062924607;
00069    fWeightMatrix0to1[1][2] = -0.119258501846939;
00070    fWeightMatrix0to1[2][2] = -1.59112873487479;
00071    fWeightMatrix0to1[3][2] = -1.12025813725499;
00072    fWeightMatrix0to1[4][2] = 0.112452891564349;
00073    fWeightMatrix0to1[5][2] = -0.0998315236391435;
00074    fWeightMatrix0to1[6][2] = 0.0526015520448152;
00075    fWeightMatrix0to1[7][2] = 0.0511204363261772;
00076    fWeightMatrix0to1[8][2] = -0.199003578977385;
00077    fWeightMatrix0to1[9][2] = -0.0382311547837;
00078    fWeightMatrix0to1[10][2] = -0.941103107877529;
00079    fWeightMatrix0to1[0][3] = 0.322056732872324;
00080    fWeightMatrix0to1[1][3] = 0.415089176220827;
00081    fWeightMatrix0to1[2][3] = 0.548403834337055;
00082    fWeightMatrix0to1[3][3] = -2.86162380450989;
00083    fWeightMatrix0to1[4][3] = -0.403773150191464;
00084    fWeightMatrix0to1[5][3] = 1.66148367999125;
00085    fWeightMatrix0to1[6][3] = -0.240273546545345;
00086    fWeightMatrix0to1[7][3] = -0.246255116374131;
00087    fWeightMatrix0to1[8][3] = 1.35384557797354;
00088    fWeightMatrix0to1[9][3] = -0.0104860071481456;
00089    fWeightMatrix0to1[10][3] = 0.411632444969606;
00090    fWeightMatrix0to1[0][4] = -0.14295743889491;
00091    fWeightMatrix0to1[1][4] = -0.191055993349208;
00092    fWeightMatrix0to1[2][4] = 0.0243542371116877;
00093    fWeightMatrix0to1[3][4] = -0.265518761673986;
00094    fWeightMatrix0to1[4][4] = 0.18595582352116;
00095    fWeightMatrix0to1[5][4] = -0.280046210509529;
00096    fWeightMatrix0to1[6][4] = 0.117837895067451;
00097    fWeightMatrix0to1[7][4] = 0.108026056512759;
00098    fWeightMatrix0to1[8][4] = -0.879114720355856;
00099    fWeightMatrix0to1[9][4] = -0.0732715043326706;
00100    fWeightMatrix0to1[10][4] = 0.978201625635376;
00101    fWeightMatrix0to1[0][5] = 0.240991233014389;
00102    fWeightMatrix0to1[1][5] = 0.134886829685813;
00103    fWeightMatrix0to1[2][5] = 0.0560516573314779;
00104    fWeightMatrix0to1[3][5] = 1.42021637375773;
00105    fWeightMatrix0to1[4][5] = -0.215876184783486;
00106    fWeightMatrix0to1[5][5] = -0.386798636718611;
00107    fWeightMatrix0to1[6][5] = -0.4983902113083;
00108    fWeightMatrix0to1[7][5] = -0.156120056686189;
00109    fWeightMatrix0to1[8][5] = 0.37963349427336;
00110    fWeightMatrix0to1[9][5] = 0.806766346478979;
00111    fWeightMatrix0to1[10][5] = -0.803837261286163;
00112    fWeightMatrix0to1[0][6] = 0.0474131827788499;
00113    fWeightMatrix0to1[1][6] = 0.0244628611139641;
00114    fWeightMatrix0to1[2][6] = 3.33813340393851;
00115    fWeightMatrix0to1[3][6] = -2.01444433972187;
00116    fWeightMatrix0to1[4][6] = -0.0348778591564187;
00117    fWeightMatrix0to1[5][6] = 0.530625370619005;
00118    fWeightMatrix0to1[6][6] = -0.0811382631126762;
00119    fWeightMatrix0to1[7][6] = -0.0431396756629698;
00120    fWeightMatrix0to1[8][6] = 0.296383865220172;
00121    fWeightMatrix0to1[9][6] = 0.0919121352245423;
00122    fWeightMatrix0to1[10][6] = 0.889992924227149;
00123    // weight matrix from layer 1 to 2
00124    fWeightMatrix1to2[0][0] = -0.1127703897388;
00125    fWeightMatrix1to2[0][1] = -0.141313032454593;
00126    fWeightMatrix1to2[0][2] = -0.323221722210457;
00127    fWeightMatrix1to2[0][3] = 0.191270879822652;
00128    fWeightMatrix1to2[0][4] = 0.134011325839833;
00129    fWeightMatrix1to2[0][5] = 0.723183215262284;
00130    fWeightMatrix1to2[0][6] = 0.0690585777444119;
00131    fWeightMatrix1to2[0][7] = 0.0949259351878116;
00132    fWeightMatrix1to2[0][8] = -0.399082315828372;
00133    fWeightMatrix1to2[0][9] = 0.116057263418085;
00134    fWeightMatrix1to2[0][10] = -0.332855787548216;
00135    fWeightMatrix1to2[0][11] = 0.711896209307204;
00136 
00137 }//L4Init

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

Definition at line 280 of file LEMLSND.cxx.

References InitTransform_1().

Referenced by LEMLSND().

00281 {
00282    InitTransform_1();
00283 }

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

Definition at line 222 of file LEMLSND.cxx.

References fMax_1, and fMin_1.

Referenced by InitTransform().

00223 {
00224 
00225    // Normalization transformation, initialisation
00226    fMin_1[0][0] = 0.0234358664602;
00227    fMax_1[0][0] = 0.963169395924;
00228    fMin_1[1][0] = 0.00440045911819;
00229    fMax_1[1][0] = 0.996161162853;
00230    fMin_1[2][0] = 0.00440045911819;
00231    fMax_1[2][0] = 0.996161162853;
00232    fMin_1[0][1] = 0.103901900351;
00233    fMax_1[0][1] = 0.988250792027;
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.503064274788;
00245    fMax_1[0][3] = 11.9998617172;
00246    fMin_1[1][3] = 0.500009179115;
00247    fMax_1[1][3] = 11.9999990463;
00248    fMin_1[2][3] = 0.500009179115;
00249    fMax_1[2][3] = 11.9999990463;
00250    fMin_1[0][4] = 0.041999027133;
00251    fMax_1[0][4] = 0.997338533401;
00252    fMin_1[1][4] = 0.0386520028114;
00253    fMax_1[1][4] = 0.996083319187;
00254    fMin_1[2][4] = 0.0386520028114;
00255    fMax_1[2][4] = 0.997338533401;
00256    fMin_1[0][5] = 0.088061593473;
00257    fMax_1[0][5] = 0.981214880943;
00258    fMin_1[1][5] = 0;
00259    fMax_1[1][5] = 1;
00260    fMin_1[2][5] = 0;
00261    fMax_1[2][5] = 1;
00262 
00263 }

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

Definition at line 54 of file LEMLSND.h.

Referenced by GetMvaValue().

00054 { return false; }

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

Definition at line 57 of file LEMLSND.h.

Referenced by GetMvaValue().

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

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

Definition at line 286 of file LEMLSND.cxx.

References Transform_1().

Referenced by GetMvaValue().

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

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

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

Definition at line 47 of file LEMLSND.h.

int LEMLSND::fLayers [private]

Definition at line 73 of file LEMLSND.h.

Referenced by GetMvaValue__(), and Initialize().

int LEMLSND::fLayerSize[3] [private]

Definition at line 74 of file LEMLSND.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 40 of file LEMLSND.h.

Referenced by InitTransform_1(), and Transform_1().

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

Definition at line 39 of file LEMLSND.h.

Referenced by InitTransform_1(), and Transform_1().

char LEMLSND::fType[6] [private]

Definition at line 63 of file LEMLSND.h.

Referenced by GetType(), and LEMLSND().

double LEMLSND::fVmax[6] [private]

Definition at line 56 of file LEMLSND.h.

Referenced by GetMvaValue(), and LEMLSND().

double LEMLSND::fVmin[6] [private]

Definition at line 55 of file LEMLSND.h.

Referenced by GetMvaValue(), and LEMLSND().

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

Definition at line 75 of file LEMLSND.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 76 of file LEMLSND.h.

Referenced by GetMvaValue__(), and Initialize().

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

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