Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
ClusterSplittingAlgorithm.cc
Go to the documentation of this file.
1
10
12
14
15using namespace pandora;
16
17namespace lar_content
18{
19
21{
22 if (m_inputClusterListNames.empty())
23 return this->RunUsingCurrentList();
24
25 std::string originalListName;
26 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentListName<Cluster>(*this, originalListName));
27
28 for (const std::string &clusterListName : m_inputClusterListNames)
29 {
30 const StatusCode listChangeStatusCode(PandoraContentApi::ReplaceCurrentList<Cluster>(*this, clusterListName));
31
32 if (STATUS_CODE_NOT_FOUND == listChangeStatusCode)
33 {
35 std::cout << "ClusterSplittingAlgorithm: cluster list not found " << clusterListName << std::endl;
36
37 continue;
38 }
39
40 if (STATUS_CODE_SUCCESS != listChangeStatusCode)
41 return listChangeStatusCode;
42
43 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->RunUsingCurrentList());
44 }
45
46 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Cluster>(*this, originalListName));
47 return STATUS_CODE_SUCCESS;
48}
49
50//------------------------------------------------------------------------------------------------------------------------------------------
51
53{
54 const ClusterList *pClusterList = NULL;
55 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pClusterList));
56
57 ClusterList internalClusterList(pClusterList->begin(), pClusterList->end());
58 internalClusterList.sort(LArClusterHelper::SortByNHits);
59
60 for (ClusterList::iterator iter = internalClusterList.begin(); iter != internalClusterList.end(); ++iter)
61 {
62 const Cluster *const pCluster = *iter;
63 ClusterList clusterSplittingList;
64
65 if (STATUS_CODE_SUCCESS != this->SplitCluster(pCluster, clusterSplittingList))
66 continue;
67
68 internalClusterList.splice(internalClusterList.end(), clusterSplittingList);
69 *iter = NULL;
70 }
71
72 return STATUS_CODE_SUCCESS;
73}
74
75//------------------------------------------------------------------------------------------------------------------------------------------
76
77StatusCode ClusterSplittingAlgorithm::SplitCluster(const Cluster *const pCluster, ClusterList &clusterSplittingList) const
78{
79 // Split cluster into two CaloHit lists
80 PandoraContentApi::Cluster::Parameters firstParameters, secondParameters;
81
82 if (STATUS_CODE_SUCCESS != this->DivideCaloHits(pCluster, firstParameters.m_caloHitList, secondParameters.m_caloHitList))
83 return STATUS_CODE_NOT_FOUND;
84
85 if (firstParameters.m_caloHitList.empty() || secondParameters.m_caloHitList.empty())
86 return STATUS_CODE_NOT_ALLOWED;
87
88 // Begin cluster fragmentation operations
89 const ClusterList clusterList(1, pCluster);
90 std::string clusterListToSaveName, clusterListToDeleteName;
91
92 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=,
93 PandoraContentApi::InitializeFragmentation(*this, clusterList, clusterListToDeleteName, clusterListToSaveName));
94
95 // Create new clusters
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));
99
100 clusterSplittingList.push_back(pFirstCluster);
101 clusterSplittingList.push_back(pSecondCluster);
102
103 // End cluster fragmentation operations
104 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::EndFragmentation(*this, clusterListToSaveName, clusterListToDeleteName));
105
106 return STATUS_CODE_SUCCESS;
107}
108
109//------------------------------------------------------------------------------------------------------------------------------------------
110
112{
113 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
114 XmlHelper::ReadVectorOfValues(xmlHandle, "InputClusterListNames", m_inputClusterListNames));
115
116 return STATUS_CODE_SUCCESS;
117}
118
119} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the cluster splitting algorithm class.
Header file for the cluster helper class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:19
static pandora::StatusCode ReplaceCurrentList(const pandora::Algorithm &algorithm, const std::string &newListName)
Replace the current list with a pre-saved list; use this new list as a permanent replacement for the ...
static pandora::StatusCode InitializeFragmentation(const pandora::Algorithm &algorithm, const pandora::ClusterList &inputClusterList, std::string &originalClustersListName, std::string &fragmentClustersListName)
Initialize cluster fragmentation operations on clusters in the algorithm input list....
static pandora::StatusCode EndFragmentation(const pandora::Algorithm &algorithm, const std::string &clusterListToSaveName, const std::string &clusterListToDeleteName)
End cluster fragmentation operations on clusters in the algorithm input list.
static pandora::StatusCode GetCurrentList(const pandora::Algorithm &algorithm, const T *&pT)
Get the current list.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
pandora::StatusCode RunUsingCurrentList() const
Run the algorithm using the current cluster list as input.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
virtual pandora::StatusCode DivideCaloHits(const pandora::Cluster *const pCluster, pandora::CaloHitList &firstCaloHitList, pandora::CaloHitList &secondCaloHitList) const =0
Divide calo hits in a cluster into two lists, each associated with a separate fragment cluster.
virtual pandora::StatusCode Run()
Run the algorithm.
pandora::StringVector m_inputClusterListNames
The list of input cluster list names - if empty, use the current cluster list.
pandora::StatusCode SplitCluster(const pandora::Cluster *const pCluster, pandora::ClusterList &clusterSplittingList) const
Split cluster into two fragments.
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,...
Cluster class.
Definition Cluster.h:31
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
static StatusCode ReadVectorOfValues(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, std::vector< T > &vector)
Read a vector of values from a (space separated) list in an xml element.
Definition XmlHelper.h:229
MANAGED_CONTAINER< const Cluster * > ClusterList
StatusCode
The StatusCode enum.