LEMNNbarpid Class Reference

#include <LEMNNbarpid.h>

List of all members.

Public Member Functions

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


Constructor & Destructor Documentation

LEMNNbarpid::LEMNNbarpid (  ) 

Definition at line 5 of file LEMNNbarpid.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.999999940395355;
00011       fVmin[1] = -1;
00012       fVmax[1] = 0.99999988079071;
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 }

LEMNNbarpid::~LEMNNbarpid (  )  [inline]

Definition at line 19 of file LEMNNbarpid.h.

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


Member Function Documentation

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

Definition at line 133 of file LEMNNbarpid.cxx.

Referenced by GetMvaValue__().

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

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

Definition at line 139 of file LEMNNbarpid.cxx.

00140 {
00141    // nothing to clear
00142 }

Double_t LEMNNbarpid::GetLEMNNbarpid ( NueAnaReader nueana  ) 

Definition at line 278 of file LEMNNbarpid.cxx.

References GetLEMNNbarpid(), and NueAnaReader::nuerecord.

00278                                                         {
00279 
00280   Double_t lemnnbarpid=-1;
00281   lemnnbarpid = GetLEMNNbarpid(nueana->nuerecord);
00282   return lemnnbarpid;
00283 
00284 }

Double_t LEMNNbarpid::GetLEMNNbarpid ( NueRecord nr  ) 

Definition at line 235 of file LEMNNbarpid.cxx.

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

Referenced by MCNNFiller::FillMCNN(), and GetLEMNNbarpid().

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

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

Definition at line 143 of file LEMNNbarpid.cxx.

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

Referenced by GetLEMNNbarpid().

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

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

Definition at line 97 of file LEMNNbarpid.cxx.

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

Referenced by GetMvaValue().

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

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

Definition at line 49 of file LEMNNbarpid.h.

References fType.

00049 { return fType[ivar]; }

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

Definition at line 31 of file LEMNNbarpid.cxx.

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

Referenced by LEMNNbarpid().

00032 {
00033   // build network structure
00034    fLayers = 3;
00035    fLayerSize[0] = 5; fWeights[0] = new double[5]; 
00036    fLayerSize[1] = 10; fWeights[1] = new double[10]; 
00037    fLayerSize[2] = 1; fWeights[2] = new double[1]; 
00038    // weight matrix from layer 0 to 1
00039    fWeightMatrix0to1[0][0] = -0.309713012422979;
00040    fWeightMatrix0to1[1][0] = -0.12173529140793;
00041    fWeightMatrix0to1[2][0] = -1.10620080358271;
00042    fWeightMatrix0to1[3][0] = 0.316693220282754;
00043    fWeightMatrix0to1[4][0] = -0.822139419463919;
00044    fWeightMatrix0to1[5][0] = -0.107919966220658;
00045    fWeightMatrix0to1[6][0] = 0.00737121886581513;
00046    fWeightMatrix0to1[7][0] = 0.331257695226745;
00047    fWeightMatrix0to1[8][0] = -0.235016688239884;
00048    fWeightMatrix0to1[0][1] = -3.10071083903785;
00049    fWeightMatrix0to1[1][1] = -0.0125816513013949;
00050    fWeightMatrix0to1[2][1] = -0.734124627255442;
00051    fWeightMatrix0to1[3][1] = 0.0726494873917826;
00052    fWeightMatrix0to1[4][1] = -2.9919445533011;
00053    fWeightMatrix0to1[5][1] = -0.00802240166475014;
00054    fWeightMatrix0to1[6][1] = 0.0647628327739011;
00055    fWeightMatrix0to1[7][1] = 0.0418374499675276;
00056    fWeightMatrix0to1[8][1] = 0.801492410958803;
00057    fWeightMatrix0to1[0][2] = -2.07696263502003;
00058    fWeightMatrix0to1[1][2] = -0.108052181627273;
00059    fWeightMatrix0to1[2][2] = 1.18690290721643;
00060    fWeightMatrix0to1[3][2] = 0.105974926675172;
00061    fWeightMatrix0to1[4][2] = -2.21306851659592;
00062    fWeightMatrix0to1[5][2] = -0.0811776303072667;
00063    fWeightMatrix0to1[6][2] = -0.0717499798285308;
00064    fWeightMatrix0to1[7][2] = 1.79145154488678;
00065    fWeightMatrix0to1[8][2] = -2.10024659000459;
00066    fWeightMatrix0to1[0][3] = 1.68513938194524;
00067    fWeightMatrix0to1[1][3] = 0.415693384976188;
00068    fWeightMatrix0to1[2][3] = -3.69442148872509;
00069    fWeightMatrix0to1[3][3] = -0.486964844732677;
00070    fWeightMatrix0to1[4][3] = -0.845716843097758;
00071    fWeightMatrix0to1[5][3] = 0.404034073184459;
00072    fWeightMatrix0to1[6][3] = -0.273909925313189;
00073    fWeightMatrix0to1[7][3] = -0.868616806953467;
00074    fWeightMatrix0to1[8][3] = 0.211570197822128;
00075    fWeightMatrix0to1[0][4] = 3.33518595004659;
00076    fWeightMatrix0to1[1][4] = 0.252688594358065;
00077    fWeightMatrix0to1[2][4] = -2.38198482387374;
00078    fWeightMatrix0to1[3][4] = -0.454727359772679;
00079    fWeightMatrix0to1[4][4] = 4.34232135994576;
00080    fWeightMatrix0to1[5][4] = 0.235631055641848;
00081    fWeightMatrix0to1[6][4] = -0.144142728267817;
00082    fWeightMatrix0to1[7][4] = 0.163349462671524;
00083    fWeightMatrix0to1[8][4] = -0.428679656804317;
00084    // weight matrix from layer 1 to 2
00085    fWeightMatrix1to2[0][0] = -0.599650931060965;
00086    fWeightMatrix1to2[0][1] = 0.120386628410008;
00087    fWeightMatrix1to2[0][2] = 0.25313127989733;
00088    fWeightMatrix1to2[0][3] = -0.232026636469371;
00089    fWeightMatrix1to2[0][4] = -0.598184790728002;
00090    fWeightMatrix1to2[0][5] = 0.121120340537825;
00091    fWeightMatrix1to2[0][6] = -0.158133097321659;
00092    fWeightMatrix1to2[0][7] = 0.641164228316898;
00093    fWeightMatrix1to2[0][8] = 0.498703249292034;
00094    fWeightMatrix1to2[0][9] = 0.427912539593404;
00095 }

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

Definition at line 221 of file LEMNNbarpid.cxx.

References InitTransform_1().

Referenced by LEMNNbarpid().

00222 {
00223    InitTransform_1();
00224 }

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

Definition at line 178 of file LEMNNbarpid.cxx.

References fMax_1, and fMin_1.

Referenced by InitTransform().

00179 {
00180    fMin_1[0][0] = 0.0215759966522;
00181    fMax_1[0][0] = 0.961885452271;
00182    fMin_1[1][0] = 0.0215759966522;
00183    fMax_1[1][0] = 0.997713088989;
00184    fMin_1[2][0] = 0.0215759966522;
00185    fMax_1[2][0] = 0.997713088989;
00186    fMin_1[0][1] = 0.0530573539436;
00187    fMax_1[0][1] = 0.960177123547;
00188    fMin_1[1][1] = 0.0318561121821;
00189    fMax_1[1][1] = 1;
00190    fMin_1[2][1] = 0.0318561121821;
00191    fMax_1[2][1] = 1;
00192    fMin_1[0][2] = 0.019999999553;
00193    fMax_1[0][2] = 1;
00194    fMin_1[1][2] = 0.019999999553;
00195    fMax_1[1][2] = 1;
00196    fMin_1[2][2] = 0.019999999553;
00197    fMax_1[2][2] = 1;
00198    fMin_1[0][3] = 0.547159016132;
00199    fMax_1[0][3] = 12.0939331055;
00200    fMin_1[1][3] = 0.545364260674;
00201    fMax_1[1][3] = 12.094080925;
00202    fMin_1[2][3] = 0.545364260674;
00203    fMax_1[2][3] = 12.094080925;
00204 }

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

Definition at line 54 of file LEMNNbarpid.h.

Referenced by GetMvaValue().

00054 { return false; }

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

Definition at line 57 of file LEMNNbarpid.h.

Referenced by GetMvaValue().

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

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

Definition at line 227 of file LEMNNbarpid.cxx.

References Transform_1().

Referenced by GetMvaValue().

00228 {
00229    Transform_1( iv, sigOrBgd );
00230 }

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

Definition at line 207 of file LEMNNbarpid.cxx.

References fMax_1, and fMin_1.

Referenced by Transform().

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


Member Data Documentation

const char* LEMNNbarpid::fClassName [private]

Definition at line 47 of file LEMNNbarpid.h.

int LEMNNbarpid::fLayers [private]

Definition at line 73 of file LEMNNbarpid.h.

Referenced by GetMvaValue__(), and Initialize().

int LEMNNbarpid::fLayerSize[3] [private]

Definition at line 74 of file LEMNNbarpid.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 40 of file LEMNNbarpid.h.

Referenced by InitTransform_1(), and Transform_1().

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

Definition at line 39 of file LEMNNbarpid.h.

Referenced by InitTransform_1(), and Transform_1().

char LEMNNbarpid::fType[4] [private]

Definition at line 63 of file LEMNNbarpid.h.

Referenced by GetType(), and LEMNNbarpid().

double LEMNNbarpid::fVmax[4] [private]

Definition at line 56 of file LEMNNbarpid.h.

Referenced by GetMvaValue(), and LEMNNbarpid().

double LEMNNbarpid::fVmin[4] [private]

Definition at line 55 of file LEMNNbarpid.h.

Referenced by GetMvaValue(), and LEMNNbarpid().

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

Definition at line 75 of file LEMNNbarpid.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 76 of file LEMNNbarpid.h.

Referenced by GetMvaValue__(), and Initialize().

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

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