LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ListMergingAlgorithm.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 StatusCode ListMergingAlgorithm::Run()
19 {
20  // Vertex list merging
21  if (m_sourceVertexListNames.size() != m_targetVertexListNames.size())
22  return STATUS_CODE_FAILURE;
23 
24  for (unsigned int iIndex = 0, iIndexEnd = m_sourceVertexListNames.size(); iIndex < iIndexEnd; ++iIndex)
25  {
26  const std::string &sourceListName(m_sourceVertexListNames.at(iIndex));
27  const std::string &targetListName(m_targetVertexListNames.at(iIndex));
28 
29  const StatusCode statusCode(PandoraContentApi::SaveList<Vertex>(*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: vertex list not found, source: " << sourceListName << ", target: " << targetListName
37  << std::endl;
38  }
39  else if (STATUS_CODE_NOT_INITIALIZED == statusCode)
40  {
41  if (this->GetPandora().GetSettings()->ShouldDisplayAlgorithmInfo())
42  std::cout << "ListMergingAlgorithm: no vertexs to move, source: " << sourceListName << ", target: " << targetListName << std::endl;
43  }
44  else
45  {
46  std::cout << "ListMergingAlgorithm: error in vertex merging, source: " << sourceListName << ", target: " << targetListName << std::endl;
47  return statusCode;
48  }
49  }
50  }
51 
52  // Cluster list merging
53  if (m_sourceClusterListNames.size() != m_targetClusterListNames.size())
54  return STATUS_CODE_FAILURE;
55 
56  for (unsigned int iIndex = 0, iIndexEnd = m_sourceClusterListNames.size(); iIndex < iIndexEnd; ++iIndex)
57  {
58  const std::string &sourceListName(m_sourceClusterListNames.at(iIndex));
59  const std::string &targetListName(m_targetClusterListNames.at(iIndex));
60 
61  const StatusCode statusCode(PandoraContentApi::SaveList<Cluster>(*this, sourceListName, targetListName));
62 
63  if (STATUS_CODE_SUCCESS != statusCode)
64  {
65  if (STATUS_CODE_NOT_FOUND == statusCode)
66  {
67  if (this->GetPandora().GetSettings()->ShouldDisplayAlgorithmInfo())
68  std::cout << "ListMergingAlgorithm: cluster list not found, source: " << sourceListName
69  << ", 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 clusters to move, source: " << sourceListName << ", target: " << targetListName << std::endl;
75  }
76  else
77  {
78  std::cout << "ListMergingAlgorithm: error in cluster merging, source: " << sourceListName << ", target: " << targetListName
79  << std::endl;
80  return statusCode;
81  }
82  }
83  }
84 
85  // Pfo list merging
86  if (m_sourcePfoListNames.size() != m_targetPfoListNames.size())
87  return STATUS_CODE_FAILURE;
88 
89  for (unsigned int iIndex = 0, iIndexEnd = m_sourcePfoListNames.size(); iIndex < iIndexEnd; ++iIndex)
90  {
91  const std::string &sourceListName(m_sourcePfoListNames.at(iIndex));
92  const std::string &targetListName(m_targetPfoListNames.at(iIndex));
93 
94  const StatusCode statusCode(PandoraContentApi::SaveList<Pfo>(*this, sourceListName, targetListName));
95 
96  if (STATUS_CODE_SUCCESS != statusCode)
97  {
98  if (STATUS_CODE_NOT_FOUND == statusCode)
99  {
100  if (this->GetPandora().GetSettings()->ShouldDisplayAlgorithmInfo())
101  std::cout << "ListMergingAlgorithm: pfo list not found, source: " << sourceListName << ", target: " << targetListName << std::endl;
102  }
103  else if (STATUS_CODE_NOT_INITIALIZED == statusCode)
104  {
105  if (this->GetPandora().GetSettings()->ShouldDisplayAlgorithmInfo())
106  std::cout << "ListMergingAlgorithm: no pfos to move, source: " << sourceListName << ", target: " << targetListName << std::endl;
107  }
108  else
109  {
110  std::cout << "ListMergingAlgorithm: error in pfo merging, source: " << sourceListName << ", target: " << targetListName << std::endl;
111  return statusCode;
112  }
113  }
114  }
115 
116  return STATUS_CODE_SUCCESS;
117 }
118 
119 //------------------------------------------------------------------------------------------------------------------------------------------
120 
121 StatusCode ListMergingAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
122 {
123  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
124  XmlHelper::ReadVectorOfValues(xmlHandle, "SourceVertexListNames", m_sourceVertexListNames));
125 
126  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
127  XmlHelper::ReadVectorOfValues(xmlHandle, "TargetVertexListNames", m_targetVertexListNames));
128 
129  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
130  XmlHelper::ReadVectorOfValues(xmlHandle, "SourceClusterListNames", m_sourceClusterListNames));
131 
132  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
133  XmlHelper::ReadVectorOfValues(xmlHandle, "TargetClusterListNames", m_targetClusterListNames));
134 
135  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
136  XmlHelper::ReadVectorOfValues(xmlHandle, "SourcePfoListNames", m_sourcePfoListNames));
137 
138  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
139  XmlHelper::ReadVectorOfValues(xmlHandle, "TargetPfoListNames", m_targetPfoListNames));
140 
141  if ((m_sourceClusterListNames.size() != m_targetClusterListNames.size()) || (m_sourcePfoListNames.size() != m_targetPfoListNames.size()))
142  {
143  std::cout << "ListMergingAlgorithm::ReadSettings: invalid list configuration " << std::endl;
144  return STATUS_CODE_INVALID_PARAMETER;
145  }
146 
147  return STATUS_CODE_SUCCESS;
148 }
149 
150 } // namespace lar_content
Header file for the list merging algorithm class.