34 if (!pClusterList || pClusterList->empty())
37 std::cout <<
"ClusterMergingAlgorithm: unable to find cluster list " <<
m_inputClusterListName << std::endl;
39 return STATUS_CODE_SUCCESS;
51 if (clusterMergeMap.empty())
57 return STATUS_CODE_SUCCESS;
66 for (
const Cluster *
const pSeedCluster : clusterVector)
72 for (
const Cluster *
const pAssociatedCluster : mergeList)
74 if (clusterVetoList.count(pAssociatedCluster))
77 if (!pAssociatedCluster->IsAvailable())
80 (void)clusterVetoList.insert(pAssociatedCluster);
109 if (clusterVetoList.count(pCurrentCluster))
112 ClusterMergeMap::const_iterator iter1 = clusterMergeMap.find(pCurrentCluster);
114 if (iter1 == clusterMergeMap.end())
117 ClusterVector associatedClusters(iter1->second.begin(), iter1->second.end());
120 for (
const Cluster *
const pAssociatedCluster : associatedClusters)
122 if (pAssociatedCluster == pSeedCluster)
125 if (associatedClusterList.end() != std::find(associatedClusterList.begin(), associatedClusterList.end(), pAssociatedCluster))
128 associatedClusterList.push_back(pAssociatedCluster);
129 this->
CollectAssociatedClusters(pSeedCluster, pAssociatedCluster, clusterMergeMap, clusterVetoList, associatedClusterList);
139 for (ClusterVector::const_iterator iter = inputClusters.begin(), iterEnd = inputClusters.end(); iter != iterEnd; ++iter)
141 const Cluster *
const pCluster = *iter;
145 pfoClusters.push_back(pCluster);
149 availableClusters.push_back(pCluster);
156 outputClusters.insert(outputClusters.end(), pfoClusters.begin(), pfoClusters.end());
157 outputClusters.insert(outputClusters.end(), availableClusters.begin(), availableClusters.end());
167 return STATUS_CODE_SUCCESS;
Header file for the cluster merging algorithm class.
Header file for the cluster helper class.
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
static pandora::StatusCode GetCurrentList(const pandora::Algorithm &algorithm, const T *&pT)
Get the current list.
static pandora::StatusCode MergeAndDeleteClusters(const pandora::Algorithm &algorithm, const pandora::Cluster *const pClusterToEnlarge, const pandora::Cluster *const pClusterToDelete)
Merge two clusters in the current list, enlarging one cluster and deleting the second.
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
virtual void GetListOfCleanClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &clusterVector) const =0
Populate cluster vector with subset of cluster list, containing clusters judged to be clean.
void CollectAssociatedClusters(const pandora::Cluster *const pSeedCluster, const ClusterMergeMap &clusterMergeMap, pandora::ClusterList &associatedClusterList) const
Collect up all clusters associations related to a given seed cluster.
virtual void PopulateClusterMergeMap(const pandora::ClusterVector &clusterVector, ClusterMergeMap &clusterMergeMap) const =0
Form associations between pointing clusters.
virtual pandora::StatusCode Run()
Run the algorithm.
std::string m_inputClusterListName
The name of the input cluster list. If not specified, will access current list.
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
void GetSortedListOfCleanClusters(const pandora::ClusterVector &inputClusters, pandora::ClusterVector &outputClusters) const
Sort the selected clusters, so that they have a well-defined ordering.
void MergeClusters(pandora::ClusterVector &clusterVector, ClusterMergeMap &clusterMergeMap) const
Merge associated clusters.
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,...
bool IsAvailable() const
Whether the cluster is available to be added to a particle flow object.
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
StatusCodeException class.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
std::vector< const Cluster * > ClusterVector
MANAGED_CONTAINER< const Cluster * > ClusterList
std::unordered_set< const Cluster * > ClusterSet
StatusCode
The StatusCode enum.