DD4hep  1.38.0
Detector Description Toolkit for High Energy Physics
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
dd4hep::sim::Geant4Context Class Reference

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
 

Detailed Description

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);

Author
M.Frank
Version
1.0

Definition at line 201 of file Geant4Context.h.

Member Typedef Documentation

◆ UserFramework

typedef std::pair<void*, const std::type_info*> dd4hep::sim::Geant4Context::UserFramework

Definition at line 204 of file Geant4Context.h.

Constructor & Destructor Documentation

◆ Geant4Context()

Geant4Context::Geant4Context ( Geant4Kernel *  kernel)
protected

Default constructor.

Definition at line 50 of file Geant4Context.cpp.

◆ ~Geant4Context()

Geant4Context::~Geant4Context ( )
virtual

Default destructor.

Definition at line 56 of file Geant4Context.cpp.

Member Function Documentation

◆ createTrajectory()

G4VTrajectory * Geant4Context::createTrajectory ( const G4Track *  track) const
virtual

Create a user trajectory.

Definition at line 101 of file Geant4Context.cpp.

◆ detectorDescription()

dd4hep::Detector & Geant4Context::detectorDescription ( ) const

Access to detector description.

Definition at line 91 of file Geant4Context.cpp.

◆ event()

Geant4Event & Geant4Context::event ( ) const

Access the geant4 event – valid only between BeginEvent() and EndEvent()!

Definition at line 84 of file Geant4Context.cpp.

◆ eventAction()

Geant4EventActionSequence & Geant4Context::eventAction ( ) const

Access to the main event action sequence from the kernel object.

Definition at line 118 of file Geant4Context.cpp.

◆ eventPtr()

Geant4Event* dd4hep::sim::Geant4Context::eventPtr ( ) const
inline

Access the geant4 event by ptr. Must be checked by clients!

Definition at line 231 of file Geant4Context.h.

◆ framework()

template<typename T >
T& dd4hep::sim::Geant4Context::framework ( ) const

Access to the user framework. Specialized function to be implemented by the client.

◆ generatorAction()

Geant4GeneratorActionSequence & Geant4Context::generatorAction ( ) const

Access to the main generator action sequence from the kernel object.

Definition at line 138 of file Geant4Context.cpp.

◆ kernel()

Geant4Kernel& dd4hep::sim::Geant4Context::kernel ( ) const
inline

Access to the kernel object.

Definition at line 233 of file Geant4Context.h.

◆ run()

Geant4Run & Geant4Context::run ( ) const

Access the geant4 run – valid only between BeginRun() and EndRun()!

Definition at line 72 of file Geant4Context.cpp.

◆ runAction()

Geant4RunActionSequence & Geant4Context::runAction ( ) const

Access to the main run action sequence from the kernel object.

Definition at line 113 of file Geant4Context.cpp.

◆ runPtr()

Geant4Run* dd4hep::sim::Geant4Context::runPtr ( ) const
inline

Access the geant4 run by ptr. Must be checked by clients!

Definition at line 225 of file Geant4Context.h.

◆ sensitiveActions()

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.

◆ setEvent()

void Geant4Context::setEvent ( Geant4Event *  new_event)

Set the geant4 event reference.

Definition at line 79 of file Geant4Context.cpp.

◆ setRun()

void Geant4Context::setRun ( Geant4Run *  new_run)

Set the geant4 run reference.

Definition at line 67 of file Geant4Context.cpp.

◆ stackingAction()

Geant4StackingActionSequence & Geant4Context::stackingAction ( ) const

Access to the main stacking action sequence from the kernel object.

Definition at line 133 of file Geant4Context.cpp.

◆ steppingAction()

Geant4SteppingActionSequence & Geant4Context::steppingAction ( ) const

Access to the main stepping action sequence from the kernel object.

Definition at line 123 of file Geant4Context.cpp.

◆ trackingAction()

Geant4TrackingActionSequence & Geant4Context::trackingAction ( ) const

Access to the main tracking action sequence from the kernel object.

Definition at line 128 of file Geant4Context.cpp.

◆ trackMgr()

G4TrackingManager * Geant4Context::trackMgr ( ) const

Access the tracking manager.

Definition at line 108 of file Geant4Context.cpp.

◆ userFramework()

Geant4Context::UserFramework & Geant4Context::userFramework ( ) const

Generic framework access.

Definition at line 96 of file Geant4Context.cpp.

◆ world()

G4VPhysicalVolume * Geant4Context::world ( ) const

Access to geometry world.

Definition at line 62 of file Geant4Context.cpp.

Friends And Related Function Documentation

◆ Geant4Kernel

friend class Geant4Kernel
friend

Definition at line 203 of file Geant4Context.h.

Member Data Documentation

◆ m_event

Geant4Event* dd4hep::sim::Geant4Context::m_event = 0
protected

Transient context variable - depending on the thread context: event reference.

Definition at line 212 of file Geant4Context.h.

◆ m_kernel

Geant4Kernel* dd4hep::sim::Geant4Context::m_kernel = 0
protected

Reference to the kernel object.

Definition at line 208 of file Geant4Context.h.

◆ m_run

Geant4Run* dd4hep::sim::Geant4Context::m_run = 0
protected

Transient context variable - depending on the thread context: run reference.

Definition at line 210 of file Geant4Context.h.


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