LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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  // 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 << ", target: " << targetListName << std::endl;
37  }
38  else if (STATUS_CODE_NOT_INITIALIZED == statusCode)
39  {
40  if (this->GetPandora().GetSettings()->ShouldDisplayAlgorithmInfo())
41  std::cout << "ListMergingAlgorithm: no clusters to move, source: " << sourceListName << ", target: " << targetListName << std::endl;
42  }
43  else
44  {
45  std::cout << "ListMergingAlgorithm: error in cluster merging, source: " << sourceListName << ", target: " << targetListName << std::endl;
46  return statusCode;
47  }
48  }
49  }
50 
51  // Pfo list merging
52  if (m_sourcePfoListNames.size() != m_targetPfoListNames.size())
53  return STATUS_CODE_FAILURE;
54 
55  for (unsigned int iIndex = 0, iIndexEnd = m_sourcePfoListNames.size(); iIndex < iIndexEnd; ++iIndex)
56  {
57  const std::string &sourceListName(m_sourcePfoListNames.at(iIndex));
58  const std::string &targetListName(m_targetPfoListNames.at(iIndex));
59 
60  const StatusCode statusCode(PandoraContentApi::SaveList<Pfo>(*this, sourceListName, targetListName));
61 
62  if (STATUS_CODE_SUCCESS != statusCode)
63  {
64  if (STATUS_CODE_NOT_FOUND == statusCode)
65  {
66  if (this->GetPandora().GetSettings()->ShouldDisplayAlgorithmInfo())
67  std::cout << "ListMergingAlgorithm: pfo list not found, source: " << sourceListName << ", target: " << targetListName << std::endl;
68  }
69  else if (STATUS_CODE_NOT_INITIALIZED == statusCode)
70  {
71  if (this->GetPandora().GetSettings()->ShouldDisplayAlgorithmInfo())
72  std::cout << "ListMergingAlgorithm: no pfos to move, source: " << sourceListName << ", target: " << targetListName << std::endl;
73  }
74  else
75  {
76  std::cout << "ListMergingAlgorithm: error in pfo merging, source: " << sourceListName << ", target: " << targetListName << std::endl;
77  return statusCode;
78  }
79  }
80  }
81 
82  return STATUS_CODE_SUCCESS;
83 }
84 
85 //------------------------------------------------------------------------------------------------------------------------------------------
86 
87 StatusCode ListMergingAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
88 {
89  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
90  "SourceClusterListNames", m_sourceClusterListNames));
91 
92  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
93  "TargetClusterListNames", m_targetClusterListNames));
94 
95  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
96  "SourcePfoListNames", m_sourcePfoListNames));
97 
98  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
99  "TargetPfoListNames", m_targetPfoListNames));
100 
101  if ((m_sourceClusterListNames.size() != m_targetClusterListNames.size()) || (m_sourcePfoListNames.size() != m_targetPfoListNames.size()))
102  {
103  std::cout << "ListMergingAlgorithm::ReadSettings: invalid list configuration " << std::endl;
104  return STATUS_CODE_INVALID_PARAMETER;
105  }
106 
107  return STATUS_CODE_SUCCESS;
108 }
109 
110 } // namespace lar_content
Header file for the list merging algorithm class.