LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
NuShowerEff_module.cc
Go to the documentation of this file.
1 // Class: NuShowerEff
3 // Plugin Type: analyzer (art v2_11_03)
4 // File: NuShowerEff_module.cc
5 //
6 // Generated at Tue Sep 18 14:20:57 2018 by Wanwei Wu using cetskelgen
7 // from cetlib version v3_03_01.
9 
10 // Framework includes
15 #include "fhiclcpp/ParameterSet.h"
17 
19 #include "art_root_io/TFileService.h"
21 
22 // LArsoft includes
28 
34 
35 // ROOT includes
36 #include "TEfficiency.h"
37 #include "TGraphAsymmErrors.h"
38 #include "TH1.h"
39 #include "TTree.h"
40 
41 // user's defined constant
42 #define MAX_SHOWERS 1000
43 
44 using namespace std;
45 
46 class NuShowerEff;
47 
48 class NuShowerEff : public art::EDAnalyzer {
49 public:
50  explicit NuShowerEff(fhicl::ParameterSet const& p);
51  // The compiler-generated destructor is fine for non-base
52  // classes without bare pointers or other resource use.
53 
54  // Plugins should not be copied or assigned.
55  NuShowerEff(NuShowerEff const&) = delete;
56  NuShowerEff(NuShowerEff&&) = delete;
57  NuShowerEff& operator=(NuShowerEff const&) = delete;
58  NuShowerEff& operator=(NuShowerEff&&) = delete;
59 
60 private:
61  // Required functions.
62  void analyze(art::Event const& e) override;
63 
64  // user's defined functions
65  void beginJob() override;
66  void endJob() override;
67  void beginRun(art::Run const& run) override;
68  void doEfficiencies();
69  bool insideFV(double vertex[4]);
70  void reset();
71 
72  // Declare member data here.
73 
74  // read from fchicl: Input Tag
75  std::string fMCTruthModuleLabel;
76  std::string fHitModuleLabel;
77  std::string fShowerModuleLabel;
79 
80  // read from fchicl: user's defined parameters
84  bool fHitShowerThroughPFParticle; // an option for getting hits associated with shower
85  double fMinPurity; // for reference
86  double fMinCompleteness; // for reference
87  float fFidVolCutX; // Fiducail Volume cut [cm]
88  float fFidVolCutY;
89  float fFidVolCutZ;
90 
91  // Fiducial Volume parameters
92  float fFidVolXmin;
93  float fFidVolXmax;
94  float fFidVolYmin;
95  float fFidVolYmax;
96  float fFidVolZmin;
97  float fFidVolZmax;
98 
99  // Event
100  int Event;
101  int Run;
102  int SubRun;
103 
104  // MC Truth: Generator
107  int MC_isCC;
110  double MC_Q2;
111  double MC_W;
112  double MC_vertex[4];
113  double MC_incoming_P[4];
114  double MC_lepton_startMomentum[4];
115  double MC_lepton_endMomentum[40];
116  double MC_lepton_startXYZT[4];
117  double MC_lepton_endXYZT[4];
121 
122  double MC_incoming_E; // incoming neutrino energy
124 
125  // recob::Shower
127  double sh_direction_X[MAX_SHOWERS];
128  double sh_direction_Y[MAX_SHOWERS];
129  double sh_direction_Z[MAX_SHOWERS];
130  double sh_start_X[MAX_SHOWERS];
131  double sh_start_Y[MAX_SHOWERS];
132  double sh_start_Z[MAX_SHOWERS];
133  double sh_length[MAX_SHOWERS];
134  double sh_ehit_Q[MAX_SHOWERS];
135  int sh_TrackId[MAX_SHOWERS];
136  int sh_hasPrimary_e[MAX_SHOWERS];
137  double sh_allhit_Q[MAX_SHOWERS];
138  double sh_purity[MAX_SHOWERS];
139  double sh_completeness[MAX_SHOWERS];
140  double esh_1_purity; // largest shower in a CC event that contains electron contributions
142  double
143  esh_each_purity[MAX_SHOWERS]; // each shower in a CC event that contains electron contributions
144  double esh_each_completeness[MAX_SHOWERS];
145  double esh_purity; // average over all electron showers in a CC event
147  int count_primary_e_in_Event; // number of showers containing electron contribution in a CC event
148 
149  // TTree
150  TTree* fEventTree;
151 
152  TH1D* h_Ev_den; // incoming neutrino energy from MC. den: denominator
153  TH1D* h_Ev_num; // recon. num: numerator
154 
155  TH1D* h_Ee_den; // primary electron energy from MC
156  TH1D* h_Ee_num;
157 
158  TEfficiency* h_Eff_Ev = 0;
159  TEfficiency* h_Eff_Ee = 0;
160 };
161 
162 // =====================================================================================
164  : EDAnalyzer(p)
165  , fMCTruthModuleLabel(p.get<std::string>("MCTruthModuleLabel"))
166  , fHitModuleLabel(p.get<std::string>("HitModuleLabel"))
167  , fShowerModuleLabel(p.get<std::string>("ShowerModuleLabel"))
168  , fTruthMatchDataModuleLabel(p.get<std::string>("TruthMatchDataModuleLabel"))
169  , fNeutrinoPDGcode(p.get<int>("NeutrinoPDGcode"))
170  , fLeptonPDGcode(p.get<int>("LeptonPDGcode"))
171  , fSaveMCTree(p.get<bool>("SaveMCTree"))
172  , fHitShowerThroughPFParticle(p.get<bool>("HitShowerThroughPFParticle"))
173  , fMinPurity(p.get<double>("MinPurity"))
174  , fMinCompleteness(p.get<double>("MinCompleteness"))
175  , fFidVolCutX(p.get<float>("FidVolCutX"))
176  , fFidVolCutY(p.get<float>("FidVolCutY"))
177  , fFidVolCutZ(p.get<float>("FidVolCutZ"))
178 {}
179 
180 //============================================================================
182 {
183  // Get geometry: Fiducial Volume
184  auto const* geo = lar::providerFrom<geo::Geometry>();
185  double minx = 1e9; // [cm]
186  double maxx = -1e9;
187  double miny = 1e9;
188  double maxy = -1e9;
189  double minz = 1e9;
190  double maxz = -1e9;
191  for (auto const& tpc : geo->Iterate<geo::TPCGeo>()) {
192  auto const world = tpc.GetCenter();
193 
194  if (minx > world.X() - tpc.HalfWidth()) minx = world.X() - tpc.HalfWidth();
195  if (maxx < world.X() + tpc.HalfWidth()) maxx = world.X() + tpc.HalfWidth();
196  if (miny > world.Y() - tpc.HalfHeight()) miny = world.Y() - tpc.HalfHeight();
197  if (maxy < world.Y() + tpc.HalfHeight()) maxy = world.Y() + tpc.HalfHeight();
198  if (minz > world.Z() - tpc.Length() / 2.) minz = world.Z() - tpc.Length() / 2.;
199  if (maxz < world.Z() + tpc.Length() / 2.) maxz = world.Z() + tpc.Length() / 2.;
200  }
201 
202  fFidVolXmin = minx + fFidVolCutX;
203  fFidVolXmax = maxx - fFidVolCutX;
204  fFidVolYmin = miny + fFidVolCutY;
205  fFidVolYmax = maxy - fFidVolCutY;
206  fFidVolZmin = minz + fFidVolCutZ;
207  fFidVolZmax = maxz - fFidVolCutZ;
208 
210 
211  double E_bins[21] = {0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4, 4.5, 5.0,
212  5.5, 6.0, 7.0, 8.0, 10.0, 12.0, 14.0, 17.0, 20.0, 25.0};
213 
214  h_Ev_den =
215  tfs->make<TH1D>("h_Ev_den",
216  "Neutrino Energy; Neutrino Energy (GeV); Shower Reconstruction Efficiency",
217  20,
218  E_bins);
219  h_Ev_den->Sumw2();
220  h_Ev_num =
221  tfs->make<TH1D>("h_Ev_num",
222  "Neutrino Energy; Neutrino Energy (GeV); Shower Reconstruction Efficiency",
223  20,
224  E_bins);
225  h_Ev_num->Sumw2();
226 
227  h_Ee_den =
228  tfs->make<TH1D>("h_Ee_den",
229  "Electron Energy; Electron Energy (GeV); Shower Reconstruction Efficiency",
230  20,
231  E_bins);
232  h_Ee_den->Sumw2();
233  h_Ee_num =
234  tfs->make<TH1D>("h_Ee_num",
235  "Electron Energy; Electron Energy (GeV); Shower Reconstruction Efficiency",
236  20,
237  E_bins);
238  h_Ee_num->Sumw2();
239 
240  if (fSaveMCTree) {
241  fEventTree = new TTree("Event", "Event Tree from Sim & Reco");
242  fEventTree->Branch("eventNo", &Event); // only select event in FV
243  fEventTree->Branch("runNo", &Run);
244  fEventTree->Branch("subRunNo", &SubRun);
245 
246  fEventTree->Branch("MC_incoming_E", &MC_incoming_E);
247  fEventTree->Branch("MC_lepton_startEnergy", &MC_lepton_startEnergy);
248 
249  fEventTree->Branch("n_showers", &n_recoShowers);
250  fEventTree->Branch("sh_hasPrimary_e", &sh_hasPrimary_e, "sh_hasPrimary_e[n_showers]/I");
251  fEventTree->Branch("count_primary_e_in_Event", &count_primary_e_in_Event);
252  fEventTree->Branch("esh_1_purity", &esh_1_purity);
253  fEventTree->Branch("esh_1_completeness", &esh_1_completeness);
254  fEventTree->Branch(
255  "esh_each_purity", &esh_each_purity, "esh_each_purity[count_primary_e_in_Event]/D");
256  fEventTree->Branch("esh_each_completeness",
258  "esh_each_completeness[count_primary_e_in_Event]/D");
259  fEventTree->Branch("esh_purity", &esh_purity);
260  fEventTree->Branch("esh_completeness", &esh_completeness);
261  }
262 }
263 
264 //============================================================================
266 {
267  doEfficiencies();
268 }
269 
270 //============================================================================
272 {
273  mf::LogInfo("ShowerEff") << "==== begin run ... ====" << endl;
274 }
275 
276 //============================================================================
278 {
279  reset(); // for some variables
280 
281  Event = e.id().event();
282  Run = e.run();
283  SubRun = e.subRun();
284 
285  // -------- find Geant4 TrackId that corresponds to e+/e- from neutrino interaction ----------
286  // MCTruth: Generator
288  e.getByLabel(fMCTruthModuleLabel, MCtruthHandle);
289  std::vector<art::Ptr<simb::MCTruth>> MCtruthlist;
290  art::fill_ptr_vector(MCtruthlist, MCtruthHandle);
291  art::Ptr<simb::MCTruth> MCtruth;
292  // MC (neutrino) interaction
293  int MCinteractions = MCtruthlist.size();
294  for (int i = 0; i < MCinteractions; i++) {
295  MCtruth = MCtruthlist[i];
296  if (MCtruth->NeutrinoSet()) { // NeutrinoSet(): whether the neutrino information has been set
297  simb::MCNeutrino nu = MCtruth->GetNeutrino(); // GetNeutrino(): reference to neutrino info
298  if (nu.CCNC() == 0)
299  MC_isCC = 1;
300  else if (nu.CCNC() == 1)
301  MC_isCC = 0;
302  simb::MCParticle neutrino = nu.Nu(); // Nu(): the incoming neutrino
303  MC_target = nu.Target(); // Target(): nuclear target, as PDG code
304  MC_incoming_PDG = std::abs(nu.Nu().PdgCode()); // here not use std::abs()
305  MC_Q2 = nu.QSqr(); // QSqr(): momentum transfer Q^2, in GeV^2
306  MC_channel = nu.InteractionType(); // 1001: CCQE
307  MC_W = nu.W(); // W(): hadronic invariant mass
308  const TLorentzVector& nu_momentum = nu.Nu().Momentum(0);
309  nu_momentum.GetXYZT(MC_incoming_P);
310  const TLorentzVector& vertex = neutrino.Position(0);
311  vertex.GetXYZT(MC_vertex);
312  simb::MCParticle lepton = nu.Lepton(); // Lepton(): the outgoing lepton
313  MC_lepton_PDG = lepton.PdgCode();
314 
316  }
317  }
318 
319  // Geant4: MCParticle -> lepton (e)
320  // Note: generator level MCPartilceList is different from Geant4 level MCParticleList. MCParticleList(Geant4) contains all particles in MCParticleList(generator) but their the indexes (TrackIds) are different.
321  simb::MCParticle* MClepton = NULL; //Geant4 level
323  const sim::ParticleList& plist = pi_serv->ParticleList();
324  simb::MCParticle* particle = 0;
325 
326  for (sim::ParticleList::const_iterator ipar = plist.begin(); ipar != plist.end(); ++ipar) {
327  particle = ipar->second; // first is index(TrackId), second is value (point address)
328 
329  auto& truth = pi_serv->ParticleToMCTruth_P(particle); // beam neutrino only
330  if (truth->Origin() == simb::kBeamNeutrino && std::abs(particle->PdgCode()) == fLeptonPDGcode &&
331  particle->Mother() == 0) { // primary lepton; Mother() = 0 means e^{-} for v+n=e^{-}+p
332  const TLorentzVector& lepton_momentum = particle->Momentum(0);
333  const TLorentzVector& lepton_position = particle->Position(0);
334  const TLorentzVector& lepton_positionEnd = particle->EndPosition();
335  const TLorentzVector& lepton_momentumEnd = particle->EndMomentum();
336  lepton_momentum.GetXYZT(MC_lepton_startMomentum);
337  lepton_position.GetXYZT(MC_lepton_startXYZT);
338  lepton_positionEnd.GetXYZT(MC_lepton_endXYZT);
339  lepton_momentumEnd.GetXYZT(MC_lepton_endMomentum);
340  MC_leptonID = particle->TrackId();
341 
343  MClepton = particle;
344  }
345  }
346 
347  // check if the interaction is inside the Fiducial Volume
348  bool isFiducial = false;
349  isFiducial = insideFV(MC_vertex);
350  if (!isFiducial) { return; }
351 
353  if (MClepton) {
354  h_Ev_den->Fill(MC_incoming_P[3]);
356  }
357  }
358 
359  // recob::Hit
360  // ---- build a map for total hit charges corresponding to MC_leptonID (Geant4) ----
361 
363  std::vector<art::Ptr<recob::Hit>> all_hits;
364  if (e.getByLabel(fHitModuleLabel, hitHandle)) { art::fill_ptr_vector(all_hits, hitHandle); }
365 
366  double ehit_total = 0.0;
367 
369  hitHandle, e, fTruthMatchDataModuleLabel);
370 
371  std::map<int, double> all_hits_trk_Q; //Q for charge: Integral()
372  for (size_t i = 0; i < all_hits.size(); ++i) {
373  art::Ptr<recob::Hit> hit = all_hits[i];
374  auto particles =
375  fmhitmc.at(hit.key()); // particles here is a pointer. A hit may come from multiple particles.
376  auto hitmatch = fmhitmc.data(hit.key()); // metadata
377  double maxenergy = -1e9;
378  int hit_TrackId = 0;
379  for (size_t j = 0; j < particles.size(); ++j) {
380  if (!particles[j]) continue;
381  if (!pi_serv->TrackIdToMotherParticle_P(particles[j]->TrackId())) continue;
382  size_t trkid = (pi_serv->TrackIdToMotherParticle_P(particles[j]->TrackId()))->TrackId();
383 
384  if ((hitmatch[j]->energy) > maxenergy) {
385  maxenergy = hitmatch[j]->energy;
386  hit_TrackId = trkid;
387  }
388  }
389  if (hit_TrackId == MC_leptonID) ehit_total += hit->Integral();
390  all_hits_trk_Q[hit_TrackId] +=
391  hit
392  ->Integral(); // Integral(): the integral under the calibrated signal waveform of the hit, in tick x ADC units
393  }
394 
395  //--------- Loop over all showers: find the associated hits for each shower ------------
396  const simb::MCParticle* MClepton_reco = NULL;
397 
398  double temp_sh_ehit_Q = 0.0;
399  double temp_sh_allHit_Q = 0.0;
400  int temp_sh_TrackId = -999;
402 
404  std::vector<art::Ptr<recob::Shower>> showerlist;
405  if (e.getByLabel(fShowerModuleLabel, showerHandle)) {
406  art::fill_ptr_vector(showerlist, showerHandle);
407  }
408  n_recoShowers = showerlist.size();
409  art::FindManyP<recob::Hit> sh_hitsAll(showerHandle, e, fShowerModuleLabel);
410 
411  std::map<int, double> showers_trk_Q;
412  for (int i = 0; i < n_recoShowers; i++) { // loop over showers
413  sh_hasPrimary_e[i] = 0;
414 
415  std::map<int, double> sh_hits_trk_Q; //Q for charge: Integral()
416  sh_hits_trk_Q.clear();
417 
418  art::Ptr<recob::Shower> shower = showerlist[i];
419  sh_direction_X[i] =
420  shower->Direction().X(); // Direction(): direction cosines at start of the shower
421  sh_direction_Y[i] = shower->Direction().Y();
422  sh_direction_Z[i] = shower->Direction().Z();
423  sh_start_X[i] = shower->ShowerStart().X();
424  sh_start_Y[i] = shower->ShowerStart().Y();
425  sh_start_Z[i] = shower->ShowerStart().Z();
426  sh_length[i] = shower->Length(); // shower length in [cm]
427 
428  std::vector<art::Ptr<recob::Hit>> sh_hits; // associated hits for ith shower
429  //In mcc8, if we get hits associated with the shower through shower->hits association directly for pandora, the hit list is incomplete. The recommended way of getting hits is through association with pfparticle:
430  //shower->pfparticle->clusters->hits
431  //----------getting hits through PFParticle (an option here)-------------------
433 
434  // PFParticle
436  std::vector<art::Ptr<recob::PFParticle>> pfps;
437  if (e.getByLabel(fShowerModuleLabel, pfpHandle)) art::fill_ptr_vector(pfps, pfpHandle);
438  // Clusters
440  std::vector<art::Ptr<recob::Cluster>> clusters;
441  if (e.getByLabel(fShowerModuleLabel, clusterHandle))
442  art::fill_ptr_vector(clusters, clusterHandle);
444  showerHandle, e, fShowerModuleLabel); // PFParticle in Shower
446  pfpHandle, e, fShowerModuleLabel); // Cluster vs. PFParticle
447  art::FindManyP<recob::Hit> fmhc(clusterHandle, e, fShowerModuleLabel); // Hit in Shower
448  if (fmps.isValid()) {
449  std::vector<art::Ptr<recob::PFParticle>> pfs = fmps.at(i);
450  for (size_t ipf = 0; ipf < pfs.size(); ++ipf) {
451  if (fmcp.isValid()) {
452  std::vector<art::Ptr<recob::Cluster>> clus = fmcp.at(pfs[ipf].key());
453  for (size_t iclu = 0; iclu < clus.size(); ++iclu) {
454  if (fmhc.isValid()) {
455  std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(clus[iclu].key());
456  for (size_t ihit = 0; ihit < hits.size(); ++ihit) {
457  sh_hits.push_back(hits[ihit]);
458  }
459  }
460  }
461  }
462  }
463  }
464  }
465  else {
466 
467  // ----- using shower->hit association for getting hits associated with shower-----
468  sh_hits =
469  sh_hitsAll.at(i); // associated hits for ith shower (using association of hits and shower)
470  } // we only choose one method for hits associated with shower here.
471 
472  for (size_t k = 0; k < sh_hits.size(); ++k) {
473  art::Ptr<recob::Hit> hit = sh_hits[k];
474  auto particles = fmhitmc.at(hit.key());
475  auto hitmatch = fmhitmc.data(hit.key());
476  double maxenergy = -1e9;
477  int hit_TrackId = 0;
478  for (size_t j = 0; j < particles.size(); ++j) {
479  if (!particles[j]) continue;
480  if (!pi_serv->TrackIdToMotherParticle_P(particles[j]->TrackId())) continue;
481  size_t trkid = (pi_serv->TrackIdToMotherParticle_P(particles[j]->TrackId()))->TrackId();
482 
483  if ((hitmatch[j]->energy) > maxenergy) {
484  maxenergy = hitmatch[j]->energy;
485  hit_TrackId = trkid;
486  }
487  }
488  if (hit_TrackId == MC_leptonID) { sh_ehit_Q[i] += hit->Integral(); }
489  sh_allhit_Q[i] += hit->Integral();
490  sh_hits_trk_Q[hit_TrackId] += hit->Integral(); // Q from the same hit_TrackId
491  }
492 
493  // get TrackId for a shower
494  double maxshowerQ = -1.0e9;
495  for (std::map<int, double>::iterator k = sh_hits_trk_Q.begin(); k != sh_hits_trk_Q.end(); k++) {
496  if (k->second > maxshowerQ) {
497  maxshowerQ = k->second;
498  sh_TrackId[i] =
499  k->first; //assign a sh_TrackId with TrackId from hit(particle) that contributing largest to the shower.
500  }
501  }
502 
503  //---------------------------------------------------------------------------------
504 
505  if (sh_TrackId[i] == MC_leptonID && sh_ehit_Q[i] > 0) {
506  temp_sh_TrackId = sh_TrackId[i];
507  sh_hasPrimary_e[i] = 1;
509  MClepton_reco = pi_serv->TrackIdToParticle_P(sh_TrackId[i]);
510 
511  if (sh_allhit_Q[i] > 0 && sh_ehit_Q[i] <= sh_allhit_Q[i]) {
512  sh_purity[i] = sh_ehit_Q[i] / sh_allhit_Q[i];
513  }
514  else {
515  sh_purity[i] = 0;
516  }
517  if (ehit_total > 0 && sh_ehit_Q[i] <= sh_allhit_Q[i]) {
518  sh_completeness[i] = sh_ehit_Q[i] / ehit_total;
519  }
520  else {
521  sh_completeness[i] = 0;
522  }
523  temp_sh_ehit_Q += sh_ehit_Q[i];
524  temp_sh_allHit_Q += sh_allhit_Q[i];
525  }
526 
527  showers_trk_Q[sh_TrackId[i]] += maxshowerQ;
528 
529  } // end: for loop over showers
530 
531  // ---------------------------------------------------------------
532  if (MClepton_reco && MClepton) {
533  if ((temp_sh_TrackId == MC_leptonID) && MC_isCC &&
535  if ((temp_sh_allHit_Q >= temp_sh_ehit_Q) && (temp_sh_ehit_Q > 0.0)) {
536  esh_purity = temp_sh_ehit_Q / temp_sh_allHit_Q;
537  esh_completeness = temp_sh_ehit_Q / ehit_total;
538 
540  h_Ev_num->Fill(MC_incoming_P[3]);
542  }
543  }
544  }
545  }
546  // --------------------------------------------------------------
547 
548  if ((MClepton_reco && MClepton) && MC_isCC && (fNeutrinoPDGcode == std::abs(MC_incoming_PDG))) {
549  for (int j = 0; j < count_primary_e_in_Event; j++) {
550  esh_each_purity[j] = 0.0;
551  }
552 
553  double temp_esh_1_allhit = -1.0e9;
554  int temp_shower_index = -999;
555  int temp_esh_index = 0;
556  for (int i = 0; i < n_recoShowers; i++) {
557  if (sh_TrackId[i] == MC_leptonID) {
558 
559  // for each electron shower
560  if (sh_ehit_Q[i] > 0) {
561  esh_each_purity[temp_esh_index] = sh_purity[i];
562  esh_each_completeness[temp_esh_index] = sh_completeness[i];
563  temp_esh_index += 1;
564  }
565 
566  // find largest shower
567  if ((sh_allhit_Q[i] > temp_esh_1_allhit) && (sh_ehit_Q[i] > 0.0)) {
568  temp_esh_1_allhit = sh_allhit_Q[i];
569  temp_shower_index = i;
570  }
571  }
572  }
573  // largest shower with electron contribution
574  esh_1_purity = sh_purity[temp_shower_index];
575  esh_1_completeness = sh_completeness[temp_shower_index];
576  }
577 
579  fEventTree->Fill();
580  } // so far, only save CC event
581 }
582 
583 // ====================================================================================
585 {
587 
588  if (TEfficiency::CheckConsistency(*h_Ev_num, *h_Ev_den)) {
589  h_Eff_Ev = tfs->make<TEfficiency>(*h_Ev_num, *h_Ev_den);
590  TGraphAsymmErrors* grEff_Ev = h_Eff_Ev->CreateGraph();
591  grEff_Ev->Write("grEff_Ev");
592  h_Eff_Ev->Write("h_Eff_Ev");
593  }
594 
595  if (TEfficiency::CheckConsistency(*h_Ee_num, *h_Ee_den)) {
596  h_Eff_Ee = tfs->make<TEfficiency>(*h_Ee_num, *h_Ee_den);
597  TGraphAsymmErrors* grEff_Ee = h_Eff_Ee->CreateGraph();
598  grEff_Ee->Write("grEff_Ee");
599  h_Eff_Ee->Write("h_Eff_Ee");
600  }
601 }
602 
603 // ====================================================================================
605 {
606  double x = vertex[0];
607  double y = vertex[1];
608  double z = vertex[2];
609 
610  if (x > fFidVolXmin && x < fFidVolXmax && y > fFidVolYmin && y < fFidVolYmax && z > fFidVolZmin &&
611  z < fFidVolZmax) {
612  return true;
613  }
614  else {
615  return false;
616  }
617 }
618 
619 // ====================================================================================
621 {
622  MC_incoming_PDG = -999;
623  MC_lepton_PDG = -999;
624  MC_isCC = -999;
625  MC_channel = -999;
626  MC_target = -999;
627  MC_Q2 = -999.0;
628  MC_W = -999.0;
629  MC_lepton_theta = -999.0;
630  MC_leptonID = -999;
631  MC_LeptonTrack = -999;
632 
633  for (int i = 0; i < MAX_SHOWERS; i++) {
634  sh_direction_X[i] = -999.0;
635  sh_direction_Y[i] = -999.0;
636  sh_direction_Z[i] = -999.0;
637  sh_start_X[i] = -999.0;
638  sh_start_Y[i] = -999.0;
639  sh_start_Z[i] = -999.0;
640  sh_length[i] = -999.0;
641  sh_hasPrimary_e[i] = -999;
642  sh_ehit_Q[i] = 0.0;
643  sh_allhit_Q[i] = 0.0;
644  sh_purity[i] = 0.0;
645  sh_completeness[i] = 0.0;
646  }
647 }
Float_t x
Definition: compare.C:6
intermediate_table::iterator iterator
double esh_each_purity[MAX_SHOWERS]
double sh_direction_X[MAX_SHOWERS]
SubRunNumber_t subRun() const
Definition: Event.cc:35
const TVector3 & ShowerStart() const
Definition: Shower.h:197
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:220
int PdgCode() const
Definition: MCParticle.h:213
int CCNC() const
Definition: MCNeutrino.h:148
double QSqr() const
Definition: MCNeutrino.h:157
const simb::MCNeutrino & GetNeutrino() const
Definition: MCTruth.h:77
double MC_lepton_startEnergy
Utilities related to art service access.
TEfficiency * h_Eff_Ee
const TLorentzVector & EndPosition() const
Definition: MCParticle.h:226
double Length() const
Definition: Shower.h:227
NuShowerEff(fhicl::ParameterSet const &p)
double sh_start_Y[MAX_SHOWERS]
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void endJob() override
const simb::MCParticle * TrackIdToParticle_P(int id) const
int Mother() const
Definition: MCParticle.h:214
Declaration of signal hit object.
Float_t y
Definition: compare.C:6
const simb::MCParticle & Nu() const
Definition: MCNeutrino.h:146
list_type::const_iterator const_iterator
Definition: ParticleList.h:132
Double_t z
Definition: plot.C:276
Geometry information for a single TPC.
Definition: TPCGeo.h:36
double sh_direction_Y[MAX_SHOWERS]
constexpr auto abs(T v)
Returns the absolute value of the argument.
std::string fMCTruthModuleLabel
STL namespace.
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:244
#define MAX_SHOWERS
data_const_reference data(size_type i) const
Definition: FindManyP.h:446
double MC_lepton_startMomentum[4]
Particle class.
const art::Ptr< simb::MCTruth > & ParticleToMCTruth_P(const simb::MCParticle *p) const
Definition: Run.h:37
int TrackId() const
Definition: MCParticle.h:211
bool fHitShowerThroughPFParticle
int sh_TrackId[MAX_SHOWERS]
std::string fShowerModuleLabel
int InteractionType() const
Definition: MCNeutrino.h:150
void hits()
Definition: readHits.C:15
const simb::MCParticle & Lepton() const
Definition: MCNeutrino.h:147
double W() const
Definition: MCNeutrino.h:154
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
void beginJob()
Definition: Breakpoints.cc:14
std::string fHitModuleLabel
double esh_each_completeness[MAX_SHOWERS]
TEfficiency * h_Eff_Ev
int sh_hasPrimary_e[MAX_SHOWERS]
void analyze(art::Event const &e) override
key_type key() const noexcept
Definition: Ptr.h:166
bool insideFV(double vertex[4])
double energy
Definition: plottest35.C:25
iterator begin()
Definition: ParticleList.h:305
const TVector3 & Direction() const
Definition: Shower.h:188
double sh_start_Z[MAX_SHOWERS]
Declaration of cluster object.
double sh_purity[MAX_SHOWERS]
Detector simulation of raw signals on wires.
const sim::ParticleList & ParticleList() const
double sh_ehit_Q[MAX_SHOWERS]
double MC_lepton_startXYZT[4]
double MC_lepton_endXYZT[4]
double sh_direction_Z[MAX_SHOWERS]
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
Definition: StdUtils.h:120
int Target() const
Definition: MCNeutrino.h:151
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
double sh_completeness[MAX_SHOWERS]
double MC_lepton_endMomentum[40]
double sh_allhit_Q[MAX_SHOWERS]
const TLorentzVector & Momentum(const int i=0) const
Definition: MCParticle.h:221
void beginJob() override
EventNumber_t event() const
Definition: EventID.h:116
void beginRun(art::Run const &run) override
std::string fTruthMatchDataModuleLabel
bool NeutrinoSet() const
Definition: MCTruth.h:78
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:306
const simb::MCParticle * TrackIdToMotherParticle_P(int id) const
Float_t e
Definition: plot.C:35
RunNumber_t run() const
Definition: Event.cc:29
Event generator information.
Definition: MCNeutrino.h:18
Namespace collecting geometry-related classes utilities.
double sh_start_X[MAX_SHOWERS]
const TLorentzVector & EndMomentum() const
Definition: MCParticle.h:241
EventID id() const
Definition: Event.cc:23
art framework interface to geometry description
double MC_incoming_P[4]
double sh_length[MAX_SHOWERS]
Beam neutrinos.
Definition: MCTruth.h:23
vertex reconstruction