9 #include "Pandora/AlgorithmHeaders.h" 20 StatusCode ClusterSplittingAlgorithm::Run()
22 if (m_inputClusterListNames.empty())
23 return this->RunUsingCurrentList();
25 std::string originalListName;
26 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentListName<Cluster>(*
this, originalListName));
28 for (
const std::string &clusterListName : m_inputClusterListNames)
30 const StatusCode listChangeStatusCode(PandoraContentApi::ReplaceCurrentList<Cluster>(*
this, clusterListName));
32 if (STATUS_CODE_NOT_FOUND == listChangeStatusCode)
34 if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
35 std::cout <<
"ClusterSplittingAlgorithm: cluster list not found " << clusterListName << std::endl;
40 if (STATUS_CODE_SUCCESS != listChangeStatusCode)
41 return listChangeStatusCode;
43 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->RunUsingCurrentList());
46 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Cluster>(*
this, originalListName));
47 return STATUS_CODE_SUCCESS;
52 StatusCode ClusterSplittingAlgorithm::RunUsingCurrentList()
const 54 const ClusterList *pClusterList = NULL;
55 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*
this, pClusterList));
57 ClusterList internalClusterList(pClusterList->begin(), pClusterList->end());
58 internalClusterList.sort(LArClusterHelper::SortByNHits);
60 for (
ClusterList::iterator iter = internalClusterList.begin(); iter != internalClusterList.end(); ++iter)
62 const Cluster *
const pCluster = *iter;
63 ClusterList clusterSplittingList;
65 if (STATUS_CODE_SUCCESS != this->SplitCluster(pCluster, clusterSplittingList))
68 internalClusterList.splice(internalClusterList.end(), clusterSplittingList);
72 return STATUS_CODE_SUCCESS;
77 StatusCode ClusterSplittingAlgorithm::SplitCluster(
const Cluster *
const pCluster, ClusterList &clusterSplittingList)
const 80 PandoraContentApi::Cluster::Parameters firstParameters, secondParameters;
82 if (STATUS_CODE_SUCCESS != this->DivideCaloHits(pCluster, firstParameters.m_caloHitList, secondParameters.m_caloHitList))
83 return STATUS_CODE_NOT_FOUND;
85 if (firstParameters.m_caloHitList.empty() || secondParameters.m_caloHitList.empty())
86 return STATUS_CODE_NOT_ALLOWED;
89 const ClusterList clusterList(1, pCluster);
90 std::string clusterListToSaveName, clusterListToDeleteName;
92 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::InitializeFragmentation(*
this, clusterList, clusterListToDeleteName,
93 clusterListToSaveName));
96 const Cluster *pFirstCluster(NULL), *pSecondCluster(NULL);
97 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*
this, firstParameters, pFirstCluster));
98 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*
this, secondParameters, pSecondCluster));
100 clusterSplittingList.push_back(pFirstCluster);
101 clusterSplittingList.push_back(pSecondCluster);
104 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::EndFragmentation(*
this, clusterListToSaveName, clusterListToDeleteName));
106 return STATUS_CODE_SUCCESS;
111 StatusCode ClusterSplittingAlgorithm::ReadSettings(
const TiXmlHandle xmlHandle)
113 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
114 "InputClusterListNames", m_inputClusterListNames));
116 return STATUS_CODE_SUCCESS;
Header file for the cluster splitting algorithm class.
Header file for the cluster helper class.