File indexing completed on 2025-01-30 09:17:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <DD4hep/Printout.h>
0016 #include <DD4hep/InstanceCount.h>
0017 #include <DDG4/Geant4Context.h>
0018 #include <DDG4/Geant4Kernel.h>
0019
0020
0021 #include <algorithm>
0022
0023 using namespace dd4hep::sim;
0024
0025
0026 Geant4Run::Geant4Run(const G4Run* run_pointer)
0027 : ObjectExtensions(typeid(Geant4Run)), m_run(run_pointer)
0028 {
0029 InstanceCount::increment(this);
0030 }
0031
0032
0033 Geant4Run::~Geant4Run() {
0034 InstanceCount::decrement(this);
0035 }
0036
0037
0038 Geant4Event::Geant4Event(const G4Event* evt, Geant4Random* rnd)
0039 : ObjectExtensions(typeid(Geant4Event)), m_event(evt), m_random(rnd)
0040 {
0041 InstanceCount::increment(this);
0042 }
0043
0044
0045 Geant4Event::~Geant4Event() {
0046 InstanceCount::decrement(this);
0047 }
0048
0049
0050 Geant4Context::Geant4Context(Geant4Kernel* kernel_pointer)
0051 : m_kernel(kernel_pointer), m_run(0), m_event(0) {
0052 InstanceCount::increment(this);
0053 }
0054
0055
0056 Geant4Context::~Geant4Context() {
0057
0058 InstanceCount::decrement(this);
0059 }
0060
0061
0062 G4VPhysicalVolume* Geant4Context::world() const {
0063 return m_kernel->world();
0064 }
0065
0066
0067 void Geant4Context::setRun(Geant4Run* new_run) {
0068 m_run = new_run;
0069 }
0070
0071
0072 Geant4Run& Geant4Context::run() const {
0073 if ( m_run ) return *m_run;
0074 invalidHandleError<Geant4Run>();
0075 return *m_run;
0076 }
0077
0078
0079 void Geant4Context::setEvent(Geant4Event* new_event) {
0080 m_event = new_event;
0081 }
0082
0083
0084 Geant4Event& Geant4Context::event() const {
0085 if ( m_event ) return *m_event;
0086 invalidHandleError<Geant4Event>();
0087 return *m_event;
0088 }
0089
0090
0091 dd4hep::Detector& Geant4Context::detectorDescription() const {
0092 return m_kernel->detectorDescription();
0093 }
0094
0095
0096 Geant4Context::UserFramework& Geant4Context::userFramework() const {
0097 return m_kernel->userFramework();
0098 }
0099
0100
0101 G4VTrajectory* Geant4Context::createTrajectory(const G4Track* ) const {
0102 std::string err = dd4hep::format("Geant4Kernel", "createTrajectory: Purely virtual method. requires overloading!");
0103 dd4hep::printout(dd4hep::FATAL, "Geant4Kernel", "createTrajectory: Purely virtual method. requires overloading!");
0104 throw std::runtime_error(err);
0105 }
0106
0107
0108 G4TrackingManager* Geant4Context::trackMgr() const {
0109 return m_kernel->trackMgr();
0110 }
0111
0112
0113 Geant4RunActionSequence& Geant4Context::runAction() const {
0114 return m_kernel->runAction();
0115 }
0116
0117
0118 Geant4EventActionSequence& Geant4Context::eventAction() const {
0119 return m_kernel->eventAction();
0120 }
0121
0122
0123 Geant4SteppingActionSequence& Geant4Context::steppingAction() const {
0124 return m_kernel->steppingAction();
0125 }
0126
0127
0128 Geant4TrackingActionSequence& Geant4Context::trackingAction() const {
0129 return m_kernel->trackingAction();
0130 }
0131
0132
0133 Geant4StackingActionSequence& Geant4Context::stackingAction() const {
0134 return m_kernel->stackingAction();
0135 }
0136
0137
0138 Geant4GeneratorActionSequence& Geant4Context::generatorAction() const {
0139 return m_kernel->generatorAction();
0140 }
0141
0142
0143 Geant4SensDetSequences& Geant4Context::sensitiveActions() const {
0144 return m_kernel->sensitiveActions();
0145 }