Public Member Functions | Private Attributes | List of all members
lar_content::LArMCParticleFactory Class Reference

LArMCParticleFactory responsible for object creation. More...

#include <LArMCParticle.h>

Inheritance diagram for lar_content::LArMCParticleFactory:

Public Member Functions

 LArMCParticleFactory (const unsigned int version=2)
 Constructor. More...
 
Parameters * NewParameters () const
 Create new parameters instance on the heap (memory-management to be controlled by user) More...
 
pandora::StatusCode Read (Parameters &parameters, pandora::FileReader &fileReader) const
 Read any additional (derived class only) object parameters from file using the specified file reader. More...
 
pandora::StatusCode Write (const Object *const pObject, pandora::FileWriter &fileWriter) const
 Persist any additional (derived class only) object parameters using the specified file writer. More...
 
pandora::StatusCode Create (const Parameters &parameters, const Object *&pObject) const
 Create an object with the given parameters. More...
 

Private Attributes

unsigned int m_version
 The LArMCParticle version. More...
 

Detailed Description

LArMCParticleFactory responsible for object creation.

Definition at line 135 of file LArMCParticle.h.

Constructor & Destructor Documentation

lar_content::LArMCParticleFactory::LArMCParticleFactory ( const unsigned int  version = 2)
inline

Constructor.

Parameters
versionthe LArMCParticle version

Definition at line 223 of file LArMCParticle.h.

223  : m_version(version)
224 {
225 }
unsigned int m_version
The LArMCParticle version.

Member Function Documentation

pandora::StatusCode lar_content::LArMCParticleFactory::Create ( const Parameters &  parameters,
const Object *&  pObject 
) const
inline

Create an object with the given parameters.

Parameters
parametersthe parameters to pass in constructor
pObjectto receive the address of the object created

Definition at line 236 of file LArMCParticle.h.

237 {
238  const LArMCParticleParameters &larMCParticleParameters(dynamic_cast<const LArMCParticleParameters &>(parameters));
239  pObject = new LArMCParticle(larMCParticleParameters);
240 
241  return pandora::STATUS_CODE_SUCCESS;
242 }
LArMCParticleFactory::Parameters * lar_content::LArMCParticleFactory::NewParameters ( ) const
inline

Create new parameters instance on the heap (memory-management to be controlled by user)

Returns
the address of the new parameters instance

Definition at line 229 of file LArMCParticle.h.

230 {
231  return (new LArMCParticleParameters);
232 }
pandora::StatusCode lar_content::LArMCParticleFactory::Read ( Parameters &  parameters,
pandora::FileReader &  fileReader 
) const
inline

Read any additional (derived class only) object parameters from file using the specified file reader.

Parameters
parametersthe parameters to pass in constructor
fileReaderthe file reader, used to extract any additional parameters from file

Definition at line 246 of file LArMCParticle.h.

247 {
248  // ATTN: To receive this call-back must have already set file reader mc particle factory to this factory
249  int nuanceCode(0);
250  int process(0);
251 
252  if (pandora::BINARY == fileReader.GetFileType())
253  {
254  pandora::BinaryFileReader &binaryFileReader(dynamic_cast<pandora::BinaryFileReader &>(fileReader));
255  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileReader.ReadVariable(nuanceCode));
256 
257  if (m_version > 1)
258  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileReader.ReadVariable(process));
259  }
260  else if (pandora::XML == fileReader.GetFileType())
261  {
262  pandora::XmlFileReader &xmlFileReader(dynamic_cast<pandora::XmlFileReader &>(fileReader));
263  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileReader.ReadVariable("NuanceCode", nuanceCode));
264 
265  if (m_version > 1)
266  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileReader.ReadVariable("Process", process));
267  }
268  else
269  {
270  return pandora::STATUS_CODE_INVALID_PARAMETER;
271  }
272 
273  LArMCParticleParameters &larMCParticleParameters(dynamic_cast<LArMCParticleParameters &>(parameters));
274  larMCParticleParameters.m_nuanceCode = nuanceCode;
275  larMCParticleParameters.m_process = process;
276 
277  return pandora::STATUS_CODE_SUCCESS;
278 }
def process(f, kind)
Definition: search.py:254
unsigned int m_version
The LArMCParticle version.
pandora::StatusCode lar_content::LArMCParticleFactory::Write ( const Object *const  pObject,
pandora::FileWriter &  fileWriter 
) const
inline

Persist any additional (derived class only) object parameters using the specified file writer.

Parameters
pObjectthe address of the object to persist
fileWriterthe file writer

Definition at line 282 of file LArMCParticle.h.

283 {
284  // ATTN: To receive this call-back must have already set file writer mc particle factory to this factory
285  const LArMCParticle *const pLArMCParticle(dynamic_cast<const LArMCParticle *>(pObject));
286 
287  if (!pLArMCParticle)
288  return pandora::STATUS_CODE_INVALID_PARAMETER;
289 
290  if (pandora::BINARY == fileWriter.GetFileType())
291  {
292  pandora::BinaryFileWriter &binaryFileWriter(dynamic_cast<pandora::BinaryFileWriter &>(fileWriter));
293  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileWriter.WriteVariable(pLArMCParticle->GetNuanceCode()));
294 
295  if (m_version > 1)
296  PANDORA_RETURN_RESULT_IF(
297  pandora::STATUS_CODE_SUCCESS, !=, binaryFileWriter.WriteVariable(static_cast<int>(pLArMCParticle->GetProcess())));
298  }
299  else if (pandora::XML == fileWriter.GetFileType())
300  {
301  pandora::XmlFileWriter &xmlFileWriter(dynamic_cast<pandora::XmlFileWriter &>(fileWriter));
302  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileWriter.WriteVariable("NuanceCode", pLArMCParticle->GetNuanceCode()));
303 
304  if (m_version > 1)
305  PANDORA_RETURN_RESULT_IF(
306  pandora::STATUS_CODE_SUCCESS, !=, xmlFileWriter.WriteVariable("Process", static_cast<int>(pLArMCParticle->GetProcess())));
307  }
308  else
309  {
310  return pandora::STATUS_CODE_INVALID_PARAMETER;
311  }
312 
313  return pandora::STATUS_CODE_SUCCESS;
314 }
unsigned int m_version
The LArMCParticle version.

Member Data Documentation

unsigned int lar_content::LArMCParticleFactory::m_version
private

The LArMCParticle version.

Definition at line 177 of file LArMCParticle.h.


The documentation for this class was generated from the following file: