File indexing completed on 2025-01-30 09:17:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #ifndef DDG4_GEANT4SCINTILLATIONPHYSICS_H
0025 #define DDG4_GEANT4SCINTILLATIONPHYSICS_H 1
0026
0027
0028 #include <DDG4/Geant4PhysicsList.h>
0029
0030
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
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
0057 namespace dd4hep {
0058
0059
0060 namespace sim {
0061
0062
0063
0064
0065
0066
0067
0068 class Geant4ScintillationPhysics : public Geant4PhysicsList {
0069 public:
0070
0071 Geant4ScintillationPhysics() = delete;
0072
0073 Geant4ScintillationPhysics(const Geant4ScintillationPhysics&) = delete;
0074
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
0094 virtual ~Geant4ScintillationPhysics() = default;
0095
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
0132
0133
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
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
0165 double m_scintillationYieldFactor { 1.0 };
0166
0167 double m_scintillationExcitationRatio { 1.0 };
0168
0169
0170 int m_verbosity { 0 };
0171
0172 bool m_stackPhotons { true };
0173
0174 bool m_finiteRiseTime { false };
0175
0176 bool m_trackSecondariesFirst { false };
0177
0178 bool m_byParticleType { false };
0179
0180 bool m_trackInfo { false };
0181
0182
0183 bool m_boundaryInvokeSD { false };
0184
0185 std::string m_WLSTimeProfile { };
0186
0187 std::string m_WLS2TimeProfile { };
0188
0189 double m_CerenkovMaxBetaChange { -1.0 };
0190
0191 int m_CerenkovMaxPhotonsPerStep { -1 };
0192
0193 bool m_ScintEnhancedTimeConstants { false };
0194 };
0195 }
0196 }
0197 #endif
0198
0199 #include <DDG4/Factories.h>
0200 using namespace dd4hep::sim;
0201 DECLARE_GEANT4ACTION(Geant4ScintillationPhysics)