Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:17:29

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 
0014 // Framework include files
0015 #include <DD4hep/Printout.h>
0016 #include <DD4hep/InstanceCount.h>
0017 #include <DDG4/Geant4Context.h>
0018 #include <DDG4/Geant4Kernel.h>
0019 
0020 // C/C++ include files
0021 #include <algorithm>
0022 
0023 using namespace dd4hep::sim;
0024 
0025 /// Intializing constructor
0026 Geant4Run::Geant4Run(const G4Run* run_pointer)
0027   : ObjectExtensions(typeid(Geant4Run)), m_run(run_pointer)
0028 {
0029   InstanceCount::increment(this);
0030 }
0031 
0032 /// Default destructor
0033 Geant4Run::~Geant4Run()   {
0034   InstanceCount::decrement(this);
0035 }
0036 
0037 /// Intializing constructor
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 /// Default destructor
0045 Geant4Event::~Geant4Event()  {
0046   InstanceCount::decrement(this);
0047 }
0048 
0049 /// Default constructor
0050 Geant4Context::Geant4Context(Geant4Kernel* kernel_pointer)
0051   : m_kernel(kernel_pointer), m_run(0), m_event(0) {
0052   InstanceCount::increment(this);
0053 }
0054 
0055 /// Default destructor
0056 Geant4Context::~Geant4Context() {
0057   // Do not delete run and event structures here. This is done outside in the framework
0058   InstanceCount::decrement(this);
0059 }
0060 
0061 /// Access to geometry world
0062 G4VPhysicalVolume* Geant4Context::world()  const  {
0063   return m_kernel->world();
0064 }
0065 
0066 /// Set the geant4 run reference
0067 void Geant4Context::setRun(Geant4Run* new_run)    {
0068   m_run = new_run;
0069 }
0070 
0071 /// Access the geant4 run -- valid only between BeginRun() and EndRun()!
0072 Geant4Run& Geant4Context::run()  const   {
0073   if ( m_run ) return *m_run;
0074   invalidHandleError<Geant4Run>();
0075   return *m_run;
0076 }
0077 
0078 /// Set the geant4 event reference
0079 void Geant4Context::setEvent(Geant4Event* new_event)   {
0080   m_event = new_event;
0081 }
0082 
0083 /// Access the geant4 event -- valid only between BeginEvent() and EndEvent()!
0084 Geant4Event& Geant4Context::event()  const   {
0085   if ( m_event ) return *m_event;
0086   invalidHandleError<Geant4Event>();
0087   return *m_event;
0088 }
0089 
0090 /// Access to detector description
0091 dd4hep::Detector& Geant4Context::detectorDescription() const {
0092   return m_kernel->detectorDescription();
0093 }
0094 
0095 /// Generic framework access
0096 Geant4Context::UserFramework& Geant4Context::userFramework() const  {
0097   return m_kernel->userFramework();
0098 }
0099 
0100 /// Create a user trajectory
0101 G4VTrajectory* Geant4Context::createTrajectory(const G4Track* /* track */) 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 /// Access the tracking manager
0108 G4TrackingManager* Geant4Context::trackMgr() const {
0109   return m_kernel->trackMgr();
0110 }
0111 
0112 /// Access to the main run action sequence from the kernel object
0113 Geant4RunActionSequence& Geant4Context::runAction() const {
0114   return m_kernel->runAction();
0115 }
0116 
0117 /// Access to the main event action sequence from the kernel object
0118 Geant4EventActionSequence& Geant4Context::eventAction() const {
0119   return m_kernel->eventAction();
0120 }
0121 
0122 /// Access to the main stepping action sequence from the kernel object
0123 Geant4SteppingActionSequence& Geant4Context::steppingAction() const {
0124   return m_kernel->steppingAction();
0125 }
0126 
0127 /// Access to the main tracking action sequence from the kernel object
0128 Geant4TrackingActionSequence& Geant4Context::trackingAction() const {
0129   return m_kernel->trackingAction();
0130 }
0131 
0132 /// Access to the main stacking action sequence from the kernel object
0133 Geant4StackingActionSequence& Geant4Context::stackingAction() const {
0134   return m_kernel->stackingAction();
0135 }
0136 
0137 /// Access to the main generator action sequence from the kernel object
0138 Geant4GeneratorActionSequence& Geant4Context::generatorAction() const {
0139   return m_kernel->generatorAction();
0140 }
0141 
0142 /// Access to the main generator action sequence from the kernel object
0143 Geant4SensDetSequences& Geant4Context::sensitiveActions() const {
0144   return m_kernel->sensitiveActions();
0145 }