Public Member Functions | Private Member Functions | Private Attributes | List of all members
lar_content::ListPruningAlgorithm Class Reference

ListPruningAlgorithm class. More...

#include <ListPruningAlgorithm.h>

Inheritance diagram for lar_content::ListPruningAlgorithm:

Public Member Functions

 ListPruningAlgorithm ()
 Default constructor. More...
 

Private Member Functions

pandora::StatusCode Run ()
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

pandora::StringVector m_pfoListNames
 The pfo list names. More...
 
pandora::StringVector m_clusterListNames
 The cluster list names. More...
 
pandora::StringVector m_vertexListNames
 The vertex list names. More...
 
bool m_warnIfObjectsUnavailable
 Whether to print warning if attempt made to delete unavailable objects. More...
 

Detailed Description

ListPruningAlgorithm class.

Definition at line 19 of file ListPruningAlgorithm.h.

Constructor & Destructor Documentation

lar_content::ListPruningAlgorithm::ListPruningAlgorithm ( )

Default constructor.

Definition at line 18 of file ListPruningAlgorithm.cc.

19 {
20 }
bool m_warnIfObjectsUnavailable
Whether to print warning if attempt made to delete unavailable objects.

Member Function Documentation

StatusCode lar_content::ListPruningAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 112 of file ListPruningAlgorithm.cc.

113 {
114  PANDORA_RETURN_RESULT_IF_AND_IF(
115  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "PfoListNames", m_pfoListNames));
116 
117  PANDORA_RETURN_RESULT_IF_AND_IF(
118  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "ClusterListNames", m_clusterListNames));
119 
120  PANDORA_RETURN_RESULT_IF_AND_IF(
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 }
pandora::StringVector m_clusterListNames
The cluster list names.
pandora::StringVector m_pfoListNames
The pfo list names.
bool m_warnIfObjectsUnavailable
Whether to print warning if attempt made to delete unavailable objects.
pandora::StringVector m_vertexListNames
The vertex list names.
StatusCode lar_content::ListPruningAlgorithm::Run ( )
private

Definition at line 24 of file ListPruningAlgorithm.cc.

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  {
46  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
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  {
74  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
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  {
102  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
103  std::cout << "ListPruningAlgorithm: vertex list " << listName << " unavailable." << std::endl;
104  }
105  }
106 
107  return STATUS_CODE_SUCCESS;
108 }
std::string string
Definition: nybbler.cc:12
pandora::StringVector m_clusterListNames
The cluster list names.
pandora::StringVector m_pfoListNames
The pfo list names.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
bool m_warnIfObjectsUnavailable
Whether to print warning if attempt made to delete unavailable objects.
std::list< Vertex > VertexList
Definition: DCEL.h:182
pandora::StringVector m_vertexListNames
The vertex list names.
QTextStream & endl(QTextStream &s)

Member Data Documentation

pandora::StringVector lar_content::ListPruningAlgorithm::m_clusterListNames
private

The cluster list names.

Definition at line 32 of file ListPruningAlgorithm.h.

pandora::StringVector lar_content::ListPruningAlgorithm::m_pfoListNames
private

The pfo list names.

Definition at line 31 of file ListPruningAlgorithm.h.

pandora::StringVector lar_content::ListPruningAlgorithm::m_vertexListNames
private

The vertex list names.

Definition at line 33 of file ListPruningAlgorithm.h.

bool lar_content::ListPruningAlgorithm::m_warnIfObjectsUnavailable
private

Whether to print warning if attempt made to delete unavailable objects.

Definition at line 34 of file ListPruningAlgorithm.h.


The documentation for this class was generated from the following files: