DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Public Member Functions | Private Attributes | List of all members
dd4hep::sim::Geant4Event Class Reference

User event context for DDG4. More...

#include <Geant4Context.h>

Inheritance diagram for dd4hep::sim::Geant4Event:
dd4hep::ObjectExtensions

Public Member Functions

 Geant4Event (const G4Event *run, Geant4Random *rndm)
 Intializing constructor. More...
 
virtual ~Geant4Event ()
 Default destructor. More...
 
 operator const G4Event & () const
 Access the G4Event directly: Automatic type conversion. More...
 
const G4Event & event () const
 Access the G4Event directly: Explicit G4Event accessor. More...
 
Geant4Randomrandom () const
 Access the random number generator. More...
 
void * addExtension (unsigned long long int k, ExtensionEntry *e)
 Add an extension object to the detector element. More...
 
template<typename T >
T * addExtension (T *ptr, bool take_ownership=true)
 Add user extension object. Ownership is transferred and object deleted at the end of the event. More...
 
template<typename T >
T * extension (bool alert=true)
 Access to type safe extension object. Exception is thrown if the object is invalid. More...
 
- Public Member Functions inherited from dd4hep::ObjectExtensions
 ObjectExtensions (const std::type_info &parent_type)
 Default constructor. More...
 
 ObjectExtensions (const ObjectExtensions &copy)=delete
 Copy constructor. More...
 
virtual ~ObjectExtensions ()
 Default destructor. More...
 
ObjectExtensionsoperator= (const ObjectExtensions &copy)=delete
 Assignment operator. More...
 
void initialize ()
 Initialize non-persistent object containers (e.g. after loading from ROOT file) More...
 
void move (ObjectExtensions &copy)
 Move extensions to target object. More...
 
void clear (bool destroy=true)
 Clear all extensions. More...
 
void copyFrom (const std::map< unsigned long long int, ExtensionEntry * > &ext, void *arg)
 Copy object extensions from another object. Hosting type must be identical! More...
 
void * addExtension (unsigned long long int key, ExtensionEntry *entry)
 Add an extension object to the detector element. More...
 
void * removeExtension (unsigned long long int key, bool destroy)
 Remove an existing extension object from the instance. More...
 
void * extension (unsigned long long int key, bool alert) const
 Access an existing extension object from the detector element. More...
 
void * extension (unsigned long long int key) const
 Access an existing extension object from the detector element. More...
 

Private Attributes

const G4Event * m_event { nullptr }
 Reference to the original Geant4 event object. More...
 
Geant4Randomm_random { nullptr }
 Reference to the main random number generator. More...
 

Additional Inherited Members

- Public Attributes inherited from dd4hep::ObjectExtensions
std::map< unsigned long long int, ExtensionEntry * > extensions
 The extensions object. More...
 

Detailed Description

User event context for DDG4.

The context is accessible from the Geant4Context pointer, which is present in every Geant4Action. The event context is only valid however, if there is actually an event being procesed ie. only during the lifetime of the corresponding G4Event objects.

Please note: Extensions are only valid within the hosting event and are INVALID across different events. Hence: They are only useful to extend data of an event.

Any random numbers used to process one event should be accessed from this location. The framework ensures that the same seeded sequence is used throughout the processing of one single event.

Author
M.Frank
Version
1.0

Definition at line 121 of file Geant4Context.h.

Constructor & Destructor Documentation

◆ Geant4Event()

Geant4Event::Geant4Event ( const G4Event *  run,
Geant4Random rndm 
)

Intializing constructor.

Definition at line 38 of file Geant4Context.cpp.

◆ ~Geant4Event()

Geant4Event::~Geant4Event ( )
virtual

Default destructor.

Definition at line 45 of file Geant4Context.cpp.

Member Function Documentation

◆ addExtension() [1/2]

template<typename T >
T* dd4hep::sim::Geant4Event::addExtension ( T *  ptr,
bool  take_ownership = true 
)
inline

Add user extension object. Ownership is transferred and object deleted at the end of the event.

Definition at line 144 of file Geant4Context.h.

◆ addExtension() [2/2]

void* dd4hep::sim::Geant4Event::addExtension ( unsigned long long int  k,
ExtensionEntry e 
)
inline

Add an extension object to the detector element.

Definition at line 140 of file Geant4Context.h.

◆ event()

const G4Event& dd4hep::sim::Geant4Event::event ( ) const
inline

Access the G4Event directly: Explicit G4Event accessor.

Definition at line 135 of file Geant4Context.h.

◆ extension()

template<typename T >
T* dd4hep::sim::Geant4Event::extension ( bool  alert = true)
inline

Access to type safe extension object. Exception is thrown if the object is invalid.

Definition at line 151 of file Geant4Context.h.

◆ operator const G4Event &()

dd4hep::sim::Geant4Event::operator const G4Event & ( ) const
inline

Access the G4Event directly: Automatic type conversion.

Definition at line 133 of file Geant4Context.h.

◆ random()

Geant4Random& dd4hep::sim::Geant4Event::random ( ) const
inline

Access the random number generator.

Definition at line 137 of file Geant4Context.h.

Member Data Documentation

◆ m_event

const G4Event* dd4hep::sim::Geant4Event::m_event { nullptr }
private

Reference to the original Geant4 event object.

Definition at line 123 of file Geant4Context.h.

◆ m_random

Geant4Random* dd4hep::sim::Geant4Event::m_random { nullptr }
private

Reference to the main random number generator.

Definition at line 125 of file Geant4Context.h.


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