DD4hep
1.30.0
Detector Description Toolkit for High Energy Physics
|
Generic context to extend user, run and event information. More...
#include <Geant4Context.h>
Public Types | |
typedef std::pair< void *, const std::type_info * > | UserFramework |
Public Member Functions | |
virtual | ~Geant4Context () |
Default destructor. More... | |
void | setRun (Geant4Run *new_run) |
Set the geant4 run reference. More... | |
Geant4Run & | run () const |
Access the geant4 run – valid only between BeginRun() and EndRun()! More... | |
Geant4Run * | runPtr () const |
Access the geant4 run by ptr. Must be checked by clients! More... | |
void | setEvent (Geant4Event *new_event) |
Set the geant4 event reference. More... | |
Geant4Event & | event () const |
Access the geant4 event – valid only between BeginEvent() and EndEvent()! More... | |
Geant4Event * | eventPtr () const |
Access the geant4 event by ptr. Must be checked by clients! More... | |
Geant4Kernel & | kernel () const |
Access to the kernel object. More... | |
G4VPhysicalVolume * | world () const |
Access to geometry world. More... | |
template<typename T > | |
T & | framework () const |
Access to the user framework. Specialized function to be implemented by the client. More... | |
UserFramework & | userFramework () const |
Generic framework access. More... | |
Detector & | detectorDescription () const |
Access to detector description. More... | |
G4TrackingManager * | trackMgr () const |
Access the tracking manager. More... | |
virtual G4VTrajectory * | createTrajectory (const G4Track *track) const |
Create a user trajectory. More... | |
Geant4RunActionSequence & | runAction () const |
Access to the main run action sequence from the kernel object. More... | |
Geant4EventActionSequence & | eventAction () const |
Access to the main event action sequence from the kernel object. More... | |
Geant4SteppingActionSequence & | steppingAction () const |
Access to the main stepping action sequence from the kernel object. More... | |
Geant4TrackingActionSequence & | trackingAction () const |
Access to the main tracking action sequence from the kernel object. More... | |
Geant4StackingActionSequence & | stackingAction () const |
Access to the main stacking action sequence from the kernel object. More... | |
Geant4GeneratorActionSequence & | generatorAction () const |
Access to the main generator action sequence from the kernel object. More... | |
Geant4SensDetSequences & | sensitiveActions () const |
Access to the sensitive detector sequences from the kernel object. More... | |
Protected Member Functions | |
Geant4Context (Geant4Kernel *kernel) | |
Default constructor. More... | |
Protected Attributes | |
Geant4Kernel * | m_kernel = 0 |
Reference to the kernel object. More... | |
Geant4Run * | m_run = 0 |
Transient context variable - depending on the thread context: run reference. More... | |
Geant4Event * | m_event = 0 |
Transient context variable - depending on the thread context: event reference. More... | |
Friends | |
class | Geant4Kernel |
Generic context to extend user, run and event information.
A valid instance of the Geant4Context is passed to every instance of a Geant4Action at creation time.
The Geant4Context is the main thread specific accessor to the dd4hep, DDG4 and the user framework.
A user defined implementations must be specialized somewhere in a compilation unit of the user framework, not in a header file. The framework object could host e.g. references for histogramming, logging, data access etc.
This way any experiment/user related data processing framework can exhibit its essential tools to DDG4 actions.
A possible specialized implementations would look like the following:
struct Gaudi { IMessageSvc* msg; IHistogramSvc* histos; .... };
template<> Gaudi& Geant4Context::userFramework<Gaudi>() const { UserFramework& fw = m_kernel->userFramework(); if ( fw.first && &typeid(T) == fw.second ) return *(T*)fw.first; throw std::runtime_error("No user specified framework context present!"); }
To access the user framework then use the following call: Gaudi* fw = context->userFramework<Gaudi>();
of course after having initialized it: Gaudi * fw = ...; GaudiKernel& kernel = ...; kernel.setUserFramework(fw);
Definition at line 201 of file Geant4Context.h.
typedef std::pair<void*, const std::type_info*> dd4hep::sim::Geant4Context::UserFramework |
Definition at line 204 of file Geant4Context.h.
|
protected |
Default constructor.
Definition at line 50 of file Geant4Context.cpp.
|
virtual |
Default destructor.
Definition at line 56 of file Geant4Context.cpp.
|
virtual |
Create a user trajectory.
Definition at line 101 of file Geant4Context.cpp.
dd4hep::Detector & Geant4Context::detectorDescription | ( | ) | const |
Access to detector description.
Definition at line 91 of file Geant4Context.cpp.
Geant4Event & Geant4Context::event | ( | ) | const |
Access the geant4 event – valid only between BeginEvent() and EndEvent()!
Definition at line 84 of file Geant4Context.cpp.
Geant4EventActionSequence & Geant4Context::eventAction | ( | ) | const |
Access to the main event action sequence from the kernel object.
Definition at line 118 of file Geant4Context.cpp.
|
inline |
Access the geant4 event by ptr. Must be checked by clients!
Definition at line 231 of file Geant4Context.h.
T& dd4hep::sim::Geant4Context::framework | ( | ) | const |
Access to the user framework. Specialized function to be implemented by the client.
Geant4GeneratorActionSequence & Geant4Context::generatorAction | ( | ) | const |
Access to the main generator action sequence from the kernel object.
Definition at line 138 of file Geant4Context.cpp.
|
inline |
Access to the kernel object.
Definition at line 233 of file Geant4Context.h.
Geant4Run & Geant4Context::run | ( | ) | const |
Access the geant4 run – valid only between BeginRun() and EndRun()!
Definition at line 72 of file Geant4Context.cpp.
Geant4RunActionSequence & Geant4Context::runAction | ( | ) | const |
Access to the main run action sequence from the kernel object.
Definition at line 113 of file Geant4Context.cpp.
|
inline |
Access the geant4 run by ptr. Must be checked by clients!
Definition at line 225 of file Geant4Context.h.
Geant4SensDetSequences & Geant4Context::sensitiveActions | ( | ) | const |
Access to the sensitive detector sequences from the kernel object.
Access to the main generator action sequence from the kernel object.
Definition at line 143 of file Geant4Context.cpp.
void Geant4Context::setEvent | ( | Geant4Event * | new_event | ) |
Set the geant4 event reference.
Definition at line 79 of file Geant4Context.cpp.
void Geant4Context::setRun | ( | Geant4Run * | new_run | ) |
Set the geant4 run reference.
Definition at line 67 of file Geant4Context.cpp.
Geant4StackingActionSequence & Geant4Context::stackingAction | ( | ) | const |
Access to the main stacking action sequence from the kernel object.
Definition at line 133 of file Geant4Context.cpp.
Geant4SteppingActionSequence & Geant4Context::steppingAction | ( | ) | const |
Access to the main stepping action sequence from the kernel object.
Definition at line 123 of file Geant4Context.cpp.
Geant4TrackingActionSequence & Geant4Context::trackingAction | ( | ) | const |
Access to the main tracking action sequence from the kernel object.
Definition at line 128 of file Geant4Context.cpp.
G4TrackingManager * Geant4Context::trackMgr | ( | ) | const |
Access the tracking manager.
Definition at line 108 of file Geant4Context.cpp.
Geant4Context::UserFramework & Geant4Context::userFramework | ( | ) | const |
Generic framework access.
Definition at line 96 of file Geant4Context.cpp.
G4VPhysicalVolume * Geant4Context::world | ( | ) | const |
Access to geometry world.
Definition at line 62 of file Geant4Context.cpp.
|
friend |
Definition at line 203 of file Geant4Context.h.
|
protected |
Transient context variable - depending on the thread context: event reference.
Definition at line 212 of file Geant4Context.h.
|
protected |
Reference to the kernel object.
Definition at line 208 of file Geant4Context.h.
|
protected |
Transient context variable - depending on the thread context: run reference.
Definition at line 210 of file Geant4Context.h.