LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::LArHierarchyHelper::RecoHierarchy::Node Class Reference

Node class. More...

#include "LArHierarchyHelper.h"

Public Member Functions

 Node (const RecoHierarchy &hierarchy, const pandora::ParticleFlowObject *pPfo, const int tier=1)
 Create a node with a primary PFO. More...
 
 Node (const RecoHierarchy &hierarchy, const pandora::PfoList &pfoList, const pandora::CaloHitList &caloHitList, const int tier=1)
 Create a node from a list of PFOs. More...
 
virtual ~Node ()
 Destructor. More...
 
void FillHierarchy (const pandora::ParticleFlowObject *pRoot, const FoldingParameters &foldParameters)
 Recursively fill the hierarchy based on the criteria established for this RecoHierarchy. More...
 
void FillFlat (const pandora::ParticleFlowObject *pRoot)
 Fill this node by folding all descendent particles to this node. More...
 
const NodeVectorGetChildren () const
 Return the vector of children for this node. More...
 
const pandora::PfoList & GetRecoParticles () const
 Retrieve the PFOs associated with this node. More...
 
const pandora::ParticleFlowObject * GetLeadingPfo () const
 Retrieve the leading reco particle for this node. More...
 
const pandora::CaloHitList & GetCaloHits () const
 Retrieve the CaloHits associated with this node. More...
 
int GetParticleId () const
 Retrieve the PDG code for the leading particle in this node Note, for reco objects the PDG codes represent tracks (muon PDG) and showers (electron PDG) More...
 
int GetHierarchyTier () const
 Retrieve the hierarchy tier of this node. More...
 
const std::string ToString (const std::string &prefix) const
 Produce a string representation of the hierarchy. More...
 

Private Attributes

const RecoHierarchym_hierarchy
 The parent reco hierarchy. More...
 
pandora::PfoList m_pfos
 The list of PFOs of which this node is composed. More...
 
pandora::CaloHitList m_caloHits
 The list of calo hits of which this node is composed. More...
 
NodeVector m_children
 The child nodes of this node. More...
 
const pandora::ParticleFlowObject * m_mainPfo
 The leading particle flow object for this node. More...
 
int m_tier
 The hierarchy tier for this node. More...
 
int m_pdg
 The particle ID (track = muon, shower = electron) More...
 

Detailed Description

Node class.

Definition at line 435 of file LArHierarchyHelper.h.

Constructor & Destructor Documentation

lar_content::LArHierarchyHelper::RecoHierarchy::Node::Node ( const RecoHierarchy hierarchy,
const pandora::ParticleFlowObject *  pPfo,
const int  tier = 1 
)

Create a node with a primary PFO.

Parameters
hierarchyThe parent hierarchy of this node
pPfoThe primary PFO with which this node should be created
tierThe tier that should be assigned to this node

Definition at line 967 of file LArHierarchyHelper.cc.

References m_caloHits, m_hierarchy, m_mainPfo, m_pdg, m_pfos, m_tier, and lar_content::LArPfoHelper::SortByNHits().

Referenced by FillFlat(), and FillHierarchy().

967  :
968  m_hierarchy{hierarchy},
969  m_mainPfo{pPfo},
970  m_tier{tier},
971  m_pdg{0}
972 {
973  if (pPfo)
974  {
975  m_pdg = pPfo->GetParticleId();
976  m_pfos.emplace_back(pPfo);
977  }
978 }
int m_tier
The hierarchy tier for this node.
const RecoHierarchy & m_hierarchy
The parent reco hierarchy.
int m_pdg
The particle ID (track = muon, shower = electron)
pandora::PfoList m_pfos
The list of PFOs of which this node is composed.
const pandora::ParticleFlowObject * m_mainPfo
The leading particle flow object for this node.
lar_content::LArHierarchyHelper::RecoHierarchy::Node::Node ( const RecoHierarchy hierarchy,
const pandora::PfoList &  pfoList,
const pandora::CaloHitList &  caloHitList,
const int  tier = 1 
)

Create a node from a list of PFOs.

Parameters
hierarchyThe parent hierarchy of this node
pfoListThe PFO list with which this node should be created caloHitList The CaloHit list with which this node should be created
tierThe tier that should be assigned to this node
lar_content::LArHierarchyHelper::RecoHierarchy::Node::~Node ( )
virtual

Destructor.

Definition at line 1001 of file LArHierarchyHelper.cc.

References m_caloHits, m_children, and m_pfos.

1002 {
1003  m_pfos.clear();
1004  m_caloHits.clear();
1005  for (const Node *node : m_children)
1006  delete node;
1007  m_children.clear();
1008 }
pandora::PfoList m_pfos
The list of PFOs of which this node is composed.
NodeVector m_children
The child nodes of this node.
pandora::CaloHitList m_caloHits
The list of calo hits of which this node is composed.
Node(const RecoHierarchy &hierarchy, const pandora::ParticleFlowObject *pPfo, const int tier=1)
Create a node with a primary PFO.

Member Function Documentation

void lar_content::LArHierarchyHelper::RecoHierarchy::Node::FillFlat ( const pandora::ParticleFlowObject *  pRoot)

Fill this node by folding all descendent particles to this node.

Parameters
pRootThe PFO acting as the root of the current branch of the hierarchy

Definition at line 1046 of file LArHierarchyHelper.cc.

References lar_content::LArPfoHelper::GetAllCaloHits(), lar_content::LArPfoHelper::GetAllDownstreamPfos(), m_children, m_hierarchy, m_tier, and Node().

1047 {
1048  PfoList allParticles;
1049  LArPfoHelper::GetAllDownstreamPfos(pRoot, allParticles);
1050  CaloHitList allHits;
1051  for (const ParticleFlowObject *pPfo : allParticles)
1052  LArPfoHelper::GetAllCaloHits(pPfo, allHits);
1053  Node *pNode{new Node(m_hierarchy, allParticles, allHits, m_tier + 1)};
1054  m_children.emplace_back(pNode);
1055 }
int m_tier
The hierarchy tier for this node.
const RecoHierarchy & m_hierarchy
The parent reco hierarchy.
static void GetAllCaloHits(const pandora::ParticleFlowObject *pPfo, pandora::CaloHitList &caloHitList)
Get a list of all calo hits (including isolated) of all types from a given pfo.
Definition: LArPfoHelper.cc:76
NodeVector m_children
The child nodes of this node.
static void GetAllDownstreamPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively, of all daughters associated with those pfos in an input lis...
Node(const RecoHierarchy &hierarchy, const pandora::ParticleFlowObject *pPfo, const int tier=1)
Create a node with a primary PFO.
void lar_content::LArHierarchyHelper::RecoHierarchy::Node::FillHierarchy ( const pandora::ParticleFlowObject *  pRoot,
const FoldingParameters foldParameters 
)

Recursively fill the hierarchy based on the criteria established for this RecoHierarchy.

Parameters
pRootThe PFO acting as the root of the current branch of the hierarchy
foldParametersThe folding parameters

Definition at line 1012 of file LArHierarchyHelper.cc.

References util::abs(), lar_content::LArPfoHelper::GetAllCaloHits(), lar_content::LArPfoHelper::GetAllDownstreamPfos(), lar_content::LArPfoHelper::GetHierarchyTier(), m_children, lar_content::LArHierarchyHelper::FoldingParameters::m_foldToLeadingShowers, lar_content::LArHierarchyHelper::FoldingParameters::m_foldToTier, m_hierarchy, lar_content::LArHierarchyHelper::FoldingParameters::m_tier, m_tier, and Node().

1013 {
1014  PfoList allParticles;
1015  int pdg{std::abs(pRoot->GetParticleId())};
1016  const bool isShower{pdg == E_MINUS};
1017  if (foldParameters.m_foldToTier && LArPfoHelper::GetHierarchyTier(pRoot) >= foldParameters.m_tier)
1018  LArPfoHelper::GetAllDownstreamPfos(pRoot, allParticles);
1019  else if (foldParameters.m_foldToLeadingShowers && isShower)
1020  LArPfoHelper::GetAllDownstreamPfos(pRoot, allParticles);
1021  else
1022  allParticles.emplace_back(pRoot);
1023 
1024  CaloHitList allHits;
1025  for (const ParticleFlowObject *pPfo : allParticles)
1026  LArPfoHelper::GetAllCaloHits(pPfo, allHits);
1027  const bool hasChildren{(foldParameters.m_foldToTier && LArPfoHelper::GetHierarchyTier(pRoot) < foldParameters.m_tier) ||
1028  (!foldParameters.m_foldToTier && !foldParameters.m_foldToLeadingShowers) || (foldParameters.m_foldToLeadingShowers && !isShower)};
1029 
1030  if (hasChildren || (!hasChildren && !allHits.empty()))
1031  {
1032  Node *pNode{new Node(m_hierarchy, allParticles, allHits, m_tier + 1)};
1033  m_children.emplace_back(pNode);
1034 
1035  if (hasChildren)
1036  {
1037  const PfoList &children{pRoot->GetDaughterPfoList()};
1038  for (const ParticleFlowObject *pChild : children)
1039  pNode->FillHierarchy(pChild, foldParameters);
1040  }
1041  }
1042 }
int m_tier
The hierarchy tier for this node.
constexpr auto abs(T v)
Returns the absolute value of the argument.
const RecoHierarchy & m_hierarchy
The parent reco hierarchy.
static void GetAllCaloHits(const pandora::ParticleFlowObject *pPfo, pandora::CaloHitList &caloHitList)
Get a list of all calo hits (including isolated) of all types from a given pfo.
Definition: LArPfoHelper.cc:76
static int GetHierarchyTier(const pandora::ParticleFlowObject *const pPfo)
Determine the position in the hierarchy for the MCParticle.
NodeVector m_children
The child nodes of this node.
static void GetAllDownstreamPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively, of all daughters associated with those pfos in an input lis...
Node(const RecoHierarchy &hierarchy, const pandora::ParticleFlowObject *pPfo, const int tier=1)
Create a node with a primary PFO.
const CaloHitList & lar_content::LArHierarchyHelper::RecoHierarchy::Node::GetCaloHits ( ) const

Retrieve the CaloHits associated with this node.

Returns
The list of CaloHits associated with this node

Definition at line 1066 of file LArHierarchyHelper.cc.

References m_caloHits.

Referenced by lar_content::LArHierarchyHelper::MCMatches::GetSelectedRecoHits(), lar_content::LArHierarchyHelper::MatchInfo::GetSelectedRecoHits(), and lar_content::LArHierarchyHelper::MatchInfo::Match().

1067 {
1068  return m_caloHits;
1069 }
pandora::CaloHitList m_caloHits
The list of calo hits of which this node is composed.
const LArHierarchyHelper::RecoHierarchy::NodeVector & lar_content::LArHierarchyHelper::RecoHierarchy::Node::GetChildren ( ) const
inline

Return the vector of children for this node.

Returns
The vector of children

Definition at line 1007 of file LArHierarchyHelper.h.

1008 {
1009  return m_children;
1010 }
NodeVector m_children
The child nodes of this node.
int lar_content::LArHierarchyHelper::RecoHierarchy::Node::GetHierarchyTier ( ) const
inline

Retrieve the hierarchy tier of this node.

Returns
The hierarchy tier of this node

Definition at line 1022 of file LArHierarchyHelper.h.

References lar_content::LArHierarchyHelper::FoldingParameters::m_tier.

1023 {
1024  return m_tier;
1025 }
int m_tier
The hierarchy tier for this node.
const pandora::ParticleFlowObject * lar_content::LArHierarchyHelper::RecoHierarchy::Node::GetLeadingPfo ( ) const
inline

Retrieve the leading reco particle for this node.

return The leading reco particle for this node

Definition at line 1014 of file LArHierarchyHelper.h.

1015 {
1016  return m_mainPfo;
1017 }
const pandora::ParticleFlowObject * m_mainPfo
The leading particle flow object for this node.
int lar_content::LArHierarchyHelper::RecoHierarchy::Node::GetParticleId ( ) const

Retrieve the PDG code for the leading particle in this node Note, for reco objects the PDG codes represent tracks (muon PDG) and showers (electron PDG)

Returns
The PDG code for the leading particle in this node

Definition at line 1073 of file LArHierarchyHelper.cc.

References m_pdg.

1074 {
1075  return m_pdg;
1076 }
int m_pdg
The particle ID (track = muon, shower = electron)
const PfoList & lar_content::LArHierarchyHelper::RecoHierarchy::Node::GetRecoParticles ( ) const

Retrieve the PFOs associated with this node.

Returns
The PFOs associated with this node

Definition at line 1059 of file LArHierarchyHelper.cc.

References m_pfos.

1060 {
1061  return m_pfos;
1062 }
pandora::PfoList m_pfos
The list of PFOs of which this node is composed.
const std::string lar_content::LArHierarchyHelper::RecoHierarchy::Node::ToString ( const std::string &  prefix) const

Produce a string representation of the hierarchy.

Returns
The string representation of the hierarchy

Definition at line 1080 of file LArHierarchyHelper.cc.

References m_caloHits, m_children, m_pdg, m_tier, and util::to_string().

1081 {
1082  std::string str(
1083  prefix + "PDG: " + std::to_string(m_pdg) + " Tier: " + std::to_string(m_tier) + " Hits: " + std::to_string(m_caloHits.size()) + "\n");
1084  for (const Node *pChild : m_children)
1085  str += pChild->ToString(prefix + " ");
1086 
1087  return str;
1088 }
int m_tier
The hierarchy tier for this node.
int m_pdg
The particle ID (track = muon, shower = electron)
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
NodeVector m_children
The child nodes of this node.
pandora::CaloHitList m_caloHits
The list of calo hits of which this node is composed.
Node(const RecoHierarchy &hierarchy, const pandora::ParticleFlowObject *pPfo, const int tier=1)
Create a node with a primary PFO.

Member Data Documentation

pandora::CaloHitList lar_content::LArHierarchyHelper::RecoHierarchy::Node::m_caloHits
private

The list of calo hits of which this node is composed.

Definition at line 530 of file LArHierarchyHelper.h.

Referenced by GetCaloHits(), Node(), ToString(), and ~Node().

NodeVector lar_content::LArHierarchyHelper::RecoHierarchy::Node::m_children
private

The child nodes of this node.

Definition at line 531 of file LArHierarchyHelper.h.

Referenced by FillFlat(), FillHierarchy(), ToString(), and ~Node().

const RecoHierarchy& lar_content::LArHierarchyHelper::RecoHierarchy::Node::m_hierarchy
private

The parent reco hierarchy.

Definition at line 528 of file LArHierarchyHelper.h.

Referenced by FillFlat(), FillHierarchy(), and Node().

const pandora::ParticleFlowObject* lar_content::LArHierarchyHelper::RecoHierarchy::Node::m_mainPfo
private

The leading particle flow object for this node.

Definition at line 532 of file LArHierarchyHelper.h.

Referenced by Node().

int lar_content::LArHierarchyHelper::RecoHierarchy::Node::m_pdg
private

The particle ID (track = muon, shower = electron)

Definition at line 534 of file LArHierarchyHelper.h.

Referenced by GetParticleId(), Node(), and ToString().

pandora::PfoList lar_content::LArHierarchyHelper::RecoHierarchy::Node::m_pfos
private

The list of PFOs of which this node is composed.

Definition at line 529 of file LArHierarchyHelper.h.

Referenced by GetRecoParticles(), Node(), and ~Node().

int lar_content::LArHierarchyHelper::RecoHierarchy::Node::m_tier
private

The hierarchy tier for this node.

Definition at line 533 of file LArHierarchyHelper.h.

Referenced by FillFlat(), FillHierarchy(), Node(), and ToString().


The documentation for this class was generated from the following files: