Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
ClusteringParentAlgorithm.cc
Go to the documentation of this file.
1
10
12
13using namespace pandora;
14
15namespace lar_content
16{
17
18ClusteringParentAlgorithm::ClusteringParentAlgorithm() : m_replaceCurrentCaloHitList(false), m_replaceCurrentClusterList(true)
19{
20}
21
22//------------------------------------------------------------------------------------------------------------------------------------------
23
25{
26 // If specified, change the current calo hit list, i.e. the input to the clustering algorithm
27 std::string originalCaloHitListName;
28
29 if (!m_inputCaloHitListName.empty())
30 {
31 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentListName<CaloHit>(*this, originalCaloHitListName));
33
34 if (STATUS_CODE_NOT_FOUND == statusCode)
35 {
37 std::cout << "ClusteringParentAlgorithm: calohit list not found " << m_inputCaloHitListName << std::endl;
38
39 return STATUS_CODE_SUCCESS;
40 }
41
42 if (STATUS_CODE_SUCCESS != statusCode)
43 return statusCode;
44 }
45
46 // Run the initial cluster formation algorithm
47 const ClusterList *pClusterList = NULL;
48 std::string newClusterListName;
49 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=,
50 PandoraContentApi::RunClusteringAlgorithm(*this, m_clusteringAlgorithmName, pClusterList, newClusterListName));
51
52 // Run the topological association algorithms to modify clusters
53 if (!pClusterList->empty() && !m_associationAlgorithmName.empty())
55
56 // Save the new cluster list
57 if (!pClusterList->empty())
58 {
60
63 }
64
65 // Unless specified, return current calo hit list to that when algorithm started
67 {
68 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<CaloHit>(*this, originalCaloHitListName));
69 }
70
71 return STATUS_CODE_SUCCESS;
72}
73
74//------------------------------------------------------------------------------------------------------------------------------------------
75
77{
78 // Daughter algorithm parameters
79 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithm(*this, xmlHandle, "ClusterFormation", m_clusteringAlgorithmName));
80
81 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
82 XmlHelper::ProcessAlgorithm(*this, xmlHandle, "ClusterAssociation", m_associationAlgorithmName));
83
84 // Input parameters: name of input calo hit list and whether it should persist as the current list after algorithm has finished
86 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "InputCaloHitListName", m_inputCaloHitListName));
87
88 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "ReplaceCurrentCaloHitList", m_replaceCurrentCaloHitList));
89
90 // Output parameters: name of output cluster list and whether it should subsequently be used as the current list
91 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "ClusterListName", m_clusterListName));
92
93 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "ReplaceCurrentClusterList", m_replaceCurrentClusterList));
94
95 return STATUS_CODE_SUCCESS;
96}
97
98} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the clustering parent algorithm 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 RunClusteringAlgorithm(const pandora::Algorithm &algorithm, const std::string &clusteringAlgorithmName, const pandora::ClusterList *&pNewClusterList, std::string &newClusterListName)
Run a clustering algorithm (an algorithm that will create new cluster objects)
static pandora::StatusCode RunDaughterAlgorithm(const pandora::Algorithm &algorithm, const std::string &daughterAlgorithmName)
Run an algorithm registered with pandora, from within a parent algorithm.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
std::string m_associationAlgorithmName
The name of the topological association algorithm to run.
pandora::StatusCode Run()
Run the algorithm.
bool m_replaceCurrentClusterList
Whether to subsequently use the new cluster list as the "current" list.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
std::string m_clusteringAlgorithmName
The name of the clustering algorithm to run.
std::string m_clusterListName
The name under which to save the new cluster list.
bool m_replaceCurrentCaloHitList
Whether to permanently replace the original calo hit list as the "current" list upon completion.
std::string m_inputCaloHitListName
The name of the input calo hit list, containing the hits to be clustered.
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
static StatusCode ProcessAlgorithm(const Algorithm &algorithm, const TiXmlHandle &xmlHandle, const std::string &description, std::string &algorithmName)
Process an algorithm described in an xml element with a matching "description = .....
Definition XmlHelper.cc:16
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
MANAGED_CONTAINER< const Cluster * > ClusterList
StatusCode
The StatusCode enum.