LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
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.

18  :
20 {
21 }
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 113 of file ListPruningAlgorithm.cc.

References m_clusterListNames, m_pfoListNames, m_vertexListNames, and m_warnIfObjectsUnavailable.

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 }
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 25 of file ListPruningAlgorithm.cc.

References m_clusterListNames, m_pfoListNames, m_vertexListNames, and m_warnIfObjectsUnavailable.

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 }
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.
std::list< Vertex > VertexList
Definition: DCEL.h:178
pandora::StringVector m_vertexListNames
The vertex list names.

Member Data Documentation

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

The cluster list names.

Definition at line 32 of file ListPruningAlgorithm.h.

Referenced by ReadSettings(), and Run().

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

The pfo list names.

Definition at line 31 of file ListPruningAlgorithm.h.

Referenced by ReadSettings(), and Run().

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

The vertex list names.

Definition at line 33 of file ListPruningAlgorithm.h.

Referenced by ReadSettings(), and Run().

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.

Referenced by ReadSettings(), and Run().


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