DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dd4hep::sim::Geant4EventReader Class Referenceabstract

Basic geant4 event reader class. This interface/base-class must be implemented by concrete readers. More...

#include <Geant4InputAction.h>

Inheritance diagram for dd4hep::sim::Geant4EventReader:
dd4hep::sim::Geant4EventReaderGuineaPig dd4hep::sim::Geant4EventReaderHepEvt dd4hep::sim::Geant4EventReaderHepMC dd4hep::sim::HEPMC3EventReader dd4hep::sim::LCIOEventReader dd4hep::sim::HEPMC3FileReader dd4hep::sim::LCIOFileReader dd4hep::sim::LCIOStdHepReader

Public Types

enum  EventReaderStatus {
  EVENT_READER_ERROR =0, EVENT_READER_OK =1, EVENT_READER_NO_DIRECT =2, EVENT_READER_NO_PRIMARIES =4,
  EVENT_READER_NO_FACTORY =6, EVENT_READER_IO_ERROR =8, EVENT_READER_EOF =10
}
 Status codes of the event reader object. Anything with NOT low-bit set is an error. More...
 
typedef Geant4Vertex Vertex
 
typedef Geant4Particle Particle
 
typedef std::vector< Particle * > Particles
 
typedef std::vector< Vertex * > Vertices
 

Public Member Functions

 Geant4EventReader (const std::string &nam)
 Initializing constructor. More...
 
virtual ~Geant4EventReader ()
 Default destructor. More...
 
Geant4Contextcontext () const
 Get the context (from the input action) More...
 
void setInputAction (Geant4InputAction *action)
 Set the input action. More...
 
const std::string & name () const
 File name. More...
 
bool hasDirectAccess () const
 Flag if direct event access (by event sequence number) is supported (Default: false) More...
 
int currentEventNumber () const
 return current Event Number More...
 
virtual EventReaderStatus moveToEvent (int event_number)
 Move to the indicated event number. More...
 
virtual EventReaderStatus skipEvent ()
 Skip event. To be implemented for sequential sources. More...
 
virtual EventReaderStatus readParticles (int event_number, Vertices &vertices, Particles &particles)=0
 Read an event and fill a vector of MCParticles. More...
 
virtual EventReaderStatus setParameters (std::map< std::string, std::string > &)
 pass parameters to the event reader object More...
 
virtual void checkParameters (std::map< std::string, std::string > &)
 make sure that all parameters have been processed, otherwise throw exceptions More...
 
virtual void registerRunParameters ()
 Register Run Parameters. More...
 

Protected Member Functions

template<typename T >
void _getParameterValue (std::map< std::string, std::string > &parameters, std::string const &parameterName, T &parameter, T defaultValue)
 transform the string parameter value into the type of parameter More...
 

Protected Attributes

std::string m_name
 File name to be opened and read. More...
 
bool m_directAccess { false }
 Flag if direct event access is supported. To be explicitly set by subclass constructors. More...
 
int m_currEvent { 0 }
 Current event number. More...
 
Geant4InputActionm_inputAction { nullptr }
 The input action context. More...
 

Detailed Description

Basic geant4 event reader class. This interface/base-class must be implemented by concrete readers.

Base class to read input files containing simulation data.

Author
P.Kostka (main author)
M.Frank (code reshuffeling into new DDG4 scheme)
R.Ete (added context from input action)
Version
1.0

Definition at line 60 of file Geant4InputAction.h.

Member Typedef Documentation

◆ Particle

Definition at line 64 of file Geant4InputAction.h.

◆ Particles

Definition at line 65 of file Geant4InputAction.h.

◆ Vertex

Definition at line 63 of file Geant4InputAction.h.

◆ Vertices

Definition at line 66 of file Geant4InputAction.h.

Member Enumeration Documentation

◆ EventReaderStatus

Status codes of the event reader object. Anything with NOT low-bit set is an error.

Enumerator
EVENT_READER_ERROR 
EVENT_READER_OK 
EVENT_READER_NO_DIRECT 
EVENT_READER_NO_PRIMARIES 
EVENT_READER_NO_FACTORY 
EVENT_READER_IO_ERROR 
EVENT_READER_EOF 

Definition at line 68 of file Geant4InputAction.h.

Constructor & Destructor Documentation

◆ Geant4EventReader()

Geant4EventReader::Geant4EventReader ( const std::string &  nam)

Initializing constructor.

Definition at line 32 of file Geant4InputAction.cpp.

◆ ~Geant4EventReader()

Geant4EventReader::~Geant4EventReader ( )
virtual

Default destructor.

Definition at line 37 of file Geant4InputAction.cpp.

Member Function Documentation

◆ _getParameterValue()

template<typename T >
void dd4hep::sim::Geant4EventReader::_getParameterValue ( std::map< std::string, std::string > &  parameters,
std::string const &  parameterName,
T &  parameter,
defaultValue 
)
inlineprotected

transform the string parameter value into the type of parameter

removes parameter from the parameters map

Definition at line 92 of file Geant4InputAction.h.

◆ checkParameters()

void Geant4EventReader::checkParameters ( std::map< std::string, std::string > &  parameters)
virtual

make sure that all parameters have been processed, otherwise throw exceptions

check if all parameters have been consumed by the reader, otherwise throws exception

Definition at line 71 of file Geant4InputAction.cpp.

◆ context()

Geant4Context * Geant4EventReader::context ( ) const

Get the context (from the input action)

Definition at line 41 of file Geant4InputAction.cpp.

◆ currentEventNumber()

int dd4hep::sim::Geant4EventReader::currentEventNumber ( ) const
inline

return current Event Number

Definition at line 118 of file Geant4InputAction.h.

◆ hasDirectAccess()

bool dd4hep::sim::Geant4EventReader::hasDirectAccess ( ) const
inline

Flag if direct event access (by event sequence number) is supported (Default: false)

Definition at line 116 of file Geant4InputAction.h.

◆ moveToEvent()

Geant4EventReader::EventReaderStatus Geant4EventReader::moveToEvent ( int  event_number)
virtual

Move to the indicated event number.

For pure sequential access, the default implementation will skip events one by one. For technologies supporting direct event access the default implementation will be empty.

Returns

Reimplemented in dd4hep::sim::Geant4EventReaderHepMC, dd4hep::sim::Geant4EventReaderGuineaPig, dd4hep::sim::LCIOStdHepReader, dd4hep::sim::HEPMC3FileReader, dd4hep::sim::LCIOFileReader, and dd4hep::sim::Geant4EventReaderHepEvt.

Definition at line 113 of file Geant4InputAction.cpp.

◆ name()

const std::string& dd4hep::sim::Geant4EventReader::name ( ) const
inline

File name.

Definition at line 114 of file Geant4InputAction.h.

◆ readParticles()

virtual EventReaderStatus dd4hep::sim::Geant4EventReader::readParticles ( int  event_number,
Vertices vertices,
Particles particles 
)
pure virtual

Read an event and fill a vector of MCParticles.

The additional argument

Implemented in dd4hep::sim::HEPMC3EventReader.

◆ registerRunParameters()

virtual void dd4hep::sim::Geant4EventReader::registerRunParameters ( )
inlinevirtual

Register Run Parameters.

Reimplemented in dd4hep::sim::HEPMC3FileReader.

Definition at line 144 of file Geant4InputAction.h.

◆ setInputAction()

void Geant4EventReader::setInputAction ( Geant4InputAction action)

Set the input action.

Definition at line 50 of file Geant4InputAction.cpp.

◆ setParameters()

virtual EventReaderStatus dd4hep::sim::Geant4EventReader::setParameters ( std::map< std::string, std::string > &  )
inlinevirtual

pass parameters to the event reader object

Reimplemented in dd4hep::sim::Geant4EventReaderGuineaPig, dd4hep::sim::HEPMC3FileReader, and dd4hep::sim::LCIOFileReader.

Definition at line 138 of file Geant4InputAction.h.

◆ skipEvent()

Geant4EventReader::EventReaderStatus Geant4EventReader::skipEvent ( )
virtual

Member Data Documentation

◆ m_currEvent

int dd4hep::sim::Geant4EventReader::m_currEvent { 0 }
protected

Current event number.

Definition at line 83 of file Geant4InputAction.h.

◆ m_directAccess

bool dd4hep::sim::Geant4EventReader::m_directAccess { false }
protected

Flag if direct event access is supported. To be explicitly set by subclass constructors.

Definition at line 81 of file Geant4InputAction.h.

◆ m_inputAction

Geant4InputAction* dd4hep::sim::Geant4EventReader::m_inputAction { nullptr }
protected

The input action context.

Definition at line 85 of file Geant4InputAction.h.

◆ m_name

std::string dd4hep::sim::Geant4EventReader::m_name
protected

File name to be opened and read.

Definition at line 79 of file Geant4InputAction.h.


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