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
0025
0026 #ifndef DDG4_GEANT4OPTICALPHOTONPHYSICS_H
0027 #define DDG4_GEANT4OPTICALPHOTONPHYSICS_H 1
0028
0029
0030 #include <DDG4/Geant4PhysicsList.h>
0031
0032
0033 #include <G4OpAbsorption.hh>
0034 #include <G4OpRayleigh.hh>
0035 #include <G4OpMieHG.hh>
0036 #include <G4OpBoundaryProcess.hh>
0037 #include <G4ParticleDefinition.hh>
0038 #include <G4ParticleTypes.hh>
0039 #include <G4ParticleTable.hh>
0040 #include <G4ProcessManager.hh>
0041 #include <G4Version.hh>
0042
0043 #if G4VERSION_NUMBER >= 1070
0044 #include <G4OpticalParameters.hh>
0045 #endif
0046
0047
0048 namespace dd4hep {
0049
0050
0051 namespace sim {
0052
0053
0054
0055
0056
0057
0058
0059 class Geant4OpticalPhotonPhysics : public Geant4PhysicsList {
0060 public:
0061
0062 Geant4OpticalPhotonPhysics() = delete;
0063
0064 Geant4OpticalPhotonPhysics(const Geant4OpticalPhotonPhysics&) = delete;
0065
0066 Geant4OpticalPhotonPhysics(Geant4Context* ctxt, const std::string& nam)
0067 : Geant4PhysicsList(ctxt, nam)
0068 {
0069 declareProperty("VerboseLevel", m_verbosity = 0);
0070 declareProperty("BoundaryInvokeSD", m_boundaryInvokeSD = false);
0071 }
0072
0073 virtual ~Geant4OpticalPhotonPhysics() = default;
0074
0075 virtual void constructProcesses(G4VUserPhysicsList* physics_list) {
0076 this->Geant4PhysicsList::constructProcesses(physics_list);
0077 info("+++ Constructing optical_photon processes:");
0078 info("+++ G4OpAbsorption G4OpRayleigh G4OpMieHG G4OpBoundaryProcess");
0079 G4ParticleTable* table = G4ParticleTable::GetParticleTable();
0080 G4ParticleDefinition* particle = table->FindParticle("opticalphoton");
0081 if (0 == particle) {
0082 except("++ Cannot resolve 'opticalphoton' particle definition!");
0083 }
0084
0085 G4OpBoundaryProcess* fBoundaryProcess = new G4OpBoundaryProcess();
0086 G4OpAbsorption* fAbsorptionProcess = new G4OpAbsorption();
0087 G4OpRayleigh* fRayleighScatteringProcess = new G4OpRayleigh();
0088 G4OpMieHG* fMieHGScatteringProcess = new G4OpMieHG();
0089
0090 #if G4VERSION_NUMBER >= 1070
0091 G4OpticalParameters* params = G4OpticalParameters::Instance();
0092 params->SetAbsorptionVerboseLevel(m_verbosity);
0093 params->SetRayleighVerboseLevel(m_verbosity);
0094 params->SetMieVerboseLevel(m_verbosity);
0095 params->SetBoundaryVerboseLevel(m_verbosity);
0096 params->SetBoundaryInvokeSD(m_boundaryInvokeSD);
0097 #else
0098 fAbsorptionProcess->SetVerboseLevel(m_verbosity);
0099 fRayleighScatteringProcess->SetVerboseLevel(m_verbosity);
0100 fMieHGScatteringProcess->SetVerboseLevel(m_verbosity);
0101 fBoundaryProcess->SetVerboseLevel(m_verbosity);
0102 #if G4VERSION_NUMBER >= 1000
0103 fBoundaryProcess->SetInvokeSD(m_boundaryInvokeSD);
0104 #endif
0105 #endif
0106 G4ProcessManager* pmanager = particle->GetProcessManager();
0107 pmanager->AddDiscreteProcess(fAbsorptionProcess);
0108 pmanager->AddDiscreteProcess(fRayleighScatteringProcess);
0109 pmanager->AddDiscreteProcess(fMieHGScatteringProcess);
0110 pmanager->AddDiscreteProcess(fBoundaryProcess);
0111 }
0112 private:
0113 int m_verbosity;
0114 bool m_boundaryInvokeSD;
0115 };
0116 }
0117 }
0118 #endif
0119
0120 #include <DDG4/Factories.h>
0121 using namespace dd4hep::sim;
0122 DECLARE_GEANT4ACTION(Geant4OpticalPhotonPhysics)