LEMAmbyE50S491 Class Reference

#include <LEMAmbyE50S491.h>

List of all members.

Public Member Functions

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


Constructor & Destructor Documentation

LEMAmbyE50S491::LEMAmbyE50S491 (  ) 

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

LEMAmbyE50S491::~LEMAmbyE50S491 (  )  [inline]

Definition at line 19 of file LEMAmbyE50S491.h.

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


Member Function Documentation

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

Definition at line 135 of file LEMAmbyE50S491.cxx.

Referenced by GetMvaValue__().

00135                                                    {
00136    // hyperbolic tan
00137    return tanh(x);
00138 }

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

Definition at line 143 of file LEMAmbyE50S491.cxx.

00144 {
00145    // nothing to clear
00146 }

Double_t LEMAmbyE50S491::GetLEMAmbyE50S491 ( NueAnaReader nueana  ) 

Definition at line 301 of file LEMAmbyE50S491.cxx.

References GetLEMAmbyE50S491(), and NueAnaReader::nuerecord.

00301                                                               {
00302 
00303   Double_t lemAmby=-1;
00304   lemAmby = GetLEMAmbyE50S491(nueana->nuerecord);
00305   return lemAmby;
00306 
00307 }

Double_t LEMAmbyE50S491::GetLEMAmbyE50S491 ( NueRecord nr  ) 

Definition at line 246 of file LEMAmbyE50S491.cxx.

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

Referenced by GetLEMAmbyE50S491(), NueStandard::GetPIDValue(), and NueStandard::SetE50PID().

00246                                                        {
00247 
00248   //LEM4 PID value
00249   Double_t lemAmby=-1;
00250 
00251   //Input variables
00252   Double_t val_mny=-1;
00253   Double_t val_mfqm=-1;
00254   Double_t val_fcc=-1;
00255   Double_t val_recoe=-1;
00256 
00257   //Define the variables (y_cut = 1.0 = no y cut)
00258   val_mny = LEMStandard::Getymean(nr,1.0);
00259   val_mfqm = LEMStandard::GetMeanFracQMatched(nr,1.0);
00260   val_fcc = LEMStandard::GetfracCCy(nr,1.0);
00261   val_recoe = nr->srevent.phNueGeV;
00262 
00263   //Preselection: return automatic -1 for out of range events.
00264   if (val_mny<0||val_mfqm<0||val_fcc<0||val_recoe<0) {
00265     lemAmby=-1;
00266   } else {
00267     //Define an input vector with the cariable names.
00268     std::vector<double> inputVec( 4 );
00269 
00270     inputVec[0]=val_mny;
00271     inputVec[1]=val_mfqm;
00272     inputVec[2]=val_fcc;
00273     inputVec[3]=val_recoe;
00274       
00275     //Calculate the LEM discriminant!
00276    lemAmby = LEMAmbyE50S491::GetMvaValue(inputVec);
00277 
00278   
00279   //Transform so that the PID value is between 0.0 to 1.0.
00280   //A1Testrun showed spread from -0.10 to 1.13
00281   //A2lemAmby = (lemAmby + 0.029)/1.170;
00282   //A3lemAmby -0.071 -- 1.134
00283   //A5(A3_9) -0.0598634--1.13229
00284   //E50S491 -0.0571659--1.05873
00285 
00286    Double_t lowval=-0.0571659;
00287    Double_t highval=1.05873;
00288    Double_t midpoint=(lowval+highval)/2.0;
00289    Double_t denom=(highval-lowval)*1.001; //1.022;
00290    //lemAmby = (( lemAmby - midpoint) / denom) + 0.5;
00291    lemAmby = (( lemAmby - lowval ) / denom); 
00292 
00293 
00294   }
00295   //return the PID:
00296   return lemAmby;
00297 
00298 }

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

Definition at line 147 of file LEMAmbyE50S491.cxx.

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

Referenced by GetLEMAmbyE50S491().

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

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

Definition at line 100 of file LEMAmbyE50S491.cxx.

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

Referenced by GetMvaValue().

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

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

Definition at line 49 of file LEMAmbyE50S491.h.

References fType.

00049 { return fType[ivar]; }

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

Definition at line 32 of file LEMAmbyE50S491.cxx.

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

Referenced by LEMAmbyE50S491().

00033 {
00034    
00035    // build network structure
00036    fLayers = 3;
00037    fLayerSize[0] = 5; fWeights[0] = new double[5]; 
00038    fLayerSize[1] = 10; fWeights[1] = new double[10]; 
00039    fLayerSize[2] = 1; fWeights[2] = new double[1]; 
00040    // weight matrix from layer 0 to 1
00041    fWeightMatrix0to1[0][0] = -0.152318321120594;
00042    fWeightMatrix0to1[1][0] = 0.140038941840388;
00043    fWeightMatrix0to1[2][0] = 0.150830788727814;
00044    fWeightMatrix0to1[3][0] = -0.152255144703905;
00045    fWeightMatrix0to1[4][0] = 0.137836159069207;
00046    fWeightMatrix0to1[5][0] = -0.121184535878213;
00047    fWeightMatrix0to1[6][0] = 0.139033891203744;
00048    fWeightMatrix0to1[7][0] = -0.108956700708734;
00049    fWeightMatrix0to1[8][0] = 0.349134725553892;
00050    fWeightMatrix0to1[0][1] = 0.205967629818834;
00051    fWeightMatrix0to1[1][1] = -0.134852396728545;
00052    fWeightMatrix0to1[2][1] = -0.178592543312265;
00053    fWeightMatrix0to1[3][1] = 0.186278178092904;
00054    fWeightMatrix0to1[4][1] = -0.125205805564187;
00055    fWeightMatrix0to1[5][1] = 0.16269157723916;
00056    fWeightMatrix0to1[6][1] = -0.130902963928656;
00057    fWeightMatrix0to1[7][1] = 0.552392965698308;
00058    fWeightMatrix0to1[8][1] = 2.00605701594573;
00059    fWeightMatrix0to1[0][2] = -0.351796753103481;
00060    fWeightMatrix0to1[1][2] = 0.119495150480259;
00061    fWeightMatrix0to1[2][2] = 0.234526141140616;
00062    fWeightMatrix0to1[3][2] = -0.259501720569135;
00063    fWeightMatrix0to1[4][2] = 0.0971029232485688;
00064    fWeightMatrix0to1[5][2] = -0.311255332162166;
00065    fWeightMatrix0to1[6][2] = 0.110460663357879;
00066    fWeightMatrix0to1[7][2] = -1.42763468116269;
00067    fWeightMatrix0to1[8][2] = 0.962545781664626;
00068    fWeightMatrix0to1[0][3] = 0.118397441928664;
00069    fWeightMatrix0to1[1][3] = -0.0814482182643213;
00070    fWeightMatrix0to1[2][3] = -0.11415203218872;
00071    fWeightMatrix0to1[3][3] = 0.119649439353558;
00072    fWeightMatrix0to1[4][3] = -0.0734675726864178;
00073    fWeightMatrix0to1[5][3] = 0.0952023767112997;
00074    fWeightMatrix0to1[6][3] = -0.0783740766209056;
00075    fWeightMatrix0to1[7][3] = 0.347262763001096;
00076    fWeightMatrix0to1[8][3] = -0.270506518649011;
00077    fWeightMatrix0to1[0][4] = -0.0842070177217706;
00078    fWeightMatrix0to1[1][4] = 0.0156252738586454;
00079    fWeightMatrix0to1[2][4] = 0.0481085654335284;
00080    fWeightMatrix0to1[3][4] = -0.0567634251254012;
00081    fWeightMatrix0to1[4][4] = 0.010838022295969;
00082    fWeightMatrix0to1[5][4] = -0.0359937871007552;
00083    fWeightMatrix0to1[6][4] = 0.0136216961169865;
00084    fWeightMatrix0to1[7][4] = -1.81344309339823;
00085    fWeightMatrix0to1[8][4] = -2.01702270861376;
00086    // weight matrix from layer 1 to 2
00087    fWeightMatrix1to2[0][0] = 0.11386357600865;
00088    fWeightMatrix1to2[0][1] = -0.0654124264943447;
00089    fWeightMatrix1to2[0][2] = -0.0759398815499141;
00090    fWeightMatrix1to2[0][3] = 0.0835250008640337;
00091    fWeightMatrix1to2[0][4] = -0.0682978470479161;
00092    fWeightMatrix1to2[0][5] = 0.0451858425686448;
00093    fWeightMatrix1to2[0][6] = -0.0663313873242806;
00094    fWeightMatrix1to2[0][7] = -0.446499096504961;
00095    fWeightMatrix1to2[0][8] = 0.58210274049323;
00096    fWeightMatrix1to2[0][9] = 0.302181334928035;
00097 
00098 }//L4Init

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

Definition at line 230 of file LEMAmbyE50S491.cxx.

References InitTransform_1().

Referenced by LEMAmbyE50S491().

00231 {
00232    InitTransform_1();
00233 }

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

Definition at line 184 of file LEMAmbyE50S491.cxx.

References fMax_1, and fMin_1.

Referenced by InitTransform().

00185 {
00186 
00187    // Normalization transformation, initialisation
00188    fMin_1[0][0] = 0.0228846855462;
00189    fMax_1[0][0] = 0.98898011446;
00190    fMin_1[1][0] = 0.00716135371476;
00191    fMax_1[1][0] = 0.998298585415;
00192    fMin_1[2][0] = 0.00716135371476;
00193    fMax_1[2][0] = 0.998298585415;
00194    fMin_1[0][1] = 0.0475189238787;
00195    fMax_1[0][1] = 1;
00196    fMin_1[1][1] = 0;
00197    fMax_1[1][1] = 1;
00198    fMin_1[2][1] = 0;
00199    fMax_1[2][1] = 1;
00200    fMin_1[0][2] = 0.019999999553;
00201    fMax_1[0][2] = 0.980000019073;
00202    fMin_1[1][2] = 0.019999999553;
00203    fMax_1[1][2] = 0.980000019073;
00204    fMin_1[2][2] = 0.019999999553;
00205    fMax_1[2][2] = 0.980000019073;
00206    fMin_1[0][3] = 0.665335953236;
00207    fMax_1[0][3] = 15.999958992;
00208    fMin_1[1][3] = 0.632570564747;
00209    fMax_1[1][3] = 15.9997463226;
00210    fMin_1[2][3] = 0.632570564747;
00211    fMax_1[2][3] = 15.999958992;
00212 
00213 }

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

Definition at line 54 of file LEMAmbyE50S491.h.

Referenced by GetMvaValue().

00054 { return false; }

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

Definition at line 57 of file LEMAmbyE50S491.h.

Referenced by GetMvaValue().

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

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

Definition at line 236 of file LEMAmbyE50S491.cxx.

References Transform_1().

Referenced by GetMvaValue().

00237 {
00238    Transform_1( iv, sigOrBgd );
00239 }

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

Definition at line 216 of file LEMAmbyE50S491.cxx.

References fMax_1, and fMin_1.

Referenced by Transform().

00217 {
00218 if (cls < 0 || cls > 2) {
00219    if (2 > 1 ) cls = 2;
00220    else cls = 2;
00221 }
00222    for (int ivar=0;ivar<4;ivar++) {
00223       double offset = fMin_1[cls][ivar];
00224       double scale  = 1.0/(fMax_1[cls][ivar]-fMin_1[cls][ivar]);
00225       iv[ivar] = (iv[ivar]-offset)*scale * 2 - 1;
00226    }
00227 }


Member Data Documentation

const char* LEMAmbyE50S491::fClassName [private]

Definition at line 47 of file LEMAmbyE50S491.h.

int LEMAmbyE50S491::fLayers [private]

Definition at line 73 of file LEMAmbyE50S491.h.

Referenced by GetMvaValue__(), and Initialize().

int LEMAmbyE50S491::fLayerSize[3] [private]

Definition at line 74 of file LEMAmbyE50S491.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 40 of file LEMAmbyE50S491.h.

Referenced by InitTransform_1(), and Transform_1().

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

Definition at line 39 of file LEMAmbyE50S491.h.

Referenced by InitTransform_1(), and Transform_1().

char LEMAmbyE50S491::fType[4] [private]

Definition at line 63 of file LEMAmbyE50S491.h.

Referenced by GetType(), and LEMAmbyE50S491().

double LEMAmbyE50S491::fVmax[4] [private]

Definition at line 56 of file LEMAmbyE50S491.h.

Referenced by GetMvaValue(), and LEMAmbyE50S491().

double LEMAmbyE50S491::fVmin[4] [private]

Definition at line 55 of file LEMAmbyE50S491.h.

Referenced by GetMvaValue(), and LEMAmbyE50S491().

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

Definition at line 75 of file LEMAmbyE50S491.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 76 of file LEMAmbyE50S491.h.

Referenced by GetMvaValue__(), and Initialize().

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

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