Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
ListPruningAlgorithm.cc
Go to the documentation of this file.
1
10
12
13using namespace pandora;
14
15namespace lar_content
16{
17
18ListPruningAlgorithm::ListPruningAlgorithm() : m_warnIfObjectsUnavailable(true)
19{
20}
21
22//------------------------------------------------------------------------------------------------------------------------------------------
23
25{
26 for (const std::string &listName : m_pfoListNames)
27 {
28 try
29 {
30 const PfoList *pPfoList(nullptr);
31 const StatusCode statusCode(PandoraContentApi::GetList(*this, listName, pPfoList));
32
33 if (STATUS_CODE_SUCCESS != statusCode)
34 throw StatusCodeException(statusCode);
35
36 const PfoList pfoList(*pPfoList);
37
38 for (const ParticleFlowObject *const pPfo : pfoList)
39 {
40 if (STATUS_CODE_SUCCESS != PandoraContentApi::Delete(*this, pPfo, listName))
41 std::cout << "ListPruningAlgorithm: Could not delete Pfo." << std::endl;
42 }
43 }
44 catch (StatusCodeException &)
45 {
47 std::cout << "ListPruningAlgorithm: pfo list " << listName << " unavailable." << std::endl;
48 }
49 }
50
51 for (const std::string &listName : m_clusterListNames)
52 {
53 try
54 {
55 const ClusterList *pClusterList(nullptr);
56 const StatusCode statusCode(PandoraContentApi::GetList(*this, listName, pClusterList));
57
58 if (STATUS_CODE_SUCCESS != statusCode)
59 throw StatusCodeException(statusCode);
60
61 const ClusterList clusterList(*pClusterList);
62
63 for (const Cluster *const pCluster : clusterList)
64 {
65 if (!m_warnIfObjectsUnavailable && !pCluster->IsAvailable())
66 continue;
67
68 if (STATUS_CODE_SUCCESS != PandoraContentApi::Delete(*this, pCluster, listName) && m_warnIfObjectsUnavailable)
69 std::cout << "ListPruningAlgorithm: Could not delete Cluster." << std::endl;
70 }
71 }
72 catch (StatusCodeException &)
73 {
75 std::cout << "ListPruningAlgorithm: cluster list " << listName << " unavailable." << std::endl;
76 }
77 }
78
79 for (const std::string &listName : m_vertexListNames)
80 {
81 try
82 {
83 const VertexList *pVertexList(nullptr);
84 const StatusCode statusCode(PandoraContentApi::GetList(*this, listName, pVertexList));
85
86 if (STATUS_CODE_SUCCESS != statusCode)
87 throw StatusCodeException(statusCode);
88
89 const VertexList vertexList(*pVertexList);
90
91 for (const Vertex *const pVertex : vertexList)
92 {
93 if (!m_warnIfObjectsUnavailable && !pVertex->IsAvailable())
94 continue;
95
96 if (STATUS_CODE_SUCCESS != PandoraContentApi::Delete(*this, pVertex, listName) && m_warnIfObjectsUnavailable)
97 std::cout << "ListPruningAlgorithm: Could not delete Vertex." << std::endl;
98 }
99 }
100 catch (StatusCodeException &)
101 {
103 std::cout << "ListPruningAlgorithm: vertex list " << listName << " unavailable." << std::endl;
104 }
105 }
106
107 return STATUS_CODE_SUCCESS;
108}
109
110//------------------------------------------------------------------------------------------------------------------------------------------
111
113{
115 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "PfoListNames", m_pfoListNames));
116
118 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "ClusterListNames", m_clusterListNames));
119
121 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "VertexListNames", m_vertexListNames));
122
123 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
124 XmlHelper::ReadValue(xmlHandle, "WarnIfObjectsUnavailable", m_warnIfObjectsUnavailable));
125
126 return STATUS_CODE_SUCCESS;
127}
128
129} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the list pruning algorithm class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
static pandora::StatusCode Delete(const pandora::Algorithm &algorithm, const T *const pT)
Delete an object from the current list.
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
pandora::StringVector m_pfoListNames
The pfo list names.
pandora::StringVector m_vertexListNames
The vertex list names.
pandora::StringVector m_clusterListNames
The cluster list names.
pandora::StatusCode Run()
Run the algorithm.
bool m_warnIfObjectsUnavailable
Whether to print warning if attempt made to delete unavailable objects.
Cluster class.
Definition Cluster.h:31
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
ParticleFlowObject class.
StatusCodeException class.
Vertex class.
Definition Vertex.h:26
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
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
MANAGED_CONTAINER< const Cluster * > ClusterList
MANAGED_CONTAINER< const Vertex * > VertexList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList