LEMbarpid Class Reference

#include <LEMbarpid.h>

List of all members.

Public Member Functions

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


Constructor & Destructor Documentation

LEMbarpid::LEMbarpid (  ) 

Definition at line 5 of file LEMbarpid.cxx.

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

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

LEMbarpid::~LEMbarpid (  )  [inline]

Definition at line 19 of file LEMbarpid.h.

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


Member Function Documentation

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

Definition at line 131 of file LEMbarpid.cxx.

Referenced by GetMvaValue__().

00131                                               {
00132    // hyperbolic tan
00133    return tanh(x);
00134 }

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

Definition at line 138 of file LEMbarpid.cxx.

00139 {
00140    // nothing to clear
00141 }

Double_t LEMbarpid::GetLEMbarpid ( NueAnaReader nueana  ) 

Definition at line 275 of file LEMbarpid.cxx.

References GetLEMbarpid(), and NueAnaReader::nuerecord.

00275                                                     {
00276 
00277   Double_t lembarpid=-1;
00278   lembarpid = GetLEMbarpid(nueana->nuerecord);
00279   return lembarpid;
00280 
00281 }

Double_t LEMbarpid::GetLEMbarpid ( NueRecord nr  ) 

Definition at line 232 of file LEMbarpid.cxx.

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

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

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

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

Definition at line 142 of file LEMbarpid.cxx.

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

Referenced by GetLEMbarpid().

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

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

Definition at line 96 of file LEMbarpid.cxx.

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

Referenced by GetMvaValue().

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

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

Definition at line 49 of file LEMbarpid.h.

References fType.

00049 { return fType[ivar]; }

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

Definition at line 30 of file LEMbarpid.cxx.

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

Referenced by LEMbarpid().

00031 { 
00032    // build network structure
00033    fLayers = 3;
00034    fLayerSize[0] = 5; fWeights[0] = new double[5]; 
00035    fLayerSize[1] = 10; fWeights[1] = new double[10]; 
00036    fLayerSize[2] = 1; fWeights[2] = new double[1]; 
00037    // weight matrix from layer 0 to 1
00038    fWeightMatrix0to1[0][0] = -0.226355608061847;
00039    fWeightMatrix0to1[1][0] = -0.020683692882633;
00040    fWeightMatrix0to1[2][0] = -0.0447833460284903;
00041    fWeightMatrix0to1[3][0] = -0.51144552880672;
00042    fWeightMatrix0to1[4][0] = 0.0196000180580687;
00043    fWeightMatrix0to1[5][0] = -0.0129908507024511;
00044    fWeightMatrix0to1[6][0] = 0.260349616808946;
00045    fWeightMatrix0to1[7][0] = 0.301180820301538;
00046    fWeightMatrix0to1[8][0] = 0.364440892829927;
00047    fWeightMatrix0to1[0][1] = -0.0717013483927656;
00048    fWeightMatrix0to1[1][1] = -0.453567954505744;
00049    fWeightMatrix0to1[2][1] = 0.203032422693094;
00050    fWeightMatrix0to1[3][1] = -2.06686483434338;
00051    fWeightMatrix0to1[4][1] = 0.359995418839525;
00052    fWeightMatrix0to1[5][1] = -0.0699554452648714;
00053    fWeightMatrix0to1[6][1] = 4.06935778135939;
00054    fWeightMatrix0to1[7][1] = 0.254292075736682;
00055    fWeightMatrix0to1[8][1] = 1.47158712146575;
00056    fWeightMatrix0to1[0][2] = 0.0832246227396965;
00057    fWeightMatrix0to1[1][2] = 1.12575264324543;
00058    fWeightMatrix0to1[2][2] = -0.061573085906697;
00059    fWeightMatrix0to1[3][2] = -1.84279023465706;
00060    fWeightMatrix0to1[4][2] = -0.0978838245394156;
00061    fWeightMatrix0to1[5][2] = 0.489525448438062;
00062    fWeightMatrix0to1[6][2] = 3.05733328504549;
00063    fWeightMatrix0to1[7][2] = -1.0962133172344;
00064    fWeightMatrix0to1[8][2] = 0.635729578777218;
00065    fWeightMatrix0to1[0][3] = -0.722074173093834;
00066    fWeightMatrix0to1[1][3] = 0.616899289750764;
00067    fWeightMatrix0to1[2][3] = -0.408930774022014;
00068    fWeightMatrix0to1[3][3] = 1.36435412986008;
00069    fWeightMatrix0to1[4][3] = -0.320319699867261;
00070    fWeightMatrix0to1[5][3] = 0.382920707881293;
00071    fWeightMatrix0to1[6][3] = -0.87192018677571;
00072    fWeightMatrix0to1[7][3] = 0.0600780516575437;
00073    fWeightMatrix0to1[8][3] = -4.22354542056813;
00074    fWeightMatrix0to1[0][4] = -0.354916860868019;
00075    fWeightMatrix0to1[1][4] = 0.48642497034323;
00076    fWeightMatrix0to1[2][4] = -0.326000699576592;
00077    fWeightMatrix0to1[3][4] = 2.09057422669969;
00078    fWeightMatrix0to1[4][4] = -0.400933749005191;
00079    fWeightMatrix0to1[5][4] = -0.892183200052141;
00080    fWeightMatrix0to1[6][4] = -5.30308537179815;
00081    fWeightMatrix0to1[7][4] = -1.15157249280537;
00082    fWeightMatrix0to1[8][4] = -2.7910355818849;
00083    // weight matrix from layer 1 to 2
00084    fWeightMatrix1to2[0][0] = -0.460497670975692;
00085    fWeightMatrix1to2[0][1] = -0.940949215103279;
00086    fWeightMatrix1to2[0][2] = -0.33060375361588;
00087    fWeightMatrix1to2[0][3] = -0.787371721613473;
00088    fWeightMatrix1to2[0][4] = -0.336249836250055;
00089    fWeightMatrix1to2[0][5] = 0.596128532006015;
00090    fWeightMatrix1to2[0][6] = 0.334151097846933;
00091    fWeightMatrix1to2[0][7] = -0.909012352081444;
00092    fWeightMatrix1to2[0][8] = 0.19833289465576;
00093    fWeightMatrix1to2[0][9] = -0.0148789736213022;
00094 }//inline void LBI

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

Definition at line 218 of file LEMbarpid.cxx.

References InitTransform_1().

Referenced by LEMbarpid().

00219 {
00220    InitTransform_1();
00221 }

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

Definition at line 175 of file LEMbarpid.cxx.

References fMax_1, and fMin_1.

Referenced by InitTransform().

00176 {
00177    fMin_1[0][0] = 0.0256043281406;
00178    fMax_1[0][0] = 0.958988547325;
00179    fMin_1[1][0] = 0.00368331838399;
00180    fMax_1[1][0] = 0.99304485321;
00181    fMin_1[2][0] = 0.00368331838399;
00182    fMax_1[2][0] = 0.99304485321;
00183    fMin_1[0][1] = 0;
00184    fMax_1[0][1] = 0.984021306038;
00185    fMin_1[1][1] = 0;
00186    fMax_1[1][1] = 1;
00187    fMin_1[2][1] = 0;
00188    fMax_1[2][1] = 1;
00189    fMin_1[0][2] = 0.019999999553;
00190    fMax_1[0][2] = 1;
00191    fMin_1[1][2] = 0.019999999553;
00192    fMax_1[1][2] = 1;
00193    fMin_1[2][2] = 0.019999999553;
00194    fMax_1[2][2] = 1;
00195    fMin_1[0][3] = 0.547159016132;
00196    fMax_1[0][3] = 12.0939331055;
00197    fMin_1[1][3] = 0.545364260674;
00198    fMax_1[1][3] = 12.094080925;
00199    fMin_1[2][3] = 0.545364260674;
00200    fMax_1[2][3] = 12.094080925;
00201 }

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

Definition at line 54 of file LEMbarpid.h.

Referenced by GetMvaValue().

00054 { return false; }

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

Definition at line 57 of file LEMbarpid.h.

Referenced by GetMvaValue().

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

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

Definition at line 224 of file LEMbarpid.cxx.

References Transform_1().

Referenced by GetMvaValue().

00225 {
00226    Transform_1( iv, sigOrBgd );
00227 }

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

Definition at line 204 of file LEMbarpid.cxx.

References fMax_1, and fMin_1.

Referenced by Transform().

00205 {
00206 if (cls < 0 || cls > 2) {
00207    if (2 > 1 ) cls = 2;
00208    else cls = 2;
00209 }
00210    for (int ivar=0;ivar<4;ivar++) {
00211       double offset = fMin_1[cls][ivar];
00212       double scale  = 1.0/(fMax_1[cls][ivar]-fMin_1[cls][ivar]);
00213       iv[ivar] = (iv[ivar]-offset)*scale * 2 - 1;
00214    }
00215 }


Member Data Documentation

const char* LEMbarpid::fClassName [private]

Definition at line 47 of file LEMbarpid.h.

int LEMbarpid::fLayers [private]

Definition at line 73 of file LEMbarpid.h.

Referenced by GetMvaValue__(), and Initialize().

int LEMbarpid::fLayerSize[3] [private]

Definition at line 74 of file LEMbarpid.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 40 of file LEMbarpid.h.

Referenced by InitTransform_1(), and Transform_1().

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

Definition at line 39 of file LEMbarpid.h.

Referenced by InitTransform_1(), and Transform_1().

char LEMbarpid::fType[4] [private]

Definition at line 63 of file LEMbarpid.h.

Referenced by GetType(), and LEMbarpid().

double LEMbarpid::fVmax[4] [private]

Definition at line 56 of file LEMbarpid.h.

Referenced by GetMvaValue(), and LEMbarpid().

double LEMbarpid::fVmin[4] [private]

Definition at line 55 of file LEMbarpid.h.

Referenced by GetMvaValue(), and LEMbarpid().

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

Definition at line 75 of file LEMbarpid.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 76 of file LEMbarpid.h.

Referenced by GetMvaValue__(), and Initialize().

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

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