Back to home page

EIC code displayed by LXR

 
 

    


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

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/InstanceCount.h>
0016 #include <DDG4/Geant4PhysicsConstructor.h>
0017 #include <G4VModularPhysicsList.hh>
0018 
0019 // Geant4 include files
0020 #include <G4Version.hh>
0021 
0022 using namespace dd4hep::sim;
0023 
0024 namespace  {
0025 
0026   /// Concrete implementation
0027   class ConstructorImp : virtual public Geant4PhysicsConstructor::Constructor   {
0028   public:
0029     Geant4PhysicsConstructor* ctor;
0030     /// Initializing constructor dealing with the callbacks
0031     ConstructorImp(Geant4PhysicsConstructor* ct, int typ)
0032       : G4VPhysicsConstructor(ct->name(),typ), Geant4PhysicsConstructor::Constructor(), ctor(ct)
0033     {}
0034     /// Default destructor
0035     virtual ~ConstructorImp() {}
0036     /// Access to a fresh (resetted) instance of the particle table iterator
0037     G4ParticleTable::G4PTblDicIterator* particleIterator()  const   {
0038       G4ParticleTable::G4PTblDicIterator* iter;
0039 
0040 #if G4VERSION_NUMBER >= 1030
0041       iter = GetParticleIterator();
0042 #elif G4VERSION_NUMBER >= 1000
0043       iter = aParticleIterator;
0044 #else  
0045       iter = theParticleIterator;
0046 #endif 
0047 
0048       iter->reset();
0049       return iter;
0050     }
0051     /// G4VPhysicsConstructor overload: This method will be invoked in the Construct() method. 
0052     virtual void ConstructParticle()   {
0053       ctor->constructParticle(*this);
0054     }
0055     /// G4VPhysicsConstructor overload: This method will be invoked in the Construct() method.
0056     virtual void ConstructProcess()   {
0057       ctor->constructProcess(*this);
0058     }
0059   };
0060 }
0061 
0062 
0063 /// Standard action constructor
0064 Geant4PhysicsConstructor::Constructor::Constructor()  
0065   : G4VPhysicsConstructor() 
0066 {
0067 }
0068 
0069 /// Default destructor
0070 Geant4PhysicsConstructor::Constructor::~Constructor()  {
0071 }
0072 
0073 /// Standard action constructor
0074 Geant4PhysicsConstructor::Geant4PhysicsConstructor(Geant4Context* ctxt, const std::string& nam)
0075   : Geant4PhysicsList(ctxt, nam)
0076 {
0077   InstanceCount::increment(this);
0078   declareProperty("PhysicsType", m_type = 0);
0079 }
0080 
0081 /// Default destructor
0082 Geant4PhysicsConstructor::~Geant4PhysicsConstructor() {
0083   InstanceCount::decrement(this);
0084   // Do NOT delete the constructor !
0085 }
0086 
0087 /// constructPhysics callback
0088 void Geant4PhysicsConstructor::constructPhysics(G4VModularPhysicsList* physics_list)   {
0089   // Register try constructor providing the callbacks
0090   physics_list->RegisterPhysics(new ConstructorImp(this, m_type));
0091 }
0092 
0093 /// Callback to construct processes (uses the G4 particle table)
0094 void Geant4PhysicsConstructor::constructProcess(Constructor& /* ctor */)   {
0095 }
0096 
0097 /// Callback to construct particles
0098 void Geant4PhysicsConstructor::constructParticle(Constructor& /* ctor */)   {
0099 }