9 #include "Pandora/AlgorithmHeaders.h" 20 BoundedRegionClusterMergingAlgorithm::BoundedRegionClusterMergingAlgorithm() :
32 const ClusterList *pClusterList{
nullptr};
36 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*
this, pClusterList));
40 PANDORA_RETURN_RESULT_IF_AND_IF(
41 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*
this,
m_inputClusterListName, pClusterList));
44 if (!pClusterList || pClusterList->empty())
46 if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
47 std::cout <<
"BoundedRegionClusterMergingAlgorithm: unable to find cluster list " <<
m_inputClusterListName << std::endl;
49 return STATUS_CODE_SUCCESS;
57 if (clusterVector.size() < 2)
61 if (clusterMergeMap.empty())
67 return STATUS_CODE_SUCCESS;
75 for (
const Cluster *
const pCluster : *pClusterList)
77 if (!pCluster->IsAvailable())
83 CartesianVector minimumPos(0.
f, 0.
f, 0.
f), maximumPos(0.
f, 0.
f, 0.
f);
88 clusterVector.emplace_back(pCluster);
91 if (!clusterVector.empty())
101 for (
unsigned int i = 0; i < clusterVector.size() - 1; ++i)
103 const Cluster *
const pCluster1{clusterVector.at(i)};
105 for (
unsigned int j = i + 1; j < clusterVector.size(); ++j)
107 const Cluster *
const pCluster2{clusterVector.at(j)};
108 if (!pCluster2->IsAvailable())
111 if (std::find(usedClusters.begin(), usedClusters.end(), pCluster2) != usedClusters.end())
116 clusterMergeMap[pCluster1].emplace_back(pCluster2);
117 usedClusters.emplace_back(pCluster2);
141 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MinimumX",
m_xRegionMin));
142 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MaximumX",
m_xRegionMax));
143 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MinimumZ",
m_zRegionMin));
144 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MaximumZ",
m_zRegionMax));
146 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MaxDistance",
m_maxDistance));
148 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MinClusterHits",
m_minClusterHits));
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 *, pandora::ClusterList > ClusterMergeMap
std::string m_inputClusterListName
The name of the input cluster list. If not specified, will access current list.
void GetListOfBoundedRegionClusters(const pandora::ClusterList *const pClusterList, pandora::ClusterVector &clusterVector) const
Populate cluster vector with all clusters starting in the defined region.
void PopulateClusterMergeMap(const pandora::ClusterVector &clusterVector, ClusterMergeMap &clusterMergeMap) const
Form associations between pointing clusters.
virtual pandora::StatusCode Run()
static void GetClusterBoundingBox(const pandora::Cluster *const pCluster, pandora::CartesianVector &minimumCoordinate, pandora::CartesianVector &maximumCoordinate)
Get minimum and maximum X, Y and Z positions of the calo hits in a cluster.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Header file for the cluster helper class.
float m_maxDistance
Maximum distance below which clusters can be associated.
float m_xRegionMin
Minimum x value of the bounded region box.
float m_zRegionMax
Maximum z value (wire dimension) of the bounded region box.
float m_xRegionMax
Maximum x value of the bounded region box.
unsigned int m_minClusterHits
Threshold on the size of clusters to be considered for merging.
void MergeClusters(pandora::ClusterVector &clusterVector, ClusterMergeMap &clusterMergeMap) const
Merge associated clusters.
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...
float m_zRegionMin
Minimum z value (wire dimension) of the bounded region box.
bool AreClustersAssociated(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2) const
Compare two clusters and decide if they should be associated with each other.
Header file for the bounded region cluster merging algorithm class.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.