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