Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
ListMergingAlgorithm.cc
Go to the documentation of this file.
1
10
12
13using namespace pandora;
14
15namespace lar_content
16{
17
19{
20 // Vertex list merging
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
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
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
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
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the list merging algorithm class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
static pandora::StatusCode ReplaceCurrentList(const pandora::Algorithm &algorithm, const std::string &newListName)
Replace the current list with a pre-saved list; use this new list as a permanent replacement for the ...
pandora::StringVector m_sourceVertexListNames
The source vertex list names.
pandora::StringVector m_sourcePfoListNames
The source pfo list names.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
pandora::StatusCode Run()
Run the algorithm.
pandora::StringVector m_targetClusterListNames
The target cluster list names.
pandora::StringVector m_targetPfoListNames
The target pfo list names.
pandora::StringVector m_sourceClusterListNames
The source cluster list names.
pandora::StringVector m_targetVertexListNames
The target vertex list names.
const Pandora & GetPandora() const
Get the associated pandora instance.
Definition Process.h:116
static StatusCode ReadVectorOfValues(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, std::vector< T > &vector)
Read a vector of values from a (space separated) list in an xml element.
Definition XmlHelper.h:229
StatusCode
The StatusCode enum.