Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
LArHierarchyHelper.h
Go to the documentation of this file.
1
8#ifndef LAR_HIERARCHY_HELPER_H
9#define LAR_HIERARCHY_HELPER_H 1
10
12
14
17
18namespace lar_content
19{
20
25{
26public:
31 {
32 public:
37
43 FoldingParameters(const bool foldDynamic, const float cosAngleTolerance = 0.9962f);
44
53 FoldingParameters(const int foldingTier);
54
59 int m_tier;
60 };
61
66 {
67 public:
72
79 QualityCuts(const float minPurity, const float minCompleteness);
80
81 const float m_minPurity;
82 const float m_minCompleteness;
83 };
84
89 {
90 public:
95 {
96 public:
101
106
115 ReconstructabilityCriteria(const unsigned int minHits, const unsigned int minHitsForGoodView, const unsigned int minGoodViews,
116 const bool removeNeutrons);
117
118 const unsigned int m_minHits;
119 const unsigned int m_minHitsForGoodView;
120 const unsigned int m_minGoodViews;
121 const bool m_removeNeutrons;
122 };
123
124 class Node;
125 typedef std::vector<const Node *> NodeVector;
126 typedef std::list<const Node *> NodeList;
127 typedef std::map<const pandora::MCParticle *, NodeVector> MCNodeVectorMap;
128
132 class Node
133 {
134 public:
142 Node(MCHierarchy &hierarchy, const pandora::MCParticle *pMCParticle, const int tier = 1);
143
152 Node(MCHierarchy &hierarchy, const pandora::MCParticleList &mcParticleList, const pandora::CaloHitList &caloHitList, const int tier = 1);
153
157 virtual ~Node();
158
164 bool IsReconstructable() const;
165
172 void FillHierarchy(const pandora::MCParticle *pRoot, const FoldingParameters &foldParameters);
173
179 void FillFlat(const pandora::MCParticle *pRoot);
180
186 const NodeVector &GetChildren() const;
187
193 int GetId() const;
194
201
208
214 const pandora::CaloHitList &GetCaloHits() const;
215
221 int GetParticleId() const;
222
228 int GetHierarchyTier() const;
229
235 bool IsNeutrinoInduced() const;
236
242 bool IsTestBeamParticle() const;
243
249 bool IsCosmicRay() const;
250
256 bool IsLeadingLepton() const;
257
263 const std::string ToString(const std::string &prefix) const;
264
265 private:
269 void SetLeadingLepton();
270
276 int m_tier;
277 int m_pdg;
279
280 friend class MCHierarchy;
281 };
282
286 MCHierarchy();
287
293 MCHierarchy(const ReconstructabilityCriteria &recoCriteria);
294
298 virtual ~MCHierarchy();
299
323 void FillHierarchy(const pandora::MCParticleList &mcParticleList, const pandora::CaloHitList &caloHitList, const FoldingParameters &foldParameters);
324
334 void InterpretHierarchy(const pandora::MCParticle *const pRoot, pandora::MCParticleList &leadingParticles,
335 pandora::MCParticleList &childParticles, const float cosAngleTolerance) const;
336
343
351 const NodeVector &GetInteractions(const pandora::MCParticle *pRoot) const;
352
358 void GetRootMCParticles(pandora::MCParticleList &rootMCParticles) const;
359
366 void GetFlattenedNodes(const pandora::MCParticle *const pRoot, NodeVector &nodeVector) const;
367
373 void RegisterNode(const Node *pNode);
374
380 const std::string ToString() const;
381
382 private:
391 void CollectContinuations(const pandora::MCParticle *pRoot, pandora::MCParticleList &continuingParticles,
392 pandora::MCParticleList &childParticles, const float cosAngleTolerance) const;
393
401 bool IsReconstructable(const pandora::MCParticle *pMCParticle) const;
402
410 bool IsReconstructable(const pandora::CaloHitList &caloHits) const;
411
414 std::map<const pandora::MCParticle *, pandora::CaloHitList> m_mcToHitsMap;
415 std::map<const Node *, int> m_nodeToIdMap;
417 };
418
423 {
424 public:
425 class Node;
426 typedef std::vector<const Node *> NodeVector;
427 typedef std::list<const Node *> NodeList;
428 typedef std::map<const pandora::ParticleFlowObject *, NodeVector> RecoNodeVectorMap;
429
433 class Node
434 {
435 public:
442 Node(const RecoHierarchy &hierarchy, const pandora::ParticleFlowObject *pPfo);
443
451 Node(const RecoHierarchy &hierarchy, const pandora::PfoList &pfoList, const pandora::CaloHitList &caloHitList);
452
456 virtual ~Node();
457
464 void FillHierarchy(const pandora::ParticleFlowObject *pRoot, const FoldingParameters &foldParameters);
465
471 void FillFlat(const pandora::ParticleFlowObject *pRoot);
472
478 const NodeVector &GetChildren() const;
479
485 const pandora::PfoList &GetRecoParticles() const;
486
493
499 const pandora::CaloHitList &GetCaloHits() const;
500
507 int GetParticleId() const;
508
514 const std::string ToString(const std::string &prefix) const;
515
516 private:
522 int m_pdg;
523 };
524
529
533 virtual ~RecoHierarchy();
534
557 void FillHierarchy(const pandora::PfoList &pfoList, const FoldingParameters &foldParameters);
558
566 const NodeVector &GetInteractions(const pandora::ParticleFlowObject *pRoot) const;
567
573 void GetRootPfos(pandora::PfoList &rootPfos) const;
574
581 void GetFlattenedNodes(const pandora::ParticleFlowObject *const pRoot, NodeVector &nodeVector) const;
582
589
595 const std::string ToString() const;
596
597 private:
599 };
600
605 {
606 public:
612 MCMatches(const MCHierarchy::Node *pMCParticle);
613
620 void AddRecoMatch(const RecoHierarchy::Node *pReco, const int nSharedHits);
621
627 const MCHierarchy::Node *GetMC() const;
628
635
643 unsigned int GetSharedHits(const RecoHierarchy::Node *pReco) const;
644
653 float GetPurity(const RecoHierarchy::Node *pReco, const bool adcWeighted = false) const;
654
664 float GetPurity(const RecoHierarchy::Node *pReco, const pandora::HitType view, const bool adcWeighted = false) const;
665
674 float GetCompleteness(const RecoHierarchy::Node *pReco, const bool adcWeighted = false) const;
675
685 float GetCompleteness(const RecoHierarchy::Node *pReco, const pandora::HitType view, const bool adcWeighted = false) const;
686
692 size_t GetNRecoMatches() const;
693
701 bool IsQuality(const QualityCuts &qualityCuts) const;
702
703 private:
713 float GetPurity(const pandora::CaloHitVector &intersection, const pandora::CaloHitList &recoHits, const bool adcWeighted) const;
714
724 float GetCompleteness(const pandora::CaloHitVector &intersection, const pandora::CaloHitList &mcHits, const bool adcWeighted) const;
725
729 };
730
731 typedef std::vector<MCMatches> MCMatchesVector;
732 typedef std::map<const pandora::MCParticle *, MCMatchesVector> InteractionInfo;
733
738 {
739 public:
746 MatchInfo(const MCHierarchy &mcHierarchy, const RecoHierarchy &recoHierarchy);
747
755 MatchInfo(const MCHierarchy &mcHierarchy, const RecoHierarchy &recoHierarchy, const QualityCuts &qualityCuts);
756
761 void Match();
762
770 const MCMatchesVector &GetMatches(const pandora::MCParticle *const pRoot) const;
771
776
784 unsigned int GetNMCNodes(const pandora::MCParticle *const pRoot) const;
785
793 unsigned int GetNNeutrinoMCNodes(const pandora::MCParticle *const pRoot) const;
794
802 unsigned int GetNCosmicRayMCNodes(const pandora::MCParticle *const pRoot) const;
803
811 unsigned int GetNTestBeamMCNodes(const pandora::MCParticle *const pRoot) const;
812
818 const MCHierarchy &GetMCHierarchy() const;
819
825 const RecoHierarchy &GetRecoHierarchy() const;
826
832 void GetRootMCParticles(pandora::MCParticleList &rootMCParticles) const;
833
839 const QualityCuts &GetQualityCuts() const;
840
847 void Print(const MCHierarchy &mcHierarchy) const;
848
849 private:
855 };
856
865 static void FillMCHierarchy(const pandora::MCParticleList &mcParticleList, const pandora::CaloHitList &caloHitList,
866 const FoldingParameters &foldParameters, MCHierarchy &hierarchy);
867
875 static void FillRecoHierarchy(const pandora::PfoList &pfoList, const FoldingParameters &foldParameters, RecoHierarchy &hierarchy);
876
882 static void MatchHierarchies(MatchInfo &matchInfo);
883
884private:
885 typedef std::set<const pandora::MCParticle *> MCParticleSet;
886 typedef std::set<const pandora::ParticleFlowObject *> PfoSet;
887
894 static void GetMCPrimaries(const pandora::MCParticle *pRoot, MCParticleSet &primaries);
895
902 static void GetRecoPrimaries(const pandora::ParticleFlowObject *pRoot, PfoSet &primaries);
903};
904
905//------------------------------------------------------------------------------------------------------------------------------------------
906//------------------------------------------------------------------------------------------------------------------------------------------
907
912
913//------------------------------------------------------------------------------------------------------------------------------------------
914
916{
917 return m_mcParticles;
918}
919
920//------------------------------------------------------------------------------------------------------------------------------------------
921
923{
924 return m_caloHits;
925}
926
927//------------------------------------------------------------------------------------------------------------------------------------------
928
930{
931 return m_mainParticle;
932}
933
934//------------------------------------------------------------------------------------------------------------------------------------------
935
937{
938 return m_pdg;
939}
940
941//------------------------------------------------------------------------------------------------------------------------------------------
942
944{
945 return m_tier;
946}
947
948//------------------------------------------------------------------------------------------------------------------------------------------
949
954
955//------------------------------------------------------------------------------------------------------------------------------------------
956
958{
959 return m_isLeadingLepton;
960}
961
962//------------------------------------------------------------------------------------------------------------------------------------------
963
965{
966 m_isLeadingLepton = true;
967}
968
969//------------------------------------------------------------------------------------------------------------------------------------------
970//------------------------------------------------------------------------------------------------------------------------------------------
971
976
977//------------------------------------------------------------------------------------------------------------------------------------------
978
983
984//------------------------------------------------------------------------------------------------------------------------------------------
985//------------------------------------------------------------------------------------------------------------------------------------------
986
988{
989 return m_pMCParticle;
990}
991
992//------------------------------------------------------------------------------------------------------------------------------------------
993
998
999//------------------------------------------------------------------------------------------------------------------------------------------
1000
1002{
1003 return m_recoNodes.size();
1004}
1005
1006//------------------------------------------------------------------------------------------------------------------------------------------
1007//------------------------------------------------------------------------------------------------------------------------------------------
1008
1010{
1011 if (m_matches.find(pRoot) == m_matches.end())
1012 throw pandora::StatusCodeException(pandora::STATUS_CODE_NOT_FOUND);
1013
1014 return m_matches.at(pRoot);
1015}
1016
1017//------------------------------------------------------------------------------------------------------------------------------------------
1018
1020{
1021 return m_unmatchedReco;
1022}
1023
1024//------------------------------------------------------------------------------------------------------------------------------------------
1025
1027{
1028 return m_mcHierarchy;
1029}
1030
1031//------------------------------------------------------------------------------------------------------------------------------------------
1032
1034{
1035 return m_recoHierarchy;
1036}
1037
1038//------------------------------------------------------------------------------------------------------------------------------------------
1039
1041{
1042 return m_qualityCuts;
1043}
1044
1045} // namespace lar_content
1046
1047#endif // #ifndef LAR_HIERARCHY_HELPER_H
Header file for the lar monte carlo particle helper helper class.
Header file for the pfo helper class.
Header file for the mc particle helper class.
Header file defining relevant internal typedefs, sort and string conversion functions.
bool m_foldToTier
Whether or not to apply folding based on particle tier.
bool m_foldDynamic
Whether or not to use process and topological information to make folding decisions.
float m_cosAngleTolerance
Cosine of the maximum angle at which topologies can be considered continuous.
int m_tier
If folding to a tier, the tier to be combined with its child particles.
bool m_foldToLeadingShowers
Whether or not to fold shower children to the leading shower particle.
bool IsTestBeamParticle() const
Check if this is a test beam particle.
const pandora::CaloHitList & GetCaloHits() const
Retrieve the CaloHits associated with this node.
int GetHierarchyTier() const
Retrieve the hierarchy tier of this node.
bool IsLeadingLepton() const
Returns whether or not this particle is the leading lepton in the event.
void FillFlat(const pandora::MCParticle *pRoot)
Fill this node by folding all descendent particles to this node.
void SetLeadingLepton()
Tags the particle as the leading lepton.
void FillHierarchy(const pandora::MCParticle *pRoot, const FoldingParameters &foldParameters)
Recursively fill the hierarchy based on the criteria established for this MCHierarchy.
const NodeVector & GetChildren() const
Return the vector of children for this node.
MCHierarchy & m_hierarchy
The parent MC hierarchy.
NodeVector m_children
The child nodes of this node.
pandora::MCParticleList m_mcParticles
The list of MC particles of which this node is composed.
const pandora::MCParticle * GetLeadingMCParticle() const
Retrieve the leading MC particle associated with this node.
bool IsReconstructable() const
Return whether or not this node should be considered reconstructable.
const pandora::MCParticleList & GetMCParticles() const
Retrieve the MC particles associated with this node.
const pandora::MCParticle * m_mainParticle
The leading MC particle for this node.
int GetId() const
Retrieve the unique ID of this node.
int m_pdg
The PDG code of the leading MC particle for this node.
int GetParticleId() const
Retrieve the PDG code for the leading particle in this node.
bool IsNeutrinoInduced() const
Check if this is a particle induced by a neutrino interaction.
pandora::CaloHitList m_caloHits
The list of calo hits of which this node is composed.
bool m_isLeadingLepton
Whether or not this node is the leading lepton.
bool IsCosmicRay() const
Check if this is a cosmic ray particle.
const unsigned int m_minHits
the minimum number of primary good Hits
const unsigned int m_minGoodViews
the minimum number of primary good views
const bool m_removeNeutrons
whether to remove neutrons and their downstream particles
const unsigned int m_minHitsForGoodView
the minimum number of Hits for a good view
const NodeVector & GetInteractions(const pandora::MCParticle *pRoot) const
Retrieve the root nodes in this hierarchy.
void GetFlattenedNodes(const pandora::MCParticle *const pRoot, NodeVector &nodeVector) const
Retrieve a flat vector of the ndoes in the hierarchy.
const std::string ToString() const
Produce a string representation of the hierarchy.
int m_nextNodeId
The ID to use for the next node.
const pandora::MCParticle * GetNeutrino() const
Retrieve the neutrino at the root of the hierarchy if it exists.
void InterpretHierarchy(const pandora::MCParticle *const pRoot, pandora::MCParticleList &leadingParticles, pandora::MCParticleList &childParticles, const float cosAngleTolerance) const
Interpret the hierarchy below a particular particle to determine if and how it should be folded....
std::map< const Node *, int > m_nodeToIdMap
A map from nodes to unique ids.
std::map< const pandora::MCParticle *, NodeVector > MCNodeVectorMap
void RegisterNode(const Node *pNode)
Register a node with the hierarchy.
void CollectContinuations(const pandora::MCParticle *pRoot, pandora::MCParticleList &continuingParticles, pandora::MCParticleList &childParticles, const float cosAngleTolerance) const
Identify downstream particles that represent continuations of the parent particle from a reconstructi...
void GetRootMCParticles(pandora::MCParticleList &rootMCParticles) const
Retrieve the root MC particles of the interaction hierarchies.
std::map< const pandora::MCParticle *, pandora::CaloHitList > m_mcToHitsMap
The map between MC particles and calo hits.
bool IsReconstructable(const pandora::MCParticle *pMCParticle) const
Checks if an individual particle meets reconstructability criteria.
MCNodeVectorMap m_interactions
Map from incident particles (e.g. neutrino) to primaries.
void FillHierarchy(const pandora::MCParticleList &mcParticleList, const pandora::CaloHitList &caloHitList, const FoldingParameters &foldParameters)
Creates an MC hierarchy representation. Without folding this will be a mirror image of the standard M...
ReconstructabilityCriteria m_recoCriteria
The criteria used to determine if the node is reconstructable.
size_t GetNRecoMatches() const
Get the number of reco nodes matched (both above and below quality cut thresholds) to the MC node.
bool IsQuality(const QualityCuts &qualityCuts) const
Get whether this match passes quality cuts.
const RecoHierarchy::NodeVector & GetRecoMatches() const
Retrieve the vector of matched reco nodes.
pandora::IntVector m_sharedHits
Number of shared hits for each match.
RecoHierarchy::NodeVector m_recoNodes
Matched reco nodes.
void AddRecoMatch(const RecoHierarchy::Node *pReco, const int nSharedHits)
Add a reconstructed node as a match for this MC node.
float GetCompleteness(const RecoHierarchy::Node *pReco, const bool adcWeighted=false) const
Retrieve the completeness of the match.
const MCHierarchy::Node * GetMC() const
Retrieve the MC node.
unsigned int GetSharedHits(const RecoHierarchy::Node *pReco) const
Retrieve the number of shared hits in the match.
const MCHierarchy::Node * m_pMCParticle
MC node associated with any matches.
float GetPurity(const RecoHierarchy::Node *pReco, const bool adcWeighted=false) const
Retrieve the purity of the match.
void Print(const MCHierarchy &mcHierarchy) const
Prints information about which reco nodes are matched to the MC nodes, information about hit sharing,...
RecoHierarchy::NodeVector m_unmatchedReco
The vector of unmatched reco nodes.
const RecoHierarchy & m_recoHierarchy
The Reco hierarchy for the matching procedure.
void GetRootMCParticles(pandora::MCParticleList &rootMCParticles) const
Retrieve the root MC particles of the interaction hierarchies.
InteractionInfo m_matches
The map between an interaction and the vector of good matches from MC to reco.
unsigned int GetNMCNodes(const pandora::MCParticle *const pRoot) const
Retrieve the number of MC nodes available to match.
const MCMatchesVector & GetMatches(const pandora::MCParticle *const pRoot) const
Retrieve the vector of matches (this will include null matches - i.e. MC nodes with no corresponding ...
QualityCuts m_qualityCuts
The quality cuts to be applied to matches.
unsigned int GetNTestBeamMCNodes(const pandora::MCParticle *const pRoot) const
Retrieve the number of test beam derived MC nodes available to match.
const RecoHierarchy & GetRecoHierarchy() const
Retrieve the reco hierarchy used for the matching.
const RecoHierarchy::NodeVector & GetUnmatchedReco() const
Retrieve the vector of unmatched reco nodes.
const MCHierarchy & m_mcHierarchy
The MC hierarchy for the matching procedure.
const MCHierarchy & GetMCHierarchy() const
Retrieve the MC hierarchy used for the matching.
unsigned int GetNCosmicRayMCNodes(const pandora::MCParticle *const pRoot) const
Retrieve the number of cosmic ray derived MC nodes available to match.
unsigned int GetNNeutrinoMCNodes(const pandora::MCParticle *const pRoot) const
Retrieve the number of neutrino interaction derived MC nodes available to match.
void Match()
Match the nodes in the MC and reco hierarchies.
const QualityCuts & GetQualityCuts() const
Retrieve the quality cuts for matching.
const float m_minPurity
The minimum purity for a match to be considered good.
const float m_minCompleteness
The minimum completeness for a match to be considered good.
void FillFlat(const pandora::ParticleFlowObject *pRoot)
Fill this node by folding all descendent particles to this node.
void FillHierarchy(const pandora::ParticleFlowObject *pRoot, const FoldingParameters &foldParameters)
Recursively fill the hierarchy based on the criteria established for this RecoHierarchy.
pandora::CaloHitList m_caloHits
The list of calo hits of which this node is composed.
const pandora::ParticleFlowObject * m_mainPfo
The leading particle flow object for this node.
pandora::PfoList m_pfos
The list of PFOs of which this node is composed.
const pandora::PfoList & GetRecoParticles() const
Retrieve the PFOs associated with this node.
NodeVector m_children
The child nodes of this nodea.
const pandora::CaloHitList & GetCaloHits() const
Retrieve the CaloHits associated with this node.
const NodeVector & GetChildren() const
Return the vector of children for this node.
int m_pdg
The particle ID (track = muon, shower = electron)
const RecoHierarchy & m_hierarchy
The parent reco hierarchy.
int GetParticleId() const
Retrieve the PDG code for the leading particle in this node Note, for reco objects the PDG codes repr...
const pandora::ParticleFlowObject * GetLeadingPfo() const
Retrieve the leading reco particle for this node.
const pandora::ParticleFlowObject * GetNeutrino() const
Retrieve the neutrino at the root of the hierarchy if it exists.
RecoNodeVectorMap m_interactions
Map from the root PFO (e.g. neutrino) to primaries.
void FillHierarchy(const pandora::PfoList &pfoList, const FoldingParameters &foldParameters)
Creates a reconstructed hierarchy representation. Without folding this will be a mirror image of the ...
const NodeVector & GetInteractions(const pandora::ParticleFlowObject *pRoot) const
Retrieve the root nodes in the hierarchy for a given interaction.
void GetRootPfos(pandora::PfoList &rootPfos) const
Retrieve the root particle flow objects of the interaction hierarchies.
std::map< const pandora::ParticleFlowObject *, NodeVector > RecoNodeVectorMap
void GetFlattenedNodes(const pandora::ParticleFlowObject *const pRoot, NodeVector &nodeVector) const
Retrieve a flat vector of the nodes in the hierarchy.
const std::string ToString() const
Produce a string representation of the hierarchy.
LArHierarchyHelper class.
static void GetRecoPrimaries(const pandora::ParticleFlowObject *pRoot, PfoSet &primaries)
Retrieves the primary PFOs from a list and returns the root (neutrino) for hierarchy,...
static void GetMCPrimaries(const pandora::MCParticle *pRoot, MCParticleSet &primaries)
Retrieves the primary MC particles from a list and returns the root (neutrino) for hierarchy,...
std::map< const pandora::MCParticle *, MCMatchesVector > InteractionInfo
std::set< const pandora::MCParticle * > MCParticleSet
static void MatchHierarchies(MatchInfo &matchInfo)
Finds the matches between reconstructed and MC hierarchies.
static void FillRecoHierarchy(const pandora::PfoList &pfoList, const FoldingParameters &foldParameters, RecoHierarchy &hierarchy)
Fill a reconstructed hierarchy based on the specified folding criteria (see RecoHierarchy::FillHierar...
std::vector< MCMatches > MCMatchesVector
static void FillMCHierarchy(const pandora::MCParticleList &mcParticleList, const pandora::CaloHitList &caloHitList, const FoldingParameters &foldParameters, MCHierarchy &hierarchy)
Fill an MC hierarchy based on the specified folding criteria (see MCHierarchy::FillHierarchy for deta...
std::set< const pandora::ParticleFlowObject * > PfoSet
MCParticle class.
Definition MCParticle.h:26
ParticleFlowObject class.
StatusCodeException class.
HitType
Calorimeter hit type enum.
MANAGED_CONTAINER< const MCParticle * > MCParticleList
std::vector< const CaloHit * > CaloHitVector
std::vector< int > IntVector
MANAGED_CONTAINER< const CaloHit * > CaloHitList
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList