Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
PluginManager.cc
Go to the documentation of this file.
1
9#include "Helpers/XmlHelper.h"
10
12
19
20namespace pandora
21{
22
23PluginManager::PluginManager(const Pandora *const pPandora) :
24 m_pBFieldPlugin(nullptr),
25 m_pLArTransformationPlugin(nullptr),
26 m_pPseudoLayerPlugin(nullptr),
27 m_pShowerProfilePlugin(nullptr),
28 m_pEnergyCorrections(nullptr),
29 m_pParticleId(nullptr),
30 m_pPandora(pPandora)
31{
32 try
33 {
36 }
37 catch (StatusCodeException &statusCodeException)
38 {
39 std::cout << "Failed to create pandora plugin manager instance " << statusCodeException.ToString() << std::endl;
40 delete this;
41 throw statusCodeException;
42 }
43 catch (...)
44 {
45 std::cout << "Failed to create pandora plugin manager instance " << std::endl;
46 delete this;
47 throw;
48 }
49}
50
51//------------------------------------------------------------------------------------------------------------------------------------------
52
63
64//------------------------------------------------------------------------------------------------------------------------------------------
65
67{
68 return (nullptr != m_pBFieldPlugin);
69}
70
71//------------------------------------------------------------------------------------------------------------------------------------------
72
74{
75 return (nullptr != m_pLArTransformationPlugin);
76}
77
78//------------------------------------------------------------------------------------------------------------------------------------------
79
81{
82 return (nullptr != m_pPseudoLayerPlugin);
83}
84
85//------------------------------------------------------------------------------------------------------------------------------------------
86
88{
89 return (nullptr != m_pShowerProfilePlugin);
90}
91
92//------------------------------------------------------------------------------------------------------------------------------------------
93
95{
96 if (!m_pBFieldPlugin)
97 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
98
99 return m_pBFieldPlugin;
100}
101
102//------------------------------------------------------------------------------------------------------------------------------------------
103
105{
107 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
108
110}
111
112//------------------------------------------------------------------------------------------------------------------------------------------
113
115{
117 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
118
120}
121
122//------------------------------------------------------------------------------------------------------------------------------------------
123
125{
127 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
128
130}
131
132//------------------------------------------------------------------------------------------------------------------------------------------
133
135{
137 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
138
140}
141
142//------------------------------------------------------------------------------------------------------------------------------------------
143
145{
146 if (!m_pParticleId)
147 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
148
149 return m_pParticleId;
150}
151
152//------------------------------------------------------------------------------------------------------------------------------------------
153
155{
156 if (nullptr != m_pBFieldPlugin)
157 return STATUS_CODE_ALREADY_INITIALIZED;
158
159 m_pBFieldPlugin = pBFieldPlugin;
160 return STATUS_CODE_SUCCESS;
161}
162
163//------------------------------------------------------------------------------------------------------------------------------------------
164
166{
167 if (nullptr != m_pLArTransformationPlugin)
168 return STATUS_CODE_ALREADY_INITIALIZED;
169
170 m_pLArTransformationPlugin = pLArTransformationPlugin;
171 return STATUS_CODE_SUCCESS;
172}
173
174//------------------------------------------------------------------------------------------------------------------------------------------
175
177{
178 if (nullptr != m_pPseudoLayerPlugin)
179 return STATUS_CODE_ALREADY_INITIALIZED;
180
181 m_pPseudoLayerPlugin = pPseudoLayerPlugin;
182 return STATUS_CODE_SUCCESS;
183}
184
185//------------------------------------------------------------------------------------------------------------------------------------------
186
188{
189 if (nullptr != m_pShowerProfilePlugin)
190 return STATUS_CODE_ALREADY_INITIALIZED;
191
192 m_pShowerProfilePlugin = pShowerProfilePlugin;
193 return STATUS_CODE_SUCCESS;
194}
195
196//------------------------------------------------------------------------------------------------------------------------------------------
197
199{
200 if (nullptr != m_pBFieldPlugin)
201 {
202 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pBFieldPlugin->RegisterDetails(m_pPandora, "BFieldPlugin", "BFieldPlugin"));
203 TiXmlElement *const pBFieldXmlElement(pXmlHandle->FirstChild("BFieldPlugin").Element());
204
205 if (nullptr != pBFieldXmlElement)
206 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pBFieldPlugin->ReadSettings(TiXmlHandle(pBFieldXmlElement)));
207
208 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pBFieldPlugin->Initialize());
209 }
210
211 if (nullptr != m_pLArTransformationPlugin)
212 {
213 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pLArTransformationPlugin->RegisterDetails(m_pPandora, "LArTransformationPlugin", "LArTransformationPlugin"));
214 TiXmlElement *const pLArTransformationXmlElement(pXmlHandle->FirstChild("LArTransformationPlugin").Element());
215
216 if (nullptr != pLArTransformationXmlElement)
217 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pLArTransformationPlugin->ReadSettings(TiXmlHandle(pLArTransformationXmlElement)));
218
220 }
221
222 if (nullptr != m_pPseudoLayerPlugin)
223 {
224 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pPseudoLayerPlugin->RegisterDetails(m_pPandora, "PseudoLayerPlugin", "PseudoLayerPlugin"));
225 TiXmlElement *const pPseudoLayerXmlElement(pXmlHandle->FirstChild("PseudoLayerPlugin").Element());
226
227 if (nullptr != pPseudoLayerXmlElement)
228 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pPseudoLayerPlugin->ReadSettings(TiXmlHandle(pPseudoLayerXmlElement)));
229
230 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pPseudoLayerPlugin->Initialize());
231 }
232
233 if (nullptr != m_pShowerProfilePlugin)
234 {
235 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pShowerProfilePlugin->RegisterDetails(m_pPandora, "ShowerProfilePlugin", "ShowerProfilePlugin"));
236 TiXmlElement *const pShowerProfileXmlElement(pXmlHandle->FirstChild("ShowerProfilePlugin").Element());
237
238 if (nullptr != pShowerProfileXmlElement)
239 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pShowerProfilePlugin->ReadSettings(TiXmlHandle(pShowerProfileXmlElement)));
240
242 }
243
244 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pEnergyCorrections->InitializePlugins(pXmlHandle));
245 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pParticleId->InitializePlugins(pXmlHandle));
246
247 return STATUS_CODE_SUCCESS;
248}
249
250//------------------------------------------------------------------------------------------------------------------------------------------
251
253{
254 if (m_pBFieldPlugin)
255 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pBFieldPlugin->Reset());
256
258 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pLArTransformationPlugin->Reset());
259
261 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pPseudoLayerPlugin->Reset());
262
264 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pShowerProfilePlugin->Reset());
265
267 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, m_pParticleId->ResetForNextEvent());
268
269 return STATUS_CODE_SUCCESS;
270}
271
272} // namespace pandora
Header file for the bfield plugin interface class.
Header file for the calo hit plugin class.
Header file for the lar transformation plugin interface class.
Header file for the particle id plugin class.
Header file for the pandora plugin manager class.
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:19
Header file for the xml helper class.
BFieldPlugin class.
StatusCode ResetForNextEvent()
Call the reset callback in all managed plugins.
StatusCode InitializePlugins(const TiXmlHandle *const pXmlHandle)
Initialize plugins.
LArTransformationPlugin class.
Pandora class.
Definition Pandora.h:40
ParticleId class.
StatusCode ResetForNextEvent()
Call the reset callback in all managed plugins.
StatusCode InitializePlugins(const TiXmlHandle *const pXmlHandle)
Initialize plugins.
const LArTransformationPlugin * GetLArTransformationPlugin() const
Get the address of the lar transformation plugin.
const EnergyCorrections * GetEnergyCorrections() const
Get the pandora energy corrections instance.
StatusCode ResetForNextEvent()
Call the reset callback in all managed plugins.
bool HasBFieldPlugin() const
Whether the b field plugin is available.
BFieldPlugin * m_pBFieldPlugin
Address of the bfield plugin.
const PseudoLayerPlugin * GetPseudoLayerPlugin() const
Get the address of the pseudo layer plugin.
LArTransformationPlugin * m_pLArTransformationPlugin
Address of the lar transformation plugin.
const BFieldPlugin * GetBFieldPlugin() const
Get the address of the b field plugin.
~PluginManager()
Destructor.
ShowerProfilePlugin * m_pShowerProfilePlugin
The shower profile plugin.
const Pandora *const m_pPandora
The associated pandora object.
StatusCode SetShowerProfilePlugin(ShowerProfilePlugin *const pShowerProfilePlugin)
Set the shower profile plugin.
StatusCode SetPseudoLayerPlugin(PseudoLayerPlugin *const pPseudoLayerPlugin)
Set the pseudo layer plugin.
EnergyCorrections * m_pEnergyCorrections
The energy corrections.
const ParticleId * GetParticleId() const
Get the address of the pandora particle id instance.
bool HasPseudoLayerPlugin() const
Whether the pseudo layer plugin is available.
bool HasShowerProfilePlugin() const
Whether the shower profile plugin is available.
StatusCode SetLArTransformationPlugin(LArTransformationPlugin *const pLArTransformationPlugin)
Set the lar transformation plugin.
bool HasLArTransformationPlugin() const
Whether the lar transformation plugin is available.
PseudoLayerPlugin * m_pPseudoLayerPlugin
Address of the pseudolayer plugin.
const ShowerProfilePlugin * GetShowerProfilePlugin() const
Get the shower profile plugin.
PluginManager(const Pandora *const pPandora)
Constructor.
StatusCode InitializePlugins(const TiXmlHandle *const pXmlHandle)
Initialize plugins.
ParticleId * m_pParticleId
The particle id.
StatusCode SetBFieldPlugin(BFieldPlugin *const pBFieldPlugin)
Set the bfield plugin.
virtual StatusCode Initialize()
Perform any operations that must occur after reading settings, but before running the process.
Definition Process.h:126
virtual StatusCode Reset()
Perform any operations when pandora is reset, typically at the end of each event.
Definition Process.h:133
virtual StatusCode ReadSettings(const TiXmlHandle xmlHandle)=0
Read the algorithm settings.
StatusCode RegisterDetails(const Pandora *const pPandora, const std::string &type, const std::string &instanceName)
Register i) the pandora instance that will run the process and ii) the process type.
Definition Process.h:146
PseudoLayerPlugin class.
ShowerProfilePlugin class.
StatusCodeException class.
std::string ToString() const
Get status code as a string.
TiXmlElement * Element() const
Definition tinyxml.h:1710
TiXmlHandle FirstChild() const
Return a handle to the first child node.
Definition tinyxml.cc:1635
StatusCode
The StatusCode enum.