LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
ClusteringParentAlgorithm.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
13 using namespace pandora;
14 
15 namespace lar_content
16 {
17 
18 ClusteringParentAlgorithm::ClusteringParentAlgorithm() :
19  m_replaceCurrentCaloHitList(false),
20  m_replaceCurrentClusterList(true)
21 {
22 }
23 
24 //------------------------------------------------------------------------------------------------------------------------------------------
25 
27 {
28  // If specified, change the current calo hit list, i.e. the input to the clustering algorithm
29  std::string originalCaloHitListName;
30 
31  if (!m_inputCaloHitListName.empty())
32  {
33  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentListName<CaloHit>(*this, originalCaloHitListName));
34  const StatusCode statusCode(PandoraContentApi::ReplaceCurrentList<CaloHit>(*this, m_inputCaloHitListName));
35 
36  if (STATUS_CODE_NOT_FOUND == statusCode)
37  {
38  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
39  std::cout << "ClusteringParentAlgorithm: calohit list not found " << m_inputCaloHitListName << std::endl;
40 
41  return STATUS_CODE_SUCCESS;
42  }
43 
44  if (STATUS_CODE_SUCCESS != statusCode)
45  return statusCode;
46  }
47 
48  // Run the initial cluster formation algorithm
49  const ClusterList *pClusterList = NULL;
50  std::string newClusterListName;
51  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RunClusteringAlgorithm(*this, m_clusteringAlgorithmName,
52  pClusterList, newClusterListName));
53 
54  // Run the topological association algorithms to modify clusters
55  if (!pClusterList->empty() && !m_associationAlgorithmName.empty())
56  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RunDaughterAlgorithm(*this, m_associationAlgorithmName));
57 
58  // Save the new cluster list
59  if (!pClusterList->empty())
60  {
61  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Cluster>(*this, m_clusterListName));
62 
64  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Cluster>(*this, m_clusterListName));
65  }
66 
67  // Unless specified, return current calo hit list to that when algorithm started
69  {
70  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<CaloHit>(*this, originalCaloHitListName));
71  }
72 
73  return STATUS_CODE_SUCCESS;
74 }
75 
76 //------------------------------------------------------------------------------------------------------------------------------------------
77 
78 StatusCode ClusteringParentAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
79 {
80  // Daughter algorithm parameters
81  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithm(*this, xmlHandle,
82  "ClusterFormation", m_clusteringAlgorithmName));
83 
84  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ProcessAlgorithm(*this, xmlHandle,
85  "ClusterAssociation", m_associationAlgorithmName));
86 
87  // Input parameters: name of input calo hit list and whether it should persist as the current list after algorithm has finished
88  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
89  "InputCaloHitListName", m_inputCaloHitListName));
90 
91  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
92  "ReplaceCurrentCaloHitList", m_replaceCurrentCaloHitList));
93 
94  // Output parameters: name of output cluster list and whether it should subsequently be used as the current list
95  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
96  "ClusterListName", m_clusterListName));
97 
98  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
99  "ReplaceCurrentClusterList", m_replaceCurrentClusterList));
100 
101  return STATUS_CODE_SUCCESS;
102 }
103 
104 } // namespace lar_content
Header file for the clustering parent algorithm class.
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.
std::string m_clusterListName
The name under which to save the new cluster list.