LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
lar_content::BranchGrowingAlgorithm Class Referenceabstract

BranchGrowingAlgorithm class. More...

#include "BranchGrowingAlgorithm.h"

Inheritance diagram for lar_content::BranchGrowingAlgorithm:
lar_content::ShowerGrowingAlgorithm

Classes

class  Association
 Association class. More...
 

Protected Types

enum  AssociationType { NONE = 0, SINGLE_ORDER = 1, STANDARD = 2, STRONG = 3 }
 AssociationType enum. More...
 
typedef std::unordered_map< const pandora::Cluster *, AssociationClusterAssociationMap
 
typedef std::unordered_map< const pandora::Cluster *, ClusterAssociationMapClusterUsageMap
 
typedef std::unordered_map< const pandora::Cluster *, pandora::ClusterVector > SeedAssociationList
 

Protected Member Functions

virtual AssociationType AreClustersAssociated (const pandora::Cluster *const pClusterSeed, const pandora::Cluster *const pCluster) const =0
 Determine whether two clusters are associated. More...
 
void FindAssociatedClusters (const pandora::Cluster *const pParticleSeed, pandora::ClusterVector &candidateClusters, ClusterUsageMap &forwardUsageMap, ClusterUsageMap &backwardUsageMap) const
 Find clusters associated with a particle seed. More...
 
void IdentifyClusterMerges (const pandora::ClusterVector &particleSeedVector, const ClusterUsageMap &backwardUsageMap, SeedAssociationList &seedAssociationList) const
 Identify cluster merges. More...
 
virtual pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Detailed Description

BranchGrowingAlgorithm class.

Definition at line 21 of file BranchGrowingAlgorithm.h.

Member Typedef Documentation

typedef std::unordered_map<const pandora::Cluster*, Association> lar_content::BranchGrowingAlgorithm::ClusterAssociationMap
protected

Definition at line 87 of file BranchGrowingAlgorithm.h.

typedef std::unordered_map<const pandora::Cluster*, ClusterAssociationMap> lar_content::BranchGrowingAlgorithm::ClusterUsageMap
protected

Definition at line 88 of file BranchGrowingAlgorithm.h.

typedef std::unordered_map<const pandora::Cluster*, pandora::ClusterVector> lar_content::BranchGrowingAlgorithm::SeedAssociationList
protected

Definition at line 111 of file BranchGrowingAlgorithm.h.

Member Enumeration Documentation

Member Function Documentation

virtual AssociationType lar_content::BranchGrowingAlgorithm::AreClustersAssociated ( const pandora::Cluster *const  pClusterSeed,
const pandora::Cluster *const  pCluster 
) const
protectedpure virtual

Determine whether two clusters are associated.

Parameters
pClusterSeedaddress of cluster seed (may be daughter of primary seed)
pClusteraddress of cluster
Returns
the association type

Implemented in lar_content::ShowerGrowingAlgorithm.

void lar_content::BranchGrowingAlgorithm::FindAssociatedClusters ( const pandora::Cluster *const  pParticleSeed,
pandora::ClusterVector &  candidateClusters,
ClusterUsageMap forwardUsageMap,
ClusterUsageMap backwardUsageMap 
) const
protected

Find clusters associated with a particle seed.

Parameters
pParticleSeedaddress of the particle seed
candidateClusterslist of clusters which may be associated with seed
forwardUsageMapthe particle seed usage map
backwardUsageMapthe cluster usage map

Definition at line 20 of file BranchGrowingAlgorithm.cc.

References lar_content::BranchGrowingAlgorithm::Association::GetType(), min, and lar_content::BranchGrowingAlgorithm::Association::SetType().

Referenced by lar_content::ShowerGrowingAlgorithm::GetSeedAssociationList().

22 {
23  ClusterVector currentSeedAssociations, newSeedAssociations;
24  currentSeedAssociations.push_back(pParticleSeed);
25 
26  unsigned int associationOrder(1);
27 
28  while (!currentSeedAssociations.empty())
29  {
30  for (ClusterVector::iterator iterI = candidateClusters.begin(), iterIEnd = candidateClusters.end(); iterI != iterIEnd; ++iterI)
31  {
32  const Cluster *const pCandidateCluster = *iterI;
33 
34  if (NULL == pCandidateCluster)
35  continue;
36 
37  for (ClusterVector::iterator iterJ = currentSeedAssociations.begin(), iterJEnd = currentSeedAssociations.end(); iterJ != iterJEnd; ++iterJ)
38  {
39  const Cluster *const pAssociatedCluster = *iterJ;
40 
41  const AssociationType associationType(this->AreClustersAssociated(pAssociatedCluster, pCandidateCluster));
42 
43  if (NONE == associationType)
44  continue;
45 
46  // Check we store best association between this seed and candidate
47  Association association(associationOrder, associationType);
48  const Association &existingAssociation = forwardUsageMap[pParticleSeed][pCandidateCluster];
49 
50  if (association.GetType() > existingAssociation.GetType())
51  {
52  // If not first association, check strength of previous association in chain
53  if (pParticleSeed != pAssociatedCluster)
54  association.SetType(std::min(association.GetType(), backwardUsageMap[pAssociatedCluster][pParticleSeed].GetType()));
55 
56  forwardUsageMap[pParticleSeed][pCandidateCluster] = association;
57  backwardUsageMap[pCandidateCluster][pParticleSeed] = association;
58  }
59 
60  newSeedAssociations.push_back(pCandidateCluster);
61  *iterI = NULL;
62  }
63  }
64 
65  currentSeedAssociations = newSeedAssociations;
66  newSeedAssociations.clear();
67  ++associationOrder;
68  }
69 }
intermediate_table::iterator iterator
std::vector< art::Ptr< recob::Cluster > > ClusterVector
Int_t min
Definition: plot.C:26
virtual AssociationType AreClustersAssociated(const pandora::Cluster *const pClusterSeed, const pandora::Cluster *const pCluster) const =0
Determine whether two clusters are associated.
void lar_content::BranchGrowingAlgorithm::IdentifyClusterMerges ( const pandora::ClusterVector &  particleSeedVector,
const ClusterUsageMap backwardUsageMap,
SeedAssociationList seedAssociationList 
) const
protected

Identify cluster merges.

Parameters
particleSeedVectorthe list of all particle seeds
backwardUsageMapthe map from cluster to particle seed associations
seedAssociationListto receive the populated seed association list

Definition at line 73 of file BranchGrowingAlgorithm.cc.

References lar_content::BranchGrowingAlgorithm::Association::GetType(), and max.

Referenced by lar_content::ShowerGrowingAlgorithm::GetSeedAssociationList().

75 {
76  ClusterVector sortedCandidates;
77  for (const auto &mapEntry : backwardUsageMap) sortedCandidates.push_back(mapEntry.first);
78  std::sort(sortedCandidates.begin(), sortedCandidates.end(), LArClusterHelper::SortByNHits);
79 
80  for (const Cluster *const pCluster : sortedCandidates)
81  {
82  const ClusterAssociationMap &particleSeedUsageMap(backwardUsageMap.at(pCluster));
83 
84  if (particleSeedUsageMap.empty())
85  throw StatusCodeException(STATUS_CODE_FAILURE);
86 
87  ClusterVector sortedSeeds;
88  for (const auto &mapEntry : particleSeedUsageMap) sortedSeeds.push_back(mapEntry.first);
89  std::sort(sortedSeeds.begin(), sortedSeeds.end(), LArClusterHelper::SortByNHits);
90 
91  const Cluster *pBestParticleSeed = NULL;
92  AssociationType bestType(NONE);
93  unsigned int bestOrder(std::numeric_limits<unsigned int>::max());
94 
95  for (const Cluster *const pParticleSeed : sortedSeeds)
96  {
97  const Association &association(particleSeedUsageMap.at(pParticleSeed));
98 
99  if ((association.GetType() > bestType) || ((association.GetType() == bestType) && (association.GetOrder() < bestOrder)))
100  {
101  // Break-out condition for single order associations
102  if ((SINGLE_ORDER == association.GetType()) && (association.GetOrder() > 1))
103  continue;
104 
105  // Type is primary consideration; order breaks ties
106  pBestParticleSeed = pParticleSeed;
107  bestType = association.GetType();
108  bestOrder = association.GetOrder();
109  }
110  else if ((association.GetType() == bestType) && (association.GetOrder() == bestOrder))
111  {
112  // Remove ambiguous cluster from algorithm
113  pBestParticleSeed = NULL;
114  }
115  }
116 
117  if (NULL == pBestParticleSeed)
118  continue;
119 
120  seedAssociationList[pBestParticleSeed].push_back(pCluster);
121  }
122 
123  // Now deal with seeds that have no associations
124  for (ClusterVector::const_iterator iter = particleSeedVector.begin(), iterEnd = particleSeedVector.end(); iter != iterEnd; ++iter)
125  {
126  const Cluster *const pParticleSeed = *iter;
127 
128  if (seedAssociationList.end() == seedAssociationList.find(pParticleSeed))
129  seedAssociationList[pParticleSeed] = ClusterVector();
130  }
131 }
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
Int_t max
Definition: plot.C:27
intermediate_table::const_iterator const_iterator
std::vector< art::Ptr< recob::Cluster > > ClusterVector
std::unordered_map< const pandora::Cluster *, Association > ClusterAssociationMap
StatusCode lar_content::BranchGrowingAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
protectedvirtual

Reimplemented in lar_content::ShowerGrowingAlgorithm.

Definition at line 135 of file BranchGrowingAlgorithm.cc.

Referenced by lar_content::ShowerGrowingAlgorithm::ReadSettings().

136 {
137  return STATUS_CODE_SUCCESS;
138 }

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