All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimpleClusterMergingAlgorithm.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArTwoDReco/LArClusterAssociation/SimpleClusterMergingAlgorithm.cc
3  *
4  * @brief Implementation of the simple cluster merging algorithm class.
5  *
6  * $Log: $
7  */
8 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
14 
15 using namespace pandora;
16 
17 namespace lar_content
18 {
19 
20 SimpleClusterMergingAlgorithm::SimpleClusterMergingAlgorithm() : m_minCaloHitsPerCluster(5), m_maxClusterSeparation(2.5f)
21 {
22 }
23 
24 //------------------------------------------------------------------------------------------------------------------------------------------
25 
26 void SimpleClusterMergingAlgorithm::GetListOfCleanClusters(const ClusterList *const pClusterList, ClusterVector &clusterVector) const
27 {
28  for (ClusterList::const_iterator iter = pClusterList->begin(), iterEnd = pClusterList->end(); iter != iterEnd; ++iter)
29  {
30  const Cluster *const pCluster = *iter;
31 
32  if (!pCluster->IsAvailable())
33  continue;
34 
35  if (pCluster->GetNCaloHits() < m_minCaloHitsPerCluster)
36  continue;
37 
38  clusterVector.push_back(pCluster);
39  }
40 
41  std::sort(clusterVector.begin(), clusterVector.end(), LArClusterHelper::SortByNHits);
42 }
43 
44 //------------------------------------------------------------------------------------------------------------------------------------------
45 
47 {
48  for (ClusterVector::const_iterator iterI = clusterVector.begin(), iterEndI = clusterVector.end(); iterI != iterEndI; ++iterI)
49  {
50  const Cluster *const pClusterI = *iterI;
51 
52  for (ClusterVector::const_iterator iterJ = iterI, iterEndJ = clusterVector.end(); iterJ != iterEndJ; ++iterJ)
53  {
54  const Cluster *const pClusterJ = *iterJ;
55 
56  if (pClusterI == pClusterJ)
57  continue;
58 
59  if (this->IsAssociated(pClusterI, pClusterJ))
60  {
61  clusterMergeMap[pClusterI].push_back(pClusterJ);
62  clusterMergeMap[pClusterJ].push_back(pClusterI);
63  }
64  }
65  }
66 }
67 
68 //------------------------------------------------------------------------------------------------------------------------------------------
69 
70 bool SimpleClusterMergingAlgorithm::IsAssociated(const Cluster *const pClusterI, const Cluster *const pClusterJ) const
71 {
73  return false;
74 
75  return true;
76 }
77 
78 //------------------------------------------------------------------------------------------------------------------------------------------
79 
80 StatusCode SimpleClusterMergingAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
81 {
82  PANDORA_RETURN_RESULT_IF_AND_IF(
83  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinCaloHitsPerCluster", m_minCaloHitsPerCluster));
84 
85  PANDORA_RETURN_RESULT_IF_AND_IF(
86  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxClusterSeparation", m_maxClusterSeparation));
87 
88  return ClusterMergingAlgorithm::ReadSettings(xmlHandle);
89 }
90 
91 } // namespace lar_content
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.
unsigned int m_minCaloHitsPerCluster
The min number of calo hits per candidate cluster.
float m_maxClusterSeparation
Maximum distance at which clusters can be joined.
Header file for the simple cluster merging algorithm class.
Header file for the cluster helper class.
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...
bool IsAssociated(const pandora::Cluster *const pClusterI, const pandora::Cluster *const pClusterJ) const
Decide whether two clusters are associated.
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
Definition: reco_sbnd.fcl:182
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void PopulateClusterMergeMap(const pandora::ClusterVector &clusterVector, ClusterMergeMap &clusterMergeMap) const
Form associations between pointing clusters.
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.