Back to home page

EIC code displayed by LXR

 
 

    


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

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 Geant4ScintillationPhysics
0018  * \brief PhysicsConstructor for Scintillation physics
0019 
0020    This plugin allows to enable Scintillation physics in the physics list
0021 
0022  * @}
0023  */
0024 #ifndef DDG4_GEANT4SCINTILLATIONPHYSICS_H
0025 #define DDG4_GEANT4SCINTILLATIONPHYSICS_H 1
0026 
0027 /// Framework include files
0028 #include <DDG4/Geant4PhysicsList.h>
0029 
0030 /// Geant4 include files
0031 #include <G4Version.hh>
0032 #include <G4ParticleTableIterator.hh>
0033 #include <G4ParticleDefinition.hh>
0034 #include <G4LossTableManager.hh>
0035 #include <G4ProcessManager.hh>
0036 #include <G4ParticleTypes.hh>
0037 #include <G4ParticleTable.hh>
0038 #include <G4EmSaturation.hh>
0039 #include <G4Threading.hh>
0040 
0041 #if G4VERSION_NUMBER >= 1070
0042 #include <G4OpticalParameters.hh>
0043 
0044 /// This is a beta release problem:
0045 #if G4VERSION_NUMBER == 110000
0046 #include <G4OpticalParameters.hh>
0047 #pragma message("Geant4 version 11 beta: temporary fix to be removed!")
0048 void G4OpticalParameters::SetScintExcitationRatio(double) {}
0049 void G4OpticalParameters::SetScintYieldFactor(double) {}
0050 #endif
0051 
0052 #endif
0053 
0054 #include <G4Scintillation.hh>
0055 
0056 /// Namespace for the AIDA detector description toolkit
0057 namespace dd4hep {
0058 
0059   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0060   namespace sim {
0061 
0062     /// Geant4 physics list action to enable Scintillation physics
0063     /**
0064      *  \author  M.Frank
0065      *  \version 1.0
0066      *  \ingroup DD4HEP_SIMULATION
0067      */
0068     class Geant4ScintillationPhysics : public Geant4PhysicsList    {
0069     public:
0070       /// Default constructor
0071       Geant4ScintillationPhysics() = delete;
0072       /// Copy constructor
0073       Geant4ScintillationPhysics(const Geant4ScintillationPhysics&) = delete;
0074       /// Initializing constructor
0075       Geant4ScintillationPhysics(Geant4Context* ctxt, const std::string& nam)
0076         : Geant4PhysicsList(ctxt, nam)
0077       {
0078         declareProperty("ScintillationYieldFactor",      m_scintillationYieldFactor = 1.0);
0079         declareProperty("ScintillationExcitationRatio",  m_scintillationExcitationRatio = 1.0);
0080         declareProperty("FiniteRiseTime",                m_finiteRiseTime = false);
0081         declareProperty("TrackSecondariesFirst",         m_trackSecondariesFirst = false);
0082         declareProperty("StackPhotons",                  m_stackPhotons = true);
0083         declareProperty("ByParticleType",                m_byParticleType = false);
0084         declareProperty("TrackInfo",                     m_trackInfo = false);
0085         declareProperty("VerboseLevel",                  m_verbosity = 0);
0086         declareProperty("BoundaryInvokeSD",              m_boundaryInvokeSD = false);
0087         declareProperty("WLSTimeProfile",                m_WLSTimeProfile);
0088         declareProperty("WLS2TimeProfile",               m_WLS2TimeProfile);
0089         declareProperty("CerenkovMaxPhotonsPerStep",     m_CerenkovMaxPhotonsPerStep = -1);
0090         declareProperty("CerenkovMaxBetaChange",         m_CerenkovMaxBetaChange = -1.0);
0091         declareProperty("ScintEnhancedTimeConstants",    m_ScintEnhancedTimeConstants=false);
0092       }
0093       /// Default destructor
0094       virtual ~Geant4ScintillationPhysics() = default;
0095       /// Callback to construct processes (uses the G4 particle table)
0096       virtual void constructProcesses(G4VUserPhysicsList* physics_list)   { 
0097         this->Geant4PhysicsList::constructProcesses(physics_list);
0098         info("+++ Constructing: yield:%f excitation:%f finite rise-time:%s "
0099              "stack photons:%s track secondaries:%s",
0100              m_scintillationYieldFactor, m_scintillationExcitationRatio,
0101              yes_no(m_finiteRiseTime), yes_no(m_stackPhotons),
0102              yes_no(m_trackSecondariesFirst));
0103         G4Scintillation* process = new G4Scintillation(name());
0104 #if G4VERSION_NUMBER >= 1070
0105         G4OpticalParameters* params = G4OpticalParameters::Instance();
0106 #if G4VERSION_NUMBER >= 1100
0107         if ( m_CerenkovMaxPhotonsPerStep > 0 )
0108           params->SetCerenkovMaxPhotonsPerStep(m_CerenkovMaxPhotonsPerStep);
0109         if ( m_CerenkovMaxBetaChange > 0e0 )
0110           params->SetCerenkovMaxBetaChange(m_CerenkovMaxBetaChange);
0111         if ( !m_WLSTimeProfile.empty()  )
0112           params->SetWLSTimeProfile(m_WLS2TimeProfile);
0113         if ( !m_WLS2TimeProfile.empty() )
0114           params->SetWLS2TimeProfile(m_WLS2TimeProfile);
0115         params->SetBoundaryInvokeSD(m_boundaryInvokeSD);
0116 #endif
0117         params->SetScintVerboseLevel(m_verbosity);
0118         params->SetScintFiniteRiseTime(m_finiteRiseTime);
0119         params->SetScintStackPhotons(m_stackPhotons);
0120         params->SetScintTrackSecondariesFirst(m_trackSecondariesFirst);
0121         params->SetScintByParticleType(m_byParticleType);
0122         params->SetScintTrackInfo(m_trackInfo);
0123 #else
0124         process->SetVerboseLevel(m_verbosity);
0125         process->SetFiniteRiseTime(m_finiteRiseTime);
0126 #if G4VERSION_NUMBER >= 1030
0127         process->SetStackPhotons(m_stackPhotons);
0128 #endif
0129         process->SetTrackSecondariesFirst(m_trackSecondariesFirst);
0130 #if G4VERSION_NUMBER == 110000
0131         /// Not yet implemented in G4 11.0.0. Only declared in the header
0132         // params->SetScintEnhancedTimeConstants(m_ScintEnhancedTimeConstants);
0133         /// These were only in the beta release:
0134         process->SetScintillationYieldFactor(m_scintillationYieldFactor);
0135         process->SetScintillationExcitationRatio(m_scintillationExcitationRatio);
0136 #endif
0137 #if G4VERSION_NUMBER >= 940
0138         process->SetScintillationByParticleType(m_byParticleType);
0139 #endif
0140 #if G4VERSION_NUMBER >= 1030
0141         process->SetScintillationTrackInfo(m_trackInfo);
0142 #endif
0143 #endif
0144         // Use Birks Correction in the Scintillation process
0145         if ( G4Threading::IsMasterThread() )  {
0146           G4EmSaturation* emSaturation =
0147             G4LossTableManager::Instance()->EmSaturation();
0148           process->AddSaturation(emSaturation);
0149         }
0150 
0151         auto pit = G4ParticleTable::GetParticleTable()->GetIterator();
0152         pit->reset();
0153         while( (*pit)() ){
0154           G4ParticleDefinition* particle = pit->value();
0155           if (process->IsApplicable(*particle)) {
0156             G4ProcessManager* pmanager = particle->GetProcessManager();
0157             pmanager->AddProcess(process);
0158             pmanager->SetProcessOrdering(process,idxPostStep);
0159           }
0160         }
0161       }
0162 
0163     private:
0164       /// G4 11 beta, then disappeared....
0165       double m_scintillationYieldFactor      { 1.0 };
0166       /// G4 11 beta, then disappeared....
0167       double m_scintillationExcitationRatio  { 1.0 };
0168 
0169       /// G4OpticalParameters: "VerboseLevel"
0170       int    m_verbosity                  { 0 };
0171       /// G4OpticalParameters: "CerenkovStackPhotons"
0172       bool   m_stackPhotons               { true };
0173       /// G4OpticalParameters: "ScintFiniteRiseTime"
0174       bool   m_finiteRiseTime             { false };
0175       /// G4OpticalParameters: "ScintTrackSecondariesFirst"
0176       bool   m_trackSecondariesFirst      { false };
0177       /// G4OpticalParameters: "ScintByParticleType"
0178       bool   m_byParticleType             { false };
0179       /// G4OpticalParameters: "ScintTrackInfo"
0180       bool   m_trackInfo                  { false };
0181 
0182       /// G4OpticalParameters: "BoundaryInvokeSD"
0183       bool m_boundaryInvokeSD             { false };
0184       /// G4OpticalParameters: "WLSTimeProfile"
0185       std::string m_WLSTimeProfile        { };
0186       /// G4OpticalParameters: "WLS2TimeProfile";
0187       std::string m_WLS2TimeProfile       { };
0188       /// G4OpticalParameters: "CerenkovMaxBetaChange"
0189       double m_CerenkovMaxBetaChange      { -1.0 };
0190       /// G4OpticalParameters: "CerenkovMaxPhotonsPerStep"
0191       int  m_CerenkovMaxPhotonsPerStep    { -1 };
0192       /// G4OpticalParameters: "ScintEnhancedTimeConstants"
0193       bool m_ScintEnhancedTimeConstants   { false };
0194     };
0195   }
0196 }
0197 #endif   // DDG4_GEANT4SCINTILLATIONPHYSICS_H
0198 
0199 #include <DDG4/Factories.h>
0200 using namespace dd4hep::sim;
0201 DECLARE_GEANT4ACTION(Geant4ScintillationPhysics)