Fill the cluster merge map.
137 for (
const auto &mapEntry : parentToDaughterMatrix)
138 sortedParentClusters.push_back(mapEntry.first);
141 for (
const Cluster *
const pParentCluster : sortedParentClusters)
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));
160 if (clusterAssociation.GetParent() ==
ClusterAssociation::INNER && clusterAssociation.GetFigureOfMerit() < maxDisplacementInner)
161 maxDisplacementInner = clusterAssociation.GetFigureOfMerit();
163 if (clusterAssociation.GetParent() ==
ClusterAssociation::OUTER && clusterAssociation.GetFigureOfMerit() < maxDisplacementOuter)
164 maxDisplacementOuter = clusterAssociation.GetFigureOfMerit();
169 for (
const Cluster *
const pDaughterCluster : sortedLocalDaughterClusters)
171 const ClusterAssociation &clusterAssociation(daughterToAssociationMap.at(pDaughterCluster));
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);
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));
207 if (clusterAssociation.GetFigureOfMerit() < minDisplacement)
209 minDisplacement = clusterAssociation.GetFigureOfMerit();
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);
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
static int max(int a, int b)
std::vector< art::Ptr< recob::Cluster > > ClusterVector