All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LArPandoraEventDump_module.cc
Go to the documentation of this file.
1 /**
2  * @file larpandora/LArPandoraEventBuilding/LArPandoraEventDump.cc
3  *
4  * @brief module for lar pandora event dump
5  */
6 
7 #include "art/Framework/Core/EDAnalyzer.h"
8 #include "art/Framework/Core/ModuleMacros.h"
9 #include "art/Framework/Principal/Event.h"
10 
11 #include "fhiclcpp/ParameterSet.h"
12 
14 
26 
28 
29 namespace lar_pandora
30 {
31 
32 class LArPandoraEventDump : public art::EDAnalyzer
33 {
34 public:
35  explicit LArPandoraEventDump(fhicl::ParameterSet const & pset);
36 
37  LArPandoraEventDump(LArPandoraEventDump const &) = delete;
41 
42  void analyze(art::Event const & evt) override;
43 
44 private:
45  template <class T>
46  using Collection = art::Handle< std::vector<T> >;
47 
48  template <class T>
49  using Association = art::FindManyP<T>;
50 
51  /**
52  * @brief Class holding the handle for all of the data types from Pandora
53  */
55  {
56  public:
57  /**
58  * @brief Default constructor
59  *
60  * @param evt the art event
61  * @param pandoraLabel the pandora producer label
62  * @param trackLabel the track producer label (optional)
63  * @param showerLabel the shower producer label (optional)
64  */
65  PandoraData(const art::Event &evt, const std::string &pandoraLabel, const std::string &trackLabel = "", const std::string &showerLabel = "");
66 
67  /**
68  * @brief Default destructor
69  */
70  ~PandoraData();
71 
72  // Collections
82 
83  // Associations
85  Association<recob::Cluster> *m_pPFParticleToClusterAssociation; ///< The PFParticle to cluster association
86  Association<recob::SpacePoint> *m_pPFParticleToSpacePointAssociation; ///< The PFParticle to space point association
87  Association<recob::Vertex> *m_pPFParticleToVertexAssociation; ///< The PFParticle to vertex association
88  Association<recob::Track> *m_pPFParticleToTrackAssociation; ///< The PFParticle to track association
89  Association<recob::Shower> *m_pPFParticleToShowerAssociation; ///< The PFParticle to shower association
90  Association<recob::Slice> *m_pPFParticleToSliceAssociation; ///< The PFParticle to slice association
91 
92  Association<recob::Hit> *m_pClusterToHitAssociation; ///< The Cluster to hit association
93  Association<recob::Hit> *m_pSpacePointToHitAssociation; ///< The SpacePoint to hit association
94  Association<recob::Hit> *m_pTrackToHitAssociation; ///< The Track to hit association
95  Association<recob::Hit> *m_pShowerToHitAssociation; ///< The Shower to hit association
96  Association<recob::Hit> *m_pSliceToHitAssociation; ///< The Slice to hit association
97 
98  Association<recob::PCAxis> *m_pShowerToPCAxisAssociation; ///< The Shower to PCAxis association
99 
100  private:
101  /**
102  * @brief Load a collection from the event
103  *
104  * @param evt the art event
105  * @param label the producer label
106  * @param collection the output collection
107  */
108  template <class T>
109  void LoadCollection(const art::Event &evt, const std::string &label, Collection<T> &collection);
110 
111  /**
112  * @brief Load an association from the event
113  *
114  * @param evt the art event
115  * @param label the producer label
116  * @param collection the input collection (from which object are associated)
117  * @param pAssociation the output association
118  */
119  template <class T, class U>
120  void LoadAssociation(const art::Event &evt, const std::string &label, const Collection<T> &collection, Association<U> *&pAssociation);
121  };
122 
123  // -------------------------------------------------------------------------------------------------------------------------------------
124 
125  /**
126  * @brief Print the metadata about the event
127  *
128  * @param evt the art event
129  */
130  void PrintEventMetadata(const art::Event &evt) const;
131 
132  /**
133  * @brief Print a summary of the event similar to the standard event dump
134  *
135  * @param data the pandora collections and associations
136  */
137  void PrintEventSummary(const PandoraData &data) const;
138 
139  /**
140  * @brief Print the full PFParticle Hierarchy
141  *
142  * @param data the pandora collections and associations
143  */
144  void PrintPFParticleHierarchy(const PandoraData &data) const;
145 
146  /**
147  * @brief Build the map from PFParticle ID to PFParticle from the input data
148  *
149  * @param data the pandora collections and associations
150  * @param pfParticleMap the output PFParticle map
151  */
152  void BuildPFParticleMap(const PandoraData &data, PFParticleMap &pfParticleMap) const;
153 
154  /**
155  * @brief Print a given PFParticle
156  *
157  * @param particle the particle to print
158  * @param pfParticleMap the input mapping from PFParticle ID to PFParticle
159  * @param data the pandora collections and associations
160  * @param depth the number of characters to indent
161  */
162  void PrintParticle(const art::Ptr< recob::PFParticle > &particle, const PFParticleMap &pfParticleMap, const PandoraData &data, const unsigned int depth) const;
163 
164  /**
165  * @brief Print a given Hit
166  *
167  * @param hit the hit to print
168  * @param depth the number of characters to indent
169  */
170  void PrintHit(const art::Ptr<recob::Hit> &hit, const unsigned int depth) const;
171 
172  /**
173  * @brief Print a given Slice
174  *
175  * @param slice the slice to print
176  * @param data the pandora collections and associations
177  * @param depth the number of characters to indent
178  */
179  void PrintSlice(const art::Ptr<recob::Slice> &slice, const PandoraData &data, const unsigned int depth) const;
180 
181  /**
182  * @brief Print a given Cluster
183  *
184  * @param cluster the cluster to print
185  * @param data the pandora collections and associations
186  * @param depth the number of characters to indent
187  */
188  void PrintCluster(const art::Ptr<recob::Cluster> &cluster, const PandoraData &data, const unsigned int depth) const;
189 
190  /**
191  * @brief Print a given Vertex
192  *
193  * @param vertex the vertex to print
194  * @param depth the number of characters to indent
195  */
196  void PrintVertex(const art::Ptr<recob::Vertex> &vertex, const unsigned int depth) const;
197 
198  /**
199  * @brief Print a given SpacePoint
200  *
201  * @param spacePoint the spacePoint to print
202  * @param data the pandora collections and associations
203  * @param depth the number of characters to indent
204  */
205  void PrintSpacePoint(const art::Ptr<recob::SpacePoint> &spacePoint, const PandoraData &data, const unsigned int depth) const;
206 
207  /**
208  * @brief Print a given Track
209  *
210  * @param track the track to print
211  * @param data the pandora collections and associations
212  * @param depth the number of characters to indent
213  */
214  void PrintTrack(const art::Ptr<recob::Track> &track, const PandoraData &data, const unsigned int depth) const;
215 
216  /**
217  * @brief Print a given Shower
218  *
219  * @param shower the shower to print
220  * @param data the pandora collections and associations
221  * @param depth the number of characters to indent
222  */
223  void PrintShower(const art::Ptr<recob::Shower> &shower, const PandoraData &data, const unsigned int depth) const;
224 
225  /**
226  * @brief Print a horizontal line
227  *
228  * @param depth the number of characters to indent
229  */
230  void PrintRule(const unsigned int depth) const;
231 
232  /**
233  * @brief Print a title line
234  *
235  * @param name the title name
236  * @param depth the number of characters to indent
237  */
238  void PrintTitle(const std::string &name, const unsigned int depth) const;
239 
240  /**
241  * @brief Print a given property with the correct amount of whitespace
242  *
243  * @param name the property name
244  * @param value the property value
245  * @param depth the number of characters to indent
246  */
247  template<class T>
248  void PrintProperty(const std::string &name, const T &value, const unsigned int depth) const;
249 
250  std::string m_verbosityLevel; ///< The level of verbosity to use
251  std::string m_pandoraLabel; ///< The label of the Pandora pattern recognition producer
252  std::string m_trackLabel; ///< The track producer label
253  std::string m_showerLabel; ///< The shower producer label
254 };
255 
256 DEFINE_ART_MODULE(LArPandoraEventDump)
257 
258 } // namespace lar_pandora
259 
260 //------------------------------------------------------------------------------------------------------------------------------------------
261 // implementation follows
262 
263 namespace lar_pandora
264 {
265 
266 LArPandoraEventDump::LArPandoraEventDump(fhicl::ParameterSet const &pset) :
267  EDAnalyzer(pset),
268  m_pandoraLabel(pset.get<std::string>("PandoraLabel")),
269  m_trackLabel(pset.get<std::string>("TrackLabel" , "")),
270  m_showerLabel(pset.get<std::string>("ShowerLabel", ""))
271 {
272  m_verbosityLevel = pset.get<std::string>("VerbosityLevel");
273  std::transform(m_verbosityLevel.begin(), m_verbosityLevel.end(), m_verbosityLevel.begin(), ::tolower);
274 
275  if (m_verbosityLevel != "brief" &&
276  m_verbosityLevel != "summary" &&
277  m_verbosityLevel != "detailed" &&
278  m_verbosityLevel != "extreme")
279  {
280  throw cet::exception("LArPandoraEventDump") << "Unknown verbosity level: " << m_verbosityLevel << std::endl;
281  }
282 }
283 
284 //------------------------------------------------------------------------------------------------------------------------------------------
285 
286 void LArPandoraEventDump::analyze(art::Event const & evt)
287 {
288  // Load the Pandora owned collections from the event
290 
291  this->PrintEventMetadata(evt);
292  this->PrintEventSummary(data);
293 
294  if (m_verbosityLevel != "brief")
295  this->PrintPFParticleHierarchy(data);
296 }
297 
298 //------------------------------------------------------------------------------------------------------------------------------------------
299 
300 void LArPandoraEventDump::PrintEventMetadata(const art::Event &evt) const
301 {
302  std::cout << std::string(80, '=') << std::endl;
303  std::cout << "run : " << evt.run() << std::endl;
304  std::cout << "subRun : " << evt.subRun() << std::endl;
305  std::cout << "event : " << evt.event() << std::endl;
306  std::cout << std::endl;
307 }
308 
309 //------------------------------------------------------------------------------------------------------------------------------------------
310 
312 {
313  std::cout << std::string(80, '-') << std::endl;
314  std::cout << "Collection sizes" << std::endl;
315  std::cout << std::string(80, '-') << std::endl;
316 
317  std::cout << "PFParticle : " << data.m_pfParticleCollection->size() << std::endl;
318  std::cout << "PFParticleMetadata : " << data.m_pfParticleMetadataCollection->size() << std::endl;
319  std::cout << "Cluster : " << data.m_clusterCollection->size() << std::endl;
320  std::cout << "SpacePoint : " << data.m_spacePointCollection->size() << std::endl;
321  std::cout << "Vertex : " << data.m_vertexCollection->size() << std::endl;
322  std::cout << "Track : " << data.m_trackCollection->size() << std::endl;
323  std::cout << "Shower : " << data.m_showerCollection->size() << std::endl;
324  std::cout << "PCAxis : " << data.m_pcAxisCollection->size() << std::endl;
325  std::cout << "Slice : " << data.m_sliceCollection->size() << std::endl;
326  std::cout << std::endl;
327 
328  std::cout << std::string(80, '-') << std::endl;
329  std::cout << "Association sizes" << std::endl;
330  std::cout << std::string(80, '-') << std::endl;
331 
333  std::cout << "PFParticle -> Metadata : " << data.m_pPFParticleToMetadataAssociation->size() << std::endl;
334 
336  std::cout << "PFParticle -> Cluster : " << data.m_pPFParticleToClusterAssociation->size() << std::endl;
337 
339  std::cout << "PFParticle -> SpacePoint : " << data.m_pPFParticleToSpacePointAssociation->size() << std::endl;
340 
342  std::cout << "PFParticle -> Vertex : " << data.m_pPFParticleToVertexAssociation->size() << std::endl;
343 
345  std::cout << "PFParticle -> Track : " << data.m_pPFParticleToTrackAssociation->size() << std::endl;
346 
348  std::cout << "PFParticle -> Shower : " << data.m_pPFParticleToShowerAssociation->size() << std::endl;
349 
351  std::cout << "PFParticle -> Slice : " << data.m_pPFParticleToSliceAssociation->size() << std::endl;
352 
354  std::cout << "Cluster -> Hit : " << data.m_pClusterToHitAssociation->size() << std::endl;
355 
357  std::cout << "SpacePoint -> Hit : " << data.m_pSpacePointToHitAssociation->size() << std::endl;
358 
359  if (data.m_pTrackToHitAssociation)
360  std::cout << "Track -> Hit : " << data.m_pTrackToHitAssociation->size() << std::endl;
361 
362  if (data.m_pShowerToHitAssociation)
363  std::cout << "Shower -> Hit : " << data.m_pShowerToHitAssociation->size() << std::endl;
364 
366  std::cout << "Shower -> PCAxis : " << data.m_pShowerToPCAxisAssociation->size() << std::endl;
367 
368  if (data.m_pSliceToHitAssociation)
369  std::cout << "Slice -> Hit : " << data.m_pSliceToHitAssociation->size() << std::endl;
370 
371  std::cout << std::endl;
372 }
373 
374 //------------------------------------------------------------------------------------------------------------------------------------------
375 
377 {
378  // Get the mapping from PFParticle ID to PFParticle
379  PFParticleMap pfParticleMap;
380  this->BuildPFParticleMap(data, pfParticleMap);
381 
382  // Print all primary PFParticles
383  for (unsigned int i = 0; i < data.m_pfParticleCollection->size(); ++i)
384  {
385  const art::Ptr<recob::PFParticle> particle(data.m_pfParticleCollection, i);
386 
387  if (!particle->IsPrimary())
388  continue;
389 
390  this->PrintParticle(particle, pfParticleMap, data, 0);
391  }
392 }
393 
394 //------------------------------------------------------------------------------------------------------------------------------------------
395 
397 {
398  for (unsigned int i = 0; i < data.m_pfParticleCollection->size(); ++i)
399  {
400  const art::Ptr<recob::PFParticle> particle(data.m_pfParticleCollection, i);
401  pfParticleMap[particle->Self()] = particle;
402  }
403 }
404 
405 //------------------------------------------------------------------------------------------------------------------------------------------
406 
407 void LArPandoraEventDump::PrintParticle(const art::Ptr< recob::PFParticle > &particle, const PFParticleMap &pfParticleMap,
408  const PandoraData &data, const unsigned int depth) const
409 {
410  this->PrintRule(depth);
411  this->PrintTitle("PFParticle", depth);
412  this->PrintRule(depth);
413 
414  // Print the PFParticle details
415  this->PrintProperty("Key", particle.key(), depth);
416  this->PrintProperty("Id", particle->Self(), depth);
417  this->PrintProperty("PDG", particle->PdgCode(), depth);
418  this->PrintProperty("IsPrimary", particle->IsPrimary(), depth);
419 
420  if (!particle->IsPrimary())
421  this->PrintProperty("Parent", particle->Parent(), depth);
422 
423  // Print the metadata
425  {
426  const auto &metadata(data.m_pPFParticleToMetadataAssociation->at(particle.key()));
427  this->PrintProperty("# Metadata", metadata.size(), depth);
428 
429  for (const auto &metadatum : metadata)
430  {
431  const auto &propertiesMap(metadatum->GetPropertiesMap());
432  this->PrintProperty("# Properties", propertiesMap.size(), depth + 2);
433 
434  for (const auto &propertiesMapEntry : propertiesMap)
435  this->PrintProperty(propertiesMapEntry.first, propertiesMapEntry.second, depth + 4);
436  }
437  }
438 
439  // Print the slices
441  {
442  const auto &slices(data.m_pPFParticleToSliceAssociation->at(particle.key()));
443  this->PrintProperty("# Slices", slices.size(), depth);
444 
445  if (m_verbosityLevel != "summary")
446  {
447  for (const auto &slice : slices)
448  this->PrintSlice(slice, data, depth + 2);
449  }
450 
451  }
452 
453  // Print the clusters
455  {
456  const auto &clusters(data.m_pPFParticleToClusterAssociation->at(particle.key()));
457  this->PrintProperty("# Clusters", clusters.size(), depth);
458 
459  if (m_verbosityLevel != "summary")
460  {
461  for (const auto &cluster : clusters)
462  this->PrintCluster(cluster, data, depth + 2);
463  }
464  }
465 
466  // Print the space points
468  {
469  const auto &spacePoints(data.m_pPFParticleToSpacePointAssociation->at(particle.key()));
470  this->PrintProperty("# SpacePoints", spacePoints.size(), depth);
471 
472  if (m_verbosityLevel != "summary")
473  {
474  for (const auto &spacePoint : spacePoints)
475  this->PrintSpacePoint(spacePoint, data, depth + 2);
476  }
477  }
478 
479  // Print the vertices
481  {
482  const auto &vertices(data.m_pPFParticleToVertexAssociation->at(particle.key()));
483  this->PrintProperty("# Vertices", vertices.size(), depth);
484 
485  if (m_verbosityLevel != "summary")
486  {
487  for (const auto &vertex : vertices)
488  this->PrintVertex(vertex, depth + 2);
489  }
490  }
491 
492  // Print the tracks
494  {
495  const auto &tracks(data.m_pPFParticleToTrackAssociation->at(particle.key()));
496  this->PrintProperty("# Tracks", tracks.size(), depth);
497 
498  if (m_verbosityLevel != "summary")
499  {
500  for (const auto &track : tracks)
501  this->PrintTrack(track, data, depth + 2);
502  }
503  }
504 
505  // Print the showers
507  {
508  const auto &showers(data.m_pPFParticleToShowerAssociation->at(particle.key()));
509  this->PrintProperty("# Showers", showers.size(), depth);
510 
511  if (m_verbosityLevel != "summary")
512  {
513  for (const auto &shower : showers)
514  this->PrintShower(shower, data, depth + 2);
515  }
516  }
517 
518  // Print the daughters
519  this->PrintProperty("# Daughters", particle->NumDaughters(), depth);
520  this->PrintRule(depth);
521 
522  for (auto &daughterId : particle->Daughters())
523  {
524  const auto daughterIter(pfParticleMap.find(daughterId));
525 
526  if (daughterIter == pfParticleMap.end())
527  throw cet::exception("LArPandoraEventDump") << "Couldn't find daughter of PFParticle in the PFParticle map";
528 
529  const auto &daughter(daughterIter->second);
530  this->PrintParticle(daughter, pfParticleMap, data, depth + 4);
531  }
532 }
533 
534 //------------------------------------------------------------------------------------------------------------------------------------------
535 
536 void LArPandoraEventDump::PrintHit(const art::Ptr<recob::Hit> &hit, const unsigned int depth) const
537 {
538  this->PrintTitle("Hit", depth);
539  this->PrintProperty("Key", hit.key(), depth + 2);
540  this->PrintProperty("Channel", hit->Channel(), depth + 2);
541  this->PrintProperty("View", hit->View(), depth + 2);
542  this->PrintProperty("Peak time", hit->PeakTime(), depth + 2);
543  this->PrintProperty("RMS", hit->RMS(), depth + 2);
544 }
545 
546 //------------------------------------------------------------------------------------------------------------------------------------------
547 
548 void LArPandoraEventDump::PrintSlice(const art::Ptr<recob::Slice> &slice, const PandoraData &data, const unsigned int depth) const
549 {
550  this->PrintTitle("Slice", depth);
551  this->PrintProperty("Key", slice.key(), depth + 2);
552  this->PrintProperty("ID", slice->ID(), depth + 2);
553 
554  if (!data.m_pSliceToHitAssociation)
555  return;
556 
557  const auto &hits(data.m_pSliceToHitAssociation->at(slice.key()));
558  this->PrintProperty("# Hits", hits.size(), depth + 2);
559 
560  if (m_verbosityLevel != "extreme")
561  return;
562 
563  // Print each associated hit
564  for (const auto &hit : hits)
565  this->PrintHit(hit, depth + 4);
566 }
567 
568 //------------------------------------------------------------------------------------------------------------------------------------------
569 
570 void LArPandoraEventDump::PrintCluster(const art::Ptr<recob::Cluster> &cluster, const PandoraData &data, const unsigned int depth) const
571 {
572  this->PrintTitle("Cluster", depth);
573  this->PrintProperty("Key", cluster.key(), depth + 2);
574  this->PrintProperty("ID", cluster->ID(), depth + 2);
575  this->PrintProperty("View", cluster->View(), depth + 2);
576 
577  if (!data.m_pClusterToHitAssociation)
578  return;
579 
580  const auto &hits(data.m_pClusterToHitAssociation->at(cluster.key()));
581  this->PrintProperty("# Hits", hits.size(), depth + 2);
582 
583  if (m_verbosityLevel == "detailed")
584  return;
585 
586  // Print each associated hit
587  for (const auto &hit : hits)
588  this->PrintHit(hit, depth + 4);
589 }
590 
591 //------------------------------------------------------------------------------------------------------------------------------------------
592 
593 void LArPandoraEventDump::PrintSpacePoint(const art::Ptr<recob::SpacePoint> &spacePoint, const PandoraData &data, const unsigned int depth) const
594 {
595  this->PrintTitle("SpacePoint", depth);
596  this->PrintProperty("Key", spacePoint.key(), depth + 2);
597  this->PrintProperty("ID", spacePoint->ID(), depth + 2);
598  const auto &position(spacePoint->XYZ());
599  this->PrintProperty("X", position[0], depth + 2);
600  this->PrintProperty("Y", position[1], depth + 2);
601  this->PrintProperty("Z", position[2], depth + 2);
602 
604  return;
605 
606  const auto &hits(data.m_pSpacePointToHitAssociation->at(spacePoint.key()));
607  this->PrintProperty("# Hits", hits.size(), depth + 2);
608 
609  if (m_verbosityLevel == "detailed")
610  return;
611 
612  // Print each associated hit
613  for (const auto &hit : hits)
614  this->PrintHit(hit, depth + 4);
615 }
616 
617 //------------------------------------------------------------------------------------------------------------------------------------------
618 
619 void LArPandoraEventDump::PrintVertex(const art::Ptr<recob::Vertex> &vertex, const unsigned int depth) const
620 {
621  this->PrintTitle("Vertex", depth);
622  this->PrintProperty("Key", vertex.key(), depth + 2);
623  this->PrintProperty("ID", vertex->ID(), depth + 2);
624  const auto &position(vertex->position());
625  this->PrintProperty("X", position.X(), depth + 2);
626  this->PrintProperty("Y", position.Y(), depth + 2);
627  this->PrintProperty("Z", position.Z(), depth + 2);
628 }
629 
630 //------------------------------------------------------------------------------------------------------------------------------------------
631 
632 void LArPandoraEventDump::PrintTrack(const art::Ptr<recob::Track> &track, const PandoraData &data, const unsigned int depth) const
633 {
634  this->PrintTitle("Track", depth);
635  this->PrintProperty("Key", track.key(), depth + 2);
636  this->PrintProperty("# Trajectory points", track->NumberTrajectoryPoints(), depth + 2);
637  this->PrintProperty("Length", track->Length(), depth + 2);
638 
639  if (!data.m_pTrackToHitAssociation)
640  return;
641 
642  const auto &hits(data.m_pTrackToHitAssociation->at(track.key()));
643  this->PrintProperty("# Hits", hits.size(), depth + 2);
644 
645  if (m_verbosityLevel == "detailed")
646  return;
647 
648  // Print each associated hit
649  for (const auto &hit : hits)
650  this->PrintHit(hit, depth + 4);
651 }
652 
653 //------------------------------------------------------------------------------------------------------------------------------------------
654 
655 void LArPandoraEventDump::PrintShower(const art::Ptr<recob::Shower> &shower, const PandoraData &data, const unsigned int depth) const
656 {
657  this->PrintTitle("Shower", depth);
658  this->PrintProperty("Key", shower.key(), depth + 2);
659  this->PrintProperty("ID", shower->ID(), depth + 2);
660  this->PrintProperty("StartX", shower->ShowerStart().X(), depth + 2);
661  this->PrintProperty("StartY", shower->ShowerStart().Y(), depth + 2);
662  this->PrintProperty("StartZ", shower->ShowerStart().Z(), depth + 2);
663  this->PrintProperty("Length", shower->Length(), depth + 2);
664  this->PrintProperty("OpenAngle", shower->OpenAngle(), depth + 2);
665 
667  {
668  const auto &pcAxes(data.m_pShowerToPCAxisAssociation->at(shower.key()));
669  this->PrintProperty("# PCAxes", pcAxes.size(), depth + 2);
670 
671  for (const auto &pcAxis : pcAxes)
672  {
673  this->PrintTitle("PCAxis", depth + 4);
674  this->PrintProperty("Key", pcAxis.key(), depth + 6);
675  this->PrintProperty("ID", pcAxis->getID(), depth + 6);
676  this->PrintProperty("# Hits used", pcAxis->getNumHitsUsed(), depth + 6);
677  }
678  }
679 
680  if (!data.m_pShowerToHitAssociation)
681  return;
682 
683  const auto &hits(data.m_pShowerToHitAssociation->at(shower.key()));
684  this->PrintProperty("# Hits", hits.size(), depth + 2);
685 
686  if (m_verbosityLevel == "detailed")
687  return;
688 
689  // Print each associated hit
690  for (const auto &hit : hits)
691  this->PrintHit(hit, depth + 4);
692 }
693 
694 //------------------------------------------------------------------------------------------------------------------------------------------
695 
696 void LArPandoraEventDump::PrintRule(const unsigned int depth) const
697 {
698  const unsigned int nDashes(std::max(0, 120 - static_cast<int>(depth)));
699 
700  std::cout << std::string(depth, ' ') << std::string(nDashes, '-') << std::endl;
701 }
702 
703 //------------------------------------------------------------------------------------------------------------------------------------------
704 
705 void LArPandoraEventDump::PrintTitle(const std::string &name, const unsigned int depth) const
706 {
707  std::cout << std::string(depth, ' ') << name << std::endl;
708 }
709 
710 
711 //------------------------------------------------------------------------------------------------------------------------------------------
712 
713 template<class T>
714 void LArPandoraEventDump::PrintProperty(const std::string &name, const T &value, const unsigned int depth) const
715 {
716  // The separation between the property name and property value
717  const unsigned int separation(std::max(0, 32 - static_cast<int>(depth)));
718 
719  std::cout << std::string(depth, ' ') << std::setw(separation) << std::left << ("- " + name) << value << std::endl;
720 }
721 
722 //------------------------------------------------------------------------------------------------------------------------------------------
723 //------------------------------------------------------------------------------------------------------------------------------------------
724 
725 LArPandoraEventDump::PandoraData::PandoraData(const art::Event &evt, const std::string &pandoraLabel, const std::string &trackLabel,
726  const std::string &showerLabel) :
727  m_pPFParticleToMetadataAssociation(nullptr),
728  m_pPFParticleToClusterAssociation(nullptr),
729  m_pPFParticleToSpacePointAssociation(nullptr),
730  m_pPFParticleToVertexAssociation(nullptr),
731  m_pPFParticleToTrackAssociation(nullptr),
732  m_pPFParticleToShowerAssociation(nullptr),
733  m_pPFParticleToSliceAssociation(nullptr),
734  m_pClusterToHitAssociation(nullptr),
735  m_pSpacePointToHitAssociation(nullptr),
736  m_pTrackToHitAssociation(nullptr),
737  m_pShowerToHitAssociation(nullptr),
738  m_pSliceToHitAssociation(nullptr),
739  m_pShowerToPCAxisAssociation(nullptr)
740 {
741 
742  // Load the collections
743  this->LoadCollection(evt, pandoraLabel, m_pfParticleCollection);
744  this->LoadCollection(evt, pandoraLabel, m_pfParticleMetadataCollection);
745  this->LoadCollection(evt, pandoraLabel, m_clusterCollection);
746  this->LoadCollection(evt, pandoraLabel, m_spacePointCollection);
747  this->LoadCollection(evt, pandoraLabel, m_vertexCollection);
748  this->LoadCollection(evt, trackLabel , m_trackCollection);
749  this->LoadCollection(evt, showerLabel , m_showerCollection);
750  this->LoadCollection(evt, showerLabel , m_pcAxisCollection);
751  this->LoadCollection(evt, pandoraLabel, m_sliceCollection);
752 
753  // Load the associations
762 
765 
769 }
770 
771 //------------------------------------------------------------------------------------------------------------------------------------------
772 
774 {
775  // Clean up all heap memory
776  delete m_pPFParticleToMetadataAssociation;
777  delete m_pPFParticleToClusterAssociation;
778  delete m_pPFParticleToSpacePointAssociation;
779  delete m_pPFParticleToVertexAssociation;
780  delete m_pPFParticleToTrackAssociation;
781  delete m_pPFParticleToShowerAssociation;
782  delete m_pPFParticleToSliceAssociation;
783  delete m_pClusterToHitAssociation;
784  delete m_pSpacePointToHitAssociation;
785  delete m_pTrackToHitAssociation;
786  delete m_pShowerToHitAssociation;
787  delete m_pShowerToPCAxisAssociation;
788  delete m_pSliceToHitAssociation;
789 }
790 
791 //------------------------------------------------------------------------------------------------------------------------------------------
792 
793 template <class T>
794 void LArPandoraEventDump::PandoraData::LoadCollection(const art::Event &evt, const std::string &label, Collection<T> &collection)
795 {
796  if (label.empty())
797  return;
798 
799  evt.getByLabel(label, collection);
800 }
801 
802 //------------------------------------------------------------------------------------------------------------------------------------------
803 
804 template <class T, class U>
805 void LArPandoraEventDump::PandoraData::LoadAssociation(const art::Event &evt, const std::string &label, const Collection<T> &collection, Association<U> *&pAssociation)
806 {
807  if (label.empty())
808  return;
809 
810  if (pAssociation)
811  throw cet::exception("LArPandoraEventDump") << "Association supplied type has already been loaded!";
812 
813  pAssociation = new Association<U>(collection, evt, label);
814 }
815 
816 } // namespace lar_pandora
817 
void BuildPFParticleMap(const PandoraData &data, PFParticleMap &pfParticleMap) const
Build the map from PFParticle ID to PFParticle from the input data.
process_name vertex
Definition: cheaterreco.fcl:51
Association< recob::Slice > * m_pPFParticleToSliceAssociation
The PFParticle to slice association.
void PrintRule(const unsigned int depth) const
Print a horizontal line.
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
std::string m_trackLabel
The track producer label.
Association< recob::Hit > * m_pClusterToHitAssociation
The Cluster to hit association.
Collection< recob::Cluster > m_clusterCollection
The Cluster handle.
ClusterModuleLabel join with tracks
static constexpr Sample_t transform(Sample_t sample)
void PrintEventMetadata(const art::Event &evt) const
Print the metadata about the event.
process_name cluster
Definition: cheaterreco.fcl:51
LArPandoraEventDump(fhicl::ParameterSet const &pset)
Association< recob::PCAxis > * m_pShowerToPCAxisAssociation
The Shower to PCAxis association.
Declaration of signal hit object.
Collection< recob::SpacePoint > m_spacePointCollection
The SpacePoint handle.
Association< recob::Hit > * m_pSliceToHitAssociation
The Slice to hit association.
void PrintShower(const art::Ptr< recob::Shower > &shower, const PandoraData &data, const unsigned int depth) const
Print a given Shower.
void PrintVertex(const art::Ptr< recob::Vertex > &vertex, const unsigned int depth) const
Print a given Vertex.
art::Handle< std::vector< T > > Collection
LArPandoraEventDump & operator=(LArPandoraEventDump const &)=delete
void PrintParticle(const art::Ptr< recob::PFParticle > &particle, const PFParticleMap &pfParticleMap, const PandoraData &data, const unsigned int depth) const
Print a given PFParticle.
process_name use argoneut_mc_hitfinder track
process_name hit
Definition: cheaterreco.fcl:51
void PrintHit(const art::Ptr< recob::Hit > &hit, const unsigned int depth) const
Print a given Hit.
process_name shower
Definition: cheaterreco.fcl:51
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
void PrintEventSummary(const PandoraData &data) const
Print a summary of the event similar to the standard event dump.
Association< recob::Shower > * m_pPFParticleToShowerAssociation
The PFParticle to shower association.
void LoadAssociation(const art::Event &evt, const std::string &label, const Collection< T > &collection, Association< U > *&pAssociation)
Load an association from the event.
Association< recob::Cluster > * m_pPFParticleToClusterAssociation
The PFParticle to cluster association.
Collection< recob::PCAxis > m_pcAxisCollection
The PCAxis handle.
std::string m_showerLabel
The shower producer label.
void PrintTrack(const art::Ptr< recob::Track > &track, const PandoraData &data, const unsigned int depth) const
Print a given Track.
Collection< recob::Slice > m_sliceCollection
The Slice handle.
void PrintSpacePoint(const art::Ptr< recob::SpacePoint > &spacePoint, const PandoraData &data, const unsigned int depth) const
Print a given SpacePoint.
walls no left
Definition: selectors.fcl:105
Association< recob::Track > * m_pPFParticleToTrackAssociation
The PFParticle to track association.
Collection< recob::Vertex > m_vertexCollection
The Vertex handle.
Declaration of cluster object.
std::string m_pandoraLabel
The label of the Pandora pattern recognition producer.
Association< larpandoraobj::PFParticleMetadata > * m_pPFParticleToMetadataAssociation
The PFParticle to metadata association.
Provides recob::Track data product.
Collection< recob::Shower > m_showerCollection
The Shower handle.
std::vector< TCSlice > slices
Definition: DataStructs.cxx:13
void PrintTitle(const std::string &name, const unsigned int depth) const
Print a title line.
void analyze(art::Event const &evt) override
Association< recob::SpacePoint > * m_pPFParticleToSpacePointAssociation
The PFParticle to space point association.
void PrintSlice(const art::Ptr< recob::Slice > &slice, const PandoraData &data, const unsigned int depth) const
Print a given Slice.
Association< recob::Hit > * m_pSpacePointToHitAssociation
The SpacePoint to hit association.
Association< recob::Hit > * m_pShowerToHitAssociation
The Shower to hit association.
std::string m_verbosityLevel
The level of verbosity to use.
void LoadCollection(const art::Event &evt, const std::string &label, Collection< T > &collection)
Load a collection from the event.
then echo fcl name
void PrintCluster(const art::Ptr< recob::Cluster > &cluster, const PandoraData &data, const unsigned int depth) const
Print a given Cluster.
temporary value
Collection< recob::PFParticle > m_pfParticleCollection
The PFParticle handle.
PandoraData(const art::Event &evt, const std::string &pandoraLabel, const std::string &trackLabel="", const std::string &showerLabel="")
Default constructor.
Collection< larpandoraobj::PFParticleMetadata > m_pfParticleMetadataCollection
The PFParticleMetadata handle.
TCEvent evt
Definition: DataStructs.cxx:8
void PrintPFParticleHierarchy(const PandoraData &data) const
Print the full PFParticle Hierarchy.
Association< recob::Vertex > * m_pPFParticleToVertexAssociation
The PFParticle to vertex association.
void PrintProperty(const std::string &name, const T &value, const unsigned int depth) const
Print a given property with the correct amount of whitespace.
Class holding the handle for all of the data types from Pandora.
helper function for LArPandoraInterface producer module
BEGIN_PROLOG could also be cout
Association< recob::Hit > * m_pTrackToHitAssociation
The Track to hit association.
Collection< recob::Track > m_trackCollection
The Track handle.