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

User run context for DDG4. More...

#include <Geant4Context.h>

Inheritance diagram for dd4hep::sim::Geant4Run:
dd4hep::ObjectExtensions

Public Member Functions

 Geant4Run (const G4Run *run)
 Intializing constructor. More...
 
virtual ~Geant4Run ()
 Default destructor. More...
 
 operator const G4Run & () const
 Access the G4Run directly: Automatic type conversion. More...
 
const G4Run & run () const
 Access the G4Event directly: Explicit G4Run accessor. 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! 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 G4Run * m_run { nullptr }
 Reference to the original Geant4 run object. 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 run context for DDG4.

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

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

Author
M.Frank
Version
1.0

Definition at line 69 of file Geant4Context.h.

Constructor & Destructor Documentation

◆ Geant4Run()

Geant4Run::Geant4Run ( const G4Run *  run)

Intializing constructor.

Definition at line 26 of file Geant4Context.cpp.

◆ ~Geant4Run()

Geant4Run::~Geant4Run ( )
virtual

Default destructor.

Definition at line 33 of file Geant4Context.cpp.

Member Function Documentation

◆ addExtension() [1/2]

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

Add user extension object. Ownership is transferred!

Definition at line 88 of file Geant4Context.h.

◆ addExtension() [2/2]

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

Add an extension object to the detector element.

Definition at line 84 of file Geant4Context.h.

◆ extension()

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

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

Definition at line 95 of file Geant4Context.h.

◆ operator const G4Run &()

dd4hep::sim::Geant4Run::operator const G4Run & ( ) const
inline

Access the G4Run directly: Automatic type conversion.

Definition at line 80 of file Geant4Context.h.

◆ run()

const G4Run& dd4hep::sim::Geant4Run::run ( ) const
inline

Access the G4Event directly: Explicit G4Run accessor.

Definition at line 82 of file Geant4Context.h.

Member Data Documentation

◆ m_run

const G4Run* dd4hep::sim::Geant4Run::m_run { nullptr }
private

Reference to the original Geant4 run object.

Definition at line 71 of file Geant4Context.h.


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