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

Node class. More...

#include <LArHierarchyHelper.h>

Public Member Functions

 Node (MCHierarchy &hierarchy, const pandora::MCParticle *pMCParticle, const int tier=1)
 Create a node with a primary MC particle. More...
 
 Node (MCHierarchy &hierarchy, const pandora::MCParticleList &mcParticleList, const pandora::CaloHitList &caloHitList, const int tier=1)
 Create a node from a list of MC particles. More...
 
virtual ~Node ()
 Destructor. More...
 
bool IsReconstructable () const
 Return whether or not this node should be considered reconstructable. More...
 
void FillHierarchy (const pandora::MCParticle *pRoot, const FoldingParameters &foldParameters)
 Recursively fill the hierarchy based on the criteria established for this MCHierarchy. More...
 
void FillFlat (const pandora::MCParticle *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...
 
int GetId () const
 Retrieve the unique ID of this node. More...
 
const pandora::MCParticle * GetLeadingMCParticle () const
 Retrieve the leading MC particle associated with this node. More...
 
const pandora::MCParticleList & GetMCParticles () const
 Retrieve the MC particles 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. More...
 
int GetHierarchyTier () const
 Retrieve the hierarchy tier of this node. More...
 
bool IsNeutrinoInduced () const
 Check if this is a particle induced by a neutrino interaction. More...
 
bool IsTestBeamParticle () const
 Check if this is a test beam particle. More...
 
bool IsCosmicRay () const
 Check if this is a cosmic ray particle. More...
 
bool IsLeadingLepton () const
 Returns whether or not this particle is the leading lepton in the event. More...
 
const std::string ToString (const std::string &prefix) const
 Produce a string representation of the hierarchy. More...
 

Private Member Functions

void SetLeadingLepton ()
 Tags the particle as the leading lepton. More...
 

Private Attributes

MCHierarchym_hierarchy
 The parent MC hierarchy. More...
 
pandora::MCParticleList m_mcParticles
 The list of MC particles 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::MCParticle * m_mainParticle
 The leading MC particle for this node. More...
 
int m_tier
 The hierarchy tier for this node. More...
 
int m_pdg
 The PDG code of the leading MC particle for this node. More...
 
bool m_isLeadingLepton
 Whether or not this node is the leading lepton. More...
 

Friends

class MCHierarchy
 

Detailed Description

Node class.

Definition at line 131 of file LArHierarchyHelper.h.

Constructor & Destructor Documentation

lar_content::LArHierarchyHelper::MCHierarchy::Node::Node ( MCHierarchy hierarchy,
const pandora::MCParticle *  pMCParticle,
const int  tier = 1 
)

Create a node with a primary MC particle.

Parameters
hierarchyThe parent hierarchy of this node
pMCParticleThe primary MC particle with which this node should be created
tierThe tier that should be assigned to this node
lar_content::LArHierarchyHelper::MCHierarchy::Node::Node ( MCHierarchy hierarchy,
const pandora::MCParticleList &  mcParticleList,
const pandora::CaloHitList &  caloHitList,
const int  tier = 1 
)

Create a node from a list of MC particles.

Parameters
hierarchyThe parent hierarchy of this node
mcParticleListThe MC particle list with which this node should be created
caloHitListThe CaloHit list with which this node should be created
tierThe tier that should be assigned to this node
lar_content::LArHierarchyHelper::MCHierarchy::Node::~Node ( )
virtual

Destructor.

Definition at line 537 of file LArHierarchyHelper.cc.

538 {
539  m_mcParticles.clear();
540  m_caloHits.clear();
541  for (const Node *node : m_children)
542  delete node;
543  m_children.clear();
544 }
pandora::CaloHitList m_caloHits
The list of calo hits of which this node is composed.
NodeVector m_children
The child nodes of this node.
Node(MCHierarchy &hierarchy, const pandora::MCParticle *pMCParticle, const int tier=1)
Create a node with a primary MC particle.
pandora::MCParticleList m_mcParticles
The list of MC particles of which this node is composed.

Member Function Documentation

void lar_content::LArHierarchyHelper::MCHierarchy::Node::FillFlat ( const pandora::MCParticle *  pRoot)

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

Parameters
pRootThe MC particle acting as the root of the current branch of the hierarchy

Definition at line 619 of file LArHierarchyHelper.cc.

620 {
621  MCParticleList allParticles{pRoot};
623  {
625  }
626  else
627  {
628  MCParticleList neutrons;
629  LArMCParticleHelper::GetAllDescendentMCParticles(pRoot, allParticles, allParticles, neutrons);
630  }
631  CaloHitList allHits;
632  for (const MCParticle *pMCParticle : allParticles)
633  {
634  // ATTN - Not all MC particles will have hits
635  if (m_hierarchy.m_mcToHitsMap.find(pMCParticle) != m_hierarchy.m_mcToHitsMap.end())
636  {
637  const CaloHitList &caloHits(m_hierarchy.m_mcToHitsMap.at(pMCParticle));
638  allHits.insert(allHits.begin(), caloHits.begin(), caloHits.end());
639  }
640  }
641  if (!allParticles.empty())
642  {
643  Node *pNode{new Node(m_hierarchy, allParticles, allHits, this->m_tier + 1)};
644  m_children.emplace_back(pNode);
645  }
646 }
std::map< const pandora::MCParticle *, pandora::CaloHitList > m_mcToHitsMap
The map between MC particles and calo hits.
NodeVector m_children
The child nodes of this node.
ReconstructabilityCriteria m_recoCriteria
The criteria used to determine if the node is reconstructable.
MCHierarchy & m_hierarchy
The parent MC hierarchy.
const bool m_removeNeutrons
whether to remove neutrons and their downstream particles
Node(MCHierarchy &hierarchy, const pandora::MCParticle *pMCParticle, const int tier=1)
Create a node with a primary MC particle.
int m_tier
The hierarchy tier for this node.
static void GetAllDescendentMCParticles(const pandora::MCParticle *const pMCParticle, pandora::MCParticleList &descendentMCParticleList)
Get all descendent mc particles.
void lar_content::LArHierarchyHelper::MCHierarchy::Node::FillHierarchy ( const pandora::MCParticle *  pRoot,
const FoldingParameters foldParameters 
)

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

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

Definition at line 548 of file LArHierarchyHelper.cc.

549 {
550  if (foldParameters.m_foldDynamic)
551  {
552  MCParticleList leadingParticles, childParticles;
553  m_hierarchy.InterpretHierarchy(pRoot, leadingParticles, childParticles, foldParameters.m_cosAngleTolerance);
554  CaloHitList allHits;
555  for (const MCParticle *pMCParticle : leadingParticles)
556  {
557  // ATTN - Not all MC particles will have hits
558  if (m_hierarchy.m_mcToHitsMap.find(pMCParticle) != m_hierarchy.m_mcToHitsMap.end())
559  {
560  const CaloHitList &caloHits(m_hierarchy.m_mcToHitsMap.at(pMCParticle));
561  allHits.insert(allHits.begin(), caloHits.begin(), caloHits.end());
562  }
563  }
564 
565  Node *pNode{new Node(m_hierarchy, leadingParticles, allHits, this->m_tier + 1)};
566  m_children.emplace_back(pNode);
567  for (const MCParticle *pChild : childParticles)
568  pNode->FillHierarchy(pChild, foldParameters);
569  }
570  else
571  {
572  MCParticleList allParticles{pRoot};
573  const int pdg{std::abs(pRoot->GetParticleId())};
574  const bool isShower{pdg == E_MINUS || pdg == PHOTON};
575  const bool isNeutron{pdg == NEUTRON};
576 
577  if (foldParameters.m_foldToTier && LArMCParticleHelper::GetHierarchyTier(pRoot) >= foldParameters.m_tier)
579  else if (foldParameters.m_foldToLeadingShowers && (isShower || (isNeutron && !m_hierarchy.m_recoCriteria.m_removeNeutrons)))
581  else if (m_hierarchy.m_recoCriteria.m_removeNeutrons && isNeutron)
582  return;
583 
584  CaloHitList allHits;
585  for (const MCParticle *pMCParticle : allParticles)
586  {
587  // ATTN - Not all MC particles will have hits
588  if (m_hierarchy.m_mcToHitsMap.find(pMCParticle) != m_hierarchy.m_mcToHitsMap.end())
589  {
590  const CaloHitList &caloHits(m_hierarchy.m_mcToHitsMap.at(pMCParticle));
591  allHits.insert(allHits.begin(), caloHits.begin(), caloHits.end());
592  }
593  }
594 
595  if (!allParticles.empty())
596  {
597  const bool hasChildren{(foldParameters.m_foldToTier && LArMCParticleHelper::GetHierarchyTier(pRoot) < foldParameters.m_tier) ||
598  (!foldParameters.m_foldToTier && !foldParameters.m_foldToLeadingShowers) ||
599  (foldParameters.m_foldToLeadingShowers && !(isShower || isNeutron))};
600  // Only add the node if it either has children, or is a leaf node with hits
601  if (hasChildren || (!hasChildren && !allHits.empty()))
602  {
603  Node *pNode{new Node(m_hierarchy, allParticles, allHits, this->m_tier + 1)};
604  m_children.emplace_back(pNode);
605  if (hasChildren)
606  {
607  // Find the children of this particle and recursively add them to the hierarchy
608  const MCParticleList &children{pRoot->GetDaughterList()};
609  for (const MCParticle *pChild : children)
610  pNode->FillHierarchy(pChild, foldParameters);
611  }
612  }
613  }
614  }
615 }
std::map< const pandora::MCParticle *, pandora::CaloHitList > m_mcToHitsMap
The map between MC particles and calo hits.
static int GetHierarchyTier(const pandora::MCParticle *const pMCParticle)
Determine the position in the hierarchy for the MCParticle.
T abs(T value)
void InterpretHierarchy(const pandora::MCParticle *const pRoot, pandora::MCParticleList &leadingParticles, pandora::MCParticleList &childParticles, const float cosAngleTolerance) const
Interpret the hierarchy below a particular particle to determine if and how it should be folded...
NodeVector m_children
The child nodes of this node.
ReconstructabilityCriteria m_recoCriteria
The criteria used to determine if the node is reconstructable.
MCHierarchy & m_hierarchy
The parent MC hierarchy.
const bool m_removeNeutrons
whether to remove neutrons and their downstream particles
Node(MCHierarchy &hierarchy, const pandora::MCParticle *pMCParticle, const int tier=1)
Create a node with a primary MC particle.
int m_tier
The hierarchy tier for this node.
static void GetAllDescendentMCParticles(const pandora::MCParticle *const pMCParticle, pandora::MCParticleList &descendentMCParticleList)
Get all descendent mc particles.
const pandora::CaloHitList & lar_content::LArHierarchyHelper::MCHierarchy::Node::GetCaloHits ( ) const
inline

Retrieve the CaloHits associated with this node.

Returns
The list of CaloHits associated with this node

Definition at line 898 of file LArHierarchyHelper.h.

899 {
900  return m_caloHits;
901 }
pandora::CaloHitList m_caloHits
The list of calo hits of which this node is composed.
const LArHierarchyHelper::MCHierarchy::NodeVector & lar_content::LArHierarchyHelper::MCHierarchy::Node::GetChildren ( ) const
inline

Return the vector of children for this node.

Returns
The vector of children

Definition at line 884 of file LArHierarchyHelper.h.

885 {
886  return m_children;
887 }
NodeVector m_children
The child nodes of this node.
int lar_content::LArHierarchyHelper::MCHierarchy::Node::GetHierarchyTier ( ) const
inline

Retrieve the hierarchy tier of this node.

Returns
The hierarchy tier of this node

Definition at line 919 of file LArHierarchyHelper.h.

920 {
921  return m_tier;
922 }
int m_tier
The hierarchy tier for this node.
int lar_content::LArHierarchyHelper::MCHierarchy::Node::GetId ( ) const

Retrieve the unique ID of this node.

Returns
The unique ID of this node

Definition at line 650 of file LArHierarchyHelper.cc.

651 {
652  return m_hierarchy.m_nodeToIdMap.at(this);
653 }
MCHierarchy & m_hierarchy
The parent MC hierarchy.
std::map< const Node *, int > m_nodeToIdMap
A map from nodes to unique ids.
const pandora::MCParticle * lar_content::LArHierarchyHelper::MCHierarchy::Node::GetLeadingMCParticle ( ) const
inline

Retrieve the leading MC particle associated with this node.

Returns
The main MC particle associated with this node

Definition at line 905 of file LArHierarchyHelper.h.

906 {
907  return m_mainParticle;
908 }
const pandora::MCParticle * m_mainParticle
The leading MC particle for this node.
const pandora::MCParticleList & lar_content::LArHierarchyHelper::MCHierarchy::Node::GetMCParticles ( ) const
inline

Retrieve the MC particles associated with this node.

Returns
The MC particles associated with this node

Definition at line 891 of file LArHierarchyHelper.h.

892 {
893  return m_mcParticles;
894 }
pandora::MCParticleList m_mcParticles
The list of MC particles of which this node is composed.
int lar_content::LArHierarchyHelper::MCHierarchy::Node::GetParticleId ( ) const
inline

Retrieve the PDG code for the leading particle in this node.

Returns
The PDG code for the leading particle in this node

Definition at line 912 of file LArHierarchyHelper.h.

913 {
914  return m_pdg;
915 }
int m_pdg
The PDG code of the leading MC particle for this node.
bool lar_content::LArHierarchyHelper::MCHierarchy::Node::IsCosmicRay ( ) const

Check if this is a cosmic ray particle.

Returns
Whether or not this is a cosmic ray

Definition at line 709 of file LArHierarchyHelper.cc.

710 {
711  if (m_mainParticle)
713  else
714  return false;
715 }
static bool IsCosmicRay(const pandora::MCParticle *const pMCParticle)
Return true if passed a primary cosmic ray MCParticle.
const pandora::MCParticle * m_mainParticle
The leading MC particle for this node.
bool lar_content::LArHierarchyHelper::MCHierarchy::Node::IsLeadingLepton ( ) const
inline

Returns whether or not this particle is the leading lepton in the event.

Returns
Whether or not this is the leading lepton

Definition at line 933 of file LArHierarchyHelper.h.

934 {
935  return m_isLeadingLepton;
936 }
bool m_isLeadingLepton
Whether or not this node is the leading lepton.
bool lar_content::LArHierarchyHelper::MCHierarchy::Node::IsNeutrinoInduced ( ) const
inline

Check if this is a particle induced by a neutrino interaction.

Returns
Whether or not this is neutrino induced

Definition at line 926 of file LArHierarchyHelper.h.

927 {
929 }
bool IsCosmicRay() const
Check if this is a cosmic ray particle.
bool IsTestBeamParticle() const
Check if this is a test beam particle.
bool lar_content::LArHierarchyHelper::MCHierarchy::Node::IsReconstructable ( ) const

Return whether or not this node should be considered reconstructable.

Returns
true if reconstructable, false otherwise

Definition at line 657 of file LArHierarchyHelper.cc.

658 {
659  const bool enoughHits{m_caloHits.size() >= m_hierarchy.m_recoCriteria.m_minHits};
660  if (!enoughHits)
661  return false;
662  bool enoughGoodViews{false};
663  unsigned int nHitsU{0}, nHitsV{0}, nHitsW{0};
664  for (const CaloHit *pCaloHit : m_caloHits)
665  {
666  switch (pCaloHit->GetHitType())
667  {
668  case TPC_VIEW_U:
669  ++nHitsU;
670  break;
671  case TPC_VIEW_V:
672  ++nHitsV;
673  break;
674  case TPC_VIEW_W:
675  ++nHitsW;
676  break;
677  default:
678  break;
679  }
680  unsigned int nGoodViews{0};
682  ++nGoodViews;
684  ++nGoodViews;
686  ++nGoodViews;
687  if (nGoodViews >= m_hierarchy.m_recoCriteria.m_minGoodViews)
688  {
689  enoughGoodViews = true;
690  break;
691  }
692  }
693 
694  return enoughGoodViews;
695 }
const unsigned int m_minHitsForGoodView
the minimum number of Hits for a good view
pandora::CaloHitList m_caloHits
The list of calo hits of which this node is composed.
ReconstructabilityCriteria m_recoCriteria
The criteria used to determine if the node is reconstructable.
MCHierarchy & m_hierarchy
The parent MC hierarchy.
const unsigned int m_minHits
the minimum number of primary good Hits
const unsigned int m_minGoodViews
the minimum number of primary good views
bool lar_content::LArHierarchyHelper::MCHierarchy::Node::IsTestBeamParticle ( ) const

Check if this is a test beam particle.

Returns
Whether or not this is a test beam particle

Definition at line 699 of file LArHierarchyHelper.cc.

700 {
701  if (m_mainParticle)
703  else
704  return false;
705 }
static bool IsBeamParticle(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary beam MCParticle.
const pandora::MCParticle * m_mainParticle
The leading MC particle for this node.
void lar_content::LArHierarchyHelper::MCHierarchy::Node::SetLeadingLepton ( )
inlineprivate

Tags the particle as the leading lepton.

Definition at line 940 of file LArHierarchyHelper.h.

941 {
942  m_isLeadingLepton = true;
943 }
bool m_isLeadingLepton
Whether or not this node is the leading lepton.
const std::string lar_content::LArHierarchyHelper::MCHierarchy::Node::ToString ( const std::string prefix) const

Produce a string representation of the hierarchy.

Returns
The string representation of the hierarchy

Definition at line 719 of file LArHierarchyHelper.cc.

720 {
721  std::string str(prefix + "PDG: " + std::to_string(m_pdg) + " Energy: " + std::to_string(m_mainParticle ? m_mainParticle->GetEnergy() : 0) +
722  " Hits: " + std::to_string(m_caloHits.size()) + "\n");
723  for (const Node *pChild : m_children)
724  str += pChild->ToString(prefix + " ");
725 
726  return str;
727 }
std::string string
Definition: nybbler.cc:12
int m_pdg
The PDG code of the leading MC particle for this node.
pandora::CaloHitList m_caloHits
The list of calo hits of which this node is composed.
NodeVector m_children
The child nodes of this node.
const pandora::MCParticle * m_mainParticle
The leading MC particle for this node.
Node(MCHierarchy &hierarchy, const pandora::MCParticle *pMCParticle, const int tier=1)
Create a node with a primary MC particle.
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
static QCString str

Friends And Related Function Documentation

friend class MCHierarchy
friend

Definition at line 279 of file LArHierarchyHelper.h.

Member Data Documentation

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

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

Definition at line 272 of file LArHierarchyHelper.h.

NodeVector lar_content::LArHierarchyHelper::MCHierarchy::Node::m_children
private

The child nodes of this node.

Definition at line 273 of file LArHierarchyHelper.h.

MCHierarchy& lar_content::LArHierarchyHelper::MCHierarchy::Node::m_hierarchy
private

The parent MC hierarchy.

Definition at line 270 of file LArHierarchyHelper.h.

bool lar_content::LArHierarchyHelper::MCHierarchy::Node::m_isLeadingLepton
private

Whether or not this node is the leading lepton.

Definition at line 277 of file LArHierarchyHelper.h.

const pandora::MCParticle* lar_content::LArHierarchyHelper::MCHierarchy::Node::m_mainParticle
private

The leading MC particle for this node.

Definition at line 274 of file LArHierarchyHelper.h.

pandora::MCParticleList lar_content::LArHierarchyHelper::MCHierarchy::Node::m_mcParticles
private

The list of MC particles of which this node is composed.

Definition at line 271 of file LArHierarchyHelper.h.

int lar_content::LArHierarchyHelper::MCHierarchy::Node::m_pdg
private

The PDG code of the leading MC particle for this node.

Definition at line 276 of file LArHierarchyHelper.h.

int lar_content::LArHierarchyHelper::MCHierarchy::Node::m_tier
private

The hierarchy tier for this node.

Definition at line 275 of file LArHierarchyHelper.h.


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