LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
ListPruningAlgorithm.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 ListPruningAlgorithm::ListPruningAlgorithm() :
19  m_warnIfObjectsUnavailable(true)
20 {
21 }
22 
23 //------------------------------------------------------------------------------------------------------------------------------------------
24 
26 {
27  for (const std::string &listName : m_pfoListNames)
28  {
29  try
30  {
31  const PfoList *pPfoList(nullptr);
32  const StatusCode statusCode(PandoraContentApi::GetList(*this, listName, pPfoList));
33 
34  if (STATUS_CODE_SUCCESS != statusCode)
35  throw StatusCodeException(statusCode);
36 
37  const PfoList pfoList(*pPfoList);
38 
39  for (const ParticleFlowObject *const pPfo : pfoList)
40  {
41  if (STATUS_CODE_SUCCESS != PandoraContentApi::Delete(*this, pPfo, listName))
42  std::cout << "ListPruningAlgorithm: Could not delete Pfo." << std::endl;
43  }
44  }
45  catch (StatusCodeException &)
46  {
47  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
48  std::cout << "ListPruningAlgorithm: pfo list " << listName << " unavailable." << std::endl;
49  }
50  }
51 
52  for (const std::string &listName : m_clusterListNames)
53  {
54  try
55  {
56  const ClusterList *pClusterList(nullptr);
57  const StatusCode statusCode(PandoraContentApi::GetList(*this, listName, pClusterList));
58 
59  if (STATUS_CODE_SUCCESS != statusCode)
60  throw StatusCodeException(statusCode);
61 
62  const ClusterList clusterList(*pClusterList);
63 
64  for (const Cluster *const pCluster : clusterList)
65  {
66  if (!m_warnIfObjectsUnavailable && !pCluster->IsAvailable())
67  continue;
68 
69  if (STATUS_CODE_SUCCESS != PandoraContentApi::Delete(*this, pCluster, listName) && m_warnIfObjectsUnavailable)
70  std::cout << "ListPruningAlgorithm: Could not delete Cluster." << std::endl;
71  }
72  }
73  catch (StatusCodeException &)
74  {
75  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
76  std::cout << "ListPruningAlgorithm: cluster list " << listName << " unavailable." << std::endl;
77  }
78  }
79 
80  for (const std::string &listName : m_vertexListNames)
81  {
82  try
83  {
84  const VertexList *pVertexList(nullptr);
85  const StatusCode statusCode(PandoraContentApi::GetList(*this, listName, pVertexList));
86 
87  if (STATUS_CODE_SUCCESS != statusCode)
88  throw StatusCodeException(statusCode);
89 
90  const VertexList vertexList(*pVertexList);
91 
92  for (const Vertex *const pVertex : vertexList)
93  {
94  if (!m_warnIfObjectsUnavailable && !pVertex->IsAvailable())
95  continue;
96 
97  if (STATUS_CODE_SUCCESS != PandoraContentApi::Delete(*this, pVertex, listName) && m_warnIfObjectsUnavailable)
98  std::cout << "ListPruningAlgorithm: Could not delete Vertex." << std::endl;
99  }
100  }
101  catch (StatusCodeException &)
102  {
103  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
104  std::cout << "ListPruningAlgorithm: vertex list " << listName << " unavailable." << std::endl;
105  }
106  }
107 
108  return STATUS_CODE_SUCCESS;
109 }
110 
111 //------------------------------------------------------------------------------------------------------------------------------------------
112 
113 StatusCode ListPruningAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
114 {
115  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
116  "PfoListNames", m_pfoListNames));
117 
118  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
119  "ClusterListNames", m_clusterListNames));
120 
121  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
122  "VertexListNames", m_vertexListNames));
123 
124  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
125  "WarnIfObjectsUnavailable", m_warnIfObjectsUnavailable));
126 
127  return STATUS_CODE_SUCCESS;
128 }
129 
130 } // namespace lar_content
pandora::StringVector m_clusterListNames
The cluster list names.
pandora::StringVector m_pfoListNames
The pfo list names.
Header file for the list pruning algorithm class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
bool m_warnIfObjectsUnavailable
Whether to print warning if attempt made to delete unavailable objects.
std::list< Vertex > VertexList
Definition: DCEL.h:178
pandora::StringVector m_vertexListNames
The vertex list names.