All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ListMergingAlgorithm.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArUtility/ListMergingAlgorithm.cc
3  *
4  * @brief Implementation of the list merging 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 StatusCode ListMergingAlgorithm::Run()
19 {
20  // Cluster list merging
21  if (m_sourceClusterListNames.size() != m_targetClusterListNames.size())
22  return STATUS_CODE_FAILURE;
23 
24  for (unsigned int iIndex = 0, iIndexEnd = m_sourceClusterListNames.size(); iIndex < iIndexEnd; ++iIndex)
25  {
26  const std::string &sourceListName(m_sourceClusterListNames.at(iIndex));
27  const std::string &targetListName(m_targetClusterListNames.at(iIndex));
28 
29  const StatusCode statusCode(PandoraContentApi::SaveList<Cluster>(*this, sourceListName, targetListName));
30 
31  if (STATUS_CODE_SUCCESS != statusCode)
32  {
33  if (STATUS_CODE_NOT_FOUND == statusCode)
34  {
35  if (this->GetPandora().GetSettings()->ShouldDisplayAlgorithmInfo())
36  std::cout << "ListMergingAlgorithm: cluster list not found, source: " << sourceListName
37  << ", target: " << targetListName << std::endl;
38  }
39  else if (STATUS_CODE_NOT_INITIALIZED == statusCode)
40  {
41  if (this->GetPandora().GetSettings()->ShouldDisplayAlgorithmInfo())
42  std::cout << "ListMergingAlgorithm: no clusters to move, source: " << sourceListName << ", target: " << targetListName << std::endl;
43  }
44  else
45  {
46  std::cout << "ListMergingAlgorithm: error in cluster merging, source: " << sourceListName << ", target: " << targetListName
47  << std::endl;
48  return statusCode;
49  }
50  }
51  }
52 
53  // Pfo list merging
54  if (m_sourcePfoListNames.size() != m_targetPfoListNames.size())
55  return STATUS_CODE_FAILURE;
56 
57  for (unsigned int iIndex = 0, iIndexEnd = m_sourcePfoListNames.size(); iIndex < iIndexEnd; ++iIndex)
58  {
59  const std::string &sourceListName(m_sourcePfoListNames.at(iIndex));
60  const std::string &targetListName(m_targetPfoListNames.at(iIndex));
61 
62  const StatusCode statusCode(PandoraContentApi::SaveList<Pfo>(*this, sourceListName, targetListName));
63 
64  if (STATUS_CODE_SUCCESS != statusCode)
65  {
66  if (STATUS_CODE_NOT_FOUND == statusCode)
67  {
68  if (this->GetPandora().GetSettings()->ShouldDisplayAlgorithmInfo())
69  std::cout << "ListMergingAlgorithm: pfo list not found, source: " << sourceListName << ", target: " << targetListName << std::endl;
70  }
71  else if (STATUS_CODE_NOT_INITIALIZED == statusCode)
72  {
73  if (this->GetPandora().GetSettings()->ShouldDisplayAlgorithmInfo())
74  std::cout << "ListMergingAlgorithm: no pfos to move, source: " << sourceListName << ", target: " << targetListName << std::endl;
75  }
76  else
77  {
78  std::cout << "ListMergingAlgorithm: error in pfo merging, source: " << sourceListName << ", target: " << targetListName << std::endl;
79  return statusCode;
80  }
81  }
82  }
83 
84  return STATUS_CODE_SUCCESS;
85 }
86 
87 //------------------------------------------------------------------------------------------------------------------------------------------
88 
89 StatusCode ListMergingAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
90 {
91  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
92  XmlHelper::ReadVectorOfValues(xmlHandle, "SourceClusterListNames", m_sourceClusterListNames));
93 
94  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
95  XmlHelper::ReadVectorOfValues(xmlHandle, "TargetClusterListNames", m_targetClusterListNames));
96 
97  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
98  XmlHelper::ReadVectorOfValues(xmlHandle, "SourcePfoListNames", m_sourcePfoListNames));
99 
100  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
101  XmlHelper::ReadVectorOfValues(xmlHandle, "TargetPfoListNames", m_targetPfoListNames));
102 
103  if ((m_sourceClusterListNames.size() != m_targetClusterListNames.size()) || (m_sourcePfoListNames.size() != m_targetPfoListNames.size()))
104  {
105  std::cout << "ListMergingAlgorithm::ReadSettings: invalid list configuration " << std::endl;
106  return STATUS_CODE_INVALID_PARAMETER;
107  }
108 
109  return STATUS_CODE_SUCCESS;
110 }
111 
112 } // namespace lar_content
Header file for the list merging algorithm class.
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
Definition: reco_sbnd.fcl:182
BEGIN_PROLOG could also be cout