Fill the cluster merge map.
185 for (
const auto &mapEntry : inputAssociationMatrix)
186 sortedInputClusters.push_back(mapEntry.first);
189 for (
const Cluster *
const pCluster1 : sortedInputClusters)
193 for (
const Cluster *
const pCluster2 : sortedInputClusters)
195 if (pCluster1 == pCluster2)
200 ClusterAssociationMap::const_iterator iter12 = associationMap1.find(pCluster2);
201 if (associationMap1.end() == iter12)
204 ClusterAssociationMap::const_iterator iter21 = associationMap2.find(pCluster1);
205 if (associationMap2.end() == iter21)
208 const ClusterAssociation &association12(iter12->second);
209 const ClusterAssociation &association21(iter21->second);
211 bool isAssociated(
true);
214 for (
const auto &mapEntry : associationMap1)
215 sortedAssociationClusters.push_back(mapEntry.first);
218 for (
const Cluster *
const pCluster3 : sortedAssociationClusters)
220 const ClusterAssociation &association13(associationMap1.at(pCluster3));
222 ClusterAssociationMap::const_iterator iter23 = associationMap2.find(pCluster3);
223 if (associationMap2.end() == iter23)
226 const ClusterAssociation &association23(iter23->second);
228 if (association12.GetParent() == association13.GetParent() && association23.GetParent() == association21.GetParent() &&
229 association13.GetDaughter() != association23.GetDaughter())
231 isAssociated =
false;
238 (
void)clusterAssociationMatrix[pCluster1].insert(ClusterAssociationMap::value_type(pCluster2, association12));
239 (
void)clusterAssociationMatrix[pCluster2].insert(ClusterAssociationMap::value_type(pCluster1, association21));
248 for (
const auto &mapEntry : clusterAssociationMatrix)
249 sortedClusters.push_back(mapEntry.first);
252 for (
const Cluster *
const pParentCluster : sortedClusters)
256 const Cluster *pBestClusterInner(
nullptr);
259 const Cluster *pBestClusterOuter(
nullptr);
263 for (
const auto &mapEntry : clusterAssociationMap)
264 sortedAssociationClusters.push_back(mapEntry.first);
267 for (
const Cluster *
const pDaughterCluster : sortedAssociationClusters)
269 const ClusterAssociation &clusterAssociation(clusterAssociationMap.at(pDaughterCluster));
274 if (clusterAssociation.GetFigureOfMerit() > bestAssociationInner.GetFigureOfMerit())
276 bestAssociationInner = clusterAssociation;
277 pBestClusterInner = pDaughterCluster;
284 if (clusterAssociation.GetFigureOfMerit() > bestAssociationOuter.GetFigureOfMerit())
286 bestAssociationOuter = clusterAssociation;
287 pBestClusterOuter = pDaughterCluster;
292 if (pBestClusterInner)
293 (
void)intermediateAssociationMatrix[pParentCluster].insert(ClusterAssociationMap::value_type(pBestClusterInner, bestAssociationInner));
295 if (pBestClusterOuter)
296 (
void)intermediateAssociationMatrix[pParentCluster].insert(ClusterAssociationMap::value_type(pBestClusterOuter, bestAssociationOuter));
301 for (
const auto &mapEntry : intermediateAssociationMatrix)
302 intermediateSortedClusters.push_back(mapEntry.first);
305 for (
const Cluster *
const pParentCluster : intermediateSortedClusters)
310 for (
const auto &mapEntry : parentAssociationMap)
311 sortedAssociationClusters.push_back(mapEntry.first);
314 for (
const Cluster *
const pDaughterCluster : sortedAssociationClusters)
316 const ClusterAssociation &parentToDaughterAssociation(parentAssociationMap.at(pDaughterCluster));
318 ClusterAssociationMatrix::const_iterator iter5 = intermediateAssociationMatrix.find(pDaughterCluster);
320 if (intermediateAssociationMatrix.end() == iter5)
325 ClusterAssociationMap::const_iterator iter6 = daughterAssociationMap.find(pParentCluster);
327 if (daughterAssociationMap.end() == iter6)
330 const ClusterAssociation &daughterToParentAssociation(iter6->second);
332 if (parentToDaughterAssociation.GetParent() == daughterToParentAssociation.GetDaughter() &&
333 parentToDaughterAssociation.GetDaughter() == daughterToParentAssociation.GetParent())
335 ClusterList &parentList(clusterMergeMap[pParentCluster]);
337 if (parentList.end() == std::find(parentList.begin(), parentList.end(), pDaughterCluster))
338 parentList.push_back(pDaughterCluster);
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 *, ClusterAssociation > ClusterAssociationMap
std::unordered_map< const pandora::Cluster *, ClusterAssociationMap > ClusterAssociationMatrix
std::vector< art::Ptr< recob::Cluster > > ClusterVector