LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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  :
246  m_version(version)
247 {
248 }
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 259 of file LArCaloHit.h.

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

253 {
254  return (new LArCaloHitParameters);
255 }
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 269 of file LArCaloHit.h.

References lar_content::LArCaloHitParameters::m_daughterVolumeId, lar_content::LArCaloHitParameters::m_larTPCVolumeId, and m_version.

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

References lar_content::LArCaloHit::GetDaughterVolumeId(), lar_content::LArCaloHit::GetLArTPCVolumeId(), and m_version.

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

Referenced by Read(), and Write().


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