LArSoft  v09_90_00
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)
 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::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...
 
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 nodea. More...
 
const pandora::ParticleFlowObject * m_mainPfo
 The leading particle flow object for this node. More...
 
int m_pdg
 The particle ID (track = muon, shower = electron) More...
 

Detailed Description

Node class.

Definition at line 433 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 965 of file LArHierarchyHelper.cc.

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

Referenced by FillFlat(), and FillHierarchy().

965  :
966  m_hierarchy{hierarchy},
967  m_mainPfo{pPfo},
968  m_pdg{0}
969 {
970  if (pPfo)
971  {
972  m_pdg = pPfo->GetParticleId();
973  m_pfos.emplace_back(pPfo);
974  }
975 }
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 
)

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

References m_caloHits, m_children, and m_pfos.

998 {
999  m_pfos.clear();
1000  m_caloHits.clear();
1001  for (const Node *node : m_children)
1002  delete node;
1003  m_children.clear();
1004 }
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 nodea.
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 1042 of file LArHierarchyHelper.cc.

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

1043 {
1044  PfoList allParticles;
1045  LArPfoHelper::GetAllDownstreamPfos(pRoot, allParticles);
1046  CaloHitList allHits;
1047  for (const ParticleFlowObject *pPfo : allParticles)
1048  LArPfoHelper::GetAllCaloHits(pPfo, allHits);
1049  Node *pNode{new Node(m_hierarchy, allParticles, allHits)};
1050  m_children.emplace_back(pNode);
1051 }
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 nodea.
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 1008 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, and Node().

1009 {
1010  PfoList allParticles;
1011  int pdg{std::abs(pRoot->GetParticleId())};
1012  const bool isShower{pdg == E_MINUS};
1013  if (foldParameters.m_foldToTier && LArPfoHelper::GetHierarchyTier(pRoot) >= foldParameters.m_tier)
1014  LArPfoHelper::GetAllDownstreamPfos(pRoot, allParticles);
1015  else if (foldParameters.m_foldToLeadingShowers && isShower)
1016  LArPfoHelper::GetAllDownstreamPfos(pRoot, allParticles);
1017  else
1018  allParticles.emplace_back(pRoot);
1019 
1020  CaloHitList allHits;
1021  for (const ParticleFlowObject *pPfo : allParticles)
1022  LArPfoHelper::GetAllCaloHits(pPfo, allHits);
1023  const bool hasChildren{(foldParameters.m_foldToTier && LArPfoHelper::GetHierarchyTier(pRoot) < foldParameters.m_tier) ||
1024  (!foldParameters.m_foldToTier && !foldParameters.m_foldToLeadingShowers) || (foldParameters.m_foldToLeadingShowers && !isShower)};
1025 
1026  if (hasChildren || (!hasChildren && !allHits.empty()))
1027  {
1028  Node *pNode{new Node(m_hierarchy, allParticles, allHits)};
1029  m_children.emplace_back(pNode);
1030 
1031  if (hasChildren)
1032  {
1033  const PfoList &children{pRoot->GetDaughterPfoList()};
1034  for (const ParticleFlowObject *pChild : children)
1035  pNode->FillHierarchy(pChild, foldParameters);
1036  }
1037  }
1038 }
constexpr auto abs(T v)
Returns the absolute value of the argument.
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
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 nodea.
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 1062 of file LArHierarchyHelper.cc.

References m_caloHits.

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

1063 {
1064  return m_caloHits;
1065 }
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 972 of file LArHierarchyHelper.h.

973 {
974  return m_children;
975 }
NodeVector m_children
The child nodes of this nodea.
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 979 of file LArHierarchyHelper.h.

980 {
981  return m_mainPfo;
982 }
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 1069 of file LArHierarchyHelper.cc.

References m_pdg.

1070 {
1071  return m_pdg;
1072 }
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 1055 of file LArHierarchyHelper.cc.

References m_pfos.

1056 {
1057  return m_pfos;
1058 }
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 1076 of file LArHierarchyHelper.cc.

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

1077 {
1078  std::string str(prefix + "PDG: " + std::to_string(m_pdg) + " Hits: " + std::to_string(m_caloHits.size()) + "\n");
1079  for (const Node *pChild : m_children)
1080  str += pChild->ToString(prefix + " ");
1081 
1082  return str;
1083 }
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.
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
NodeVector m_children
The child nodes of this nodea.
pandora::CaloHitList m_caloHits
The list of calo hits of which this node is composed.

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 519 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 nodea.

Definition at line 520 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 517 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 521 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 522 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 518 of file LArHierarchyHelper.h.

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


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