45 for (ClusterVector::const_iterator iter = clusterVector.begin(), iterEnd = clusterVector.end(); iter != iterEnd; ++iter)
47 const Cluster *
const pCluster(*iter);
62 for (LArPointingClusterList::const_iterator iter1 = pointingClusterList.begin(), iterEnd1 = pointingClusterList.end(); iter1 != iterEnd1; ++iter1)
66 for (ClusterVector::const_iterator iter2 = clusterVector.begin(), iterEnd2 = clusterVector.end(); iter2 != iterEnd2; ++iter2)
68 const Cluster *
const pDaughterCluster(*iter2);
70 if (parentCluster.
GetCluster() == pDaughterCluster)
85 if (pParentCluster == pDaughterCluster)
88 for (
unsigned int useInner = 0; useInner < 2; ++useInner)
91 const ClusterAssociation::VertexType vertexType(useInner == 1 ? ClusterAssociation::INNER : ClusterAssociation::OUTER);
93 if (pointingVertex.GetRms() > 0.5f)
101 ClusterAssociation::AssociationType associationType(ClusterAssociation::WEAK);
102 float figureOfMerit(projectedDisplacement);
108 float firstL(0.f), firstT(0.f), secondT(0.f), secondL(0.f);
112 const float innerL(firstL < secondL ? firstL : secondL);
113 const float innerT(firstL < secondL ? firstT : secondT);
114 const float outerL(firstL > secondL ? firstL : secondL);
115 const float outerT(firstL > secondL ? firstT : secondT);
120 associationType = ClusterAssociation::STRONG;
121 figureOfMerit = outerL;
124 (void)clusterAssociationMatrix[pParentCluster].insert(
125 ClusterAssociationMap::value_type(pDaughterCluster,
ClusterAssociation(vertexType, vertexType, associationType, figureOfMerit)));
137 for (
const auto &mapEntry : parentToDaughterMatrix)
138 sortedParentClusters.push_back(mapEntry.first);
141 for (
const Cluster *
const pParentCluster : sortedParentClusters)
145 float maxDisplacementInner(std::numeric_limits<float>::max());
146 float maxDisplacementOuter(std::numeric_limits<float>::max());
150 for (
const auto &mapEntry : daughterToAssociationMap)
151 sortedLocalDaughterClusters.push_back(mapEntry.first);
154 for (
const Cluster *
const pDaughterCluster : sortedLocalDaughterClusters)
156 const ClusterAssociation &clusterAssociation(daughterToAssociationMap.at(pDaughterCluster));
158 if (clusterAssociation.
GetAssociation() == ClusterAssociation::WEAK)
160 if (clusterAssociation.
GetParent() == ClusterAssociation::INNER && clusterAssociation.
GetFigureOfMerit() < maxDisplacementInner)
163 if (clusterAssociation.
GetParent() == ClusterAssociation::OUTER && clusterAssociation.
GetFigureOfMerit() < maxDisplacementOuter)
169 for (
const Cluster *
const pDaughterCluster : sortedLocalDaughterClusters)
171 const ClusterAssociation &clusterAssociation(daughterToAssociationMap.at(pDaughterCluster));
173 if (clusterAssociation.
GetAssociation() == ClusterAssociation::STRONG)
175 if (clusterAssociation.
GetParent() == ClusterAssociation::INNER && clusterAssociation.
GetFigureOfMerit() < maxDisplacementInner)
176 (void)daughterToParentMatrix[pDaughterCluster].insert(ClusterAssociationMap::value_type(pParentCluster, clusterAssociation));
178 if (clusterAssociation.
GetParent() == ClusterAssociation::OUTER && clusterAssociation.
GetFigureOfMerit() < maxDisplacementOuter)
179 (
void)daughterToParentMatrix[pDaughterCluster].insert(ClusterAssociationMap::value_type(pParentCluster, clusterAssociation));
186 for (
const auto &mapEntry : daughterToParentMatrix)
187 sortedDaughterClusters.push_back(mapEntry.first);
191 for (
const Cluster *
const pDaughterCluster : sortedDaughterClusters)
195 const Cluster *pParentCluster(
nullptr);
196 float minDisplacement(std::numeric_limits<float>::max());
199 for (
const auto &mapEntry : parentToAssociationMap)
200 sortedLocalParentClusters.push_back(mapEntry.first);
203 for (
const Cluster *
const pCandidateParentCluster : sortedLocalParentClusters)
205 const ClusterAssociation &clusterAssociation(parentToAssociationMap.at(pCandidateParentCluster));
210 pParentCluster = pCandidateParentCluster;
216 ClusterList &parentList(clusterMergeMap[pParentCluster]);
218 if (parentList.end() == std::find(parentList.begin(), parentList.end(), pDaughterCluster))
219 parentList.push_back(pDaughterCluster);
221 ClusterList &daughterList(clusterMergeMap[pDaughterCluster]);
223 if (daughterList.end() == std::find(daughterList.begin(), daughterList.end(), pParentCluster))
224 daughterList.push_back(pParentCluster);
std::unordered_map< const pandora::Cluster *, ClusterAssociationMap > ClusterAssociationMatrix
std::unordered_map< const pandora::Cluster *, ClusterAssociation > ClusterAssociationMap
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
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,...
static void GetExtremalCoordinates(const pandora::ClusterList &clusterList, pandora::CartesianVector &innerCoordinate, pandora::CartesianVector &outerCoordinate)
Get positions of the two most distant calo hits in a list of cluster (ordered by Z)
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
static void GetImpactParameters(const LArPointingCluster::Vertex &pointingVertex, const LArPointingCluster::Vertex &targetVertex, float &longitudinal, float &transverse)
Calculate impact parameters between a pair of pointing vertices.
LArPointingCluster class.
const Vertex & GetInnerVertex() const
Get the inner vertex.
const pandora::Cluster * GetCluster() const
Get the address of the cluster.
const Vertex & GetOuterVertex() const
Get the outer vertex.
void FillClusterMergeMap(const ClusterAssociationMatrix &clusterAssociationMatrix, ClusterMergeMap &clusterMergeMap) const
Fill the cluster merge map.
void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &clusterVector) const
Populate cluster vector with subset of cluster list, containing clusters judged to be clean.
void FillClusterAssociationMatrix(const pandora::ClusterVector &clusterVector, ClusterAssociationMatrix &clusterAssociationMatrix) const
Fill the cluster association matrix.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
std::vector< LArPointingCluster > LArPointingClusterList