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

RecoHierarchy class. More...

#include "LArHierarchyHelper.h"

Classes

class  Node
 Node class. More...
 

Public Types

typedef std::vector< const Node * > NodeVector
 
typedef std::list< const Node * > NodeList
 
typedef std::map< const pandora::ParticleFlowObject *, NodeVectorRecoNodeVectorMap
 

Public Member Functions

 RecoHierarchy ()
 Default constructor. More...
 
virtual ~RecoHierarchy ()
 Destructor. More...
 
void FillHierarchy (const pandora::PfoList &pfoList, const FoldingParameters &foldParameters)
 Creates a reconstructed hierarchy representation. Without folding this will be a mirror image of the standard ParticleFlowObject (PFO) relationships. However, with folding options selected the hierarchy structure will group together PFOs into nodes based on the folding requirements. More...
 
const NodeVectorGetInteractions (const pandora::ParticleFlowObject *pRoot) const
 Retrieve the root nodes in the hierarchy for a given interaction. More...
 
void GetRootPfos (pandora::PfoList &rootPfos) const
 Retrieve the root particle flow objects of the interaction hierarchies. More...
 
void GetFlattenedNodes (const pandora::ParticleFlowObject *const pRoot, NodeVector &nodeVector) const
 Retrieve a flat vector of the nodes in the hierarchy. More...
 
const pandora::ParticleFlowObject * GetNeutrino () const
 Retrieve the neutrino at the root of the hierarchy if it exists. More...
 
const std::string ToString () const
 Produce a string representation of the hierarchy. More...
 

Private Attributes

RecoNodeVectorMap m_interactions
 Map from the root PFO (e.g. neutrino) to primaries. More...
 

Detailed Description

RecoHierarchy class.

Definition at line 422 of file LArHierarchyHelper.h.

Member Typedef Documentation

Definition at line 427 of file LArHierarchyHelper.h.

Definition at line 425 of file LArHierarchyHelper.h.

typedef std::map<const pandora::ParticleFlowObject *, NodeVector> lar_content::LArHierarchyHelper::RecoHierarchy::RecoNodeVectorMap

Definition at line 428 of file LArHierarchyHelper.h.

Constructor & Destructor Documentation

lar_content::LArHierarchyHelper::RecoHierarchy::RecoHierarchy ( )

Default constructor.

Definition at line 811 of file LArHierarchyHelper.cc.

812 {
813 }
lar_content::LArHierarchyHelper::RecoHierarchy::~RecoHierarchy ( )
virtual

Destructor.

Definition at line 817 of file LArHierarchyHelper.cc.

References lar_content::LArHierarchyHelper::MCHierarchy::m_interactions.

818 {
819  for (const auto &[pRoot, nodeVector] : m_interactions)
820  {
821  for (const Node *pNode : nodeVector)
822  delete pNode;
823  }
824  m_interactions.clear();
825 }
RecoNodeVectorMap m_interactions
Map from the root PFO (e.g. neutrino) to primaries.

Member Function Documentation

void lar_content::LArHierarchyHelper::RecoHierarchy::FillHierarchy ( const pandora::PfoList &  pfoList,
const FoldingParameters foldParameters 
)

Creates a reconstructed hierarchy representation. Without folding this will be a mirror image of the standard ParticleFlowObject (PFO) relationships. However, with folding options selected the hierarchy structure will group together PFOs into nodes based on the folding requirements.

If only folding back to primaries, the hierarchy will be relatively flat, with a top-level neutrino or test beam particle, if appropriate, and then a set of leaf nodes, one for each primary particles also containing the PFOs (and corresponding hits) from daughter particles.

If only folding back to leading shower particles, the hierarchy will largely mirror the standard PFO hierarchy, but, when a shower particle is reached (based on the track/shower characterisation), this particle and all daughter particles will be represented by a single leaf node.

If folding back to both primary and leading shower particles the hierarchy will again be rather flat, but in this case, if a primary track-like particle has a downstream shower particle then all downstream particles above the shower-like particle will be folded into the primary node, but a new, daughter leaf node will be created for the shower-like particle and all of its daughters, and a parent-child relationship will be formed between the primary node and shower node.

Parameters
pfoListThe list of PFOs with which to fill the hierarchy
foldParametersThe folding parameters to use for the hierarchy

Definition at line 829 of file LArHierarchyHelper.cc.

References util::abs(), lar_content::LArPfoHelper::GetAllCaloHits(), lar_content::LArPfoHelper::GetAllDownstreamPfos(), lar_content::LArHierarchyHelper::GetRecoPrimaries(), lar_content::LArHierarchyHelper::FoldingParameters::m_foldToLeadingShowers, lar_content::LArHierarchyHelper::FoldingParameters::m_foldToTier, lar_content::LArHierarchyHelper::MCHierarchy::m_interactions, lar_content::LArHierarchyHelper::FoldingParameters::m_tier, and lar_content::LArPfoHelper::SortByNHits().

Referenced by lar_content::LArHierarchyHelper::FillRecoHierarchy().

830 {
831  PfoList rootNodes;
832  for (const ParticleFlowObject *pPfo : pfoList)
833  {
834  const PfoList &parentList{pPfo->GetParentPfoList()};
835  if (parentList.empty())
836  {
837  rootNodes.emplace_back(pPfo);
838  }
839  }
840 
841  for (const ParticleFlowObject *const pRoot : rootNodes)
842  {
843  PfoSet primarySet;
844  LArHierarchyHelper::GetRecoPrimaries(pRoot, primarySet);
845  PfoList primaries(primarySet.begin(), primarySet.end());
846  primaries.sort(LArPfoHelper::SortByNHits);
847  if (foldParameters.m_foldToTier && foldParameters.m_tier == 1)
848  {
849  for (const ParticleFlowObject *pPrimary : primaries)
850  {
851  PfoList allParticles;
852  // ATTN - pPrimary gets added to the list of downstream PFOs, not just the child PFOs
853  LArPfoHelper::GetAllDownstreamPfos(pPrimary, allParticles);
854  CaloHitList allHits;
855  for (const ParticleFlowObject *pPfo : allParticles)
856  LArPfoHelper::GetAllCaloHits(pPfo, allHits);
857  m_interactions[pRoot].emplace_back(new Node(*this, allParticles, allHits));
858  }
859  }
860  else if (foldParameters.m_foldToLeadingShowers)
861  {
862  for (const ParticleFlowObject *pPrimary : primaries)
863  {
864  PfoList allParticles;
865  int pdg{std::abs(pPrimary->GetParticleId())};
866  const bool isShower{pdg == E_MINUS};
867  // ATTN - pPrimary gets added to the list of downstream PFOs, not just the child PFOs
868  if (isShower)
869  LArPfoHelper::GetAllDownstreamPfos(pPrimary, allParticles);
870  else
871  allParticles.emplace_back(pPrimary);
872 
873  CaloHitList allHits;
874  for (const ParticleFlowObject *pPfo : allParticles)
875  LArPfoHelper::GetAllCaloHits(pPfo, allHits);
876  Node *pNode{new Node(*this, allParticles, allHits)};
877  m_interactions[pRoot].emplace_back(pNode);
878  if (!isShower)
879  {
880  // Find the children of this particle and recursively add them to the hierarchy
881  const PfoList &children{pPrimary->GetDaughterPfoList()};
882  for (const ParticleFlowObject *pChild : children)
883  pNode->FillHierarchy(pChild, foldParameters);
884  }
885  }
886  }
887  else
888  {
889  // Dynamic fold, Unfolded and fold to tier > 1 have the same behaviour for primaries
890  for (const ParticleFlowObject *pPrimary : primaries)
891  {
892  PfoList allParticles{pPrimary};
893  CaloHitList allHits;
894  for (const ParticleFlowObject *pPfo : allParticles)
895  LArPfoHelper::GetAllCaloHits(pPfo, allHits);
896  Node *pNode{new Node(*this, allParticles, allHits)};
897  m_interactions[pRoot].emplace_back(pNode);
898  // Find the children of this particle and recursively add them to the hierarchy
899  const PfoList &children{pPrimary->GetDaughterPfoList()};
900  for (const ParticleFlowObject *pChild : children)
901  pNode->FillHierarchy(pChild, foldParameters.m_foldToLeadingShowers);
902  }
903  }
904  }
905 }
static void GetRecoPrimaries(const pandora::ParticleFlowObject *pRoot, PfoSet &primaries)
Retrieves the primary PFOs from a list and returns the root (neutrino) for hierarchy, if it exists.
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
constexpr auto abs(T v)
Returns the absolute value of the argument.
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
RecoNodeVectorMap m_interactions
Map from the root PFO (e.g. neutrino) to primaries.
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...
std::set< const pandora::ParticleFlowObject * > PfoSet
void lar_content::LArHierarchyHelper::RecoHierarchy::GetFlattenedNodes ( const pandora::ParticleFlowObject *const  pRoot,
NodeVector nodeVector 
) const

Retrieve a flat vector of the nodes in the hierarchy.

Parameters
pRootThe root particle flow object for an interaction
nodeVectorThe output vector for the nodes in the hierarchy in breadth first order

Definition at line 927 of file LArHierarchyHelper.cc.

References lar_content::LArHierarchyHelper::MCHierarchy::m_interactions.

Referenced by lar_content::LArHierarchyHelper::MatchInfo::Match(), and lar_content::HierarchyMonitoringAlgorithm::Run().

928 {
929  NodeList queue;
930  for (const Node *pNode : m_interactions.at(pRoot))
931  {
932  nodeVector.emplace_back(pNode);
933  queue.emplace_back(pNode);
934  }
935  while (!queue.empty())
936  {
937  const NodeVector &children{queue.front()->GetChildren()};
938  queue.pop_front();
939  for (const Node *pChild : children)
940  {
941  nodeVector.emplace_back(pChild);
942  queue.emplace_back(pChild);
943  }
944  }
945 }
RecoNodeVectorMap m_interactions
Map from the root PFO (e.g. neutrino) to primaries.
const LArHierarchyHelper::RecoHierarchy::NodeVector & lar_content::LArHierarchyHelper::RecoHierarchy::GetInteractions ( const pandora::ParticleFlowObject *  pRoot) const

Retrieve the root nodes in the hierarchy for a given interaction.

Parameters
pRootThe root of the interaction hierarchy
Returns
The root nodes in this hierarchy

Definition at line 909 of file LArHierarchyHelper.cc.

References lar_content::LArHierarchyHelper::MCHierarchy::m_interactions.

910 {
911  if (m_interactions.find(pRoot) == m_interactions.end())
912  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
913 
914  return m_interactions.at(pRoot);
915 }
RecoNodeVectorMap m_interactions
Map from the root PFO (e.g. neutrino) to primaries.
const pandora::ParticleFlowObject* lar_content::LArHierarchyHelper::RecoHierarchy::GetNeutrino ( ) const

Retrieve the neutrino at the root of the hierarchy if it exists.

Returns
The address of the incident neutrino (nullptr if it doesn't exist)
void lar_content::LArHierarchyHelper::RecoHierarchy::GetRootPfos ( pandora::PfoList &  rootPfos) const

Retrieve the root particle flow objects of the interaction hierarchies.

Parameters
rootPfosThe output list of root particle flow objects

Definition at line 919 of file LArHierarchyHelper.cc.

References lar_content::LArHierarchyHelper::MCHierarchy::m_interactions.

Referenced by lar_content::LArHierarchyHelper::MatchInfo::Match(), lar_content::HierarchyValidationAlgorithm::Run(), and lar_content::HierarchyMonitoringAlgorithm::Run().

920 {
921  for (auto iter = m_interactions.begin(); iter != m_interactions.end(); ++iter)
922  rootPfos.emplace_back(iter->first);
923 }
RecoNodeVectorMap m_interactions
Map from the root PFO (e.g. neutrino) to primaries.
const std::string lar_content::LArHierarchyHelper::RecoHierarchy::ToString ( ) const

Produce a string representation of the hierarchy.

Returns
The string representation of the hierarchy

Definition at line 949 of file LArHierarchyHelper.cc.

References lar_content::LArHierarchyHelper::MCHierarchy::m_interactions, and util::to_string().

Referenced by lar_content::HierarchyMonitoringAlgorithm::Run().

950 {
951  std::string str;
952  for (const auto &[pRoot, nodeVector] : m_interactions)
953  {
954  str += "=== Reco Interaction : PDG " + std::to_string(pRoot->GetParticleId()) + "\n";
955  for (const Node *pNode : nodeVector)
956  str += " " + pNode->ToString("") + "\n";
957  }
958 
959  return str;
960 }
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
RecoNodeVectorMap m_interactions
Map from the root PFO (e.g. neutrino) to primaries.

Member Data Documentation

RecoNodeVectorMap lar_content::LArHierarchyHelper::RecoHierarchy::m_interactions
private

Map from the root PFO (e.g. neutrino) to primaries.

Definition at line 598 of file LArHierarchyHelper.h.


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