Back to home page

EIC code displayed by LXR

 
 

    


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

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 /** \addtogroup Geant4PhysicsConstructor
0015  *
0016  * @{
0017  * \package Geant4CerenkovPhysics
0018  * \brief PhysicsConstructor for Cerenkov physics
0019 
0020  This plugin allows to enable Cerenkov physics in the physics list
0021 
0022  * @}
0023  */
0024 #ifndef DDG4_GEANT4CERENKOVPHYSICS_H
0025 #define DDG4_GEANT4CERENKOVPHYSICS_H 1
0026 
0027 /// Framework include files
0028 #include <DDG4/Geant4PhysicsList.h>
0029 
0030 /// Geant4 include files
0031 #include <G4ParticleTableIterator.hh>
0032 #include <G4ParticleDefinition.hh>
0033 #include <G4ParticleTypes.hh>
0034 #include <G4ParticleTable.hh>
0035 #include <G4ProcessManager.hh>
0036 #include <G4Version.hh>
0037 
0038 #if G4VERSION_NUMBER >= 1070
0039 #include <G4OpticalParameters.hh>
0040 #endif
0041 
0042 #include <G4Cerenkov.hh>
0043 
0044 /// Namespace for the AIDA detector description toolkit
0045 namespace dd4hep {
0046 
0047   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0048   namespace sim {
0049 
0050     /// Geant4 physics list action to enable Cerenkov physics
0051     /**
0052      *  \author  M.Frank
0053      *  \version 1.0
0054      *  \ingroup DD4HEP_SIMULATION
0055      */
0056     class Geant4CerenkovPhysics : public Geant4PhysicsList    {
0057     public:
0058       /// Default constructor
0059       Geant4CerenkovPhysics() = delete;
0060       /// Copy constructor
0061       Geant4CerenkovPhysics(const Geant4CerenkovPhysics&) = delete;
0062       /// Initializing constructor
0063       Geant4CerenkovPhysics(Geant4Context* ctxt, const std::string& nam)
0064         : Geant4PhysicsList(ctxt, nam)
0065       {
0066         declareProperty("MaxNumPhotonsPerStep",  m_maxNumPhotonsPerStep = 0);
0067         declareProperty("MaxBetaChangePerStep",  m_maxBetaChangePerStep = 0.0);
0068         declareProperty("TrackSecondariesFirst", m_trackSecondariesFirst = false);
0069         declareProperty("StackPhotons",          m_stackPhotons = true);
0070         declareProperty("VerboseLevel",          m_verbosity = 0);
0071       }
0072       /// Default destructor
0073       virtual ~Geant4CerenkovPhysics() = default;
0074       /// Callback to construct processes (uses the G4 particle table)
0075       virtual void constructProcesses(G4VUserPhysicsList* physics_list)   { 
0076         this->Geant4PhysicsList::constructProcesses(physics_list);
0077         info("+++ Constructing: maxNumPhotonsPerStep:%d maxBeta:%f "
0078              "track secondaries:%s stack photons:%s track secondaries:%s",
0079              m_maxNumPhotonsPerStep, m_maxBetaChangePerStep,
0080              yes_no(m_trackSecondariesFirst), yes_no(m_stackPhotons),
0081              yes_no(m_trackSecondariesFirst));
0082         G4Cerenkov* process = new G4Cerenkov(name());
0083 #if G4VERSION_NUMBER >= 1070
0084         G4OpticalParameters* params = G4OpticalParameters::Instance();
0085         params->SetCerenkovVerboseLevel(m_verbosity);
0086         params->SetCerenkovMaxPhotonsPerStep(m_maxNumPhotonsPerStep);
0087         params->SetCerenkovMaxBetaChange(m_maxBetaChangePerStep);
0088         params->SetCerenkovTrackSecondariesFirst(m_trackSecondariesFirst);
0089         params->SetCerenkovStackPhotons(m_stackPhotons);
0090 #else
0091         process->SetVerboseLevel(m_verbosity);
0092         process->SetMaxNumPhotonsPerStep(m_maxNumPhotonsPerStep);
0093         process->SetMaxBetaChangePerStep(m_maxBetaChangePerStep);
0094         process->SetTrackSecondariesFirst(m_trackSecondariesFirst);
0095 #if G4VERSION_NUMBER > 1030
0096         process->SetStackPhotons(m_stackPhotons);
0097 #endif
0098 #endif
0099         auto pit = G4ParticleTable::GetParticleTable()->GetIterator();
0100         pit->reset();
0101         while( (*pit)() ){
0102           G4ParticleDefinition* particle = pit->value();
0103           if (process->IsApplicable(*particle)) {
0104             G4ProcessManager* pmanager = particle->GetProcessManager();
0105             pmanager->AddProcess(process);
0106             pmanager->SetProcessOrdering(process,idxPostStep);
0107           }
0108         }
0109       }
0110 
0111     private:
0112       double      m_maxBetaChangePerStep;
0113       int         m_maxNumPhotonsPerStep;
0114       int         m_verbosity;
0115       bool        m_trackSecondariesFirst;
0116       bool        m_stackPhotons;
0117     };
0118   }
0119 }
0120 #endif   // DDG4_GEANT4CERENKOVPHYSICS_H
0121 
0122 #include <DDG4/Factories.h>
0123 using namespace dd4hep::sim;
0124 DECLARE_GEANT4ACTION(Geant4CerenkovPhysics)