Fill the cluster merge map.
186 for (
const auto &mapEntry : parentToDaughterMatrix)
187 sortedParentClusters.push_back(mapEntry.first);
190 for (
const Cluster *
const pParentCluster : sortedParentClusters)
195 for (
const auto &mapEntry : daughterToAssociationMap)
196 sortedLocalDaughterClusters.push_back(mapEntry.first);
199 for (
const Cluster *
const pDaughterCluster : sortedLocalDaughterClusters)
201 const ClusterAssociation &clusterAssociation(daughterToAssociationMap.at(pDaughterCluster));
202 (void)daughterToParentMatrix[pDaughterCluster].insert(ClusterAssociationMap::value_type(pParentCluster, clusterAssociation));
209 for (
const auto &mapEntry : daughterToParentMatrix)
210 sortedDaughterClusters.push_back(mapEntry.first);
214 for (
const Cluster *
const pDaughterCluster : sortedDaughterClusters)
218 const Cluster *pBestInner(NULL);
219 const Cluster *pBestOuter(NULL);
221 float bestFomInner(std::numeric_limits<float>::max());
222 float bestFomOuter(std::numeric_limits<float>::max());
225 for (
const auto &mapEntry : parentToAssociationMap)
226 sortedLocalParentClusters.push_back(mapEntry.first);
229 for (
const Cluster *
const pParentCluster : sortedLocalParentClusters)
231 const ClusterAssociation &clusterAssociation(parentToAssociationMap.at(pParentCluster));
235 if (clusterAssociation.GetFigureOfMerit() < bestFomInner)
237 bestFomInner = clusterAssociation.GetFigureOfMerit();
241 pBestInner = pParentCluster;
252 if (clusterAssociation.GetFigureOfMerit() < bestFomOuter)
254 bestFomOuter = clusterAssociation.GetFigureOfMerit();
258 pBestOuter = pParentCluster;
272 if (parentToDaughterMatrix.end() == iter3A)
273 throw pandora::StatusCodeException(STATUS_CODE_FAILURE);
278 if (parentToDaughterMap.end() == iter3B)
279 throw pandora::StatusCodeException(STATUS_CODE_FAILURE);
281 const ClusterAssociation &bestAssociationInner(iter3B->second);
282 (void)reducedParentToDaughterMatrix[pBestInner].insert(ClusterAssociationMap::value_type(pDaughterCluster, bestAssociationInner));
289 if (parentToDaughterMatrix.end() == iter3A)
290 throw pandora::StatusCodeException(STATUS_CODE_FAILURE);
295 if (parentToDaughterMap.end() == iter3B)
296 throw pandora::StatusCodeException(STATUS_CODE_FAILURE);
298 const ClusterAssociation &bestAssociationOuter(iter3B->second);
299 (void)reducedParentToDaughterMatrix[pBestOuter].insert(ClusterAssociationMap::value_type(pDaughterCluster, bestAssociationOuter));
304 for (
const auto &mapEntry : reducedParentToDaughterMatrix)
305 sortedReducedParentClusters.push_back(mapEntry.first);
308 for (
const Cluster *
const pParentCluster : sortedReducedParentClusters)
310 const ClusterAssociationMap &daughterToAssociationMap(reducedParentToDaughterMatrix.at(pParentCluster));
312 const Cluster *pBestInner(NULL);
313 const Cluster *pBestOuter(NULL);
315 float bestFomInner(std::numeric_limits<float>::max());
316 float bestFomOuter(std::numeric_limits<float>::max());
319 for (
const auto &mapEntry : daughterToAssociationMap)
320 sortedLocalDaughterClusters.push_back(mapEntry.first);
323 for (
const Cluster *
const pDaughterCluster : sortedLocalDaughterClusters)
325 const ClusterAssociation &clusterAssociation(daughterToAssociationMap.at(pDaughterCluster));
329 if (clusterAssociation.GetFigureOfMerit() < bestFomInner)
331 bestFomInner = clusterAssociation.GetFigureOfMerit();
335 pBestInner = pDaughterCluster;
346 if (clusterAssociation.GetFigureOfMerit() < bestFomOuter)
348 bestFomOuter = clusterAssociation.GetFigureOfMerit();
352 pBestOuter = pDaughterCluster;
364 ClusterList &parentList(clusterMergeMap[pParentCluster]);
366 if (parentList.end() == std::find(parentList.begin(), parentList.end(), pBestInner))
367 parentList.push_back(pBestInner);
369 ClusterList &bestInnerList(clusterMergeMap[pBestInner]);
371 if (bestInnerList.end() == std::find(bestInnerList.begin(), bestInnerList.end(), pParentCluster))
372 bestInnerList.push_back(pParentCluster);
377 ClusterList &parentList(clusterMergeMap[pParentCluster]);
379 if (parentList.end() == std::find(parentList.begin(), parentList.end(), pBestOuter))
380 parentList.push_back(pBestOuter);
382 ClusterList &bestOuterList(clusterMergeMap[pBestOuter]);
384 if (bestOuterList.end() == std::find(bestOuterList.begin(), bestOuterList.end(), pParentCluster))
385 bestOuterList.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
std::vector< art::Ptr< recob::Cluster > > ClusterVector