Classes | Public Types | Public Member Functions | Private Attributes | List of all members
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
 

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 NodeVectorGetRootNodes () const
 Retrieve the root nodes in this hierarchy. More...
 
void GetFlattenedNodes (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

NodeVector m_rootNodes
 The leading nodes (e.g. primary particles, cosmic rays, ...) More...
 
const pandora::ParticleFlowObject * m_pNeutrino
 The incident neutrino, if it exists. More...
 

Detailed Description

RecoHierarchy class.

Definition at line 426 of file LArHierarchyHelper.h.

Member Typedef Documentation

Definition at line 431 of file LArHierarchyHelper.h.

Definition at line 429 of file LArHierarchyHelper.h.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 764 of file LArHierarchyHelper.cc.

764  : m_pNeutrino{nullptr}
765 {
766 }
const pandora::ParticleFlowObject * m_pNeutrino
The incident neutrino, if it exists.
lar_content::LArHierarchyHelper::RecoHierarchy::~RecoHierarchy ( )
virtual

Destructor.

Definition at line 770 of file LArHierarchyHelper.cc.

771 {
772  for (const Node *pNode : m_rootNodes)
773  delete pNode;
774  m_rootNodes.clear();
775 }
QMapNodeBase Node
Definition: qmap.cpp:41
NodeVector m_rootNodes
The leading nodes (e.g. primary particles, cosmic rays, ...)

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

780 {
781  PfoSet primarySet;
782  m_pNeutrino = LArHierarchyHelper::GetRecoPrimaries(pfoList, primarySet);
783  PfoList primaries(primarySet.begin(), primarySet.end());
784  primaries.sort(LArPfoHelper::SortByNHits);
785  if (foldParameters.m_foldToTier && foldParameters.m_tier == 1)
786  {
787  for (const ParticleFlowObject *pPrimary : primaries)
788  {
789  PfoList allParticles;
790  // ATTN - pPrimary gets added to the list of downstream PFOs, not just the child PFOs
791  LArPfoHelper::GetAllDownstreamPfos(pPrimary, allParticles);
792  CaloHitList allHits;
793  for (const ParticleFlowObject *pPfo : allParticles)
794  LArPfoHelper::GetAllCaloHits(pPfo, allHits);
795  m_rootNodes.emplace_back(new Node(*this, allParticles, allHits));
796  }
797  }
798  else if (foldParameters.m_foldToLeadingShowers)
799  {
800  for (const ParticleFlowObject *pPrimary : primaries)
801  {
802  PfoList allParticles;
803  int pdg{std::abs(pPrimary->GetParticleId())};
804  const bool isShower{pdg == E_MINUS};
805  // ATTN - pPrimary gets added to the list of downstream PFOs, not just the child PFOs
806  if (isShower)
807  LArPfoHelper::GetAllDownstreamPfos(pPrimary, allParticles);
808  else
809  allParticles.emplace_back(pPrimary);
810 
811  CaloHitList allHits;
812  for (const ParticleFlowObject *pPfo : allParticles)
813  LArPfoHelper::GetAllCaloHits(pPfo, allHits);
814  Node *pNode{new Node(*this, allParticles, allHits)};
815  m_rootNodes.emplace_back(pNode);
816  if (!isShower)
817  {
818  // Find the children of this particle and recursively add them to the hierarchy
819  const PfoList &children{pPrimary->GetDaughterPfoList()};
820  for (const ParticleFlowObject *pChild : children)
821  pNode->FillHierarchy(pChild, foldParameters);
822  }
823  }
824  }
825  else
826  {
827  // Dynamic fold, Unfolded and fold to tier > 1 have the same behaviour for primaries
828  for (const ParticleFlowObject *pPrimary : primaries)
829  {
830  PfoList allParticles{pPrimary};
831  CaloHitList allHits;
832  for (const ParticleFlowObject *pPfo : allParticles)
833  LArPfoHelper::GetAllCaloHits(pPfo, allHits);
834  Node *pNode{new Node(*this, allParticles, allHits)};
835  m_rootNodes.emplace_back(pNode);
836  // Find the children of this particle and recursively add them to the hierarchy
837  const PfoList &children{pPrimary->GetDaughterPfoList()};
838  for (const ParticleFlowObject *pChild : children)
839  pNode->FillHierarchy(pChild, foldParameters.m_foldToLeadingShowers);
840  }
841  }
842 }
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
QMapNodeBase Node
Definition: qmap.cpp:41
const pandora::ParticleFlowObject * m_pNeutrino
The incident neutrino, if it exists.
static const pandora::ParticleFlowObject * GetRecoPrimaries(const pandora::PfoList &pfoList, PfoSet &primaries)
Retrieves the primary PFOs from a list and returns the root (neutrino) for hierarchy, if it exists.
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 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
NodeVector m_rootNodes
The leading nodes (e.g. primary particles, cosmic rays, ...)
void lar_content::LArHierarchyHelper::RecoHierarchy::GetFlattenedNodes ( NodeVector nodeVector) const

Retrieve a flat vector of the nodes in the hierarchy.

Parameters
nodeVectorThe output vector for the nodes in the hierarchy in breadth first order

Definition at line 846 of file LArHierarchyHelper.cc.

847 {
848  NodeList queue;
849  for (const Node *pNode : m_rootNodes)
850  {
851  nodeVector.emplace_back(pNode);
852  queue.emplace_back(pNode);
853  }
854  while (!queue.empty())
855  {
856  const NodeVector &children{queue.front()->GetChildren()};
857  queue.pop_front();
858  for (const Node *pChild : children)
859  {
860  nodeVector.emplace_back(pChild);
861  queue.emplace_back(pChild);
862  }
863  }
864 }
QMapNodeBase Node
Definition: qmap.cpp:41
NodeVector m_rootNodes
The leading nodes (e.g. primary particles, cosmic rays, ...)
const pandora::ParticleFlowObject * lar_content::LArHierarchyHelper::RecoHierarchy::GetNeutrino ( ) const
inline

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)

Definition at line 992 of file LArHierarchyHelper.h.

993 {
994  return m_pNeutrino;
995 }
const pandora::ParticleFlowObject * m_pNeutrino
The incident neutrino, if it exists.
const LArHierarchyHelper::RecoHierarchy::NodeVector & lar_content::LArHierarchyHelper::RecoHierarchy::GetRootNodes ( ) const
inline

Retrieve the root nodes in this hierarchy.

Returns
The root nodes in this hierarchy

Definition at line 985 of file LArHierarchyHelper.h.

986 {
987  return m_rootNodes;
988 }
NodeVector m_rootNodes
The leading nodes (e.g. primary particles, cosmic rays, ...)
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 868 of file LArHierarchyHelper.cc.

869 {
871  for (const Node *pNode : m_rootNodes)
872  str += pNode->ToString("") + "\n";
873 
874  return str;
875 }
QMapNodeBase Node
Definition: qmap.cpp:41
std::string string
Definition: nybbler.cc:12
static QCString str
NodeVector m_rootNodes
The leading nodes (e.g. primary particles, cosmic rays, ...)

Member Data Documentation

const pandora::ParticleFlowObject* lar_content::LArHierarchyHelper::RecoHierarchy::m_pNeutrino
private

The incident neutrino, if it exists.

Definition at line 584 of file LArHierarchyHelper.h.

NodeVector lar_content::LArHierarchyHelper::RecoHierarchy::m_rootNodes
private

The leading nodes (e.g. primary particles, cosmic rays, ...)

Definition at line 583 of file LArHierarchyHelper.h.


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