Public Member Functions | Private Attributes | List of all members
lar_content::LArHierarchyHelper::RecoHierarchy::Node Class Reference

Node class. More...

#include <LArHierarchyHelper.h>

Public Member Functions

 Node (const RecoHierarchy &hierarchy, const pandora::ParticleFlowObject *pPfo)
 Create a node with a primary PFO. More...
 
 Node (const RecoHierarchy &hierarchy, const pandora::PfoList &pfoList, const pandora::CaloHitList &caloHitList)
 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::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...
 
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...
 
int m_pdg
 The particle ID (track = muon, shower = electron) More...
 

Detailed Description

Node class.

Definition at line 436 of file LArHierarchyHelper.h.

Constructor & Destructor Documentation

lar_content::LArHierarchyHelper::RecoHierarchy::Node::Node ( const RecoHierarchy hierarchy,
const pandora::ParticleFlowObject *  pPfo 
)

Create a node with a primary PFO.

Parameters
hierarchyThe parent hierarchy of this node
pPfoThe primary PFO with which this node should be created

Definition at line 880 of file LArHierarchyHelper.cc.

880  :
881  m_hierarchy(hierarchy),
882  m_pdg{0}
883 {
884  if (pPfo)
885  {
886  m_pdg = pPfo->GetParticleId();
887  m_pfos.emplace_back(pPfo);
888  }
889 }
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.
lar_content::LArHierarchyHelper::RecoHierarchy::Node::Node ( const RecoHierarchy hierarchy,
const pandora::PfoList &  pfoList,
const pandora::CaloHitList &  caloHitList 
)

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
lar_content::LArHierarchyHelper::RecoHierarchy::Node::~Node ( )
virtual

Destructor.

Definition at line 907 of file LArHierarchyHelper.cc.

908 {
909  m_pfos.clear();
910  m_caloHits.clear();
911  for (const Node *node : m_children)
912  delete node;
913  m_children.clear();
914 }
Node(const RecoHierarchy &hierarchy, const pandora::ParticleFlowObject *pPfo)
Create a node with a primary PFO.
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.

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 953 of file LArHierarchyHelper.cc.

954 {
955  PfoList allParticles;
956  LArPfoHelper::GetAllDownstreamPfos(pRoot, allParticles);
957  CaloHitList allHits;
958  for (const ParticleFlowObject *pPfo : allParticles)
959  LArPfoHelper::GetAllCaloHits(pPfo, allHits);
960  Node *pNode{new Node(m_hierarchy, allParticles, allHits)};
961  m_children.emplace_back(pNode);
962 }
const RecoHierarchy & m_hierarchy
The parent reco hierarchy.
Node(const RecoHierarchy &hierarchy, const pandora::ParticleFlowObject *pPfo)
Create a node with a primary PFO.
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...
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 918 of file LArHierarchyHelper.cc.

919 {
920  PfoList allParticles;
921  int pdg{std::abs(pRoot->GetParticleId())};
922  const bool isShower{pdg == E_MINUS};
923  if (foldParameters.m_foldToTier && LArPfoHelper::GetHierarchyTier(pRoot) >= foldParameters.m_tier)
924  LArPfoHelper::GetAllDownstreamPfos(pRoot, allParticles);
925  else if (foldParameters.m_foldToLeadingShowers && isShower)
926  LArPfoHelper::GetAllDownstreamPfos(pRoot, allParticles);
927  else
928  allParticles.emplace_back(pRoot);
929 
930  CaloHitList allHits;
931  for (const ParticleFlowObject *pPfo : allParticles)
932  LArPfoHelper::GetAllCaloHits(pPfo, allHits);
933  const bool hasChildren{(foldParameters.m_foldToTier && LArPfoHelper::GetHierarchyTier(pRoot) < foldParameters.m_tier) ||
934  (!foldParameters.m_foldToTier && !foldParameters.m_foldToLeadingShowers) ||
935  (foldParameters.m_foldToLeadingShowers && !isShower)};
936 
937  if (hasChildren || (!hasChildren && !allHits.empty()))
938  {
939  Node *pNode{new Node(m_hierarchy, allParticles, allHits)};
940  m_children.emplace_back(pNode);
941 
942  if (hasChildren)
943  {
944  const PfoList &children{pRoot->GetDaughterPfoList()};
945  for (const ParticleFlowObject *pChild : children)
946  pNode->FillHierarchy(pChild, foldParameters);
947  }
948  }
949 }
const RecoHierarchy & m_hierarchy
The parent reco hierarchy.
Node(const RecoHierarchy &hierarchy, const pandora::ParticleFlowObject *pPfo)
Create a node with a primary PFO.
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
T abs(T value)
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...
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 973 of file LArHierarchyHelper.cc.

974 {
975  return m_caloHits;
976 }
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 977 of file LArHierarchyHelper.h.

978 {
979  return m_children;
980 }
NodeVector m_children
The child nodes of 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 980 of file LArHierarchyHelper.cc.

981 {
982  return m_pdg;
983 }
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 966 of file LArHierarchyHelper.cc.

967 {
968  return m_pfos;
969 }
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 987 of file LArHierarchyHelper.cc.

988 {
989  std::string str(prefix + "PDG: " + std::to_string(m_pdg) + " Hits: " + std::to_string(m_caloHits.size()) + "\n");
990  for (const Node *pChild : m_children)
991  str += pChild->ToString(prefix + " ");
992 
993  return str;
994 }
std::string string
Definition: nybbler.cc:12
int m_pdg
The particle ID (track = muon, shower = electron)
Node(const RecoHierarchy &hierarchy, const pandora::ParticleFlowObject *pPfo)
Create a node with a primary PFO.
NodeVector m_children
The child nodes of this node.
pandora::CaloHitList m_caloHits
The list of calo hits of which this node is composed.
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
static QCString str

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 515 of file LArHierarchyHelper.h.

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

The child nodes of this node.

Definition at line 516 of file LArHierarchyHelper.h.

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

The parent reco hierarchy.

Definition at line 513 of file LArHierarchyHelper.h.

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

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

Definition at line 517 of file LArHierarchyHelper.h.

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

The list of PFOs of which this node is composed.

Definition at line 514 of file LArHierarchyHelper.h.


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