7#include "art/Framework/Core/EDAnalyzer.h"
8#include "art/Framework/Core/ModuleMacros.h"
9#include "art/Framework/Principal/Event.h"
11#include "fhiclcpp/ParameterSet.h"
13#include "lardata/Utilities/AssociationUtil.h"
15#include "lardataobj/RecoBase/Cluster.h"
16#include "lardataobj/RecoBase/Hit.h"
17#include "lardataobj/RecoBase/PCAxis.h"
18#include "lardataobj/RecoBase/PFParticle.h"
19#include "lardataobj/RecoBase/PFParticleMetadata.h"
20#include "lardataobj/RecoBase/Seed.h"
21#include "lardataobj/RecoBase/Shower.h"
22#include "lardataobj/RecoBase/Slice.h"
23#include "lardataobj/RecoBase/SpacePoint.h"
24#include "lardataobj/RecoBase/Track.h"
25#include "lardataobj/RecoBase/Vertex.h"
40 void analyze(art::Event
const& evt)
override;
63 const std::string& pandoraLabel,
64 const std::string& trackLabel =
"",
65 const std::string& showerLabel =
"");
119 const std::string& label,
130 template <
class T,
class U>
132 const std::string& label,
176 void PrintParticle(
const art::Ptr<recob::PFParticle>& particle,
179 const unsigned int depth)
const;
187 void PrintHit(
const art::Ptr<recob::Hit>& hit,
const unsigned int depth)
const;
196 void PrintSlice(
const art::Ptr<recob::Slice>& slice,
198 const unsigned int depth)
const;
209 const unsigned int depth)
const;
217 void PrintVertex(
const art::Ptr<recob::Vertex>& vertex,
const unsigned int depth)
const;
228 const unsigned int depth)
const;
237 void PrintTrack(
const art::Ptr<recob::Track>& track,
239 const unsigned int depth)
const;
250 const unsigned int depth)
const;
257 void PrintRule(
const unsigned int depth)
const;
265 void PrintTitle(
const std::string& name,
const unsigned int depth)
const;
275 void PrintProperty(
const std::string& name,
const T& value,
const unsigned int depth)
const;
294 , m_pandoraLabel(pset.get<std::string>(
"PandoraLabel"))
295 , m_trackLabel(pset.get<std::string>(
"TrackLabel",
""))
296 , m_showerLabel(pset.get<std::string>(
"ShowerLabel",
""))
304 throw cet::exception(
"LArPandoraEventDump")
326 std::cout << std::string(80,
'=') << std::endl;
327 std::cout <<
"run : " << evt.run() << std::endl;
328 std::cout <<
"subRun : " << evt.subRun() << std::endl;
329 std::cout <<
"event : " << evt.event() << std::endl;
330 std::cout << std::endl;
337 std::cout << std::string(80,
'-') << std::endl;
338 std::cout <<
"Collection sizes" << std::endl;
339 std::cout << std::string(80,
'-') << std::endl;
351 std::cout << std::endl;
353 std::cout << std::string(80,
'-') << std::endl;
354 std::cout <<
"Association sizes" << std::endl;
355 std::cout << std::string(80,
'-') << std::endl;
366 std::cout <<
"PFParticle -> SpacePoint : "
409 std::cout << std::endl;
424 if (!particle->IsPrimary())
continue;
437 pfParticleMap[particle->Self()] = particle;
446 const unsigned int depth)
const
456 this->
PrintProperty(
"IsPrimary", particle->IsPrimary(), depth);
458 if (!particle->IsPrimary()) this->
PrintProperty(
"Parent", particle->Parent(), depth);
465 for (
const auto& metadatum : metadata) {
466 const auto& propertiesMap(metadatum->GetPropertiesMap());
467 this->
PrintProperty(
"# Properties", propertiesMap.size(), depth + 2);
469 for (
const auto& propertiesMapEntry : propertiesMap)
470 this->
PrintProperty(propertiesMapEntry.first, propertiesMapEntry.second, depth + 4);
480 for (
const auto& slice : slices)
491 for (
const auto&
cluster : clusters)
499 this->
PrintProperty(
"# SpacePoints", spacePoints.size(), depth);
502 for (
const auto& spacePoint : spacePoints)
513 for (
const auto& vertex : vertices)
524 for (
const auto& track : tracks)
535 for (
const auto&
shower : showers)
541 this->
PrintProperty(
"# Daughters", particle->NumDaughters(), depth);
544 for (
auto& daughterId : particle->Daughters()) {
545 const auto daughterIter(pfParticleMap.find(daughterId));
547 if (daughterIter == pfParticleMap.end())
548 throw cet::exception(
"LArPandoraEventDump")
549 <<
"Couldn't find daughter of PFParticle in the PFParticle map";
551 const auto& daughter(daughterIter->second);
552 this->
PrintParticle(daughter, pfParticleMap, data, depth + 4);
559 const unsigned int depth)
const
565 this->
PrintProperty(
"Peak time", hit->PeakTime(), depth + 2);
573 const unsigned int depth)
const
587 for (
const auto& hit : hits)
595 const unsigned int depth)
const
610 for (
const auto& hit : hits)
618 const unsigned int depth)
const
623 const auto& position(spacePoint->XYZ());
636 for (
const auto& hit : hits)
643 const unsigned int depth)
const
648 const auto& position(vertex->position());
658 const unsigned int depth)
const
662 this->
PrintProperty(
"# Trajectory points", track->NumberTrajectoryPoints(), depth + 2);
673 for (
const auto& hit : hits)
681 const unsigned int depth)
const
686 this->
PrintProperty(
"StartX", shower->ShowerStart().X(), depth + 2);
687 this->
PrintProperty(
"StartY", shower->ShowerStart().Y(), depth + 2);
688 this->
PrintProperty(
"StartZ", shower->ShowerStart().Z(), depth + 2);
690 this->
PrintProperty(
"OpenAngle", shower->OpenAngle(), depth + 2);
696 for (
const auto& pcAxis : pcAxes) {
700 this->
PrintProperty(
"# Hits used", pcAxis->getNumHitsUsed(), depth + 6);
712 for (
const auto& hit : hits)
720 const unsigned int nDashes(std::max(0, 120 -
static_cast<int>(depth)));
722 std::cout << std::string(depth,
' ') << std::string(nDashes,
'-') << std::endl;
729 std::cout << std::string(depth,
' ') << name << std::endl;
737 const unsigned int depth)
const
740 const unsigned int separation(std::max(0, 32 -
static_cast<int>(depth)));
742 std::cout << std::string(depth,
' ') << std::setw(separation) << std::left << (
"- " + name)
743 << value << std::endl;
750 const std::string& pandoraLabel,
751 const std::string& trackLabel,
752 const std::string& showerLabel)
753 : m_pPFParticleToMetadataAssociation(nullptr)
754 , m_pPFParticleToClusterAssociation(nullptr)
755 , m_pPFParticleToSpacePointAssociation(nullptr)
756 , m_pPFParticleToVertexAssociation(nullptr)
757 , m_pPFParticleToTrackAssociation(nullptr)
758 , m_pPFParticleToShowerAssociation(nullptr)
759 , m_pPFParticleToSliceAssociation(nullptr)
760 , m_pClusterToHitAssociation(nullptr)
761 , m_pSpacePointToHitAssociation(nullptr)
762 , m_pTrackToHitAssociation(nullptr)
763 , m_pShowerToHitAssociation(nullptr)
764 , m_pSliceToHitAssociation(nullptr)
765 , m_pShowerToPCAxisAssociation(nullptr)
808 delete m_pPFParticleToMetadataAssociation;
809 delete m_pPFParticleToClusterAssociation;
810 delete m_pPFParticleToSpacePointAssociation;
811 delete m_pPFParticleToVertexAssociation;
812 delete m_pPFParticleToTrackAssociation;
813 delete m_pPFParticleToShowerAssociation;
814 delete m_pPFParticleToSliceAssociation;
815 delete m_pClusterToHitAssociation;
816 delete m_pSpacePointToHitAssociation;
817 delete m_pTrackToHitAssociation;
818 delete m_pShowerToHitAssociation;
819 delete m_pShowerToPCAxisAssociation;
820 delete m_pSliceToHitAssociation;
827 const std::string& label,
830 if (label.empty())
return;
832 evt.getByLabel(label, collection);
837 template <
class T,
class U>
839 const std::string& label,
843 if (label.empty())
return;
846 throw cet::exception(
"LArPandoraEventDump")
847 <<
"Association supplied type has already been loaded!";
helper function for LArPandoraInterface producer module
Class holding the handle for all of the data types from Pandora.
Association< recob::Cluster > * m_pPFParticleToClusterAssociation
The PFParticle to cluster association.
Collection< recob::Cluster > m_clusterCollection
The Cluster handle.
Association< recob::SpacePoint > * m_pPFParticleToSpacePointAssociation
The PFParticle to space point association.
Association< recob::Hit > * m_pClusterToHitAssociation
The Cluster to hit association.
void LoadAssociation(const art::Event &evt, const std::string &label, const Collection< T > &collection, Association< U > *&pAssociation)
Load an association from the event.
Collection< recob::Track > m_trackCollection
The Track handle.
~PandoraData()
Default destructor.
Association< larpandoraobj::PFParticleMetadata > * m_pPFParticleToMetadataAssociation
The PFParticle to metadata association.
void LoadCollection(const art::Event &evt, const std::string &label, Collection< T > &collection)
Load a collection from the event.
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.
Collection< recob::Slice > m_sliceCollection
The Slice handle.
Association< recob::Track > * m_pPFParticleToTrackAssociation
The PFParticle to track association.
Collection< recob::Shower > m_showerCollection
The Shower handle.
Association< recob::Slice > * m_pPFParticleToSliceAssociation
The PFParticle to slice association.
Collection< recob::PFParticle > m_pfParticleCollection
The PFParticle handle.
Collection< recob::SpacePoint > m_spacePointCollection
The SpacePoint handle.
Collection< recob::PCAxis > m_pcAxisCollection
The PCAxis handle.
Association< recob::Hit > * m_pShowerToHitAssociation
The Shower to hit association.
Association< recob::Hit > * m_pTrackToHitAssociation
The Track to hit association.
Association< recob::Vertex > * m_pPFParticleToVertexAssociation
The PFParticle to vertex association.
Collection< recob::Vertex > m_vertexCollection
The Vertex handle.
Association< recob::Hit > * m_pSpacePointToHitAssociation
The SpacePoint to hit association.
Association< recob::Hit > * m_pSliceToHitAssociation
The Slice to hit association.
Association< recob::Shower > * m_pPFParticleToShowerAssociation
The PFParticle to shower association.
Association< recob::PCAxis > * m_pShowerToPCAxisAssociation
The Shower to PCAxis association.
LArPandoraEventDump & operator=(LArPandoraEventDump const &)=delete
void PrintCluster(const art::Ptr< recob::Cluster > &cluster, const PandoraData &data, const unsigned int depth) const
Print a given Cluster.
void PrintHit(const art::Ptr< recob::Hit > &hit, const unsigned int depth) const
Print a given Hit.
void PrintEventSummary(const PandoraData &data) const
Print a summary of the event similar to the standard event dump.
void PrintSpacePoint(const art::Ptr< recob::SpacePoint > &spacePoint, const PandoraData &data, const unsigned int depth) const
Print a given SpacePoint.
void PrintEventMetadata(const art::Event &evt) const
Print the metadata about the event.
void PrintVertex(const art::Ptr< recob::Vertex > &vertex, const unsigned int depth) const
Print a given Vertex.
void PrintProperty(const std::string &name, const T &value, const unsigned int depth) const
Print a given property with the correct amount of whitespace.
void PrintPFParticleHierarchy(const PandoraData &data) const
Print the full PFParticle Hierarchy.
void PrintTrack(const art::Ptr< recob::Track > &track, const PandoraData &data, const unsigned int depth) const
Print a given Track.
art::Handle< std::vector< T > > Collection
std::string m_pandoraLabel
The label of the Pandora pattern recognition producer.
void PrintRule(const unsigned int depth) const
Print a horizontal line.
void BuildPFParticleMap(const PandoraData &data, PFParticleMap &pfParticleMap) const
Build the map from PFParticle ID to PFParticle from the input data.
std::string m_verbosityLevel
The level of verbosity to use.
std::string m_trackLabel
The track producer label.
std::string m_showerLabel
The shower producer label.
void analyze(art::Event const &evt) override
LArPandoraEventDump & operator=(LArPandoraEventDump &&)=delete
void PrintSlice(const art::Ptr< recob::Slice > &slice, const PandoraData &data, const unsigned int depth) const
Print a given Slice.
LArPandoraEventDump(LArPandoraEventDump &&)=delete
void PrintShower(const art::Ptr< recob::Shower > &shower, const PandoraData &data, const unsigned int depth) const
Print a given Shower.
art::FindManyP< T > Association
void PrintParticle(const art::Ptr< recob::PFParticle > &particle, const PFParticleMap &pfParticleMap, const PandoraData &data, const unsigned int depth) const
Print a given PFParticle.
LArPandoraEventDump(fhicl::ParameterSet const &pset)
LArPandoraEventDump(LArPandoraEventDump const &)=delete
void PrintTitle(const std::string &name, const unsigned int depth) const
Print a title line.
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap