PFParticleCosmicAna_module.cc
Go to the documentation of this file.
1 /**
2  * @file larpandora/LArPandoraAnalysis/PFParticleCosmicAna_module.cc
3  *
4  * @brief Analysis module for created particles
5  */
6 
9 
11 
12 #include "TTree.h"
13 
14 #include <string>
15 
16 //------------------------------------------------------------------------------------------------------------------------------------------
17 
18 namespace lar_pandora
19 {
20 
21 /**
22  * @brief PFParticleCosmicAna class
23  */
25 {
26 public:
27  /**
28  * @brief Constructor
29  *
30  * @param pset
31  */
33 
34  /**
35  * @brief Destructor
36  */
37  virtual ~PFParticleCosmicAna();
38 
39  void beginJob();
40  void endJob();
41  void analyze(const art::Event &evt);
42  void reconfigure(fhicl::ParameterSet const &pset);
43 
44 private:
45 
46  /**
47  * @brief Fill event-level variables using input maps between reconstructed objects
48  *
49  * @param recoParticlesToHits mapping from particles to hits
50  * @param recoParticlesToTracks mapping from particles to tracks
51  * @param recoTracksToCosmicTags mapping from tracks to cosmic tags
52  */
53  void FillRecoTree(const PFParticlesToHits &recoParticlesToHits, const PFParticlesToTracks &recoParticlesToTracks,
54  const TracksToCosmicTags &recoTracksToCosmicTags);
55 
56  /**
57  * @brief Fill track-level variables using input maps between reconstructed objects
58  *
59  * @param hitVector input vector of reconstructed hits
60  * @param trueHitsToParticles mapping between true hits and particles
61  * @param recoHitsToParticles mapping between reconstructed hits and particles
62  * @param particlesToTruth mapping between MC particles and MC truth
63  * @param particlesToTracks mapping between reconstructed particles and tracks
64  * @param tracksToCosmicTags mapping between reconstructed tracks and cosmic tags
65  */
66  void FillTrueTree(const HitVector &hitVector, const HitsToMCParticles &trueHitsToParticles, const HitsToPFParticles &recoHitsToParticles,
67  const MCParticlesToMCTruth &particlesToTruth, const PFParticlesToTracks &particlesToTracks, const TracksToCosmicTags &tracksToCosmicTags);
68 
69  /**
70  * @brief Get cosmic score for a PFParticle using track-level information
71  *
72  * @param particle input reconstructed particle
73  * @param recoParticlesToTracks mapping between reconstructed particles and tracks
74  * @param recoTracksToCosmicTags mapping between reconstructed tracks and cosmic tags
75  */
76  float GetCosmicScore(const art::Ptr<recob::PFParticle> particle, const PFParticlesToTracks &recoParticlesToTracks,
77  const TracksToCosmicTags &recoTracksToCosmicTags) const;
78 
79  TTree *m_pRecoTree; ///<
80  TTree *m_pTrueTree; ///<
81 
82  int m_run; ///<
83  int m_event; ///<
84  int m_index; ///<
85 
86  int m_self; ///<
87  int m_pdgCode; ///<
88  int m_isTrackLike; ///<
89  int m_isPrimary; ///<
90  float m_cosmicScore; ///<
91  int m_nTracks; ///<
92  int m_nHits; ///<
93 
94  float m_trackVtxX; ///<
95  float m_trackVtxY; ///<
96  float m_trackVtxZ; ///<
97  float m_trackEndX; ///<
98  float m_trackEndY; ///<
99  float m_trackEndZ; ///<
100  float m_trackVtxDirX; ///<
101  float m_trackVtxDirY; ///<
102  float m_trackVtxDirZ; ///<
103  float m_trackEndDirX; ///<
104  float m_trackEndDirY; ///<
105  float m_trackEndDirZ; ///<
106  float m_trackLength; ///<
107  float m_trackWidthX; ///<
108  float m_trackWidthY; ///<
109  float m_trackWidthZ; ///<
110  float m_trackVtxDeltaYZ; ///<
111  float m_trackEndDeltaYZ; ///<
112 
115 
122 
129 
135 
138 
140 };
141 
143 
144 } // namespace lar_pandora
145 
146 //------------------------------------------------------------------------------------------------------------------------------------------
147 // implementation follows
148 
150 #include "fhiclcpp/ParameterSet.h"
153 #include "art_root_io/TFileService.h"
154 #include "art_root_io/TFileDirectory.h"
156 #include "canvas/Persistency/Common/FindManyP.h"
157 #include "canvas/Persistency/Common/FindOneP.h"
158 
164 
165 #include <iostream>
166 
167 namespace lar_pandora
168 {
169 
171 {
172  this->reconfigure(pset);
173 }
174 
175 //------------------------------------------------------------------------------------------------------------------------------------------
176 
178 {
179 }
180 
181 //------------------------------------------------------------------------------------------------------------------------------------------
182 
184 {
185  m_cosmicLabel = pset.get<std::string>("CosmicTagModule","cosmictagger");
186  m_particleLabel = pset.get<std::string>("PFParticleModule","pandora");
187  m_trackfitLabel = pset.get<std::string>("TrackFitModule","trackfit");
188  m_hitfinderLabel = pset.get<std::string>("HitFinderModule","gaushit");
189  m_geantModuleLabel = pset.get<std::string>("GeantModule","largeant");
190 
191  m_useDaughterPFParticles = pset.get<bool>("UseDaughterPFParticles",true);
192  m_useDaughterMCParticles = pset.get<bool>("UseDaughterMCParticles",true);
193 
194  m_cosmicContainmentCut = pset.get<double>("CosmicContainmentCut",5.0);
195 }
196 
197 //------------------------------------------------------------------------------------------------------------------------------------------
198 
200 {
201  mf::LogDebug("LArPandora") << " *** PFParticleCosmicAna::beginJob() *** " << std::endl;
202 
203  //
205 
206  m_pRecoTree = tfs->make<TTree>("recoTree", "LAr Cosmic Reco Tree");
207  m_pRecoTree->Branch("run", &m_run, "run/I");
208  m_pRecoTree->Branch("event", &m_event, "event/I");
209  m_pRecoTree->Branch("index", &m_index, "index/I");
210  m_pRecoTree->Branch("self", &m_self, "self/I");
211  m_pRecoTree->Branch("pdgCode", &m_pdgCode, "pdgCode/I");
212  m_pRecoTree->Branch("isTrackLike", &m_isTrackLike, "isTrackLike/I");
213  m_pRecoTree->Branch("isPrimary", &m_isPrimary, "isPrimary/I");
214  m_pRecoTree->Branch("cosmicScore", &m_cosmicScore, "cosmicScore/F");
215  m_pRecoTree->Branch("trackVtxX", &m_trackVtxX, "trackVtxX/F");
216  m_pRecoTree->Branch("trackVtxY", &m_trackVtxY, "trackVtxY/F");
217  m_pRecoTree->Branch("trackVtxZ", &m_trackVtxZ, "trackVtxZ/F");
218  m_pRecoTree->Branch("trackEndX", &m_trackEndX, "trackEndX/F");
219  m_pRecoTree->Branch("trackEndY", &m_trackEndY, "trackEndY/F");
220  m_pRecoTree->Branch("trackEndZ", &m_trackEndZ, "trackEndZ/F");
221  m_pRecoTree->Branch("trackVtxDirX", &m_trackVtxDirX, "trackVtxDirX/F");
222  m_pRecoTree->Branch("trackVtxDirY", &m_trackVtxDirY, "trackVtxDirY/F");
223  m_pRecoTree->Branch("trackVtxDirZ", &m_trackVtxDirZ, "trackVtxDirZ/F");
224  m_pRecoTree->Branch("trackEndDirX", &m_trackEndDirX, "trackEndDirX/F");
225  m_pRecoTree->Branch("trackEndDirY", &m_trackEndDirY, "trackEndDirY/F");
226  m_pRecoTree->Branch("trackEndDirZ", &m_trackEndDirZ, "trackEndDirZ/F");
227  m_pRecoTree->Branch("trackLength", &m_trackLength, "trackLength/F");
228  m_pRecoTree->Branch("trackWidthX", &m_trackWidthX, "trackWidthX/F");
229  m_pRecoTree->Branch("trackWidthY", &m_trackWidthY, "trackWidthY/F");
230  m_pRecoTree->Branch("trackWidthZ", &m_trackWidthZ, "trackWidthZ/F");
231  m_pRecoTree->Branch("trackVtxDeltaYZ", &m_trackVtxDeltaYZ, "trackVtxDeltaYZ/F");
232  m_pRecoTree->Branch("trackEndDeltaYZ", &m_trackEndDeltaYZ, "trackEndDeltaYZ/F");
233  m_pRecoTree->Branch("trackVtxContained", &m_trackVtxContained, "trackVtxContained/I");
234  m_pRecoTree->Branch("trackEndContained", &m_trackEndContained, "trackEndContained/I");
235  m_pRecoTree->Branch("nTracks", &m_nTracks, "nTracks/I");
236  m_pRecoTree->Branch("nHits", &m_nHits, "nHits/I");
237 
238  m_pTrueTree = tfs->make<TTree>("trueTree", "LAr Cosmic True Tree");
239  m_pTrueTree->Branch("run", &m_run, "run/I");
240  m_pTrueTree->Branch("event", &m_event, "event/I");
241  m_pTrueTree->Branch("nHits", &m_nHits, "nHits/I");
242  m_pTrueTree->Branch("nNeutrinoHits", &m_nNeutrinoHits, "nNeutrinoHits/I");
243  m_pTrueTree->Branch("nNeutrinoHitsFullyTagged", &m_nNeutrinoHitsFullyTagged, "nNeutrinoHitsFullyTagged/I");
244  m_pTrueTree->Branch("nNeutrinoHitsSemiTagged", &m_nNeutrinoHitsSemiTagged, "nNeutrinoHitsSemiTagged/I");
245  m_pTrueTree->Branch("nNeutrinoHitsNotTagged", &m_nNeutrinoHitsNotTagged, "nNeutrinoHitsNotTagged/I");
246  m_pTrueTree->Branch("nNeutrinoHitsNotReconstructed", &m_nNeutrinoHitsNotReconstructed, "nNeutrinoHitsNotReconstructed/I");
247  m_pTrueTree->Branch("nNeutrinoHitsReconstructed", &m_nNeutrinoHitsReconstructed, "nNeutrinoHitsReconstructed/I");
248  m_pTrueTree->Branch("nCosmicHits", &m_nCosmicHits, "nCosmicHits/I");
249  m_pTrueTree->Branch("nCosmicHitsFullyTagged", &m_nCosmicHitsFullyTagged, "nCosmicHitsFullyTagged/I");
250  m_pTrueTree->Branch("nCosmicHitsSemiTagged", &m_nCosmicHitsSemiTagged, "nCosmicHitsSemiTagged/I");
251  m_pTrueTree->Branch("nCosmicHitsNotTagged", &m_nCosmicHitsNotTagged, "nCosmicHitsNotTagged/I");
252  m_pTrueTree->Branch("nCosmicHitsNotReconstructed", &m_nCosmicHitsNotReconstructed, "nCosmicHitsNotReconstructed/I");
253  m_pTrueTree->Branch("nCosmicHitsReconstructed", &m_nCosmicHitsReconstructed, "nCosmicHitsReconstructed/I");
254 }
255 
256 //------------------------------------------------------------------------------------------------------------------------------------------
257 
259 {
260 }
261 
262 //------------------------------------------------------------------------------------------------------------------------------------------
263 
265 {
266  std::cout << " *** PFParticleCosmicAna::analyze(...) *** " << std::endl;
267 
268  //
269  // Note: I've made this is MicroBooNE-only module
270  //
271 
272  m_run = evt.run();
273  m_event = evt.id().event();
274 
275  std::cout << " Run: " << m_run << std::endl;
276  std::cout << " Event: " << m_event << std::endl;
277 
278 
279  // Collect True Particles
280  // ======================
281  HitVector hitVector;
282  MCTruthToMCParticles truthToParticles;
283  MCParticlesToMCTruth particlesToTruth;
284  MCParticlesToHits trueParticlesToHits;
285  HitsToMCParticles trueHitsToParticles;
286 
288  LArPandoraHelper::CollectMCParticles(evt, m_geantModuleLabel, truthToParticles, particlesToTruth);
289  LArPandoraHelper::BuildMCParticleHitMaps(evt, m_geantModuleLabel, hitVector, trueParticlesToHits, trueHitsToParticles,
291 
292 
293  // Collect Reco Particles
294  // ======================
295  PFParticleVector recoParticleVector;
296  PFParticlesToHits recoParticlesToHits;
297  HitsToPFParticles recoHitsToParticles;
298 
299  LArPandoraHelper::CollectPFParticles(evt, m_particleLabel, recoParticleVector);
300  LArPandoraHelper::BuildPFParticleHitMaps(evt, m_particleLabel, m_particleLabel, recoParticlesToHits, recoHitsToParticles,
301  (m_useDaughterPFParticles ? LArPandoraHelper::kAddDaughters : LArPandoraHelper::kIgnoreDaughters));
302 
303  std::cout << " PFParticles: " << recoParticleVector.size() << std::endl;
304 
305 
306  // Collect Reco Tracks
307  // ===================
308  TrackVector recoTrackVector;
309  PFParticlesToTracks recoParticlesToTracks;
310  LArPandoraHelper::CollectTracks(evt, m_trackfitLabel, recoTrackVector, recoParticlesToTracks);
311 
312 
313  // Collect Cosmic Tags
314  // =====================
315  CosmicTagVector recoCosmicTagVector;
316  TracksToCosmicTags recoTracksToCosmicTags;
317  LArPandoraHelper::CollectCosmicTags(evt, m_cosmicLabel, recoCosmicTagVector, recoTracksToCosmicTags);
318 
319 
320  // Analyse Reconstructed Particles
321  // ===============================
322  this->FillRecoTree(recoParticlesToHits, recoParticlesToTracks, recoTracksToCosmicTags);
323 
324 
325  // Analyse True Hits
326  // =================
327  this->FillTrueTree(hitVector, trueHitsToParticles, recoHitsToParticles, particlesToTruth, recoParticlesToTracks, recoTracksToCosmicTags);
328 }
329 
330 //------------------------------------------------------------------------------------------------------------------------------------------
331 
332 void PFParticleCosmicAna::FillRecoTree(const PFParticlesToHits &recoParticlesToHits, const PFParticlesToTracks &recoParticlesToTracks,
333  const TracksToCosmicTags &recoTracksToCosmicTags)
334 {
335  // Set up Geometry Service
336  // =======================
338 
339  const double xmin(0.0);
340  const double xmax(2.0 * theGeometry->DetHalfWidth());
341  const double ymin(-theGeometry->DetHalfHeight());
342  const double ymax(+theGeometry->DetHalfHeight());
343  const double zmin(0.0);
344  const double zmax(theGeometry->DetLength());
345  const double xyzCut(m_cosmicContainmentCut);
346 
347  m_index = 0;
348 
349  m_self = 0;
350  m_pdgCode = 0;
351  m_isTrackLike = 0;
352  m_isPrimary = 0;
353  m_cosmicScore = 0.f;
354 
355  m_trackVtxX = 0.f;
356  m_trackVtxY = 0.f;
357  m_trackVtxZ = 0.f;
358  m_trackEndX = 0.f;
359  m_trackEndY = 0.f;
360  m_trackEndZ = 0.f;
361  m_trackVtxDirX = 0.f;
362  m_trackVtxDirY = 0.f;
363  m_trackVtxDirZ = 0.f;
364  m_trackEndDirX = 0.f;
365  m_trackEndDirY = 0.f;
366  m_trackEndDirZ = 0.f;
367  m_trackLength = 0.f;
368  m_trackWidthX = 0.f;
369  m_trackWidthY = 0.f;
370  m_trackWidthZ = 0.f;
371  m_trackVtxDeltaYZ = 0.f;
372  m_trackEndDeltaYZ = 0.f;
373 
376 
377  m_nTracks = 0;
378  m_nHits = 0;
379 
380  // Loop over Reco Particles
381  // ========================
382  for (PFParticlesToHits::const_iterator iter1 = recoParticlesToHits.begin(), iterEnd1 = recoParticlesToHits.end();
383  iter1 != iterEnd1; ++iter1)
384  {
385  const art::Ptr<recob::PFParticle> recoParticle = iter1->first;
386 
387  const HitVector &hitVector = iter1->second;
388  if (hitVector.empty())
389  continue;
390 
391  PFParticlesToTracks::const_iterator iter2 = recoParticlesToTracks.find(recoParticle);
392  if (recoParticlesToTracks.end() == iter2)
393  continue;
394 
395  const TrackVector &trackVector = iter2->second;
396  if (trackVector.empty())
397  continue;
398 
399  m_nHits = hitVector.size();
400  m_nTracks = trackVector.size();
401 
402  m_self = recoParticle->Self();
403  m_pdgCode = recoParticle->PdgCode();
404  m_isPrimary = recoParticle->IsPrimary();
406  m_cosmicScore = this->GetCosmicScore(recoParticle, recoParticlesToTracks, recoTracksToCosmicTags);
407 
408  m_trackVtxX = 0.f;
409  m_trackVtxY = 0.f;
410  m_trackVtxZ = 0.f;
411  m_trackEndX = 0.f;
412  m_trackEndY = 0.f;
413  m_trackEndZ = 0.f;
414  m_trackVtxDirX = 0.f;
415  m_trackVtxDirY = 0.f;
416  m_trackVtxDirZ = 0.f;
417  m_trackEndDirX = 0.f;
418  m_trackEndDirY = 0.f;
419  m_trackEndDirZ = 0.f;
420  m_trackLength = 0.f;
421  m_trackWidthX = 0.f;
422  m_trackWidthY = 0.f;
423  m_trackWidthZ = 0.f;
424  m_trackVtxDeltaYZ = 0.f;
425  m_trackEndDeltaYZ = 0.f;
426 
429 
430  for (TrackVector::const_iterator iter3 = trackVector.begin(), iterEnd3 = trackVector.end(); iter3 != iterEnd3; ++iter3)
431  {
432  const art::Ptr<recob::Track> track = *iter3;
433  const float trackLength(track->Length());
434 
435  if (trackLength < m_trackLength)
436  continue;
437 
438  m_trackLength = trackLength;
439 
440  const auto &trackVtxPosition = track->Vertex();
441  const auto &trackVtxDirection = track->VertexDirection();
442  const auto &trackEndPosition = track->End();
443  const auto &trackEndDirection = track->EndDirection();
444 
445  m_trackVtxX = trackVtxPosition.x();
446  m_trackVtxY = trackVtxPosition.y();
447  m_trackVtxZ = trackVtxPosition.z();
448  m_trackVtxDirX = trackVtxDirection.x();
449  m_trackVtxDirY = trackVtxDirection.y();
450  m_trackVtxDirZ = trackVtxDirection.z();
451  m_trackEndX = trackEndPosition.x();
452  m_trackEndY = trackEndPosition.y();
453  m_trackEndZ = trackEndPosition.z();
454  m_trackEndDirX = trackEndDirection.x();
455  m_trackEndDirY = trackEndDirection.y();
456  m_trackEndDirZ = trackEndDirection.z();
457 
458  m_trackWidthX = std::fabs(m_trackEndX - m_trackVtxX);
459  m_trackWidthY = std::fabs(m_trackEndY - m_trackVtxY);
460  m_trackWidthZ = std::fabs(m_trackEndZ - m_trackVtxZ);
461 
462  m_trackVtxDeltaYZ = std::min((ymax - m_trackVtxY), std::min((m_trackVtxZ - zmin), (zmax - m_trackVtxZ)));
463  m_trackEndDeltaYZ = std::min((m_trackEndY - ymin), std::min((m_trackEndZ - zmin), (zmax - m_trackEndZ)));
464 
465  m_trackVtxContained = ((m_trackVtxX > xmin + xyzCut && m_trackVtxX < xmax - xyzCut) &&
466  (m_trackVtxY > ymin + xyzCut && m_trackVtxY < ymax - xyzCut) &&
467  (m_trackVtxZ > zmin + xyzCut && m_trackVtxZ < zmax - xyzCut));
468  m_trackEndContained = ((m_trackEndX > xmin + xyzCut && m_trackEndX < xmax - xyzCut) &&
469  (m_trackEndY > ymin + xyzCut && m_trackEndY < ymax - xyzCut) &&
470  (m_trackEndZ > zmin + xyzCut && m_trackEndZ < zmax - xyzCut));
471  }
472 
473  std::cout << " PFParticle: [" << m_index << "] nHits=" << m_nHits
474  << ", nTracks=" << m_nTracks << ", cosmicScore=" << m_cosmicScore << std::endl;
475 
476  m_pRecoTree->Fill();
477  ++m_index;
478  }
479 }
480 
481 //------------------------------------------------------------------------------------------------------------------------------------------
482 
483 void PFParticleCosmicAna::FillTrueTree(const HitVector &hitVector, const HitsToMCParticles &trueHitsToParticles,
484  const HitsToPFParticles &recoHitsToParticles, const MCParticlesToMCTruth &particlesToTruth, const PFParticlesToTracks &particlesToTracks,
485  const TracksToCosmicTags &tracksToCosmicTags)
486 {
487  m_nHits = 0;
488 
489  m_nNeutrinoHits = 0;
495 
496  m_nCosmicHits = 0;
502 
503  for (HitVector::const_iterator iter2 = hitVector.begin(), iterEnd2 = hitVector.end(); iter2 != iterEnd2; ++iter2)
504  {
505  const art::Ptr<recob::Hit> hit = *iter2;
506 
507  HitsToMCParticles::const_iterator iter3 = trueHitsToParticles.find(hit);
508  if (trueHitsToParticles.end() == iter3)
509  continue;
510 
511  const art::Ptr<simb::MCParticle> trueParticle = iter3->second;
512 
513  MCParticlesToMCTruth::const_iterator iter4 = particlesToTruth.find(trueParticle);
514  if (particlesToTruth.end() == iter4)
515  throw cet::exception("LArPandora") << " PFParticleCosmicAna::analyze --- Found a true particle without any ancestry information ";
516 
517  const art::Ptr<simb::MCTruth> truth = iter4->second;
518 
519  float cosmicScore(-0.2);
520 
521  HitsToPFParticles::const_iterator iter5 = recoHitsToParticles.find(hit);
522  if (recoHitsToParticles.end() != iter5)
523  {
524  const art::Ptr<recob::PFParticle> particle = iter5->second;
525  cosmicScore = this->GetCosmicScore(particle, particlesToTracks, tracksToCosmicTags);
526  }
527 
528  ++m_nHits;
529 
530  if (truth->NeutrinoSet())
531  {
532  ++m_nNeutrinoHits;
533 
534  if (cosmicScore >= 0) ++m_nNeutrinoHitsReconstructed;
536 
537  if (cosmicScore > 0.51) ++m_nNeutrinoHitsFullyTagged;
538  else if ( cosmicScore > 0.39) ++m_nNeutrinoHitsSemiTagged;
540  }
541  else
542  {
543  ++m_nCosmicHits;
544 
545  if (cosmicScore >= 0) ++m_nCosmicHitsReconstructed;
547 
548  if (cosmicScore > 0.51) ++m_nCosmicHitsFullyTagged;
549  else if ( cosmicScore > 0.39) ++m_nCosmicHitsSemiTagged;
550  else ++m_nCosmicHitsNotTagged;
551  }
552  }
553 
554  m_pTrueTree->Fill();
555 }
556 
557 //------------------------------------------------------------------------------------------------------------------------------------------
558 
560  const TracksToCosmicTags &recoTracksToCosmicTags) const
561 {
562  float cosmicScore(0.f);
563 
564  // Get cosmic tags associated with this particle
565  PFParticlesToTracks::const_iterator iter2 = recoParticlesToTracks.find(particle);
566  if (recoParticlesToTracks.end() != iter2)
567  {
568  for (TrackVector::const_iterator iter3 = iter2->second.begin(), iterEnd3 = iter2->second.end(); iter3 != iterEnd3; ++iter3)
569  {
570  const art::Ptr<recob::Track> track = *iter3;
571 
572  TracksToCosmicTags::const_iterator iter4 = recoTracksToCosmicTags.find(track);
573  if (recoTracksToCosmicTags.end() != iter4)
574  {
575  for (CosmicTagVector::const_iterator iter5 = iter4->second.begin(), iterEnd5 = iter4->second.end();
576  iter5 != iterEnd5; ++iter5)
577  {
578  const art::Ptr<anab::CosmicTag> cosmicTag = *iter5;
579  if (cosmicTag->CosmicScore() > cosmicScore)
580  cosmicScore = cosmicTag->CosmicScore();
581  }
582  }
583  }
584  }
585 
586  return cosmicScore;
587 }
588 
589 } //namespace lar_pandora
static void BuildPFParticleHitMaps(const PFParticleVector &particleVector, const PFParticlesToSpacePoints &particlesToSpacePoints, const SpacePointsToHits &spacePointsToHits, PFParticlesToHits &particlesToHits, HitsToPFParticles &hitsToParticles, const DaughterMode daughterMode=kUseDaughters)
Build mapping between PFParticles and Hits using PFParticle/SpacePoint/Hit maps.
std::map< art::Ptr< recob::Hit >, art::Ptr< simb::MCParticle > > HitsToMCParticles
geo::Length_t DetHalfWidth(geo::TPCID const &tpcid) const
Returns the half width of the active volume of the specified TPC.
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
std::string string
Definition: nybbler.cc:12
void FillTrueTree(const HitVector &hitVector, const HitsToMCParticles &trueHitsToParticles, const HitsToPFParticles &recoHitsToParticles, const MCParticlesToMCTruth &particlesToTruth, const PFParticlesToTracks &particlesToTracks, const TracksToCosmicTags &tracksToCosmicTags)
Fill track-level variables using input maps between reconstructed objects.
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
Vector_t VertexDirection() const
Definition: Track.h:132
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
intermediate_table::const_iterator const_iterator
std::vector< art::Ptr< anab::CosmicTag > > CosmicTagVector
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::map< art::Ptr< recob::PFParticle >, TrackVector > PFParticlesToTracks
float & CosmicScore()
Definition: CosmicTag.h:61
art framework interface to geometry description
std::map< art::Ptr< recob::Track >, CosmicTagVector > TracksToCosmicTags
void reconfigure(fhicl::ParameterSet const &pset)
geo::Length_t DetHalfHeight(geo::TPCID const &tpcid) const
Returns the half height of the active volume of the specified TPC.
double Length(size_t p=0) const
Access to various track properties.
Definition: Track.h:167
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
std::map< art::Ptr< simb::MCParticle >, HitVector > MCParticlesToHits
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
std::map< art::Ptr< simb::MCTruth >, MCParticleVector > MCTruthToMCParticles
T get(std::string const &key) const
Definition: ParameterSet.h:271
std::map< art::Ptr< recob::PFParticle >, HitVector > PFParticlesToHits
Point_t const & Vertex() const
Definition: Track.h:124
geo::Length_t DetLength(geo::TPCID const &tpcid) const
Returns the length of the active volume of the specified TPC.
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:86
std::vector< art::Ptr< recob::Track > > TrackVector
RunNumber_t run() const
Definition: DataViewImpl.cc:71
static void CollectTracks(const art::Event &evt, const std::string &label, TrackVector &trackVector, PFParticlesToTracks &particlesToTracks)
Collect the reconstructed PFParticles and associated Tracks from the ART event record.
static void CollectPFParticles(const art::Event &evt, const std::string &label, PFParticleVector &particleVector)
Collect the reconstructed PFParticles from the ART event record.
void FillRecoTree(const PFParticlesToHits &recoParticlesToHits, const PFParticlesToTracks &recoParticlesToTracks, const TracksToCosmicTags &recoTracksToCosmicTags)
Fill event-level variables using input maps between reconstructed objects.
static void CollectHits(const art::Event &evt, const std::string &label, HitVector &hitVector)
Collect the reconstructed Hits from the ART event record.
Detector simulation of raw signals on wires.
std::vector< art::Ptr< recob::Hit > > HitVector
float GetCosmicScore(const art::Ptr< recob::PFParticle > particle, const PFParticlesToTracks &recoParticlesToTracks, const TracksToCosmicTags &recoTracksToCosmicTags) const
Get cosmic score for a PFParticle using track-level information.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::PFParticle > > HitsToPFParticles
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Vector_t EndDirection() const
Definition: Track.h:133
static bool IsTrack(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as track-like.
Provides recob::Track data product.
EventNumber_t event() const
Definition: EventID.h:116
Point_t const & End() const
Definition: Track.h:125
bool NeutrinoSet() const
Definition: MCTruth.h:78
TCEvent evt
Definition: DataStructs.cxx:7
static void BuildMCParticleHitMaps(const art::Event &evt, const HitVector &hitVector, const SimChannelVector &simChannelVector, HitsToTrackIDEs &hitsToTrackIDEs)
Collect the links from reconstructed hits to their true energy deposits.
static void CollectMCParticles(const art::Event &evt, const std::string &label, MCParticleVector &particleVector)
Collect a vector of MCParticle objects from the ART event record.
helper function for LArPandoraInterface producer module
PFParticleCosmicAna(fhicl::ParameterSet const &pset)
Constructor.
EventID id() const
Definition: Event.cc:34
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
static void CollectCosmicTags(const art::Event &evt, const std::string &label, CosmicTagVector &cosmicTagVector, TracksToCosmicTags &tracksToCosmicTags)
Collect a vector of cosmic tags from the ART event record.