8 #ifndef LAR_MC_PARTICLE_H
9 #define LAR_MC_PARTICLE_H 1
11 #include "Objects/MCParticle.h"
13 #include "Pandora/ObjectCreation.h"
14 #include "Pandora/PandoraObjectFactories.h"
16 #include "Persistency/BinaryFileReader.h"
17 #include "Persistency/BinaryFileWriter.h"
18 #include "Persistency/XmlFileReader.h"
19 #include "Persistency/XmlFileWriter.h"
135 class LArMCParticleFactory :
public pandora::ObjectFactory<object_creation::MCParticle::Parameters, object_creation::MCParticle::Object>
158 pandora::StatusCode
Read(
Parameters ¶meters, pandora::FileReader &fileReader)
const;
166 pandora::StatusCode
Write(
const Object *
const pObject, pandora::FileWriter &fileWriter)
const;
174 pandora::StatusCode
Create(
const Parameters ¶meters,
const Object *&pObject)
const;
184 object_creation::MCParticle::Object(parameters),
185 m_nuanceCode(parameters.m_nuanceCode.Get()),
186 m_process(parameters.m_process.Get())
203 parameters.m_energy = this->GetEnergy();
204 parameters.m_momentum = this->GetMomentum();
205 parameters.m_vertex = this->GetVertex();
206 parameters.m_endpoint = this->GetEndpoint();
207 parameters.m_particleId = this->GetParticleId();
208 parameters.m_mcParticleType = this->GetMCParticleType();
210 parameters.m_pParentAddress =
static_cast<const void *
>(
this);
238 const LArMCParticleParameters &larMCParticleParameters(dynamic_cast<const LArMCParticleParameters &>(parameters));
241 return pandora::STATUS_CODE_SUCCESS;
252 if (pandora::BINARY == fileReader.GetFileType())
254 pandora::BinaryFileReader &binaryFileReader(dynamic_cast<pandora::BinaryFileReader &>(fileReader));
255 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileReader.ReadVariable(nuanceCode));
258 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileReader.ReadVariable(process));
260 else if (pandora::XML == fileReader.GetFileType())
262 pandora::XmlFileReader &xmlFileReader(dynamic_cast<pandora::XmlFileReader &>(fileReader));
263 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileReader.ReadVariable(
"NuanceCode", nuanceCode));
266 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileReader.ReadVariable(
"Process", process));
270 return pandora::STATUS_CODE_INVALID_PARAMETER;
275 larMCParticleParameters.
m_process = process;
277 return pandora::STATUS_CODE_SUCCESS;
285 const LArMCParticle *
const pLArMCParticle(dynamic_cast<const LArMCParticle *>(pObject));
288 return pandora::STATUS_CODE_INVALID_PARAMETER;
290 if (pandora::BINARY == fileWriter.GetFileType())
292 pandora::BinaryFileWriter &binaryFileWriter(dynamic_cast<pandora::BinaryFileWriter &>(fileWriter));
293 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileWriter.WriteVariable(pLArMCParticle->
GetNuanceCode()));
296 PANDORA_RETURN_RESULT_IF(
297 pandora::STATUS_CODE_SUCCESS, !=, binaryFileWriter.WriteVariable(static_cast<int>(pLArMCParticle->
GetProcess())));
299 else if (pandora::XML == fileWriter.GetFileType())
301 pandora::XmlFileWriter &xmlFileWriter(dynamic_cast<pandora::XmlFileWriter &>(fileWriter));
302 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileWriter.WriteVariable(
"NuanceCode", pLArMCParticle->
GetNuanceCode()));
305 PANDORA_RETURN_RESULT_IF(
306 pandora::STATUS_CODE_SUCCESS, !=, xmlFileWriter.WriteVariable(
"Process", static_cast<int>(pLArMCParticle->
GetProcess())));
310 return pandora::STATUS_CODE_INVALID_PARAMETER;
313 return pandora::STATUS_CODE_SUCCESS;
318 #endif // #ifndef LAR_MC_PARTICLE_H
int m_process
The process that created the particle.
int GetNuanceCode() const
Get the nuance code.
MCProcess GetProcess() const
Get the process.
LArMCParticleFactory(const unsigned int version=2)
Constructor.
int m_nuanceCode
The nuance code.
pandora::StatusCode Write(const Object *const pObject, pandora::FileWriter &fileWriter) const
Persist any additional (derived class only) object parameters using the specified file writer...
pandora::InputInt m_process
The process creating the particle.
void FillParameters(LArMCParticleParameters ¶meters) const
Fill the parameters associated with this MC particle.
pandora::StatusCode Create(const Parameters ¶meters, const Object *&pObject) const
Create an object with the given parameters.
unsigned int m_version
The LArMCParticle version.
pandora::StatusCode Read(Parameters ¶meters, pandora::FileReader &fileReader) const
Read any additional (derived class only) object parameters from file using the specified file reader...
LArMCParticleFactory responsible for object creation.
fhicl::Table< sbnd::crt::CRTDetSimParams > Parameters
LAr mc particle parameters.
pandora::InputInt m_nuanceCode
The nuance code.
LArMCParticle(const LArMCParticleParameters ¶meters)
Constructor.
Parameters * NewParameters() const
Create new parameters instance on the heap (memory-management to be controlled by user) ...