LIDBuilder_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \brief Build and write out the ShowerLID objects and make nue PID
3 ///
4 /// \TODO Jianming's oscillation weighting: Need to find standard
5 // infrastructure to do this and replace his
6 /// code, which I stripped out of this class
7 ///
8 /// \author Alex Smith smith@physics.umn.edu
9 ////////////////////////////////////////////////////////////////////////
10 
11 // ROOT includes
12 #include "TFile.h"
13 #include "TH1D.h"
14 #include "TLorentzVector.h"
15 #include "TMath.h"
16 #include "TMultiLayerPerceptron.h"
17 #include "TRandom.h"
18 #include "TTree.h"
19 
20 // NOvA includes
21 #include "Geometry/Geometry.h"
22 #include "RecoBase/Cluster.h"
23 #include "RecoBase/PID.h"
24 #include "RecoBase/FilterList.h"
25 #include "RecoBase/Vertex.h"
26 #include "Utilities/AssociationUtil.h"
27 #include "Calibrator/Calibrator.h"
29 #include "ShowerLID/NuEEnergyAlg.h"
31 #include "ShowerLID/LIDAlg.h"
32 #include "ShowerLID/EventLID.h"
33 #include "ShowerLID/ShowerLID.h"
34 
35 // ART includes
39 #include "art_root_io/TFileService.h"
47 #include "fhiclcpp/ParameterSet.h"
49 #include <cmath>
50 
51 namespace slid {
52 
53  class LIDBuilder : public art::EDProducer {
54  public:
55  explicit LIDBuilder(const fhicl::ParameterSet& pset);
56  ~LIDBuilder();
57  virtual void produce(art::Event& evt);
58  virtual void reconfigure(const fhicl::ParameterSet& pset);
59  virtual void beginRun(art::Run& run);
60 
61  protected:
65  std::vector<std::string> fFilterLabels; ///< Labels of filter lists to obey
66 
72 
74  int kIDNuE = 12; // TEMP, should find where stadard defs are.
75  /// Particle ID alorithm (loglikelihoods and dE/dx)
78  /// MVAAlgorithm (Neural Net, KNN, etc. May include any algorithm that is
79  /// a subclass of slid::LIDAlg)
84  /// FCL parameters for NuE Energy alorithm
86 
87  /// FCL parameters for particle ID alorithm (loglikelihoods and dE/dx)
89 
90  /// FCL parameters for LID alorithm
92 
93  /// determine if library load is necessary or not when moving to a new run
94  bool libLoad = false;
95 
96  };
97  bool CompareByE( const slid::ShowerLID& a, const slid::ShowerLID& b);
98 } // namespace
99 
100 namespace slid {
101  int Ncount0 = 0, Ncount1 = 0, Ncount2 = 0;
102  int Nfill = 0, Nput = 0;
103  //......................................................................
104 
106  : EDProducer(pset)
107  , fParticleIDAlg(0), fNuEEnergyAlg(0),
108  fMVAAlg(0),
109  fMVAAlgWithE(0),
110  fMVAAlgEPi0(0),
111  fMVAAlgECos(0),
112  fNuEEnergyAlgPSet(pset.get< fhicl::ParameterSet >("NuEEnergyAlgPSet")),
113  fParticleIDAlgPSet(pset.get< fhicl::ParameterSet >("ParticleIDAlgPSet")),
114  fLIDAlgPSet(pset.get< fhicl::ParameterSet >("LIDAlgPSet"))
115  {
116  reconfigure(pset);
117  // Define output structures produced.
118  produces<std::vector<slid::ShowerLID> >();
119  produces<std::vector<slid::EventLID> >();
120  produces< art::Assns<slid::EventLID, rb::Cluster> >();
121  produces< art::Assns<slid::ShowerLID, rb::Shower> >();
122  produces< art::Assns<slid::ShowerLID, rb::Cluster> >();
123  }
124 
125  //......................................................................
126 
128  {
129  if (fParticleIDAlg) delete fParticleIDAlg;
130  if (fNuEEnergyAlg) delete fNuEEnergyAlg;
131  if (fMVAAlg) delete fMVAAlg;
132  if (fMVAAlgWithE) delete fMVAAlgWithE;
133  if (fMVAAlgEPi0) delete fMVAAlgEPi0;
134  if (fMVAAlgECos) delete fMVAAlgECos;
135  }
136 
137  //......................................................................
138 
140  {
141  //
142  // Read FCL parameters
143  //
144  fNuEEnergyAlgPSet = pset.get< fhicl::ParameterSet >("NuEEnergyAlgPSet");
145  fParticleIDAlgPSet = pset.get< fhicl::ParameterSet >("ParticleIDAlgPSet");
146  fLIDAlgPSet = pset.get< fhicl::ParameterSet >("LIDAlgPSet");
147  fObeyPreselection = pset.get<bool>("ObeyPreselection");
148  fSkipNoiseSlices = pset.get<bool>("SkipNoiseSlices");
149  fTrainingMode = pset.get<bool>("TrainingMode");
150  fParticleIDMode = pset.get<bool>("ParticleIDMode");
151  fFilterLabels = pset.get< std::vector<std::string> >("FilterLabels");
152  fSlicerLabel = pset.get< std::string >("SlicerLabel");
153  fShowerLabel = pset.get< std::string >("ShowerLabel");
154  fVertexLabel = pset.get< std::string >("VertexLabel");
155  fLibPath = util::EnvExpansion(pset.get< std::string >("LibraryPath"));
156  fPIDOnlyForHighestEShower = pset.get<bool>("PIDOnlyForHighestEShower");
157 
158  }
159 
161  {
162  }
163 
164 
165  //......................................................................
166 
168  {
169  // Currently libraries only depend on the detector. Safe to only initialize
170  // once.
171  if (!libLoad){
173  if (fParticleIDMode){
175  novadaq::cnv::DetId detId = geom->DetId();
177  }
178  if (!fTrainingMode){
187  }
188  libLoad = true;
189  }
190 
191 
193 
194  MF_LOG_DEBUG("LIDBuilderDEBUG") << "In LIDBuilder::produce" << '\n';
195 
196  std::unique_ptr<std::vector<slid::ShowerLID>> showerlidcol(new std::vector<slid::ShowerLID>);
197  std::unique_ptr<std::vector<slid::EventLID>> elidcol(new std::vector<slid::EventLID>);
198  std::unique_ptr<art::Assns<slid::ShowerLID,rb::Shower>> assnSlidShower(new art::Assns<slid::ShowerLID, rb::Shower>);
199  std::unique_ptr<art::Assns<slid::ShowerLID,rb::Cluster>> assnSlidSlice(new art::Assns<slid::ShowerLID, rb::Cluster>);
200  std::unique_ptr<art::Assns<slid::EventLID,rb::Cluster>> assnElidSlice(new art::Assns<slid::EventLID, rb::Cluster>);
201 
203  evt.getByLabel(fSlicerLabel, slicecol);
204  art::PtrVector<rb::Cluster> slicelist;
205  for (unsigned int i = 0; i < slicecol->size(); ++i) {
206  art::Ptr<rb::Cluster> slice(slicecol, i);
207  slicelist.push_back(slice);
208  }
209  //
210  // Grab list of rb::Shower* for calculations and reading
211  // and list of art::Ptr<rb::Shower>
212  // for writing the output data products. Since these
213  // **should** be indexed the same, this
214  // should be OK.
215  //
216  art::FindManyP<rb::Shower> fmtP(slicecol, evt, fShowerLabel);
218  art::FindManyP<rb::Vertex> fmv(slicecol, evt, fVertexLabel);
219 
220  // loop over all of the slices
221  for (unsigned int iSlice = 0; iSlice < slicelist.size(); ++iSlice) {
222  const size_t nextShwIdx = showerlidcol->size();
223 
224  // Skip noise slices if this option is selected in FCL
225 
226  if (fSkipNoiseSlices && slicelist[iSlice]->IsNoise()) continue;
227 
228  // If there was nue preselection, skip slice if it
229  // failed if this option is selected in FCL
230 
231  if (fObeyPreselection &&
232  rb::IsFiltered(evt, slicecol, iSlice, fFilterLabels))
233  continue;
234 
235 
236  // get all of the showers in this slice
237  if ((!fmt.isValid())||(!fmtP.isValid())) continue;
238  const std::vector< const rb::Shower* > showercol = fmt.at(iSlice);
239  const std::vector < art::Ptr < rb::Shower >>
240  showercolPtr = fmtP.at(iSlice);
241  if ((showercol.empty())||(showercolPtr.empty())) continue;
242 
243  // hold slid objects temporarily before sorting
244  std::vector<slid::ShowerLID> tempslidcol;
245  // keep track of shower index associationed with the
246  // slid object after sorting
247  std::vector<std::pair<double,int> > associationlist;
248 
249 
250  //get the vertex for the slice
251  const std::vector<art::Ptr<rb::Vertex>> vertCol = fmv.at(iSlice);
252  //currently only one vertex per slice
253  TVector3 vert = vertCol[0]->GetXYZ();
254 
255  //
256  // Get indices of highest and second-highest energy showers
257  //
258  double eShHighest = 0;
259  double sliceShwE = 0;
260  unsigned int iHighestEnergySh = -1;
261  for (unsigned int jShower = 0;
262  jShower < showercol.size();
263  ++jShower) {
264  double thisESh = fNuEEnergyAlg->ShowerEnergy(showercol[jShower],
265  showercol, evt);
266  sliceShwE += thisESh;
267  if (thisESh > eShHighest) {
268  eShHighest = thisESh;
269  iHighestEnergySh = jShower;
270  }
271  }
272 
273  TLorentzVector evtP4(0.0,0.0,0.0,0.0);
274  //
275  // Loop over showers to fill PID info
276  //
277  std::map<int, int> showerLidToShower;
278  unsigned int nShowers = showercol.size();
279  for (unsigned int iShower = 0; iShower < nShowers; ++iShower) {
280 
281 
282  slid::ShowerLID showerlid;
283  if(fParticleIDMode){
284  // we only have to calculate the electron longitudinal
285  // and transverse likelihoods once, and can save the values
286  double ellmax = -9999;
287  double electronLongLL = -9999;
288  double electronTransLL = -9999;
289  for(int itype=0;
291  ++itype){
292  if(itype == int(slid::DedxParticleType::kELECTRON)||
297  double eLongLLTest =
299  showercol[iShower],
300  showercol, evt);
301  double eTransLLTest =
303  showercol[iShower],
304  showercol, evt);
305  if(ellmax< eLongLLTest+eTransLLTest){
306  ellmax = eLongLLTest+eTransLLTest;
307  electronLongLL = eLongLLTest;
308  electronTransLL = eTransLLTest;
309  }
310  }
311  }
312  showerlid.SetEGLLL(electronLongLL
314  showercol, evt));
315  showerlid.SetEGLLT(electronTransLL
317  showercol, evt));
318  showerlid.SetEMuLLL(electronLongLL
320  showercol, evt));
321  showerlid.SetEMuLLT(electronTransLL
323  showercol, evt));
324  showerlid.SetEPi0LLL(electronLongLL
326  showercol, evt));
327  showerlid.SetEPi0LLT(electronTransLL
329  showercol, evt));
330  showerlid.SetEPLLL(electronLongLL
332  showercol, evt));
333  showerlid.SetEPLLT(electronTransLL
335  showercol, evt));
336  showerlid.SetENLLL(electronLongLL
338  showercol, evt));
339  showerlid.SetENLLT(electronTransLL
341  showercol, evt));
342  showerlid.SetEPiLLL(electronLongLL
344  showercol, evt));
345  showerlid.SetEPiLLT(electronTransLL
347  showercol, evt));
349  showercol, evt));
350  showerlid.SetPi0PhotonID(fParticleIDAlg->Pi0SecondPhoton(showercol, iShower, evt) );
351 
352  showerlid.SetGap(fParticleIDAlg->GetGapVertexToShowerStart(showercol[iShower], vert, evt));
353 
354  showerlid.SetNMIPPlanes( fParticleIDAlg->GetMIPPlanes( showercol[iShower], showercol, evt));
355 
356  showerlid.SetPi0mass(std::max(fParticleIDAlg->Pi0Mass(showercol, iShower, evt), 0.0));
357  showerlid.SetRadius(fParticleIDAlg->Radius(showercol, iShower, evt));
358 
359 
360  showerlid.SetDedx0(0);
361  showerlid.SetDedx1(0);
362  showerlid.SetDedx2(0);
363  showerlid.SetDedx3(0);
364  showerlid.SetDedx4(0);
365  showerlid.SetDedx5(0);
366  fParticleIDAlg->SetShower(showercol[iShower],
367  showercol, evt);
368 
369  if(showercol[iShower]->ExtentPlane()>0)
370  showerlid.SetDedx0(fParticleIDAlg->PlaneLongDedx(0));
371  if(showercol[iShower]->ExtentPlane()>1)
372  showerlid.SetDedx1(fParticleIDAlg->PlaneLongDedx(1));
373  if(showercol[iShower]->ExtentPlane()>2)
374  showerlid.SetDedx2(fParticleIDAlg->PlaneLongDedx(2));
375  if(showercol[iShower]->ExtentPlane()>3)
376  showerlid.SetDedx3(fParticleIDAlg->PlaneLongDedx(3));
377  if(showercol[iShower]->ExtentPlane()>4)
378  showerlid.SetDedx4(fParticleIDAlg->PlaneLongDedx(4));
379  if(showercol[iShower]->ExtentPlane()>5)
380  showerlid.SetDedx5(fParticleIDAlg->PlaneLongDedx(5));
381 
382  for(int cell=-5;cell<=5;cell++){
383  for(int plane=0;plane<6;plane++){
384  double cpdedx = fParticleIDAlg->CellPlaneDedx(cell,plane);
385  showerlid.fVtxDedx[plane][cell] = cpdedx;
386  }
387  }
388 
389  showerlid.SetDedxp0c0(showerlid.fVtxDedx[0][0]);
390  showerlid.SetDedxp0c1(0.5*(showerlid.fVtxDedx[0][-1]+showerlid.fVtxDedx[0][1]));
391  showerlid.SetDedxp1c0(showerlid.fVtxDedx[1][0]);
392  showerlid.SetDedxp1c1(0.5*(showerlid.fVtxDedx[1][-1]+showerlid.fVtxDedx[1][1]));
393  showerlid.SetDedxp2c0(showerlid.fVtxDedx[2][0]);
394  showerlid.SetDedxp2c1(0.5*(showerlid.fVtxDedx[2][-1]+showerlid.fVtxDedx[2][1]));
395  showerlid.SetDedxp3c0(showerlid.fVtxDedx[3][0]);
396  showerlid.SetDedxp3c1(0.5*(showerlid.fVtxDedx[3][-1]+showerlid.fVtxDedx[3][1]));
397  showerlid.SetDedxp4c0(showerlid.fVtxDedx[4][0]);
398  showerlid.SetDedxp4c1(0.5*(showerlid.fVtxDedx[4][-1]+showerlid.fVtxDedx[4][1]));
399  showerlid.SetDedxp5c0(showerlid.fVtxDedx[5][0]);
400  showerlid.SetDedxp5c1(0.5*(showerlid.fVtxDedx[5][-1]+showerlid.fVtxDedx[5][1]));
401  }
402 
403  double shwE = fNuEEnergyAlg->ShowerEnergy(showercol.at(iShower),
404  showercol, evt);
405  if (sliceShwE > 1e-10) showerlid.SetShowerEFrac(shwE/sliceShwE);
406  else showerlid.SetShowerEFrac(0.0);
407 
408  if (shwE < 1e-10) shwE = 0.0;
409  showerlid.SetShowerEnergy(shwE);
410 
411  TLorentzVector showerptrk(showercol[iShower]->Dir()[0]*shwE,
412  showercol[iShower]->Dir()[1]*shwE,
413  showercol[iShower]->Dir()[2]*shwE,
414  shwE);
415 
416  TVector3 nuDir = fGeom->NuMIBeamDirection();
417  double theta = showerptrk.Angle(nuDir);
418 
419  showerlid.SetCosTheta(cos(theta));
420  showerlid.SetVertexEnergy(fNuEEnergyAlg->VertexEnergy(showercol.at(iShower), showercol, vertCol.at(0).get(), slicelist.at(iSlice).get(), evt));
421  evtP4 += showerptrk;
422 
423  if (std::isnan(sliceShwE) ||
424  std::isnan(shwE) ||
425  std::isinf(sliceShwE) ||
426  std::isinf(shwE)) {
427  mf::LogError("LIDBuilder")<< "sliceShwE/shwE is nan or inf";
428  continue;
429  }
430 
431  showerlid.SetIsMuon(!(showerlid.EMuLLL() > -0.2 &&
432  showerlid.EMuLLT() > -99999));
433  showerlid.SetPdg(kIDNuE);
434  showerlid.SetAlgDescription("dummy");
435  showerlid.SetShowerDepEnergy(fNuEEnergyAlg->ShowerDepEnergy(showercol.at(iShower),
436  showercol,
437  evt));
438 
439  showerlid.SetNueEnergy(fNuEEnergyAlg->NuEEnergy(showercol,
440  slicelist.at(iSlice).get(),
441  iShower, evt));
442 
443  showerlid.SetHadronicEnergy(fNuEEnergyAlg->HadronicEnergy(showercol,
444  slicelist.at(iSlice).get(),
445  iShower,
446  evt));
447 
449  || iShower == iHighestEnergySh){
450  // in training mode just write -5,
451  // since the ann weights have not been determined
452  if (fTrainingMode){
453  showerlid.SetAlgDescription(""); // not needed?
454  showerlid.SetVal(-5);
455  showerlid.SetValWithE(-5);
456  showerlid.SetValEPi0(-5);
457  showerlid.SetValECos(-5);
458  }
459  //standard running, calculate the ann
460  else{
461  showerlid.SetAlgDescription(fMVAAlg->Description()); // not needed?
462  showerlid.SetVal(fMVAAlg->CalcMVAResult(showerlid));
463  showerlid.SetValWithE(fMVAAlgWithE->CalcMVAResult(showerlid));
464 // std::cout<<"EPi0 PID = "<<fMVAAlgEPi0->CalcMVAResult(showerlid)<<std::endl;
465  showerlid.SetValEPi0(fMVAAlgEPi0->CalcMVAResult(showerlid));
466  showerlid.SetValECos(fMVAAlgECos->CalcMVAResult(showerlid));
467  }
468  }
469  if(fParticleIDMode){
470  showerlid.SetVtxDoca(fParticleIDAlg->PointDoca(vertCol.at(0)->GetXYZ(),
471  showercol[iShower]->Start(),
472  showercol[iShower]->Stop()));
473 
476  }
477 
478  tempslidcol.push_back(showerlid);
479  associationlist.push_back(std::make_pair(showerlid.ShowerEnergy(),
480  iShower));
481  }// end loop over showers
482 
483  std::sort( tempslidcol.begin(), tempslidcol.end(), CompareByE);
484  std::sort(associationlist.rbegin(), associationlist.rend());
485 
486  for (unsigned int islid=0; islid<tempslidcol.size(); ++islid){
487  showerlidcol->push_back(tempslidcol[islid]);
488  util::CreateAssn(evt, *(showerlidcol.get()),
489  showercolPtr[associationlist[islid].second],
490  *(assnSlidShower.get()));
491  }
492 
493  //if we have added new showers, make event pid and associations to slice
494  if (showerlidcol->size() > nextShwIdx){
495  // for the event lid nextShwIdx points to the most
496  // energetic shower, which is what we want
497  slid::EventLID elid;
498  elid.SetPdg( showerlidcol->at(nextShwIdx).Pdg());
499  elid.SetVal( showerlidcol->at(nextShwIdx).Value());
500  elid.SetValWithE( showerlidcol->at(nextShwIdx).ValueWithE() );
501  elid.SetValEPi0( showerlidcol->at(nextShwIdx).ValueEPi0() );
502  elid.SetValECos( showerlidcol->at(nextShwIdx).ValueECos() );
503  elidcol->push_back(elid);
504  util::CreateAssn(evt, *(elidcol.get()), slicelist[iSlice],
505  *(assnElidSlice.get()));
506  //create new associations for the most recent set of showers
507  util::CreateAssn(evt, *showerlidcol, slicelist[iSlice],
508  *(assnSlidSlice.get()), nextShwIdx,
509  showerlidcol->size());
510  }
511 
512  } //end loop over slices
513  evt.put(std::move(showerlidcol));
514  evt.put(std::move(elidcol));
515  evt.put(std::move(assnSlidShower));
516  evt.put(std::move(assnElidSlice));
517  evt.put(std::move(assnSlidSlice));
518 
519  }// end of producer
520 
521  ////////////////////////////////////////////////////////////////////////
522 
524 
525  {
526  return a.ShowerEnergy() > b.ShowerEnergy();
527  }
528 
530 }
void SetValEPi0(float in)
Definition: ShowerLID.h:51
T max(const caf::Proxy< T > &a, T b)
std::string fVertexLabel
void SetEPiLLL(float in)
Definition: ShowerLID.h:41
void SetEMuLLT(float in)
Definition: ShowerLID.h:34
static bool CreateAssn(art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
Create a 1 to 1 association between a new product and one already in the event.
double VertexEnergy(const rb::Shower *shower, const std::vector< const rb::Shower * > showercol, const rb::Vertex *vertex, const rb::Cluster *slice, const art::Event &evt)
Returns energy within 8 planes of the start of the shower.
void SetDedx3(float in)
Definition: ShowerLID.h:57
void SetVtxDoca(float in)
Definition: ShowerLID.h:84
std::string fSlicerLabel
void SetDedxp2c0(float in)
Definition: ShowerLID.h:65
void SetNueEnergy(float in)
Definition: ShowerLID.h:95
double NuEEnergy(const std::vector< const rb::Shower * > shower, const rb::Cluster *slice, const int &elecShowerIndex, const art::Event &evt)
Returns the neutrino energy, assuming &#39;shower&#39; is electron shower.
slid::LIDAlg * fMVAAlgEPi0
pdg code and pid value
fhicl::ParameterSet fParticleIDAlgPSet
FCL parameters for particle ID alorithm (loglikelihoods and dE/dx)
double DedxTransLL(const slid::DedxParticleType partHyp, const rb::Shower *vShower, const std::vector< const rb::Shower * > showercol, const art::Event &evt)
Calculate transverse dE/dx log-likelihood for specific particle hypothesis.
double GetGapVertexToShowerStart(const rb::Shower *vShower, TVector3 evtVtx, const art::Event &evt)
Calculate the gap between the vertex and the start of the shower.
void SetValWithE(float in)
Definition: EventLID.h:24
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
std::map< int, float > fPartLongLL
Map of the longitudinal ll by paricle type.
Definition: ShowerLID.h:238
std::string EnvExpansion(const std::string &inString)
Function to expand environment variables.
Definition: EnvExpand.cxx:8
void SetShowerEnergy(float in)
Definition: ShowerLID.h:94
std::string fShowerLabel
void SetEMuLLL(float in)
Definition: ShowerLID.h:33
void SetDedxp0c0(float in)
Definition: ShowerLID.h:61
void SetDedx4(float in)
Definition: ShowerLID.h:58
void SetDedxp3c1(float in)
Definition: ShowerLID.h:68
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
bool CompareByE(const slid::ShowerLID &a, const slid::ShowerLID &b)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
virtual void beginRun(art::Run &run)
NuEEnergyAlg * fNuEEnergyAlg
DEFINE_ART_MODULE(TestTMapFile)
void SetDedx2(float in)
Definition: ShowerLID.h:56
double PlaneLongDedx(unsigned int pIdx)
return longitudinal dedx for a specified plane index
std::string Description()
Definition: LIDAlg.h:72
void SetEPi0LLL(float in)
Definition: ShowerLID.h:35
void SetShowerEFrac(float in)
Definition: ShowerLID.h:46
void SetPi0mass(float in)
Definition: ShowerLID.h:44
Definition: Run.h:21
void SetAlgDescription(const std::string &algDescription)
set algorithm description
Definition: ShowerLID.h:90
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
int GetMIPPlanes(const rb::Shower *shower, const std::vector< const rb::Shower * > showercol, const art::Event &evt)
Number of MIP planes within the first 20 planes of the start of the shower.
void SetValEPi0(float in)
Definition: EventLID.h:25
void SetEPiLLT(float in)
Definition: ShowerLID.h:42
DedxParticleType
An enum used to give allowed particle types a visible name in the code. Note that for electron...
double HadronicEnergy(const std::vector< const rb::Shower * > showercol, const rb::Cluster *slice, const int &elecShowerIndex, const art::Event &evt)
Returns the hadronic energy in the slice, assuming &#39;shower&#39; is the electron shower.
void SetDedx0(float in)
Definition: ShowerLID.h:54
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:446
slid::LIDAlg * fMVAAlgWithE
void SetDedxp0c1(float in)
Definition: ShowerLID.h:62
void SetShowerDepEnergy(float in)
Definition: ShowerLID.h:92
void SetEPi0LLT(float in)
Definition: ShowerLID.h:36
TensorflowHandler for ShowerLID.
void SetRadius(float in)
Definition: ShowerLID.h:79
double CellPlaneDedx(int tpIdx, unsigned int pIdx)
return transverse dedx for specified transverse plane
int Pi0SecondPhoton(const std::vector< const rb::Shower * > showerCollection, unsigned int iShower, const art::Event &evt)
Index in showerCollection of the shower for which the reconstructed invariant mass was closest to pi0...
void SetInverseGLLL(float in)
Definition: ShowerLID.h:81
void SetENLLT(float in)
Definition: ShowerLID.h:40
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
void SetDedxp4c1(float in)
Definition: ShowerLID.h:70
LIDBuilder(const fhicl::ParameterSet &pset)
void SetDedxp2c1(float in)
Definition: ShowerLID.h:66
virtual void reconfigure(const fhicl::ParameterSet &pset)
const double a
double ShowerDepEnergy(const rb::Shower *shower, const std::vector< const rb::Shower * > showercol, const art::Event &evt)
Returns the deposited energy of a shower. Does not contain corrections due to dead material or thresh...
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
int evt
void SetENLLL(float in)
Definition: ShowerLID.h:39
void SetDedxp1c0(float in)
Definition: ShowerLID.h:63
bool libLoad
determine if library load is necessary or not when moving to a new run
void SetDedx5(float in)
Definition: ShowerLID.h:59
float EMuLLL() const
Definition: ShowerLID.h:107
void SetIsMuon(bool in)
Definition: ShowerLID.h:48
bool IsFiltered(const art::Event &evt, art::Ptr< T > x, const std::vector< std::string > &labels)
Is this Ptr marked "filtered out"?
Definition: FilterList.h:96
std::map< int, float > fPartTransLL
Map of the transverse ll by particle type.
Definition: ShowerLID.h:241
void SetCosTheta(float in)
Definition: ShowerLID.h:47
virtual void produce(art::Event &evt)
void SetDedxp5c0(float in)
Definition: ShowerLID.h:71
reference at(size_type n)
Definition: PtrVector.h:359
void SetVertexEnergy(float in)
Definition: ShowerLID.h:93
std::map< int, float > fPartTransLL
Map of the transverse ll by particle type.
void SetHadronicEnergy(float in)
Definition: ShowerLID.h:96
Vertex location in position and time.
double PointDoca(TVector3 vtx, TVector3 start, TVector3 stop)
Get distance of closest approach between shower and vertex.
void SetEPLLL(float in)
Definition: ShowerLID.h:37
void SetValWithE(float in)
Setters.
Definition: ShowerLID.h:30
Definition: run.py:1
size_type size() const
Definition: PtrVector.h:302
void SetPi0PhotonID(float in)
Definition: ShowerLID.h:45
ParticleIDAlg * fParticleIDAlg
Particle ID alorithm (loglikelihoods and dE/dx)
double ShowerEnergy(const rb::Shower *shower, const std::vector< const rb::Shower * > showercol, const art::Event &evt)
Returns the total energy of a shower. along with corrections due to dead material and threshold effec...
std::vector< std::string > fFilterLabels
Labels of filter lists to obey.
void SetPdg(int pdg)
Definition: PID.h:23
void SetValECos(float in)
Definition: ShowerLID.h:77
slid::LIDAlg * fMVAAlg
TVector3 NuMIBeamDirection() const
Direction of neutrinos from the NuMI beam (unit vector)
void SetDedxp5c1(float in)
Definition: ShowerLID.h:72
fhicl::ParameterSet fNuEEnergyAlgPSet
FCL parameters for NuE Energy alorithm.
void SetDedxp1c1(float in)
Definition: ShowerLID.h:64
Calculate dE/dx and log likelihoods for different particle hypotheses. This information will be of us...
float ShowerEnergy() const
Definition: ShowerLID.h:157
Calculates deposited and corrected energy of the electron shower and of electron flavoured neutrino...
slid::LIDAlg * fMVAAlgECos
void SetGap(float in)
Definition: ShowerLID.h:43
void geom(int which=0)
Definition: geom.C:163
#define MF_LOG_DEBUG(id)
const hit & b
Definition: hits.cxx:21
float EMuLLT() const
Definition: ShowerLID.h:108
T cos(T number)
Definition: d0nt_math.hpp:78
void SetDedxp3c0(float in)
Definition: ShowerLID.h:67
double Radius(const std::vector< const rb::Shower * > showerCollection, unsigned int iShower, const art::Event &evt)
Calculate the shower radius.
void SetEGLLT(float in)
Definition: ShowerLID.h:32
void SetValECos(float in)
Definition: EventLID.h:26
Build slid::LID objects to store electron ID, if asked for, otherwise, calculate LID info and make av...
Definition: FillPIDs.h:13
void SetNMIPPlanes(float in)
Definition: ShowerLID.h:82
void SetVal(double val)
Definition: PID.h:24
void SetDedx1(float in)
Definition: ShowerLID.h:55
Float_t e
Definition: plot.C:35
std::map< int, float > fPartLongLL
Map of the longitudinal ll by paricle type.
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:730
void SetEGLLL(float in)
Definition: ShowerLID.h:31
double DedxInverseLongLL(const slid::DedxParticleType partHyp, const rb::Shower *vShower, const std::vector< const rb::Shower * > showercol, const art::Event &evt)
Calculate longitudinal dE/dx log-likelihood for specific particle hypothesis assuming that the partic...
double Pi0Mass(const std::vector< const rb::Shower * > showerCollection, unsigned int iShower, const art::Event &evt)
Calculate the mass of candidate and any other shower in the slice that is closest to the pi0 mass...
void SetDedxp4c0(float in)
Definition: ShowerLID.h:69
Encapsulate the geometry of one entire detector (near, far, ndos)
void SetEPLLT(float in)
Definition: ShowerLID.h:38
std::map< int, std::map< int, float > > fVtxDedx
Definition: ShowerLID.h:242
double DedxLongLL(const slid::DedxParticleType partHyp, const rb::Shower *vShower, const std::vector< const rb::Shower * > showercol, const art::Event &evt)
Calculate longitudinal dE/dx log-likelihood for specific particle hypothesis.
fhicl::ParameterSet fLIDAlgPSet
FCL parameters for LID alorithm.
void SetShower(const rb::Shower *vShower, const std::vector< const rb::Shower * > showercol, const art::Event &evt)
Set rb::Prong to be analyzed. This must be set before any calculations can be done.
enum BeamMode string