File indexing completed on 2026-03-31 08:18:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef DDG4_GEANT4PHYSICSLIST_H
0015 #define DDG4_GEANT4PHYSICSLIST_H
0016
0017
0018 #include <DDG4/Geant4Action.h>
0019
0020
0021 #include <map>
0022 #include <vector>
0023
0024
0025 class G4VPhysicsConstructor;
0026 class G4VModularPhysicsList;
0027 class G4VUserPhysicsList;
0028
0029
0030 namespace dd4hep {
0031
0032
0033 namespace sim {
0034
0035
0036
0037
0038
0039
0040
0041 class Geant4PhysicsList: public Geant4Action {
0042 public:
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 class Process {
0054 public:
0055 std::string name;
0056 int ordAtRestDoIt=-1, ordAlongSteptDoIt=-1, ordPostStepDoIt=-1;
0057
0058 Process();
0059
0060 Process(const Process& p);
0061
0062 Process& operator=(const Process& p);
0063 };
0064 typedef std::vector<Process> ParticleProcesses;
0065 typedef std::map<std::string, ParticleProcesses> PhysicsProcesses;
0066
0067
0068
0069
0070
0071
0072
0073 class ParticleConstructor : public std::string {
0074 public:
0075
0076 ParticleConstructor() = default;
0077
0078 ParticleConstructor(const ParticleConstructor& copy) = default;
0079
0080 ParticleConstructor(const std::string& s) : std::string(s) { }
0081
0082 ParticleConstructor& operator=(const ParticleConstructor& c) = default;
0083 };
0084 typedef std::vector<ParticleConstructor> ParticleConstructors;
0085
0086
0087
0088
0089
0090
0091
0092 class PhysicsConstructor: public std::string {
0093 public:
0094
0095 G4VPhysicsConstructor* pointer { nullptr };
0096
0097 G4VModularPhysicsList* physics_list { nullptr };
0098 public:
0099
0100 PhysicsConstructor() = default;
0101
0102 PhysicsConstructor(const PhysicsConstructor& c) = default;
0103
0104 PhysicsConstructor(const std::string& s) : std::string(s), pointer(0) {}
0105
0106 PhysicsConstructor& operator=(const PhysicsConstructor& c) = default;
0107 };
0108 typedef std::vector<PhysicsConstructor> PhysicsConstructors;
0109
0110 PhysicsProcesses m_processes;
0111 PhysicsProcesses m_discreteProcesses;
0112 PhysicsConstructors m_physics;
0113 ParticleConstructors m_particles;
0114 ParticleConstructors m_particlegroups;
0115
0116 public:
0117
0118 Geant4PhysicsList(Geant4Context* context, const std::string& nam);
0119
0120 virtual ~Geant4PhysicsList();
0121
0122
0123 void dump();
0124
0125
0126 virtual void installCommandMessenger() override;
0127
0128 PhysicsProcesses& processes() {
0129 return m_processes;
0130 }
0131
0132 const PhysicsProcesses& processes() const {
0133 return m_processes;
0134 }
0135
0136 ParticleProcesses& processes(const std::string& part_name);
0137
0138 const ParticleProcesses& processes(const std::string& part_name) const;
0139
0140
0141 PhysicsProcesses& discreteProcesses() {
0142 return m_discreteProcesses;
0143 }
0144
0145 const PhysicsProcesses& discreteProcesses() const {
0146 return m_discreteProcesses;
0147 }
0148
0149 ParticleProcesses& discreteProcesses(const std::string& part_name);
0150
0151 const ParticleProcesses& discreteProcesses(const std::string& part_name) const;
0152
0153
0154 PhysicsConstructor physics(const std::string& name) const;
0155
0156
0157 ParticleConstructors& particles() {
0158 return m_particles;
0159 }
0160
0161 const ParticleConstructors& particles() const {
0162 return m_particles;
0163 }
0164
0165 ParticleConstructors& particlegroups() {
0166 return m_particlegroups;
0167 }
0168
0169 const ParticleConstructors& particlegroups() const {
0170 return m_particlegroups;
0171 }
0172
0173 PhysicsConstructors& physics() {
0174 return m_physics;
0175 }
0176
0177 const PhysicsConstructors& physics() const {
0178 return m_physics;
0179 }
0180
0181
0182 void addParticleConstructor(const std::string& part_name);
0183
0184 void addParticleGroup(const std::string& part_name);
0185
0186 void addParticleProcess(const std::string& part_name, const std::string& proc_name,
0187 int ordAtRestDoIt,int ordAlongSteptDoIt,int ordPostStepDoIt);
0188
0189 void addDiscreteParticleProcess(const std::string& part_name, const std::string& proc_name);
0190
0191
0192
0193
0194
0195 void addPhysicsConstructor(const std::string& physics_name);
0196
0197
0198
0199
0200
0201
0202
0203
0204 void adoptPhysicsConstructor(Geant4Action* action);
0205
0206 G4VPhysicsConstructor* addPhysicsConstructorType(const std::string& physics_name);
0207
0208
0209 virtual void constructPhysics(G4VModularPhysicsList* physics);
0210
0211 virtual void constructParticles(G4VUserPhysicsList* physics);
0212
0213 virtual void constructProcesses(G4VUserPhysicsList* physics);
0214
0215 virtual void enable(G4VUserPhysicsList* physics);
0216 };
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227 class Geant4PhysicsListActionSequence: public Geant4Action {
0228 public:
0229
0230 protected:
0231
0232 CallbackSequence m_physics { };
0233
0234 CallbackSequence m_process { };
0235
0236 CallbackSequence m_particle { };
0237
0238 Actors<Geant4PhysicsList> m_actors { };
0239
0240
0241 virtual void constructDecays(G4VUserPhysicsList* physics);
0242 public:
0243
0244 bool m_transportation { false };
0245
0246 bool m_decays { false };
0247
0248 int m_verbosity { 1 };
0249
0250 int m_physics_verbosity { -1 };
0251
0252 double m_rangecut;
0253
0254 std::string m_extends;
0255
0256 public:
0257
0258 Geant4PhysicsListActionSequence(Geant4Context* context, const std::string& nam);
0259
0260 virtual ~Geant4PhysicsListActionSequence();
0261
0262 void dump();
0263
0264 virtual void installCommandMessenger() override;
0265
0266 void setTransportation(bool value) {
0267 m_transportation = value;
0268 }
0269
0270 bool transportation() const {
0271 return m_transportation;
0272 }
0273
0274 template <typename Q, typename T>
0275 void constructPhysics(Q* p, void (T::*f)(G4VModularPhysicsList*)) {
0276 m_physics.add(p, f);
0277 }
0278
0279 template <typename Q, typename T>
0280 void constructProcess(Q* p, void (T::*f)(G4VUserPhysicsList*)) {
0281 m_process.add(p, f);
0282 }
0283
0284 template <typename Q, typename T>
0285 void constructParticle(Q* p, void (T::*f)(G4VUserPhysicsList*)) {
0286 m_particle.add(p, f);
0287 }
0288
0289 void adopt(Geant4PhysicsList* action);
0290
0291
0292 virtual void constructProcesses(G4VUserPhysicsList* physics);
0293
0294 virtual void constructParticles(G4VUserPhysicsList* physics);
0295
0296 virtual void constructPhysics(G4VModularPhysicsList* physics);
0297
0298 virtual void enable(G4VUserPhysicsList* physics);
0299
0300 G4VUserPhysicsList* extensionList();
0301 };
0302
0303 }
0304 }
0305
0306 #endif