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

LArCaloHitFactory responsible for object creation. More...

#include <LArCaloHit.h>

Inheritance diagram for lar_content::LArCaloHitFactory:

Public Member Functions

 LArCaloHitFactory (const unsigned int version=1)
 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 LArCaloHit version. More...
 

Detailed Description

LArCaloHitFactory responsible for object creation.

Definition at line 110 of file LArCaloHit.h.

Constructor & Destructor Documentation

lar_content::LArCaloHitFactory::LArCaloHitFactory ( const unsigned int  version = 1)
inline

Constructor.

Parameters
versionthe LArCaloHit version

Definition at line 245 of file LArCaloHit.h.

245  : m_version(version)
246 {
247 }
unsigned int m_version
The LArCaloHit version.
Definition: LArCaloHit.h:152

Member Function Documentation

pandora::StatusCode lar_content::LArCaloHitFactory::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 258 of file LArCaloHit.h.

259 {
260  const LArCaloHitParameters &larCaloHitParameters(dynamic_cast<const LArCaloHitParameters &>(parameters));
261  pObject = new LArCaloHit(larCaloHitParameters);
262 
263  return pandora::STATUS_CODE_SUCCESS;
264 }
LArCaloHitFactory::Parameters * lar_content::LArCaloHitFactory::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 251 of file LArCaloHit.h.

252 {
253  return (new LArCaloHitParameters);
254 }
pandora::StatusCode lar_content::LArCaloHitFactory::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 268 of file LArCaloHit.h.

269 {
270  // ATTN: To receive this call-back must have already set file reader mc particle factory to this factory
271  unsigned int larTPCVolumeId(std::numeric_limits<unsigned int>::max());
272  unsigned int daughterVolumeId(0);
273 
274  if (pandora::BINARY == fileReader.GetFileType())
275  {
276  pandora::BinaryFileReader &binaryFileReader(dynamic_cast<pandora::BinaryFileReader &>(fileReader));
277  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileReader.ReadVariable(larTPCVolumeId));
278  if (m_version > 1)
279  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileReader.ReadVariable(daughterVolumeId));
280  }
281  else if (pandora::XML == fileReader.GetFileType())
282  {
283  pandora::XmlFileReader &xmlFileReader(dynamic_cast<pandora::XmlFileReader &>(fileReader));
284  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileReader.ReadVariable("LArTPCVolumeId", larTPCVolumeId));
285  if (m_version > 1)
286  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileReader.ReadVariable("DaughterVolumeId", daughterVolumeId));
287  }
288  else
289  {
290  return pandora::STATUS_CODE_INVALID_PARAMETER;
291  }
292 
293  LArCaloHitParameters &larCaloHitParameters(dynamic_cast<LArCaloHitParameters &>(parameters));
294  larCaloHitParameters.m_larTPCVolumeId = larTPCVolumeId;
295  larCaloHitParameters.m_daughterVolumeId = daughterVolumeId;
296 
297  return pandora::STATUS_CODE_SUCCESS;
298 }
unsigned int m_version
The LArCaloHit version.
Definition: LArCaloHit.h:152
static int max(int a, int b)
pandora::StatusCode lar_content::LArCaloHitFactory::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 302 of file LArCaloHit.h.

303 {
304  // ATTN: To receive this call-back must have already set file writer mc particle factory to this factory
305  const LArCaloHit *const pLArCaloHit(dynamic_cast<const LArCaloHit *>(pObject));
306 
307  if (!pLArCaloHit)
308  return pandora::STATUS_CODE_INVALID_PARAMETER;
309 
310  if (pandora::BINARY == fileWriter.GetFileType())
311  {
312  pandora::BinaryFileWriter &binaryFileWriter(dynamic_cast<pandora::BinaryFileWriter &>(fileWriter));
313  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileWriter.WriteVariable(pLArCaloHit->GetLArTPCVolumeId()));
314  if (m_version > 1)
315  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, binaryFileWriter.WriteVariable(pLArCaloHit->GetDaughterVolumeId()));
316  }
317  else if (pandora::XML == fileWriter.GetFileType())
318  {
319  pandora::XmlFileWriter &xmlFileWriter(dynamic_cast<pandora::XmlFileWriter &>(fileWriter));
320  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, xmlFileWriter.WriteVariable("LArTPCVolumeId", pLArCaloHit->GetLArTPCVolumeId()));
321  if (m_version > 1)
322  PANDORA_RETURN_RESULT_IF(
323  pandora::STATUS_CODE_SUCCESS, !=, xmlFileWriter.WriteVariable("DaughterVolumeId", pLArCaloHit->GetDaughterVolumeId()));
324  }
325  else
326  {
327  return pandora::STATUS_CODE_INVALID_PARAMETER;
328  }
329 
330  return pandora::STATUS_CODE_SUCCESS;
331 }
unsigned int m_version
The LArCaloHit version.
Definition: LArCaloHit.h:152

Member Data Documentation

unsigned int lar_content::LArCaloHitFactory::m_version
private

The LArCaloHit version.

Definition at line 152 of file LArCaloHit.h.


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