DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4Context.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
14 // Framework include files
15 #include <DD4hep/Printout.h>
16 #include <DD4hep/InstanceCount.h>
17 #include <DDG4/Geant4Context.h>
18 #include <DDG4/Geant4Kernel.h>
19 
20 // C/C++ include files
21 #include <algorithm>
22 
23 using namespace dd4hep::sim;
24 
26 Geant4Run::Geant4Run(const G4Run* run_pointer)
27  : ObjectExtensions(typeid(Geant4Run)), m_run(run_pointer)
28 {
30 }
31 
35 }
36 
38 Geant4Event::Geant4Event(const G4Event* evt, Geant4Random* rnd)
39  : ObjectExtensions(typeid(Geant4Event)), m_event(evt), m_random(rnd)
40 {
42 }
43 
47 }
48 
51  : m_kernel(kernel_pointer), m_run(0), m_event(0) {
53 }
54 
57  // Do not delete run and event structures here. This is done outside in the framework
59 }
60 
62 G4VPhysicalVolume* Geant4Context::world() const {
63  return m_kernel->world();
64 }
65 
68  m_run = new_run;
69 }
70 
73  if ( m_run ) return *m_run;
74  invalidHandleError<Geant4Run>();
75  return *m_run;
76 }
77 
80  m_event = new_event;
81 }
82 
85  if ( m_event ) return *m_event;
86  invalidHandleError<Geant4Event>();
87  return *m_event;
88 }
89 
92  return m_kernel->detectorDescription();
93 }
94 
97  return m_kernel->userFramework();
98 }
99 
101 G4VTrajectory* Geant4Context::createTrajectory(const G4Track* /* track */) const {
102  std::string err = dd4hep::format("Geant4Kernel", "createTrajectory: Purely virtual method. requires overloading!");
103  dd4hep::printout(dd4hep::FATAL, "Geant4Kernel", "createTrajectory: Purely virtual method. requires overloading!");
104  throw std::runtime_error(err);
105 }
106 
108 G4TrackingManager* Geant4Context::trackMgr() const {
109  return m_kernel->trackMgr();
110 }
111 
114  return m_kernel->runAction();
115 }
116 
119  return m_kernel->eventAction();
120 }
121 
124  return m_kernel->steppingAction();
125 }
126 
129  return m_kernel->trackingAction();
130 }
131 
134  return m_kernel->stackingAction();
135 }
136 
139  return m_kernel->generatorAction();
140 }
141 
144  return m_kernel->sensitiveActions();
145 }
dd4hep::sim::Geant4Context::runAction
Geant4RunActionSequence & runAction() const
Access to the main run action sequence from the kernel object.
Definition: Geant4Context.cpp:113
dd4hep::sim::Geant4Context::setEvent
void setEvent(Geant4Event *new_event)
Set the geant4 event reference.
Definition: Geant4Context.cpp:79
dd4hep::sim::Geant4Run
User run context for DDG4.
Definition: Geant4Context.h:69
dd4hep::sim::Geant4Context::detectorDescription
Detector & detectorDescription() const
Access to detector description.
Definition: Geant4Context.cpp:91
dd4hep::sim::Geant4StackingActionSequence
Concrete implementation of the Geant4 stacking action sequence.
Definition: Geant4StackingAction.h:128
dd4hep::ObjectExtensions
Implementation of an object supporting arbitrary user extensions.
Definition: ObjectExtensions.h:33
dd4hep::sim::Geant4ActionContainer::runAction
Geant4RunActionSequence * runAction(bool create)
Access run action sequence.
Definition: Geant4ActionContainer.cpp:92
dd4hep::sim::Geant4Context::m_kernel
Geant4Kernel * m_kernel
Reference to the kernel object.
Definition: Geant4Context.h:208
dd4hep::sim::Geant4Context::run
Geant4Run & run() const
Access the geant4 run – valid only between BeginRun() and EndRun()!
Definition: Geant4Context.cpp:72
dd4hep::sim::Geant4Context::setRun
void setRun(Geant4Run *new_run)
Set the geant4 run reference.
Definition: Geant4Context.cpp:67
dd4hep::sim::Geant4ActionContainer::stackingAction
Geant4StackingActionSequence * stackingAction(bool create)
Access stacking action sequence.
Definition: Geant4ActionContainer.cpp:120
dd4hep::sim::Geant4Kernel
Class, which allows all Geant4Action derivatives to access the DDG4 kernel structures.
Definition: Geant4Kernel.h:64
dd4hep::sim::Geant4ActionContainer::trackingAction
Geant4TrackingActionSequence * trackingAction(bool create)
Access tracking action sequence.
Definition: Geant4ActionContainer.cpp:113
dd4hep::sim::Geant4Context::m_run
Geant4Run * m_run
Transient context variable - depending on the thread context: run reference.
Definition: Geant4Context.h:210
dd4hep::InstanceCount::increment
static void increment(T *)
Increment count according to type information.
Definition: InstanceCount.h:98
dd4hep::sim::Geant4Context::event
Geant4Event & event() const
Access the geant4 event – valid only between BeginEvent() and EndEvent()!
Definition: Geant4Context.cpp:84
dd4hep::sim::Geant4Context::world
G4VPhysicalVolume * world() const
Access to geometry world.
Definition: Geant4Context.cpp:62
dd4hep::sim::Geant4Context::sensitiveActions
Geant4SensDetSequences & sensitiveActions() const
Access to the sensitive detector sequences from the kernel object.
Definition: Geant4Context.cpp:143
dd4hep::sim::Geant4Context::Geant4Context
Geant4Context(Geant4Kernel *kernel)
Default constructor.
Definition: Geant4Context.cpp:50
dd4hep::sim::Geant4TrackingActionSequence
Concrete implementation of the Geant4 tracking action sequence.
Definition: Geant4TrackingAction.h:114
dd4hep::sim::Geant4Kernel::detectorDescription
Detector & detectorDescription() const
Access to detector description.
Definition: Geant4Kernel.h:201
dd4hep::sim::Geant4GeneratorActionSequence
Concrete implementation of the Geant4 generator action sequence.
Definition: Geant4GeneratorAction.h:115
dd4hep::sim::Geant4Event::~Geant4Event
virtual ~Geant4Event()
Default destructor.
Definition: Geant4Context.cpp:45
dd4hep::sim::Geant4ActionContainer::eventAction
Geant4EventActionSequence * eventAction(bool create)
Access run action sequence.
Definition: Geant4ActionContainer.cpp:99
dd4hep::InstanceCount::decrement
static void decrement(T *)
Decrement count according to type information.
Definition: InstanceCount.h:102
dd4hep::sim::Geant4RunActionSequence
Concrete basic implementation of the Geant4 run action sequencer.
Definition: Geant4RunAction.h:117
dd4hep::sim::Geant4Kernel::trackMgr
G4TrackingManager * trackMgr() const
Access the tracking manager.
Definition: Geant4Kernel.h:203
dd4hep::sim::Geant4SensDetSequences
Geant4SensDetSequences: class to access groups of sensitive actions.
Definition: Geant4SensDetAction.h:464
dd4hep::sim::Geant4Kernel::world
G4VPhysicalVolume * world() const
Access to geometry world.
Definition: Geant4Kernel.cpp:256
dd4hep::sim::Geant4Context::m_event
Geant4Event * m_event
Transient context variable - depending on the thread context: event reference.
Definition: Geant4Context.h:212
dd4hep::sim::Geant4Random
Mini interface to THE random generator of the application.
Definition: Geant4Random.h:59
dd4hep::sim::Geant4Run::Geant4Run
Geant4Run(const G4Run *run)
Intializing constructor.
Definition: Geant4Context.cpp:26
dd4hep::sim::Geant4Event::Geant4Event
Geant4Event(const G4Event *run, Geant4Random *rndm)
Intializing constructor.
Definition: Geant4Context.cpp:38
dd4hep::sim::Geant4Run::~Geant4Run
virtual ~Geant4Run()
Default destructor.
Definition: Geant4Context.cpp:33
dd4hep::sim::Geant4Context::createTrajectory
virtual G4VTrajectory * createTrajectory(const G4Track *track) const
Create a user trajectory.
Definition: Geant4Context.cpp:101
dd4hep::sim::Geant4Kernel::userFramework
UserFramework & userFramework()
Generic framework access.
Definition: Geant4Kernel.h:213
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: Geant4Output2EDM4hep.cpp:49
dd4hep::sim::Geant4Context::userFramework
UserFramework & userFramework() const
Generic framework access.
Definition: Geant4Context.cpp:96
dd4hep::sim::Geant4ActionContainer::steppingAction
Geant4SteppingActionSequence * steppingAction(bool create)
Access stepping action sequence.
Definition: Geant4ActionContainer.cpp:106
dd4hep::sim::Geant4Context::stackingAction
Geant4StackingActionSequence & stackingAction() const
Access to the main stacking action sequence from the kernel object.
Definition: Geant4Context.cpp:133
dd4hep::sim::Geant4Context::~Geant4Context
virtual ~Geant4Context()
Default destructor.
Definition: Geant4Context.cpp:56
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::sim::Geant4Context::trackMgr
G4TrackingManager * trackMgr() const
Access the tracking manager.
Definition: Geant4Context.cpp:108
dd4hep::sim::Geant4EventActionSequence
Concrete implementation of the Geant4 event action sequence.
Definition: Geant4EventAction.h:124
Geant4Kernel.h
dd4hep::sim::Geant4Context::steppingAction
Geant4SteppingActionSequence & steppingAction() const
Access to the main stepping action sequence from the kernel object.
Definition: Geant4Context.cpp:123
dd4hep::sim::Geant4ActionContainer::sensitiveActions
Geant4SensDetSequences & sensitiveActions() const
Access to the sensitive detector sequences from the actioncontainer object.
Definition: Geant4ActionContainer.cpp:134
dd4hep::sim::Geant4Context::generatorAction
Geant4GeneratorActionSequence & generatorAction() const
Access to the main generator action sequence from the kernel object.
Definition: Geant4Context.cpp:138
dd4hep::sim::Geant4Context::trackingAction
Geant4TrackingActionSequence & trackingAction() const
Access to the main tracking action sequence from the kernel object.
Definition: Geant4Context.cpp:128
InstanceCount.h
dd4hep::sim::Geant4SteppingActionSequence
Concrete implementation of the Geant4 stepping action sequence.
Definition: Geant4SteppingAction.h:104
dd4hep::sim::Geant4Event
User event context for DDG4.
Definition: Geant4Context.h:121
Printout.h
Geant4Context.h
dd4hep::sim::Geant4Context::eventAction
Geant4EventActionSequence & eventAction() const
Access to the main event action sequence from the kernel object.
Definition: Geant4Context.cpp:118
dd4hep::sim::Geant4ActionContainer::generatorAction
Geant4GeneratorActionSequence * generatorAction(bool create)
Access generator action sequence.
Definition: Geant4ActionContainer.cpp:85
dd4hep::sim::Geant4Context::UserFramework
std::pair< void *, const std::type_info * > UserFramework
Definition: Geant4Context.h:204