ClusteringParentAlgorithm.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArTwoDReco/LArClusterCreation/ClusteringParentAlgorithm.cc
3  *
4  * @brief Implementation of the clustering parent algorithm class.
5  *
6  * $Log: $
7  */
8 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
13 using namespace pandora;
14 
15 namespace lar_content
16 {
17 
18 ClusteringParentAlgorithm::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));
32  const StatusCode statusCode(PandoraContentApi::ReplaceCurrentList<CaloHit>(*this, m_inputCaloHitListName));
33 
34  if (STATUS_CODE_NOT_FOUND == statusCode)
35  {
36  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
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())
54  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RunDaughterAlgorithm(*this, m_associationAlgorithmName));
55 
56  // Save the new cluster list
57  if (!pClusterList->empty())
58  {
59  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Cluster>(*this, m_clusterListName));
60 
62  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Cluster>(*this, m_clusterListName));
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 
76 StatusCode ClusteringParentAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
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
85  PANDORA_RETURN_RESULT_IF_AND_IF(
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
Header file for the clustering parent algorithm class.
std::string string
Definition: nybbler.cc:12
std::string m_clusteringAlgorithmName
The name of the clustering algorithm to run.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::string m_associationAlgorithmName
The name of the topological association algorithm to run.
std::string m_inputCaloHitListName
The name of the input calo hit list, containing the hits to be clustered.
bool m_replaceCurrentCaloHitList
Whether to permanently replace the original calo hit list as the "current" list upon completion...
bool m_replaceCurrentClusterList
Whether to subsequently use the new cluster list as the "current" list.
QTextStream & endl(QTextStream &s)
std::string m_clusterListName
The name under which to save the new cluster list.