All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Protected Types | Protected Member Functions | List of all members
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
*, Association
ClusterAssociationMap
 
typedef std::unordered_map
< const pandora::Cluster
*, ClusterAssociationMap
ClusterUsageMap
 
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.

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 }
std::vector< art::Ptr< recob::Cluster > > ClusterVector
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.

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

Reimplemented in lar_content::ShowerGrowingAlgorithm.

Definition at line 137 of file BranchGrowingAlgorithm.cc.

138 {
139  return STATUS_CODE_SUCCESS;
140 }

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