LEMAmbyE50S6111 Class Reference

#include <LEMAmbyE50S6111.h>

List of all members.

Public Member Functions

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


Constructor & Destructor Documentation

LEMAmbyE50S6111::LEMAmbyE50S6111 (  ) 

Definition at line 5 of file LEMAmbyE50S6111.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       fVmin[4] = -1;
00018       fVmax[4] = 1;
00019       fVmin[5] = -1;
00020       fVmax[5] = 0.999999940395355;
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 }//LEMAmbyE50S6111

LEMAmbyE50S6111::~LEMAmbyE50S6111 (  )  [inline]

Definition at line 19 of file LEMAmbyE50S6111.h.

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


Member Function Documentation

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

Definition at line 174 of file LEMAmbyE50S6111.cxx.

Referenced by GetMvaValue__().

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

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

Definition at line 182 of file LEMAmbyE50S6111.cxx.

00183 {
00184    // nothing to clear
00185 }

Double_t LEMAmbyE50S6111::GetLEMAmbyE50S6111 ( NueAnaReader nueana  ) 

Definition at line 357 of file LEMAmbyE50S6111.cxx.

References GetLEMAmbyE50S6111(), and NueAnaReader::nuerecord.

00357                                                                 {
00358 
00359   Double_t lemAmby=-1;
00360   lemAmby = GetLEMAmbyE50S6111(nueana->nuerecord);
00361   return lemAmby;
00362 
00363 }

Double_t LEMAmbyE50S6111::GetLEMAmbyE50S6111 ( NueRecord nr  ) 

Definition at line 296 of file LEMAmbyE50S6111.cxx.

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

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

00296                                                          {
00297 
00298   //LEM4 PID value
00299   Double_t lemAmby=-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     lemAmby=-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    lemAmby = LEMAmbyE50S6111::GetMvaValue(inputVec);
00333 
00334   
00335   //Transform so that the PID value is between 0.0 to 1.0.
00336   //A1Testrun showed spread from -0.10 to 1.13
00337   //A2lemAmby = (lemAmby + 0.029)/1.170;
00338   //A3lemAmby -0.071 -- 1.134
00339   //A5(A3_9) -0.0598634--1.13229
00340   //E50S6111 -0.193389--1.21563
00341 
00342    Double_t lowval=-0.193389;
00343    Double_t highval=1.21563;
00344    Double_t midpoint=(lowval+highval)/2.0;
00345    Double_t denom=(highval-lowval)*1.001; //prev 1.022mod
00346    //lemAmby = (( lemAmby - midpoint) / denom) + 0.5;
00347    lemAmby = (( lemAmby - lowval ) / denom); 
00348   
00349 
00350   }
00351   //return the PID:
00352   return lemAmby;
00353 
00354 }

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

Definition at line 186 of file LEMAmbyE50S6111.cxx.

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

Referenced by GetLEMAmbyE50S6111().

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

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

Definition at line 49 of file LEMAmbyE50S6111.h.

References fType.

00049 { return fType[ivar]; }

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

Definition at line 38 of file LEMAmbyE50S6111.cxx.

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

Referenced by LEMAmbyE50S6111().

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.083121590015731;
00047    fWeightMatrix0to1[1][0] = -0.0694457612269468;
00048    fWeightMatrix0to1[2][0] = 0.685637009440163;
00049    fWeightMatrix0to1[3][0] = 0.342671733353603;
00050    fWeightMatrix0to1[4][0] = -0.119603330022932;
00051    fWeightMatrix0to1[5][0] = -0.115201585853233;
00052    fWeightMatrix0to1[6][0] = -1.1875661314965;
00053    fWeightMatrix0to1[7][0] = 1.00710082440743;
00054    fWeightMatrix0to1[8][0] = 0.372779268529842;
00055    fWeightMatrix0to1[9][0] = -0.0762001480626949;
00056    fWeightMatrix0to1[10][0] = 0.196339172274784;
00057    fWeightMatrix0to1[0][1] = -0.0495130331903871;
00058    fWeightMatrix0to1[1][1] = 0.0512663624798177;
00059    fWeightMatrix0to1[2][1] = -3.34571175600414;
00060    fWeightMatrix0to1[3][1] = -0.141702240183657;
00061    fWeightMatrix0to1[4][1] = 0.132330620311934;
00062    fWeightMatrix0to1[5][1] = -0.334964467630249;
00063    fWeightMatrix0to1[6][1] = -0.0739458217441201;
00064    fWeightMatrix0to1[7][1] = -0.0222287943845477;
00065    fWeightMatrix0to1[8][1] = -0.139663395346911;
00066    fWeightMatrix0to1[9][1] = -1.56755366895971;
00067    fWeightMatrix0to1[10][1] = -0.0696921162893565;
00068    fWeightMatrix0to1[0][2] = 0.00791074433997016;
00069    fWeightMatrix0to1[1][2] = -0.00182562210424479;
00070    fWeightMatrix0to1[2][2] = -1.3233035244087;
00071    fWeightMatrix0to1[3][2] = -0.191818762006844;
00072    fWeightMatrix0to1[4][2] = 0.0296200113283813;
00073    fWeightMatrix0to1[5][2] = 0.625038248657348;
00074    fWeightMatrix0to1[6][2] = 0.212756242224463;
00075    fWeightMatrix0to1[7][2] = 0.33267195738308;
00076    fWeightMatrix0to1[8][2] = 0.170468096104995;
00077    fWeightMatrix0to1[9][2] = -1.47866641430129;
00078    fWeightMatrix0to1[10][2] = 0.0624704684624715;
00079    fWeightMatrix0to1[0][3] = 0.0720973247436447;
00080    fWeightMatrix0to1[1][3] = -0.0375296663916766;
00081    fWeightMatrix0to1[2][3] = 0.238209307712342;
00082    fWeightMatrix0to1[3][3] = -0.602326855751943;
00083    fWeightMatrix0to1[4][3] = 0.34039623116343;
00084    fWeightMatrix0to1[5][3] = 0.906491746204339;
00085    fWeightMatrix0to1[6][3] = -0.179708450627512;
00086    fWeightMatrix0to1[7][3] = 0.116246050315267;
00087    fWeightMatrix0to1[8][3] = 0.327587481449303;
00088    fWeightMatrix0to1[9][3] = 0.79243306253268;
00089    fWeightMatrix0to1[10][3] = 0.19864783111865;
00090    fWeightMatrix0to1[0][4] = 0.200038581784406;
00091    fWeightMatrix0to1[1][4] = -0.191408792798715;
00092    fWeightMatrix0to1[2][4] = -0.70752149848274;
00093    fWeightMatrix0to1[3][4] = -0.0897907765711268;
00094    fWeightMatrix0to1[4][4] = 0.277608726763573;
00095    fWeightMatrix0to1[5][4] = 0.426299581726032;
00096    fWeightMatrix0to1[6][4] = 0.376488411775727;
00097    fWeightMatrix0to1[7][4] = -0.321024456100442;
00098    fWeightMatrix0to1[8][4] = -0.0826538142891127;
00099    fWeightMatrix0to1[9][4] = 0.704339960452973;
00100    fWeightMatrix0to1[10][4] = 0.184744249691757;
00101    fWeightMatrix0to1[0][5] = 0.0645180100965935;
00102    fWeightMatrix0to1[1][5] = -0.0634010313120446;
00103    fWeightMatrix0to1[2][5] = 0.48261703569048;
00104    fWeightMatrix0to1[3][5] = 0.563153736674491;
00105    fWeightMatrix0to1[4][5] = -0.0245483190006208;
00106    fWeightMatrix0to1[5][5] = -0.693368349090623;
00107    fWeightMatrix0to1[6][5] = -0.0153854166776991;
00108    fWeightMatrix0to1[7][5] = 0.0708173225172613;
00109    fWeightMatrix0to1[8][5] = -0.422179616068662;
00110    fWeightMatrix0to1[9][5] = -0.510708733476035;
00111    fWeightMatrix0to1[10][5] = 0.0281121865074263;
00112    fWeightMatrix0to1[0][6] = -0.036025183436302;
00113    fWeightMatrix0to1[1][6] = 0.0444156172762133;
00114    fWeightMatrix0to1[2][6] = 4.41936386369922;
00115    fWeightMatrix0to1[3][6] = 0.200924321310566;
00116    fWeightMatrix0to1[4][6] = -0.118537429269469;
00117    fWeightMatrix0to1[5][6] = 0.624039141173744;
00118    fWeightMatrix0to1[6][6] = 0.401375697307283;
00119    fWeightMatrix0to1[7][6] = 0.127251790931036;
00120    fWeightMatrix0to1[8][6] = 0.123872643578347;
00121    fWeightMatrix0to1[9][6] = 2.03177128125334;
00122    fWeightMatrix0to1[10][6] = 0.0190922903321442;
00123    // weight matrix from layer 1 to 2
00124    fWeightMatrix1to2[0][0] = 0.107123038119557;
00125    fWeightMatrix1to2[0][1] = -0.0833851802034414;
00126    fWeightMatrix1to2[0][2] = -0.283968486492741;
00127    fWeightMatrix1to2[0][3] = -0.353733064910912;
00128    fWeightMatrix1to2[0][4] = 0.316367635541481;
00129    fWeightMatrix1to2[0][5] = -0.479112257406579;
00130    fWeightMatrix1to2[0][6] = 0.487996811064229;
00131    fWeightMatrix1to2[0][7] = 0.473760916102641;
00132    fWeightMatrix1to2[0][8] = 0.272379371082346;
00133    fWeightMatrix1to2[0][9] = -0.312474153491213;
00134    fWeightMatrix1to2[0][10] = 0.176459768481484;
00135    fWeightMatrix1to2[0][11] = 0.807250610604085;
00136 
00137 }//L4Init

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

Definition at line 280 of file LEMAmbyE50S6111.cxx.

References InitTransform_1().

Referenced by LEMAmbyE50S6111().

00281 {
00282    InitTransform_1();
00283 }

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

Definition at line 222 of file LEMAmbyE50S6111.cxx.

References fMax_1, and fMin_1.

Referenced by InitTransform().

00223 {
00224 
00225    // Normalization transformation, initialisation
00226    fMin_1[0][0] = 0.0228846855462;
00227    fMax_1[0][0] = 0.98898011446;
00228    fMin_1[1][0] = 0.00716135371476;
00229    fMax_1[1][0] = 0.998298585415;
00230    fMin_1[2][0] = 0.00716135371476;
00231    fMax_1[2][0] = 0.998298585415;
00232    fMin_1[0][1] = 0.0475189238787;
00233    fMax_1[0][1] = 1;
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.665335953236;
00245    fMax_1[0][3] = 15.999958992;
00246    fMin_1[1][3] = 0.632570564747;
00247    fMax_1[1][3] = 15.9997463226;
00248    fMin_1[2][3] = 0.632570564747;
00249    fMax_1[2][3] = 15.999958992;
00250    fMin_1[0][4] = 0;
00251    fMax_1[0][4] = 0.998935520649;
00252    fMin_1[1][4] = 0;
00253    fMax_1[1][4] = 0.997940421104;
00254    fMin_1[2][4] = 0;
00255    fMax_1[2][4] = 0.998935520649;
00256    fMin_1[0][5] = 0.0351097136736;
00257    fMax_1[0][5] = 0.987394332886;
00258    fMin_1[1][5] = 0;
00259    fMax_1[1][5] = 0.991289019585;
00260    fMin_1[2][5] = 0;
00261    fMax_1[2][5] = 0.991289019585;
00262 
00263 }

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

Definition at line 54 of file LEMAmbyE50S6111.h.

Referenced by GetMvaValue().

00054 { return false; }

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

Definition at line 57 of file LEMAmbyE50S6111.h.

Referenced by GetMvaValue().

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

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

Definition at line 286 of file LEMAmbyE50S6111.cxx.

References Transform_1().

Referenced by GetMvaValue().

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

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

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

Definition at line 47 of file LEMAmbyE50S6111.h.

int LEMAmbyE50S6111::fLayers [private]

Definition at line 73 of file LEMAmbyE50S6111.h.

Referenced by GetMvaValue__(), and Initialize().

int LEMAmbyE50S6111::fLayerSize[3] [private]

Definition at line 74 of file LEMAmbyE50S6111.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 40 of file LEMAmbyE50S6111.h.

Referenced by InitTransform_1(), and Transform_1().

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

Definition at line 39 of file LEMAmbyE50S6111.h.

Referenced by InitTransform_1(), and Transform_1().

char LEMAmbyE50S6111::fType[6] [private]

Definition at line 63 of file LEMAmbyE50S6111.h.

Referenced by GetType(), and LEMAmbyE50S6111().

double LEMAmbyE50S6111::fVmax[6] [private]

Definition at line 56 of file LEMAmbyE50S6111.h.

Referenced by GetMvaValue(), and LEMAmbyE50S6111().

double LEMAmbyE50S6111::fVmin[6] [private]

Definition at line 55 of file LEMAmbyE50S6111.h.

Referenced by GetMvaValue(), and LEMAmbyE50S6111().

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

Definition at line 75 of file LEMAmbyE50S6111.h.

Referenced by GetMvaValue__(), and Initialize().

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

Definition at line 76 of file LEMAmbyE50S6111.h.

Referenced by GetMvaValue__(), and Initialize().

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

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