9 #include "Pandora/AlgorithmHeaders.h" 20 SimpleClusterCreationAlgorithm::SimpleClusterCreationAlgorithm() :
21 m_clusteringWindowSquared(1.
f)
29 const CaloHitList *pCaloHitList = NULL;
30 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*
this, pCaloHitList));
33 CaloHitList caloHitList;
36 if (caloHitList.empty())
37 return STATUS_CODE_SUCCESS;
46 return STATUS_CODE_SUCCESS;
53 for (
const CaloHit *
const pCaloHit : *pInputList)
55 if (PandoraContentApi::IsAvailable(*
this, pCaloHit))
56 outputList.push_back(pCaloHit);
64 for (
const CaloHit *
const pCaloHitI : caloHitList)
66 for (
const CaloHit *
const pCaloHitJ : caloHitList)
68 if (pCaloHitI == pCaloHitJ)
73 CaloHitList &caloHitListI(hitAssociationMap[pCaloHitI]);
75 if (caloHitListI.end() == std::find(caloHitListI.begin(), caloHitListI.end(), pCaloHitJ))
76 caloHitListI.push_back(pCaloHitJ);
78 CaloHitList &caloHitListJ(hitAssociationMap[pCaloHitI]);
80 if (caloHitListJ.end() == std::find(caloHitListJ.begin(), caloHitListJ.end(), pCaloHitI))
81 caloHitListJ.push_back(pCaloHitI);
92 CaloHitVector caloHitVector(caloHitList.begin(), caloHitList.end());
95 for (
const CaloHit *
const pSeedCaloHit : caloHitVector)
97 if (vetoList.count(pSeedCaloHit))
100 CaloHitList mergeList;
103 const Cluster *pCluster = NULL;
104 PandoraContentApi::Cluster::Parameters parameters;
105 parameters.m_caloHitList.push_back(pSeedCaloHit);
106 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*
this, parameters, pCluster));
107 vetoList.insert(pSeedCaloHit);
109 for (
const CaloHit *
const pAssociatedCaloHit : mergeList)
111 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToCluster(*
this, pCluster, pAssociatedCaloHit));
112 vetoList.insert(pAssociatedCaloHit);
120 const HitAssociationMap &hitAssociationMap,
const CaloHitSet &vetoList, CaloHitList &mergeList)
const 122 if (vetoList.count(pCurrentCaloHit))
126 if (iter1 == hitAssociationMap.end())
129 CaloHitVector caloHitVector(iter1->second.begin(), iter1->second.end());
132 for (
const CaloHit *
const pAssociatedCaloHit : caloHitVector)
134 if (pAssociatedCaloHit == pSeedCaloHit)
137 if (mergeList.end() != std::find(mergeList.begin(), mergeList.end(), pAssociatedCaloHit))
140 mergeList.push_back(pAssociatedCaloHit);
142 this->
CollectAssociatedHits(pSeedCaloHit, pAssociatedCaloHit, hitAssociationMap, vetoList, mergeList);
150 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
151 "ClusteringWindow", clusteringWindow));
154 return STATUS_CODE_SUCCESS;
void BuildAssociationMap(const pandora::CaloHitList &caloHitList, HitAssociationMap &hitAssociationMap) const
Create map of associations between calo hits.
void SelectCaloHits(const pandora::CaloHitList *const pInputList, pandora::CaloHitList &outputList) const
Select calo hits for clustering.
pandora::StatusCode Run()
void CreateClusters(const pandora::CaloHitList &caloHitList, const HitAssociationMap &hitAssociationMap) const
Create clusters from selected calo hits and their associations.
std::unordered_map< const pandora::CaloHit *, pandora::CaloHitList > HitAssociationMap
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
Header file for the cluster helper class.
float m_clusteringWindowSquared
Maximum distance (squared) for two hits to be joined.
void CollectAssociatedHits(const pandora::CaloHit *const pSeedCaloHit, const pandora::CaloHit *const pCurrentCaloHit, const HitAssociationMap &hitAssociationMap, const pandora::CaloHitSet &vetoList, pandora::CaloHitList &mergeList) const
For a given seed calo hits, collect up all the associated calo hits.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Header file for the cluster creation algorithm class.