PostProcessingAlgorithm.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArControlFlow/PostProcessingAlgorithm.cc
3  *
4  * @brief Implementation of the list moving algorithm class.
5  *
6  * $Log: $
7  */
8 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
13 using namespace pandora;
14 
15 namespace lar_content
16 {
17 
18 PostProcessingAlgorithm::PostProcessingAlgorithm() : m_listCounter(0)
19 {
20 }
21 
22 //------------------------------------------------------------------------------------------------------------------------------------------
23 
25 {
26  m_listCounter = 0;
27  return STATUS_CODE_SUCCESS;
28 }
29 
30 //------------------------------------------------------------------------------------------------------------------------------------------
31 
33 {
34  for (const std::string &listName : m_pfoListNames)
35  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->RenameList<PfoList>(listName));
36 
37  for (const std::string &listName : m_clusterListNames)
38  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->RenameList<ClusterList>(listName));
39 
40  for (const std::string &listName : m_vertexListNames)
41  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->RenameList<VertexList>(listName));
42 
43  for (const std::string &listName : m_caloHitListNames)
44  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->RenameList<CaloHitList>(listName));
45 
46  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::DropCurrentList<CaloHit>(*this));
47  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::DropCurrentList<Track>(*this));
48  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::DropCurrentList<MCParticle>(*this));
49  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::DropCurrentList<Cluster>(*this));
50  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::DropCurrentList<ParticleFlowObject>(*this));
51  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::DropCurrentList<Vertex>(*this));
52 
53  if (!m_currentPfoListReplacement.empty())
54  {
55  const std::string replacementListName(m_currentPfoListReplacement + TypeToString(m_listCounter));
56 
57  if (STATUS_CODE_SUCCESS != PandoraContentApi::ReplaceCurrentList<Pfo>(*this, replacementListName))
58  {
59  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
60  std::cout << "PostProcessingAlgorithm: could not replace current pfo list with list named: " << replacementListName << std::endl;
61 
62  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::DropCurrentList<Pfo>(*this));
63  }
64  }
65 
66  ++m_listCounter;
67  return STATUS_CODE_SUCCESS;
68 }
69 
70 //------------------------------------------------------------------------------------------------------------------------------------------
71 
72 template <typename T>
73 StatusCode PostProcessingAlgorithm::RenameList(const std::string &oldListName) const
74 {
75  const std::string newListName(oldListName + TypeToString(m_listCounter));
76  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, PandoraContentApi::RenameList<T>(*this, oldListName, newListName));
77  return STATUS_CODE_SUCCESS;
78 }
79 
80 //------------------------------------------------------------------------------------------------------------------------------------------
81 
82 StatusCode PostProcessingAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
83 {
84  PANDORA_RETURN_RESULT_IF_AND_IF(
85  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "PfoListNames", m_pfoListNames));
86 
87  PANDORA_RETURN_RESULT_IF_AND_IF(
88  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "ClusterListNames", m_clusterListNames));
89 
90  PANDORA_RETURN_RESULT_IF_AND_IF(
91  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "VertexListNames", m_vertexListNames));
92 
93  PANDORA_RETURN_RESULT_IF_AND_IF(
94  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "CaloHitListNames", m_caloHitListNames));
95 
96  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
97  XmlHelper::ReadValue(xmlHandle, "CurrentPfoListReplacement", m_currentPfoListReplacement));
98 
99  return STATUS_CODE_SUCCESS;
100 }
101 
102 //------------------------------------------------------------------------------------------------------------------------------------------
103 //------------------------------------------------------------------------------------------------------------------------------------------
104 
105 template pandora::StatusCode PostProcessingAlgorithm::RenameList<PfoList>(const std::string &) const;
106 template pandora::StatusCode PostProcessingAlgorithm::RenameList<ClusterList>(const std::string &) const;
107 template pandora::StatusCode PostProcessingAlgorithm::RenameList<VertexList>(const std::string &) const;
108 template pandora::StatusCode PostProcessingAlgorithm::RenameList<CaloHitList>(const std::string &) const;
109 
110 } // namespace lar_content
std::string string
Definition: nybbler.cc:12
std::string m_currentPfoListReplacement
The name of the pfo list to replace the current list.
pandora::StringVector m_clusterListNames
The list of cluster list names.
Header file for the post processing algorithm class.
unsigned int m_listCounter
The counter appended to output (and replacement current) list names and reset each event...
pandora::StringVector m_caloHitListNames
The list of calo hit list names.
pandora::StringVector m_vertexListNames
The list of vertex list names.
pandora::StringVector m_pfoListNames
The list of pfo list names.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
pandora::StatusCode RenameList(const std::string &oldListName) const
Rename a list of relevant type with specified name - the new name will be the old name with appended ...
QTextStream & endl(QTextStream &s)