Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
Pandora.cc
Go to the documentation of this file.
1
9#include "Api/PandoraApi.h"
10#include "Api/PandoraApiImpl.h"
13
18#include "Managers/MCManager.h"
23
24#include "Pandora/Pandora.h"
25#include "Pandora/PandoraImpl.h"
27
28#include "Xml/tinyxml.h"
29
30namespace pandora
31{
32
33Pandora::Pandora(const std::string &name) :
34 m_pAlgorithmManager(nullptr),
35 m_pCaloHitManager(nullptr),
36 m_pClusterManager(nullptr),
37 m_pGeometryManager(nullptr),
38 m_pMCManager(nullptr),
39 m_pPfoManager(nullptr),
40 m_pPluginManager(nullptr),
41 m_pTrackManager(nullptr),
42 m_pVertexManager(nullptr),
43 m_pPandoraSettings(nullptr),
44 m_pPandoraApiImpl(nullptr),
45 m_pPandoraContentApiImpl(nullptr),
46 m_pPandoraImpl(nullptr),
47 m_name(name)
48{
49 try
50 {
55 m_pMCManager = new MCManager(this);
58 m_pTrackManager = new TrackManager(this);
63 m_pPandoraImpl = new PandoraImpl(this);
64 }
65 catch (StatusCodeException &statusCodeException)
66 {
67 std::cout << "Failed to create pandora instance " << statusCodeException.ToString() << std::endl;
68 delete this;
69 throw statusCodeException;
70 }
71 catch (...)
72 {
73 std::cout << "Failed to create pandora instance " << std::endl;
74 delete this;
75 throw;
76 }
77}
78
79//------------------------------------------------------------------------------------------------------------------------------------------
80
82{
84 delete m_pCaloHitManager;
85 delete m_pClusterManager;
86 delete m_pGeometryManager;
87 delete m_pMCManager;
88 delete m_pPfoManager;
89 delete m_pPluginManager;
90 delete m_pTrackManager;
91 delete m_pVertexManager;
92 delete m_pPandoraSettings;
93 delete m_pPandoraApiImpl;
95 delete m_pPandoraImpl;
96}
97
98//------------------------------------------------------------------------------------------------------------------------------------------
99
101{
103 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pPandoraImpl->PrepareCaloHits());
104 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pPandoraImpl->PrepareTracks());
105
106 return STATUS_CODE_SUCCESS;
107}
108
109//------------------------------------------------------------------------------------------------------------------------------------------
110
112{
113 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->PrepareEvent());
114
115 // Loop over algorithms
116 const StringVector &pandoraAlgorithms(m_pPandoraImpl->GetPandoraAlgorithms());
117
118 for (const std::string &algorithmName : pandoraAlgorithms)
119 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pPandoraImpl->RunAlgorithm(algorithmName));
120
121 return STATUS_CODE_SUCCESS;
122}
123
124//------------------------------------------------------------------------------------------------------------------------------------------
125
130
131//------------------------------------------------------------------------------------------------------------------------------------------
132
133StatusCode Pandora::ReadSettings(const std::string &xmlFileName)
134{
135 try
136 {
137 TiXmlDocument xmlDocument(xmlFileName);
138
139 if (!xmlDocument.LoadFile())
140 {
141 std::cout << "Pandora::ReadSettings - Invalid xml file." << std::endl;
142 throw StatusCodeException(STATUS_CODE_FAILURE);
143 }
144
145 const TiXmlHandle xmlDocumentHandle(&xmlDocument);
146 const TiXmlHandle xmlHandle(TiXmlHandle(xmlDocumentHandle.FirstChildElement().Element()));
147
148 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pPandoraImpl->InitializeSettings(&xmlHandle));
149 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pPandoraImpl->InitializeAlgorithms(&xmlHandle));
150 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pPandoraImpl->InitializePlugins(&xmlHandle));
151 }
152 catch (StatusCodeException &statusCodeException)
153 {
154 std::cout << "Failure in reading pandora settings, " << statusCodeException.ToString() << std::endl;
155 return STATUS_CODE_FAILURE;
156 }
157 catch (...)
158 {
159 std::cout << "Failure in reading pandora settings, unrecognized exception" << std::endl;
160 return STATUS_CODE_FAILURE;
161 }
162
163 return STATUS_CODE_SUCCESS;
164}
165
166//------------------------------------------------------------------------------------------------------------------------------------------
167
172
173//------------------------------------------------------------------------------------------------------------------------------------------
174
179
180//------------------------------------------------------------------------------------------------------------------------------------------
181
183{
184 return m_pPandoraSettings;
185}
186
187//------------------------------------------------------------------------------------------------------------------------------------------
188
190{
191 return m_pGeometryManager;
192}
193
194//------------------------------------------------------------------------------------------------------------------------------------------
195
197{
198 return m_pPluginManager;
199}
200
201//------------------------------------------------------------------------------------------------------------------------------------------
202
203const std::string &Pandora::GetName() const
204{
205 return m_name;
206}
207
208} // namespace pandora
Header file for the algorithm manager class.
Header file for the calo hit manager class.
Header file for the cluster manager class.
Header file for the geometry manager class.
Header file for the mc particle manager class.
Header file for the pandora class.
Header file for the pandora api class.
Header file for the pandora api implementation class.
Header file for the pandora content api class.
Header file for the pandora content api implementation class.
Header file for the pandora impl class.
Header file for the pandora settings class.
Header file for the particle flow object manager class.
Header file for the pandora plugin manager class.
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:43
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:19
Header file for the track manager class.
Header file for the vertex manager class.
AlgorithmManager class.
CaloHitManager class.
ClusterManager class.
GeometryManager class.
MCManager class.
Definition MCManager.h:23
PandoraApiImpl class.
PandoraContentApiImpl class.
friend class PandoraContentApiImpl
Definition Pandora.h:137
VertexManager * m_pVertexManager
The vertex manager.
Definition Pandora.h:127
MCManager * m_pMCManager
The MC manager.
Definition Pandora.h:123
StatusCode ProcessEvent()
Process event, calling event prepare event function, then running the algorithms.
Definition Pandora.cc:111
TrackManager * m_pTrackManager
The track manager.
Definition Pandora.h:126
friend class PandoraImpl
Definition Pandora.h:138
friend class PandoraApiImpl
Definition Pandora.h:136
CaloHitManager * m_pCaloHitManager
The hit manager.
Definition Pandora.h:120
AlgorithmManager * m_pAlgorithmManager
The algorithm manager.
Definition Pandora.h:119
PandoraSettings * m_pPandoraSettings
The pandora settings instance.
Definition Pandora.h:129
PluginManager * m_pPluginManager
The pandora plugin manager.
Definition Pandora.h:125
~Pandora()
Destructor.
Definition Pandora.cc:81
const std::string & GetName() const
Get the descriptive name or label for the pandora instance.
Definition Pandora.cc:203
Pandora(const std::string &name="")
Default constructor.
Definition Pandora.cc:33
ClusterManager * m_pClusterManager
The cluster manager.
Definition Pandora.h:121
PandoraApiImpl * m_pPandoraApiImpl
The pandora api implementation.
Definition Pandora.h:130
GeometryManager * m_pGeometryManager
The geometry manager.
Definition Pandora.h:122
std::string m_name
The descriptive name or label for the pandora instance.
Definition Pandora.h:134
const PandoraApiImpl * GetPandoraApiImpl() const
Get the pandora api impl.
Definition Pandora.cc:168
const PandoraContentApiImpl * GetPandoraContentApiImpl() const
Get the pandora content api impl.
Definition Pandora.cc:175
StatusCode ResetEvent()
Reset event, calling manager reset functions and any registered reset functions.
Definition Pandora.cc:126
const PandoraSettings * GetSettings() const
Get the pandora settings instance.
Definition Pandora.cc:182
StatusCode PrepareEvent()
Prepare event, calculating properties of input objects for later use in algorithms.
Definition Pandora.cc:100
PandoraImpl * m_pPandoraImpl
The pandora implementation.
Definition Pandora.h:132
ParticleFlowObjectManager * m_pPfoManager
The particle flow object manager.
Definition Pandora.h:124
const GeometryManager * GetGeometry() const
Get the pandora geometry instance.
Definition Pandora.cc:189
const PluginManager * GetPlugins() const
Get the pandora plugin instance, providing access to user registered functions and calculators.
Definition Pandora.cc:196
PandoraContentApiImpl * m_pPandoraContentApiImpl
The pandora content api implementation.
Definition Pandora.h:131
StatusCode ReadSettings(const std::string &xmlFileName)
Read pandora settings.
Definition Pandora.cc:133
StatusCode PrepareCaloHits() const
Prepare calo hits: order the hits by pseudo layer, calculate density weights, identify isolated hits,...
StatusCode ResetEvent() const
Ï event, calling manager reset functions and any registered reset functions.
StatusCode PrepareTracks() const
Prepare tracks: add track associations (parent-daughter and sibling)
const StringVector & GetPandoraAlgorithms() const
Get the list of algorithms to be run by pandora.
StatusCode RunAlgorithm(const std::string &algorithmName) const
Run an algorithm registered with pandora.
StatusCode InitializeSettings(const TiXmlHandle *const pXmlHandle) const
Initialize pandora settings.
StatusCode InitializeAlgorithms(const TiXmlHandle *const pXmlHandle) const
Initialize pandora algorithms.
StatusCode InitializePlugins(const TiXmlHandle *const pXmlHandle) const
Initialize pandora plugins.
StatusCode PrepareMCParticles() const
Prepare mc particles: select mc pfo targets, match tracks and calo hits to the correct mc particles f...
PandoraSettings class.
ParticleFlowObjectManager class.
PluginManager class.
StatusCodeException class.
std::string ToString() const
Get status code as a string.
bool LoadFile(TiXmlEncoding encoding=TIXML_DEFAULT_ENCODING)
Definition tinyxml.cc:957
TiXmlHandle FirstChildElement() const
Return a handle to the first child element.
Definition tinyxml.cc:1659
TiXmlElement * Element() const
Definition tinyxml.h:1710
TrackManager class.
VertexManager class.
std::vector< std::string > StringVector
StatusCode
The StatusCode enum.