Warning, file /DD4hep/DDG4/plugins/Geant4CerenkovPhysics.cpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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_GEANT4CERENKOVPHYSICS_H
0025 #define DDG4_GEANT4CERENKOVPHYSICS_H 1
0026
0027
0028 #include <DDG4/Geant4PhysicsList.h>
0029
0030
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
0045 namespace dd4hep {
0046
0047
0048 namespace sim {
0049
0050
0051
0052
0053
0054
0055
0056 class Geant4CerenkovPhysics : public Geant4PhysicsList {
0057 public:
0058
0059 Geant4CerenkovPhysics() = delete;
0060
0061 Geant4CerenkovPhysics(const Geant4CerenkovPhysics&) = delete;
0062
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
0073 virtual ~Geant4CerenkovPhysics() = default;
0074
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
0121
0122 #include <DDG4/Factories.h>
0123 using namespace dd4hep::sim;
0124 DECLARE_GEANT4ACTION(Geant4CerenkovPhysics)