LEM4pid Class Reference

#include <LEM4pid.h>

List of all members.

Public Member Functions

 LEM4pid ()
 ~LEM4pid ()
double GetMvaValue (const std::vector< double > &inputValues) const
Double_t GetLEM4pid (NueRecord *nr)
Double_t GetLEM4pid (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][4]
double fMax_1 [3][4]
const char * fClassName
double fVmin [4]
double fVmax [4]
char fType [4]
int fLayers
int fLayerSize [3]
double fWeightMatrix0to1 [10][5]
double fWeightMatrix1to2 [1][10]
double * fWeights [3]

Detailed Description

Definition at line 13 of file LEM4pid.h.


Constructor & Destructor Documentation

LEM4pid::LEM4pid (  ) 

Definition at line 5 of file LEM4pid.cxx.

References fType, fVmax, fVmin, Initialize(), and InitTransform().

00006 {
00007     // initialize min and max vectors (for normalisation)
00008 
00009       fVmin[0] = -1;
00010       fVmax[0] = 0.99999988079071;
00011       fVmin[1] = -1;
00012       fVmax[1] = 0.999999940395355;
00013       fVmin[2] = -1;
00014       fVmax[2] = 1;
00015       fVmin[3] = -1;
00016       fVmax[3] = 1;
00017 
00018       // initialize input variable types
00019       fType[0] = 'F';
00020       fType[1] = 'F';
00021       fType[2] = 'F';
00022       fType[3] = 'F';
00023 
00024       // initialize constants
00025       Initialize();
00026 
00027       // initialize transformation
00028       InitTransform();
00029 }//LEM4pid

LEM4pid::~LEM4pid (  )  [inline]

Definition at line 19 of file LEM4pid.h.

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


Member Function Documentation

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

Definition at line 133 of file LEM4pid.cxx.

Referenced by GetMvaValue__().

00133                                             {
00134    // hyperbolic tan
00135    return tanh(x);
00136 }

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

Definition at line 141 of file LEM4pid.cxx.

00142 {
00143    // nothing to clear
00144 }

Double_t LEM4pid::GetLEM4pid ( NueAnaReader nueana  ) 

Definition at line 283 of file LEM4pid.cxx.

References GetLEM4pid(), and NueAnaReader::nuerecord.

00283                                                 {
00284 
00285   Double_t lem4pid=-1;
00286   lem4pid = GetLEM4pid(nueana->nuerecord);
00287   return lem4pid;
00288 
00289 }

Double_t LEM4pid::GetLEM4pid ( NueRecord nr  ) 

Definition at line 240 of file LEM4pid.cxx.

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

Referenced by MCNNFiller::FillMCNN(), GetLEM4pid(), and NueStandard::GetPIDValue().

00240                                          {
00241 
00242   //LEM4 PID value
00243   Double_t lem4pid=-1;
00244 
00245   //Input variables
00246   Double_t val_mny=-1;
00247   Double_t val_mfqm=-1;
00248   Double_t val_fcc=-1;
00249   Double_t val_recoe=-1;
00250 
00251   //Define the variables (y_cut = 1.0 = no y cut)
00252   val_mny = LEMStandard::Getymean(nr,1.0);
00253   val_mfqm = LEMStandard::GetMeanFracQMatched(nr,1.0);
00254   val_fcc = LEMStandard::GetfracCCy(nr,1.0);
00255   val_recoe = nr->srevent.phNueGeV;
00256 
00257   //Preselection: return automatic -1 for out of range events.
00258   if (val_mny<0||val_mfqm<0||val_fcc<0||val_recoe<0) {
00259     lem4pid=-1;
00260   } else {
00261     //Define an input vector with the cariable names.
00262     std::vector<double> inputVec( 4 );
00263 
00264     inputVec[0]=val_mny;
00265     inputVec[1]=val_mfqm;
00266     inputVec[2]=val_fcc;
00267     inputVec[3]=val_recoe;
00268       
00269     //Calculate the LEM discriminant!
00270    lem4pid = LEM4pid::GetMvaValue(inputVec);
00271 
00272   
00273   //Transform so that the PID value is between 0.0 to 1.0.
00274   lem4pid = (lem4pid + 1.1)/2.2;
00275 
00276   }
00277   //return the PID:
00278   return lem4pid;
00279 
00280 }

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

Definition at line 145 of file LEM4pid.cxx.

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

Referenced by GetLEM4pid().

00146    {
00147       // classifier response value
00148       double retval = 0;
00149 
00150       // classifier response, sanity check first
00151    
00152          if (IsNormalised()) {
00153             // normalise variables
00154             std::vector<double> iV;
00155             int ivar = 0;
00156             for (std::vector<double>::const_iterator varIt = inputValues.begin();
00157                  varIt != inputValues.end(); varIt++, ivar++) {
00158                iV.push_back(NormVariable( *varIt, fVmin[ivar], fVmax[ivar] ));
00159             }
00160             Transform( iV, -1 );
00161             retval = GetMvaValue__( iV );
00162          }
00163          else {
00164             std::vector<double> iV;
00165             int ivar = 0;
00166             for (std::vector<double>::const_iterator varIt = inputValues.begin();
00167                  varIt != inputValues.end(); varIt++, ivar++) {
00168                iV.push_back(*varIt);
00169             }
00170             Transform( iV, -1 );
00171             retval = GetMvaValue__( iV );
00172          }
00173      
00174 
00175       return retval;
00176    }//cleanup

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

Definition at line 98 of file LEM4pid.cxx.

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

Referenced by GetMvaValue().

00099 {
00100    if (inputValues.size() != (unsigned int)fLayerSize[0]-1) {
00101       std::cout << "Input vector needs to be of size " << fLayerSize[0]-1 << std::endl;
00102       return 0;
00103    }
00104 
00105    for (int l=0; l<fLayers; l++)
00106       for (int i=0; i<fLayerSize[l]; i++) fWeights[l][i]=0;
00107 
00108    for (int l=0; l<fLayers-1; l++)
00109       fWeights[l][fLayerSize[l]-1]=1;
00110 
00111    for (int i=0; i<fLayerSize[0]-1; i++)
00112       fWeights[0][i]=inputValues[i];
00113 
00114    // layer 0 to 1
00115    for (int o=0; o<fLayerSize[1]-1; o++) {
00116       for (int i=0; i<fLayerSize[0]; i++) {
00117          double inputVal = fWeightMatrix0to1[o][i] * fWeights[0][i];
00118          fWeights[1][o] += inputVal;
00119       }
00120       fWeights[1][o] = ActivationFnc(fWeights[1][o]);
00121    }
00122    // layer 1 to 2
00123    for (int o=0; o<fLayerSize[2]; o++) {
00124       for (int i=0; i<fLayerSize[1]; i++) {
00125          double inputVal = fWeightMatrix1to2[o][i] * fWeights[1][i];
00126          fWeights[2][o] += inputVal;
00127       }
00128    }
00129 
00130    return fWeights[2][0];
00131 }//GetMVAvalue

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

Definition at line 49 of file LEM4pid.h.

References fType.

00049 { return fType[ivar]; }

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

Definition at line 32 of file LEM4pid.cxx.

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

Referenced by LEM4pid().

00033 {
00034    // build network structure
00035    fLayers = 3;
00036    fLayerSize[0] = 5; fWeights[0] = new double[5]; 
00037    fLayerSize[1] = 10; fWeights[1] = new double[10]; 
00038    fLayerSize[2] = 1; fWeights[2] = new double[1]; 
00039    // weight matrix from layer 0 to 1
00040    fWeightMatrix0to1[0][0] = -0.393809135460912;
00041    fWeightMatrix0to1[1][0] = -0.408776401663087;
00042    fWeightMatrix0to1[2][0] = -0.183322002131785;
00043    fWeightMatrix0to1[3][0] = -0.0304841952579745;
00044    fWeightMatrix0to1[4][0] = 0.941805387131979;
00045    fWeightMatrix0to1[5][0] = 0.641328096902566;
00046    fWeightMatrix0to1[6][0] = -0.291228748162671;
00047    fWeightMatrix0to1[7][0] = 0.898434134878503;
00048    fWeightMatrix0to1[8][0] = -0.00852724246711963;
00049    fWeightMatrix0to1[0][1] = -0.127301921113354;
00050    fWeightMatrix0to1[1][1] = -1.65660766620401;
00051    fWeightMatrix0to1[2][1] = -0.0376941224859565;
00052    fWeightMatrix0to1[3][1] = 2.583811272997;
00053    fWeightMatrix0to1[4][1] = 5.24758218736016;
00054    fWeightMatrix0to1[5][1] = 0.134909295827119;
00055    fWeightMatrix0to1[6][1] = -0.080968940376267;
00056    fWeightMatrix0to1[7][1] = 3.50633833003507;
00057    fWeightMatrix0to1[8][1] = -0.000674903749495457;
00058    fWeightMatrix0to1[0][2] = -0.34890584284385;
00059    fWeightMatrix0to1[1][2] = -2.45117596526325;
00060    fWeightMatrix0to1[2][2] = -0.194918521423538;
00061    fWeightMatrix0to1[3][2] = -0.427458462014497;
00062    fWeightMatrix0to1[4][2] = 1.04796561573008;
00063    fWeightMatrix0to1[5][2] = -1.22202668553485;
00064    fWeightMatrix0to1[6][2] = -0.284834001472708;
00065    fWeightMatrix0to1[7][2] = -1.96336396953682;
00066    fWeightMatrix0to1[8][2] = -0.00955340784527446;
00067    fWeightMatrix0to1[0][3] = 0.219851263403076;
00068    fWeightMatrix0to1[1][3] = -0.51847437906083;
00069    fWeightMatrix0to1[2][3] = 0.141879988924907;
00070    fWeightMatrix0to1[3][3] = -3.20110959289011;
00071    fWeightMatrix0to1[4][3] = -1.66135902103889;
00072    fWeightMatrix0to1[5][3] = 1.29617220012235;
00073    fWeightMatrix0to1[6][3] = 0.184315213341596;
00074    fWeightMatrix0to1[7][3] = -2.39458522238751;
00075    fWeightMatrix0to1[8][3] = 0.0082582561429092;
00076    fWeightMatrix0to1[0][4] = 0.0752713265371175;
00077    fWeightMatrix0to1[1][4] = 3.83909469612474;
00078    fWeightMatrix0to1[2][4] = 0.0825204919095855;
00079    fWeightMatrix0to1[3][4] = -3.29187322566101;
00080    fWeightMatrix0to1[4][4] = -4.05287527133699;
00081    fWeightMatrix0to1[5][4] = 0.955119886404769;
00082    fWeightMatrix0to1[6][4] = 0.0893410626714083;
00083    fWeightMatrix0to1[7][4] = -6.40378480693984;
00084    fWeightMatrix0to1[8][4] = 0.0051871646557296;
00085    // weight matrix from layer 1 to 2
00086    fWeightMatrix1to2[0][0] = -0.111933163002204;
00087    fWeightMatrix1to2[0][1] = -0.906386780031441;
00088    fWeightMatrix1to2[0][2] = -0.0381821232687122;
00089    fWeightMatrix1to2[0][3] = 0.207804082616805;
00090    fWeightMatrix1to2[0][4] = 0.460451434841681;
00091    fWeightMatrix1to2[0][5] = -0.25802080256488;
00092    fWeightMatrix1to2[0][6] = -0.0684680250395479;
00093    fWeightMatrix1to2[0][7] = -0.682360741389277;
00094    fWeightMatrix1to2[0][8] = -0.00198484216080161;
00095    fWeightMatrix1to2[0][9] = 0.232467408611416;
00096 }//L4Init

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

Definition at line 224 of file LEM4pid.cxx.

References InitTransform_1().

Referenced by LEM4pid().

00225 {
00226    InitTransform_1();
00227 }

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

Definition at line 181 of file LEM4pid.cxx.

References fMax_1, and fMin_1.

Referenced by InitTransform().

00182 {
00183    fMin_1[0][0] = 0.0243627969176;
00184    fMax_1[0][0] = 0.967587172985;
00185    fMin_1[1][0] = 0.0183596666902;
00186    fMax_1[1][0] = 0.992570221424;
00187    fMin_1[2][0] = 0.0183596666902;
00188    fMax_1[2][0] = 0.992570221424;
00189    fMin_1[0][1] = 0.131170228124;
00190    fMax_1[0][1] = 0.985574424267;
00191    fMin_1[1][1] = 0.0353097617626;
00192    fMax_1[1][1] = 1;
00193    fMin_1[2][1] = 0.0353097617626;
00194    fMax_1[2][1] = 1;
00195    fMin_1[0][2] = 0.019999999553;
00196    fMax_1[0][2] = 1;
00197    fMin_1[1][2] = 0.019999999553;
00198    fMax_1[1][2] = 1;
00199    fMin_1[2][2] = 0.019999999553;
00200    fMax_1[2][2] = 1;
00201    fMin_1[0][3] = 0.503779053688;
00202    fMax_1[0][3] = 11.9999046326;
00203    fMin_1[1][3] = 0.50007301569;
00204    fMax_1[1][3] = 11.9999961853;
00205    fMin_1[2][3] = 0.50007301569;
00206    fMax_1[2][3] = 11.9999961853;
00207 }

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

Definition at line 54 of file LEM4pid.h.

Referenced by GetMvaValue().

00054 { return false; }

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

Definition at line 57 of file LEM4pid.h.

Referenced by GetMvaValue().

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

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

Definition at line 230 of file LEM4pid.cxx.

References Transform_1().

Referenced by GetMvaValue().

00231 {
00232    Transform_1( iv, sigOrBgd );
00233 }

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

Definition at line 210 of file LEM4pid.cxx.

References fMax_1, and fMin_1.

Referenced by Transform().

00211 {
00212 if (cls < 0 || cls > 2) {
00213    if (2 > 1 ) cls = 2;
00214    else cls = 2;
00215 }
00216    for (int ivar=0;ivar<4;ivar++) {
00217       double offset = fMin_1[cls][ivar];
00218       double scale  = 1.0/(fMax_1[cls][ivar]-fMin_1[cls][ivar]);
00219       iv[ivar] = (iv[ivar]-offset)*scale * 2 - 1;
00220    }
00221 }


Member Data Documentation

const char* LEM4pid::fClassName [private]

Definition at line 47 of file LEM4pid.h.

int LEM4pid::fLayers [private]

Definition at line 73 of file LEM4pid.h.

Referenced by GetMvaValue__(), and Initialize().

int LEM4pid::fLayerSize[3] [private]

Definition at line 74 of file LEM4pid.h.

Referenced by GetMvaValue__(), and Initialize().

double LEM4pid::fMax_1[3][4] [private]

Definition at line 40 of file LEM4pid.h.

Referenced by InitTransform_1(), and Transform_1().

double LEM4pid::fMin_1[3][4] [private]

Definition at line 39 of file LEM4pid.h.

Referenced by InitTransform_1(), and Transform_1().

char LEM4pid::fType[4] [private]

Definition at line 63 of file LEM4pid.h.

Referenced by GetType(), and LEM4pid().

double LEM4pid::fVmax[4] [private]

Definition at line 56 of file LEM4pid.h.

Referenced by GetMvaValue(), and LEM4pid().

double LEM4pid::fVmin[4] [private]

Definition at line 55 of file LEM4pid.h.

Referenced by GetMvaValue(), and LEM4pid().

double LEM4pid::fWeightMatrix0to1[10][5] [private]

Definition at line 75 of file LEM4pid.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 76 of file LEM4pid.h.

Referenced by GetMvaValue__(), and Initialize().

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

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