DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geant4Context.cpp
Go to the documentation of this file.
1 // $Id: $
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 
15 // Framework include files
16 #include "DD4hep/Printout.h"
17 #include "DD4hep/InstanceCount.h"
18 #include "DDG4/Geant4Context.h"
19 #include "DDG4/Geant4Kernel.h"
20 
21 // C/C++ include files
22 #include <algorithm>
23 
24 using namespace std;
25 using namespace DD4hep;
26 using namespace DD4hep::Simulation;
27 
29 Geant4Run::Geant4Run(const G4Run* run_pointer)
30  : ObjectExtensions(typeid(Geant4Run)), m_run(run_pointer)
31 {
33 }
34 
38 }
39 
41 Geant4Event::Geant4Event(const G4Event* evt, Geant4Random* rnd)
42  : ObjectExtensions(typeid(Geant4Event)), m_event(evt), m_random(rnd)
43 {
45 }
46 
50 }
51 
54  : m_kernel(kernel_pointer), m_run(0), m_event(0) {
56 }
57 
60  // Do not delete run and event structures here. This is done outside in the framework
62 }
63 
66  m_run = new_run;
67 }
68 
71  if ( m_run ) return *m_run;
72  invalidHandleError<Geant4Run>();
73  return *m_run;
74 }
75 
78  m_event = new_event;
79 }
80 
83  if ( m_event ) return *m_event;
84  invalidHandleError<Geant4Event>();
85  return *m_event;
86 }
87 
90  return m_kernel->lcdd();
91 }
92 
94 G4VTrajectory* Geant4Context::createTrajectory(const G4Track* /* track */) const {
95  string err = DD4hep::format("Geant4Kernel", "createTrajectory: Purely virtual method. requires overloading!");
96  DD4hep::printout(DD4hep::FATAL, "Geant4Kernel", "createTrajectory: Purely virtual method. requires overloading!");
97  throw runtime_error(err);
98 }
99 
101 G4TrackingManager* Geant4Context::trackMgr() const {
102  return m_kernel->trackMgr();
103 }
104 
107  return m_kernel->runAction();
108 }
109 
112  return m_kernel->eventAction();
113 }
114 
117  return m_kernel->steppingAction();
118 }
119 
122  return m_kernel->trackingAction();
123 }
124 
127  return m_kernel->stackingAction();
128 }
129 
132  return m_kernel->generatorAction();
133 }
134 
137  return m_kernel->sensitiveActions();
138 }
Concrete implementation of the Geant4 stepping action sequence.
Geant4Event & event() const
Access the geant4 event – valid only between BeginEvent() and EndEvent()!
virtual ~Geant4Event()
Default destructor.
User event context for DDG4.
Geant4SteppingActionSequence * steppingAction(bool create)
Access stepping action sequence.
G4TrackingManager * trackMgr() const
Access the tracking manager.
Geant4TrackingActionSequence * trackingAction(bool create)
Access tracking action sequence.
static void decrement(T *)
Decrement count according to type information.
Geant4StackingActionSequence * stackingAction(bool create)
Access stacking action sequence.
LCDD & lcdd() const
Access to detector description.
Definition: Geant4Kernel.h:153
Concrete implementation of the Geant4 event action sequence.
Concrete implementation of the Geant4 tracking action sequence.
std::string format(const std::string &src, const std::string &fmt,...)
Build formatted string.
Definition: Printout.cpp:267
Geant4StackingActionSequence & stackingAction() const
Access to the main stacking action sequence from the kernel object.
Concrete implementation of the Geant4 stacking action sequence.
Class, which allows all Geant4Action derivatives to access the DDG4 kernel structures.
Definition: Geant4Kernel.h:43
Geant4Run & run() const
Access the geant4 run – valid only between BeginRun() and EndRun()!
Geant4RunActionSequence & runAction() const
Access to the main run action sequence from the kernel object.
Geant4EventActionSequence * eventAction(bool create)
Access run action sequence.
virtual ~Geant4Context()
Default destructor.
Geant4Event(const G4Event *run, Geant4Random *rndm)
Intializing constructor.
User run context for DDG4.
Definition: Geant4Context.h:71
Geant4GeneratorActionSequence & generatorAction() const
Access to the main generator action sequence from the kernel object.
Geant4GeneratorActionSequence * generatorAction(bool create)
Access generator action sequence.
Concrete implementation of the Geant4 generator action sequence.
Concrete basic implementation of the Geant4 run action sequencer.
virtual ~Geant4Run()
Default destructor.
static void increment(T *)
Increment count according to type information.
Definition: InstanceCount.h:98
Geant4Context(Geant4Kernel *kernel)
Default constructor.
void setEvent(Geant4Event *new_event)
Set the geant4 event reference.
Geant4SensDetSequences & sensitiveActions() const
Access to the sensitive detector sequences from the kernel object.
virtual G4VTrajectory * createTrajectory(const G4Track *track) const
Create a user trajectory.
void setRun(Geant4Run *new_run)
Set the geant4 run reference.
Geometry::LCDD & lcdd() const
Access to detector description.
Geant4EventActionSequence & eventAction() const
Access to the main event action sequence from the kernel object.
G4TrackingManager * trackMgr() const
Access the tracking manager.
Definition: Geant4Kernel.h:155
The main interface to the DD4hep detector description package.
Definition: LCDD.h:82
Geant4SteppingActionSequence & steppingAction() const
Access to the main stepping action sequence from the kernel object.
Mini interface to THE random generator of the application.
Definition: Geant4Random.h:60
Geant4SensDetSequences & sensitiveActions() const
Access to the sensitive detector sequences from the actioncontainer object.
int printout(PrintLevel severity, const char *src, const char *fmt,...)
Calls the display action with a given severity level.
Definition: Printout.cpp:111
Geant4SensDetSequences: class to access groups of sensitive actions.
Implementation of an object supporting arbitrary user extensions.
Geant4RunActionSequence * runAction(bool create)
Access run action sequence.
Geant4TrackingActionSequence & trackingAction() const
Access to the main tracking action sequence from the kernel object.