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" 109 int GetNuanceCode()
const;
135 class LArMCParticleFactory :
public pandora::ObjectFactory<object_creation::MCParticle::Parameters, object_creation::MCParticle::Object>
150 Parameters *NewParameters()
const;
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),
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);
239 const LArMCParticleParameters &larMCParticleParameters(dynamic_cast<const LArMCParticleParameters &>(parameters));
242 return pandora::STATUS_CODE_SUCCESS;
253 if (pandora::BINARY == fileReader.GetFileType())
255 pandora::BinaryFileReader &binaryFileReader(dynamic_cast<pandora::BinaryFileReader &>(fileReader));
256 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileReader.ReadVariable(nuanceCode));
259 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileReader.ReadVariable(process));
261 else if (pandora::XML == fileReader.GetFileType())
263 pandora::XmlFileReader &xmlFileReader(dynamic_cast<pandora::XmlFileReader &>(fileReader));
264 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileReader.ReadVariable(
"NuanceCode", nuanceCode));
267 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileReader.ReadVariable(
"Process", process));
271 return pandora::STATUS_CODE_INVALID_PARAMETER;
276 larMCParticleParameters.
m_process = process;
278 return pandora::STATUS_CODE_SUCCESS;
286 const LArMCParticle *
const pLArMCParticle(dynamic_cast<const LArMCParticle *>(pObject));
289 return pandora::STATUS_CODE_INVALID_PARAMETER;
291 if (pandora::BINARY == fileWriter.GetFileType())
293 pandora::BinaryFileWriter &binaryFileWriter(dynamic_cast<pandora::BinaryFileWriter &>(fileWriter));
294 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileWriter.WriteVariable(pLArMCParticle->
GetNuanceCode()));
297 PANDORA_RETURN_RESULT_IF(
298 pandora::STATUS_CODE_SUCCESS, !=, binaryFileWriter.WriteVariable(static_cast<int>(pLArMCParticle->
GetProcess())));
300 else if (pandora::XML == fileWriter.GetFileType())
302 pandora::XmlFileWriter &xmlFileWriter(dynamic_cast<pandora::XmlFileWriter &>(fileWriter));
303 PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileWriter.WriteVariable(
"NuanceCode", pLArMCParticle->
GetNuanceCode()));
306 PANDORA_RETURN_RESULT_IF(
307 pandora::STATUS_CODE_SUCCESS, !=, xmlFileWriter.WriteVariable(
"Process", static_cast<int>(pLArMCParticle->
GetProcess())));
311 return pandora::STATUS_CODE_INVALID_PARAMETER;
314 return pandora::STATUS_CODE_SUCCESS;
319 #endif // #ifndef LAR_MC_PARTICLE_H int m_process
The process that created the particle.
Read("Flexi","livermore")
int GetNuanceCode() const
Get the nuance code.
MCProcess GetProcess() const
Get the process.
LArMCParticleFactory(const unsigned int version=2)
Constructor.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
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.
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) ...