SPIDAlg.cxx
Go to the documentation of this file.
1 /*
2  * File: SPIDAlg.cxx
3  * Author: smith
4  *
5  * Created on November 14, 2013, 12:00 PM
6  */
7 
8 
9 
10 #include "ShowerLID/SPIDAlg.h"
12 #include <cmath>
13 
14 namespace slid {
15 
17  NuEEnergyAlg* fNuEEnergyAlgIn,
18  int pidType) :
19  fNuEEnergyAlg(fNuEEnergyAlgIn),
20  fPIDType(pidType),
21  fMlp(0),
22  fReader(0) {
23  //
24  // read and set FCL parameters
25  //
26  fLibPath = util::EnvExpansion(pset.get< std::string >("LibPath"));
27  fUseTMVATraining = pset.get< bool >("UseTMVATraining");
28 
29  mf::LogInfo("SPIDAlg") << " SPIDAlg::SPIDAlg() Alg = " << fAlgorithmName << "\n";
30 
31  Initialize();
32  }
33 
34  SPIDAlg::SPIDAlg(const SPIDAlg& orig)
35  {
36  }
37 
39  {
40  if (fReader) delete fReader;
41  if (fMlp) delete fMlp;
42  }
43 
44  // void SPIDAlg::reconfigure(const fhicl::ParameterSet& pset) {
45  // fLibPath = pset.get< std::string >("LibraryPath");
46  // }
47 
49  {
51  int detectorID = geom->DetId();
52  //
53  // TMVA MVA Methods
54  //
55  std::string weightfile0(fLibPath);
56  std::string weightfile2(fLibPath);
57  std::string weightfileEPi0(fLibPath);
58  std::string weightfileEPi0EL(fLibPath);
59  switch (detectorID) {
61  if (fUseTMVATraining){
62  weightfile0 += "TMVAClassification_" + fMVAMethod + ".weights_FD_elec.xml";
63  weightfile2 += "TMVAClassification_" + fMVAMethod + ".weights_FD_elec_withNue.xml";
64  }
65  else {
66  weightfile0 += "weights_shape_fd_elec.txt";
67  weightfile2 += "weights_shape_fd_elec_E.txt";
68  weightfileEPi0 += "weights_shape_fd_elec_E_epi0.txt";
69  weightfileEPi0EL += "weights_shape_fd_elec_E_epi0EL.txt";
70  }
71  break;
73  if (fUseTMVATraining){
74  weightfile0 += "TMVAClassification_" + fMVAMethod + ".weights_NDOS_elec.xml";
75  weightfile2 += "TMVAClassification_" + fMVAMethod + ".weights_NDOS_elec_withNue.xml";
76  }
77  else {
78  weightfile0 += "weights_shape_fd_elec.txt";
79  weightfile2 += "weights_shape_fd_elec_E.txt";
80  weightfileEPi0 += "weights_shape_fd_elec_E_epi0.txt";
81  weightfileEPi0EL += "weights_shape_fd_elec_E_epi0EL.txt";
82  }
83  break;
85  if (fUseTMVATraining){
86  weightfile0 += "TMVAClassification_" + fMVAMethod + ".weights_ND_elec.xml";
87  weightfile2 += "TMVAClassification_" + fMVAMethod + ".weights_ND_elec_withNue.xml";
88  }
89  else {
90  weightfile0 += "weights_shape_fd_elec.txt";
91  weightfile2 += "weights_shape_fd_elec_E.txt";
92  weightfileEPi0 += "weights_shape_fd_elec_E_epi0.txt";
93  weightfileEPi0EL += "weights_shape_fd_elec_E_epi0EL.txt";
94  }
95  break;
96  default:
97  throw cet::exception("BAD DETID") << __FILE__ << ":" << __LINE__
98  << " Bad detector id = " << detectorID;
99  }
100 
101 
102  //
103  // mode 0 training variable set (base, without reco nue energy)
104  //
105  if (fUseTMVATraining){
106  if (fPIDType==0) {// Without energy
107  std::cout << "Defining TMVA::Reader object for mode 0..." << std::endl;
108  fReader = new TMVA::Reader("!Color:!Silent");
109  std::cout << "Adding variables to Reader for mode 0..." << std::endl;
110  fReader->AddVariable("egLLL", &fShowerPID->fEGLLL);
111  fReader->AddVariable("egLLT", &fShowerPID->fEGLLT);
112  fReader->AddVariable("emuLLL", &fShowerPID->fEMuLLL);
113  fReader->AddVariable("emuLLT", &fShowerPID->fEMuLLT);
114  fReader->AddVariable("epi0LLL", &fShowerPID->fEPi0LLL);
115  fReader->AddVariable("epi0LLT", &fShowerPID->fEPi0LLT);
116  fReader->AddVariable("epLLL", &fShowerPID->fEPLLL);
117  fReader->AddVariable("epLLT", &fShowerPID->fEPLLT);
118  fReader->AddVariable("enLLL", &fShowerPID->fENLLL);
119  fReader->AddVariable("enLLT", &fShowerPID->fENLLT);
120  fReader->AddVariable("epiLLL", &fShowerPID->fEPiLLL);
121  fReader->AddVariable("epiLLT", &fShowerPID->fEPiLLT);
122  fReader->AddVariable("gap", &fShowerPID->fGap);
123  fReader->AddVariable("pi0mass", &fShowerPID->fPi0mass);
124  fReader->AddVariable("vtxgev", &fShowerPID->fVtxE);
125  fReader->AddVariable("shE", &fShowerPID->fShwEFrac);
126  fReader->AddSpectator("sbtype", &fType);
127  // Book the TMVA Algorithms
128  //
129  // Set the training weights file. **NOTE** due to a bug in TMVA model using weights from file
130  // does not work.
131  //
132  // fWeightsFile = fXMLPath + "TMVAClassification_KNN.weights.xml";
133  // Book Method
134  fReader->BookMVA((fMVAMethod + TString(" method")), weightfile0);
135  }
136  else if(fPIDType==1){// With energy
137  std::cout << "Defining TMVA::Reader object for mode 2..." << std::endl;
138  fReader = new TMVA::Reader("!Color:!Silent");
139  std::cout << "Adding variables to Reader for mode 2..." << std::endl;
140  fReader->AddVariable("egLLL", &(fShowerPID->fEGLLL));
141  fReader->AddVariable("egLLT", &(fShowerPID->fEGLLT));
142  fReader->AddVariable("emuLLL", &(fShowerPID->fEMuLLL));
143  fReader->AddVariable("emuLLT", &(fShowerPID->fEMuLLT));
144  fReader->AddVariable("epi0LLL", &(fShowerPID->fEPi0LLL));
145  fReader->AddVariable("epi0LLT", &(fShowerPID->fEPi0LLT));
146  fReader->AddVariable("epLLL", &(fShowerPID->fEPLLL));
147  fReader->AddVariable("epLLT", &(fShowerPID->fEPLLT));
148  fReader->AddVariable("enLLL", &(fShowerPID->fENLLL));
149  fReader->AddVariable("enLLT", &(fShowerPID->fENLLT));
150  fReader->AddVariable("epiLLL", &(fShowerPID->fEPiLLL));
151  fReader->AddVariable("epiLLT", &(fShowerPID->fEPiLLT));
152  fReader->AddVariable("gap", &(fShowerPID->fGap));
153  fReader->AddVariable("pi0mass", &(fShowerPID->fPi0mass));
154  fReader->AddVariable("vtxgev", &(fShowerPID->fVtxE));
155  fReader->AddVariable("shE", &(fShowerPID->fShwEFrac));
156  fReader->AddVariable("nueRecEnergy",&(fShowerPID->fNueEnergy));
157  fReader->AddSpectator("sbtype", &fType);
158  // Book the TMVA Algorithms
159  //
160  // Set the training weights file. **NOTE** due to a bug in TMVA model using weights from file
161  // does not work.
162  //
163  // fWeightsFile = fXMLPath + "TMVAClassification_KNN.weights.xml";
164  // Book Method
165  fReader->BookMVA((fMVAMethod + TString(" method")), weightfile2);
166  }
167  }
168  else{
169 
170  //NOTE the varialbe shE really means showerEnergy/SliceEnergy. I am not changing the name here because this is how it is listed in the training files.
171  //At some point the training should be updated so that this name makes more sense.
172 
173  double egLLL;
174  double egLLT;
175  double emuLLL;
176  double emuLLT;
177  double epi0LLL;
178  double epi0LLT;
179  double epLLL;
180  double epLLT;
181  double enLLL;
182  double enLLT;
183  double epiLLL;
184  double epiLLT;
185  double vtxgev;
186  double pi0mass;
187  double shE;
188  double nuE;
189  double gap;
190  double length;
191  double costheta;
192  double dedx0;
193  double dedx1;
194  double dedx2;
195  double dedx3;
196  int type;
197 
198  TTree *trainTree = new TTree("trainTree","m_trainTree");
199  trainTree->Branch("egLLL", &egLLL, "egLLL/D");
200  trainTree->Branch("egLLT", &egLLT, "egLLT/D");
201  trainTree->Branch("emuLLL", &emuLLL, "emuLLL/D");
202  trainTree->Branch("emuLLT", &emuLLT, "emuLLT/D");
203  trainTree->Branch("epi0LLL", &epi0LLL, "epi0LLL/D");
204  trainTree->Branch("epi0LLT", &epi0LLT, "epi0LLT/D");
205  trainTree->Branch("epLLL", &epLLL, "epLLL/D");
206  trainTree->Branch("epLLT", &epLLT, "epLLT/D");
207  trainTree->Branch("enLLL", &enLLL, "enLLL/D");
208  trainTree->Branch("enLLT", &enLLT, "enLLT/D");
209  trainTree->Branch("epiLLL", &epiLLL, "epiLLL/D");
210  trainTree->Branch("epiLLT", &epiLLT, "epiLLT/D");
211  trainTree->Branch("gap", &gap, "gap/D");
212  trainTree->Branch("pi0mass", &pi0mass, "pi0mass/D");
213  trainTree->Branch("vtxgev", &vtxgev, "vtxgev/D");
214  trainTree->Branch("shE", &shE, "shE/D");
215  trainTree->Branch("nuE", &nuE, "nuE/D");
216  trainTree->Branch("costheta", &costheta, "costheta/D");
217  trainTree->Branch("length", &length, "length/D");
218  trainTree->Branch("dedx0", &dedx0, "dedx0/D");
219  trainTree->Branch("dedx1", &dedx1, "dedx1/D");
220  trainTree->Branch("dedx2", &dedx2, "dedx2/D");
221  trainTree->Branch("dedx3", &dedx3, "dedx3/D");
222  trainTree->Branch("type", &type, "type/I");
223 
224  if (fPIDType!=1&&fPIDType!=2&&fPIDType!=3)fPIDType = 0;
225  if (fPIDType==0) {// ANN without E
226  fMlp = new TMultiLayerPerceptron("@egLLL,@egLLT,@emuLLL,@emuLLT,@epi0LLL,@epi0LLT,@epLLL,@epLLT,@enLLL,@enLLT,@epiLLL,@epiLLT,@pi0mass,@shE,@vtxgev,@gap,@costheta:22:12:6:type", trainTree);
227  fMlp->LoadWeights(weightfile0.c_str());
228  }
229  else if (fPIDType==1){// ANN with E
230  fMlp = new TMultiLayerPerceptron("@egLLL,@egLLT,@emuLLL,@emuLLT,@epi0LLL,@epi0LLT,@epLLL,@epLLT,@enLLL,@enLLT,@epiLLL,@epiLLT,@pi0mass,@shE,@vtxgev,@gap,@costheta,@nuE:22:12:6:type", trainTree);
231  fMlp->LoadWeights(weightfile2.c_str());
232  }
233  else if (fPIDType==2){// e/pi0 PID
234  fMlp = new TMultiLayerPerceptron("@dedx0,@dedx1,@dedx2,@dedx3,@costheta:25:12:6:type", trainTree);
235  fMlp->LoadWeights(weightfileEPi0.c_str());
236  }
237  else if (fPIDType==3){// e/pi PID for nu-E scattering
238  fMlp = new TMultiLayerPerceptron("@dedx0,@dedx1,@dedx2,@dedx3:25:12:6:type", trainTree);
239  fMlp->LoadWeights(weightfileEPi0EL.c_str());
240  }
241 
242  delete trainTree;
243  }
244 
245  }
246 
248  {
249  double ann = -5.0;
250  // // This is the correct way, except that there seems to be a bug in TMVA that makes in not work
251  // ann = fReader->EvaluateMVA(annInputs, (fMVAMethod + TString(" method")));
252 
253 
254  //
255  // Set the trained models. **NOTE** due to a bug in TMVA model using weights from file
256  // does not work. As a workaround, loading the C++ code created by TMVA DOES work, so we use
257  // that in order to move ahead. Loading the XML weights file would be preferable however,
258  // so that recompilation is not required to pick up a new MVA model.
259  //
260  if (fUseTMVATraining){
261  if (fPIDType==0) {
262 
265  showerpid.EGLLL(),
266  showerpid.EGLLT(),
267  showerpid.EMuLLL(),
268  showerpid.EMuLLT(),
269  showerpid.EPi0LLL(),
270  showerpid.EPi0LLT(),
271  showerpid.EPLLL(),
272  showerpid.EPLLT(),
273  showerpid.ENLLL(),
274  showerpid.ENLLT(),
275  showerpid.EPiLLL(),
276  showerpid.EPiLLT(),
277  showerpid.Gap(),
278  showerpid.Pi0mass(),
279  showerpid.ShowerEFrac(),
280  showerpid.VertexEnergy() );
282  }
283 
284  else if (fPIDType==1) {
287  showerpid.EGLLL(),
288  showerpid.EGLLT(),
289  showerpid.EMuLLL(),
290  showerpid.EMuLLT(),
291  showerpid.EPi0LLL(),
292  showerpid.EPi0LLT(),
293  showerpid.EPLLL(),
294  showerpid.EPLLT(),
295  showerpid.ENLLL(),
296  showerpid.ENLLT(),
297  showerpid.EPiLLL(),
298  showerpid.EPiLLT(),
299  showerpid.Gap(),
300  showerpid.Pi0mass(),
301  showerpid.ShowerEFrac(),
302  showerpid.VertexEnergy(),
303  showerpid.NueEnergy());
305  }
306  else {
307  throw cet::exception("MVAALgorithmNotDefined2")
308  << " not found. See SPIDBuilder_module.cc for list of defined algorithms.";
309  }
310  }
311  else{
312  if (fPIDType==0) {
313  Double_t params_shape[17];
314  for(int i=0;i<17;i++){
315  params_shape[i]=0;
316  }
317  params_shape[0] = showerpid.EGLLL();
318  params_shape[1] = showerpid.EGLLT();
319  params_shape[2] = showerpid.EMuLLL();
320  params_shape[3] = showerpid.EMuLLT();
321  params_shape[4] = showerpid.EPi0LLL();
322  params_shape[5] = showerpid.EPi0LLT();
323  params_shape[6] = showerpid.EPLLL();
324  params_shape[7] = showerpid.EPLLT();
325  params_shape[8] = showerpid.ENLLL();
326  params_shape[9] = showerpid.ENLLT();
327  params_shape[10] = showerpid.EPiLLL();
328  params_shape[11] = showerpid.EPiLLT();
329  params_shape[12] = showerpid.Pi0mass();
330  params_shape[13] = showerpid.ShowerEFrac();
331  params_shape[14] = showerpid.VertexEnergy();
332  params_shape[15] = showerpid.Gap();
333  params_shape[16] = showerpid.CosTheta();
334 
335  ann = fMlp->Evaluate(0,params_shape);
336 
337  }
338 
339  else if (fPIDType==1){
340  Double_t params_shape[18];
341  for(int i=0;i<18;i++){
342  params_shape[i]=0;
343  }
344  params_shape[0] = showerpid.EGLLL();
345  params_shape[1] = showerpid.EGLLT();
346  params_shape[2] = showerpid.EMuLLL();
347  params_shape[3] = showerpid.EMuLLT();
348  params_shape[4] = showerpid.EPi0LLL();
349  params_shape[5] = showerpid.EPi0LLT();
350  params_shape[6] = showerpid.EPLLL();
351  params_shape[7] = showerpid.EPLLT();
352  params_shape[8] = showerpid.ENLLL();
353  params_shape[9] = showerpid.ENLLT();
354  params_shape[10] = showerpid.EPiLLL();
355  params_shape[11] = showerpid.EPiLLT();
356  params_shape[12] = showerpid.Pi0mass();
357  params_shape[13] = showerpid.ShowerEFrac();
358  params_shape[14] = showerpid.VertexEnergy();
359  params_shape[15] = showerpid.Gap();
360  params_shape[16] = showerpid.CosTheta();
361  params_shape[17] = showerpid.NueEnergy();
362 
363  ann = fMlp->Evaluate(0,params_shape);
364 
365  }
366  else if (fPIDType==2){
367  Double_t params_shape[5];
368  for(int i=0;i<5;i++){
369  params_shape[i]=0;
370  }
371  params_shape[0] = showerpid.Dedx0();
372  params_shape[1] = showerpid.Dedx1();
373  params_shape[2] = showerpid.Dedx2();
374  params_shape[3] = showerpid.Dedx3();
375  params_shape[4] = showerpid.CosTheta();
376  ann = fMlp->Evaluate(0,params_shape);
377 
378  }
379  else if (fPIDType==3){
380  Double_t params_shape[4];
381  for(int i=0;i<4;i++){
382  params_shape[i]=0;
383  }
384  params_shape[0] = showerpid.Dedx0();
385  params_shape[1] = showerpid.Dedx1();
386  params_shape[2] = showerpid.Dedx2();
387  params_shape[3] = showerpid.Dedx3();
388  ann = fMlp->Evaluate(0,params_shape);
389  }
390  else {
391  throw cet::exception("MVAALgorithmNotDefined2")
392  << " not found. See SPIDBuilder_module.cc for list of defined algorithms.";
393  }
394  }
395 
396  // protect against nan values
397  if(std::isnan(ann)){
398  ann = -5;
399  // These messages fire all the time. Disable them but keep them in case
400  // they're useful for someone actually debugging the problem.
401  /*
402  std::cout<<"!!!!!!!!!!!!!!!!!!!"<<std::endl;
403  std::cout<<" PID returned NaN value from calculation!"<<std::endl;
404  std::cout<<" EGLLL: "<<showerpid.EGLLL()<<" EGLLT: "<<showerpid.EGLLT()<<std::endl;
405  std::cout<<" EMuLLL: "<<showerpid.EMuLLL()<<" EMuLLT: "<<showerpid.EMuLLT()<<std::endl;
406  std::cout<<" ENLLL: "<<showerpid.ENLLL()<<" ENLLT: "<<showerpid.ENLLT()<<std::endl;
407  std::cout<<" EPLLL: "<<showerpid.EPLLL()<<" EPLLT: "<<showerpid.EPLLT()<<std::endl;
408  std::cout<<" EPiLLL: "<<showerpid.EPiLLL()<<" EPiLLT: "<<showerpid.EPiLLT()<<std::endl;
409  std::cout<<" EPiLLL: "<<showerpid.EPi0LLL()<<" EPi0LLT: "<<showerpid.EPi0LLT()<<std::endl;
410  std::cout<<" Pi0Mass: "<<showerpid.Pi0mass()<<" ShowerEFrac: "<<showerpid.ShowerEFrac()<<std::endl;
411  std::cout<<" Gap: "<<showerpid.Gap()<<" Costheta: "<<showerpid.CosTheta()<<std::endl;
412  std::cout<<"!!!!!!!!!!!!!!!!!!!"<<std::endl;
413  */
414  }
415 
416  return ann;
417  }
418 
420  {
421 
422  }
423 
425  {
426  // //
427  // // I think this in Jianming's output training TTree. Should be packaged up
428  // // for readability
429  // //
430  // art::ServiceHandle<art::TFileService> tfs;
431  // //True neutrino information
432  // fEvent = tfs->make<TTree>("fEvent", "fEvent");
433  //// fEvent->Branch("evtTrueNuCCNC", &m_evtTrueNuCCNC);
434  //// fEvent->Branch("evtTrueNuMode", &m_evtTrueNuMode);
435  //// fEvent->Branch("evtTrueNuPdg", &m_evtTrueNuPdg);
436  //// fEvent->Branch("evtTrueNuEnergy", &m_evtTrueNuEnergy);
437  //// fEvent->Branch("evtTrueNuIsFid", &m_evtTrueNuIsFid);
438  //// fEvent->Branch("evtTrueNuP4[4]", m_evtTrueNuP4);
439  //// fEvent->Branch("evtTrueNuVtx[3]", m_evtTrueNuVtx);
440  //// fEvent->Branch("evtTrueEnergy[20]", m_evtTrueEnergy);
441  //// fEvent->Branch("evtTruePdg[20]", m_evtTruePdg);
442  //// fEvent->Branch("evtTrueMother[20]", m_evtTrueMother);
443  //
444  // //Reconstructed information
445  // fEvent->Branch("evtRun", &m_evtRun);
446  // fEvent->Branch("evtSRun", &m_evtSRun);
447  // fEvent->Branch("evtNSlice", &m_evtNSlice);
448  // fEvent->Branch("evtNSh", &m_evtNSh);
449  //
450  //// fEvent->Branch("evtEtot", &m_evtEtot);
451  //// fEvent->Branch("evtSigOscW", &m_evtSigOscW);
452  //// fEvent->Branch("evtBkgOscW", &m_evtBkgOscW);
453  //// fEvent->Branch("evtIsMuon", &m_evtIsMuon);
454  //// fEvent->Branch("evtIsMuonSh1", &m_evtIsMuonSh1);
455  //// fEvent->Branch("evtIsInvPhoton", &m_evtIsInvPhoton);
456  //// fEvent->Branch("evtDetEnergy", &m_evtDetEnergy);
457  //// fEvent->Branch("evtNuEnergy", &m_evtNuEnergy);
458  //// fEvent->Branch("evtSh1ExclEnergy", &m_evtSh1ExclEnergy);
459  //// fEvent->Branch("evtSh1Length", &m_evtSh1Length);
460  //// fEvent->Branch("evtSh1Start[3]", m_evtSh1Start);
461  //// fEvent->Branch("evtSh1Stop[3]", m_evtSh1Stop);
462  //// fEvent->Branch("evtSh1Dir[3]", m_evtSh1Dir);
463  //
464  //// fEvent->Branch("evtVtx[3]", m_evtVtx);
465  //
466  // fEvent->Branch("sh1EGLLL", &m_sh1EGLLL);
467  // fEvent->Branch("sh1EGLLT", &m_sh1EGLLT);
468  // fEvent->Branch("sh1EMuLLL", &m_sh1EMuLLL);
469  // fEvent->Branch("sh1EMuLLT", &m_sh1EMuLLT);
470  // fEvent->Branch("sh1EPi0LLL", &m_sh1EPi0LLL);
471  // fEvent->Branch("sh1EPi0LLT", &m_sh1EPi0LLT);
472  // fEvent->Branch("sh1EPLLL", &m_sh1EPLLL);
473  // fEvent->Branch("sh1EPLLT", &m_sh1EPLLT);
474  // fEvent->Branch("sh1ENLLL", &m_sh1ENLLL);
475  // fEvent->Branch("sh1ENLLT", &m_sh1ENLLT);
476  // fEvent->Branch("sh1EPiLLL", &m_sh1EPiLLL);
477  // fEvent->Branch("sh1EPiLLT", &m_sh1EPiLLT);
478  // fEvent->Branch("sh1VtxGeV", &m_sh1VtxGeV);
479  // fEvent->Branch("sh1Pi0Mass", &m_sh1Pi0Mass);
480  // fEvent->Branch("sh1ShE", &m_sh1ShE);
481  // fEvent->Branch("sh1Gap", &m_sh1Gap);
482  // fEvent->Branch("sh1Energy", &m_sh1Energy);
483  //
484  //// fEvent->Branch("evtSh1ELLL", &m_evtSh1ELLL);
485  //// fEvent->Branch("evtSh1ELLT", &m_evtSh1ELLT);
486  //// fEvent->Branch("evtSh1MuLLL", &m_evtSh1MuLLL);
487  //// fEvent->Branch("evtSh1MuLLT", &m_evtSh1MuLLT);
488  //// fEvent->Branch("evtSh1GLLL", &m_evtSh1GLLL);
489  //// fEvent->Branch("evtSh1InvGLLL", &m_evtSh1InvGLLL);
490  //// fEvent->Branch("evtSh1DistToEdge", &m_evtSh1DistToEdge);
491  //// fEvent->Branch("evtSh1SliceEdge2GeV", &m_evtSh1SliceEdge2GeV);
492  //// fEvent->Branch("evtSh1SliceEdge5GeV", &m_evtSh1SliceEdge5GeV);
493  //// fEvent->Branch("evtSh1SliceEdge10GeV", &m_evtSh1SliceEdge10GeV);
494  //
495  //
496  // fEvent->Branch("eIdANNNoNuE", &m_eIdANNNoNuE);
497  // fEvent->Branch("eIdANNWithNuE", &m_eIdANNWithNuE);
498 
499  }
500 
502  {
503  // //fEvent
504  // m_evtTrueNuCCNC = 0;
505  // m_evtTrueNuMode = 0;
506  // m_evtTrueNuPdg = 0;
507  // m_evtTrueNuEnergy = 0;
508  // m_evtTrueNuIsFid = 0;
509  // for (int i = 0; i < 4; i++) {
510  // m_evtTrueNuP4[i] = 0;
511  // }
512  // for (int i = 0; i < 3; i++) {
513  // m_evtTrueNuVtx[i] = 0;
514  // }
515  // for (int i = 0; i < 20; i++) {
516  // m_evtTruePdg[i] = 0;
517  // }
518  // for (int i = 0; i < 20; i++) {
519  // m_evtTrueMother[i] = 0;
520  // }
521  // for (int i = 0; i < 20; i++) {
522  // m_evtTrueEnergy[i] = 0;
523  // }
524  // m_evtRun = 0;
525  // m_evtSRun = 0;
526  // m_evtEvent = 0;
527  // m_evtNSlice = 0;
528  // m_evtNSh = 0;
529  // m_evt = 0;
530  // m_evtANN = -5;
531  // m_evtSh1DedxANN = -5;
532  // m_evtSh1DedxANNE = -5;
533  // m_evtEtot = 0;
534  // m_evtSigOscW = 0;
535  // m_evtBkgOscW = 0;
536  // m_evtIsMuon = 0;
537  // m_evtIsInvPhoton = 0;
538  // m_evtDetEnergy = 0;
539  // m_evtTrueNuEnergy = 0;
540  // m_evtNuEnergy = 0;
541  // m_evtSh1Energy = 0;
542  // m_evtSh1ExclEnergy = 0;
543  // m_evtSh1Length = 0;
544  //
545  // for (int i = 0; i < 3; i++) {
546  // m_evtVtx[i] = 0;
547  // m_evtSh1Start[i] = 0;
548  // m_evtSh1Stop[i] = 0;
549  // m_evtSh1Dir[i] = 0;
550  // }
551  //
552  // m_evtSh1EGLLL = 0;
553  // m_evtSh1EGLLT = 0;
554  // m_evtSh1EMuLLL = 0;
555  // m_evtSh1EMuLLT = 0;
556  // m_evtSh1EPi0LLL = 0;
557  // m_evtSh1EPi0LLT = 0;
558  // m_evtSh1EPLLL = 0;
559  // m_evtSh1EPLLT = 0;
560  // m_evtSh1ENLLL = 0;
561  // m_evtSh1ENLLT = 0;
562  // m_evtSh1EPiLLL = 0;
563  // m_evtSh1EPiLLT = 0;
564  // m_evtSh1VtxGeV = 0;
565  // m_evtSh1Pi0Mass = 0;
566  // m_evtSh1ShE = 0;
567  // m_evtSh1Gap = 0;
568  // m_evtSh1ELLL = 0;
569  // m_evtSh1ELLT = 0;
570  // m_evtSh1MuLLL = 0;
571  // m_evtSh1MuLLT = 0;
572  // m_evtSh1GLLL = 0;
573  // m_evtSh1InvGLLL = 0;
574  // m_evtSh1DistToEdge = 0;
575  // m_evtSh1SliceEdge2GeV = 0;
576  // m_evtSh1SliceEdge5GeV = 0;
577  // m_evtSh1SliceEdge10GeV = 0;
578  }
579 
580 
581 
582 
583 
584 
585 } // end namespace slid
TMultiLayerPerceptron * fMlp
FCL parameters for Nue energy calculation algorithm.
Definition: SPIDAlg.h:105
std::string fLibPath
Location of weight files. Set from FCL file.
Definition: SPIDAlg.h:95
void FillTrainingTree(const slid::ShowerPID &showerspid)
Fill tree to be used for training the algorithms.
Definition: SPIDAlg.cxx:419
float ENLLT() const
Definition: ShowerLID.h:114
float EGLLL() const
Definition: ShowerLID.h:105
float Dedx2() const
Definition: ShowerPID.h:62
float Dedx0() const
Definition: ShowerPID.h:60
float EPiLLT() const
Definition: ShowerLID.h:116
slid::ShowerPID * fShowerPID
Definition: SPIDAlg.h:124
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::string fAlgorithmName
FCL Parameters for LIDAlg.
Definition: SPIDAlg.h:79
std::string EnvExpansion(const std::string &inString)
Function to expand environment variables.
Definition: EnvExpand.cxx:8
double Value(int index, double in0, double in1, double in2, double in3, double in4, double in5, double in6, double in7, double in8, double in9, double in10, double in11, double in12, double in13, double in14, double in15, double in16)
virtual ~SPIDAlg()
Definition: SPIDAlg.cxx:38
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
float EPLLL() const
Definition: ShowerLID.h:111
void DefineTrainingTree()
Define mapping of branches to class fields for tree to be used for training the algorithms.
Definition: SPIDAlg.cxx:424
float CosTheta() const
Definition: ShowerLID.h:121
void Initialize()
Initialize the MVA algorithm. The parameter detectorID is an int corresponding to the detector defini...
Definition: SPIDAlg.cxx:48
int isnan(const stan::math::var &a)
Definition: std_isnan.hpp:18
float EPi0LLT() const
Definition: ShowerLID.h:110
double CalcMVAResult(slid::ShowerPID &showerspid)
Calculate value of predictors for MVA Algorithm using candidate rb::Shower. A pointer to the object o...
Definition: SPIDAlg.cxx:247
const std::string fMVAMethod
Definition: SPIDAlg.h:87
Far Detector at Ash River, MN.
length
Definition: demo0.py:21
Prototype Near Detector on the surface at FNAL.
T get(std::string const &key) const
Definition: ParameterSet.h:231
novadaq::cnv::DetId DetId() const
Prefer ds::DetectorService::DetId() instead.
Definition: GeometryBase.h:243
float Dedx1() const
Definition: ShowerPID.h:61
SPIDAlg(fhicl::ParameterSet const &pset, NuEEnergyAlg *fNuEEnergyAlgIn, int pidType)
Algorithm name with ENu.
Definition: SPIDAlg.cxx:16
Near Detector in the NuMI cavern.
float EMuLLL() const
Definition: ShowerLID.h:107
float EPi0LLL() const
Definition: ShowerLID.h:109
int fPIDType
If true, the ANN is computed with event energy as an input variable.
Definition: SPIDAlg.h:85
TMVAClassification_TMlpANN_NoENu * fTMVAModuleTMlpANNNoENu
Definition: SPIDAlg.h:115
double Value(int index, double in0, double in1, double in2, double in3, double in4, double in5, double in6, double in7, double in8, double in9, double in10, double in11, double in12, double in13, double in14, double in15)
int fType
event classification answer: 1 = signal, 0 = background
Definition: SPIDAlg.h:119
OStream cout
Definition: OStream.cxx:6
float EPiLLL() const
Definition: ShowerLID.h:115
float Dedx3() const
Definition: ShowerPID.h:63
bool fUseTMVATraining
Use TMVA training or RecoJMShower training.
Definition: SPIDAlg.h:98
float Pi0mass() const
Definition: ShowerLID.h:118
float NueEnergy() const
Definition: ShowerLID.h:158
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
float VertexEnergy() const
Definition: ShowerLID.h:155
void geom(int which=0)
Definition: geom.C:163
void InitializeTrainingTree()
Initialize tree to be used for training the algorithms.
Definition: SPIDAlg.cxx:501
float EMuLLT() const
Definition: ShowerLID.h:108
float ENLLL() const
Definition: ShowerLID.h:113
Build slid::LID objects to store electron ID, if asked for, otherwise, calculate LID info and make av...
Definition: FillPIDs.h:13
TMVA::Reader * fReader
TMVA reader object used to store MVA model.
Definition: SPIDAlg.h:109
TMVAClassification_TMlpANN_WithENu * fTMVAModuleTMlpANNWithENu
Definition: SPIDAlg.h:114
float Gap() const
Definition: ShowerLID.h:117
float fNueEnergy
Definition: ShowerLID.h:208
float EGLLT() const
Definition: ShowerLID.h:106
float ShowerEFrac() const
Definition: ShowerLID.h:120
float EPLLT() const
Definition: ShowerLID.h:112