File indexing completed on 2025-01-18 09:55:24
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 = 0;
0096 public:
0097
0098 PhysicsConstructor() = default;
0099
0100 PhysicsConstructor(const PhysicsConstructor& c) = default;
0101
0102 PhysicsConstructor(const std::string& s) : std::string(s), pointer(0) {}
0103
0104 PhysicsConstructor& operator=(const PhysicsConstructor& c) = default;
0105 };
0106 typedef std::vector<PhysicsConstructor> PhysicsConstructors;
0107
0108 PhysicsProcesses m_processes;
0109 PhysicsProcesses m_discreteProcesses;
0110 PhysicsConstructors m_physics;
0111 ParticleConstructors m_particles;
0112 ParticleConstructors m_particlegroups;
0113
0114 public:
0115
0116 Geant4PhysicsList(Geant4Context* context, const std::string& nam);
0117
0118 virtual ~Geant4PhysicsList();
0119
0120
0121 void dump();
0122
0123
0124 virtual void installCommandMessenger();
0125
0126 PhysicsProcesses& processes() {
0127 return m_processes;
0128 }
0129
0130 const PhysicsProcesses& processes() const {
0131 return m_processes;
0132 }
0133
0134 ParticleProcesses& processes(const std::string& part_name);
0135
0136 const ParticleProcesses& processes(const std::string& part_name) const;
0137
0138
0139 PhysicsProcesses& discreteProcesses() {
0140 return m_discreteProcesses;
0141 }
0142
0143 const PhysicsProcesses& discreteProcesses() const {
0144 return m_discreteProcesses;
0145 }
0146
0147 ParticleProcesses& discreteProcesses(const std::string& part_name);
0148
0149 const ParticleProcesses& discreteProcesses(const std::string& part_name) const;
0150
0151
0152 PhysicsConstructor physics(const std::string& name) const;
0153
0154
0155 ParticleConstructors& particles() {
0156 return m_particles;
0157 }
0158
0159 const ParticleConstructors& particles() const {
0160 return m_particles;
0161 }
0162
0163 ParticleConstructors& particlegroups() {
0164 return m_particlegroups;
0165 }
0166
0167 const ParticleConstructors& particlegroups() const {
0168 return m_particlegroups;
0169 }
0170
0171 PhysicsConstructors& physics() {
0172 return m_physics;
0173 }
0174
0175 const PhysicsConstructors& physics() const {
0176 return m_physics;
0177 }
0178
0179
0180 void addParticleConstructor(const std::string& part_name);
0181
0182 void addParticleGroup(const std::string& part_name);
0183
0184 void addParticleProcess(const std::string& part_name, const std::string& proc_name,
0185 int ordAtRestDoIt,int ordAlongSteptDoIt,int ordPostStepDoIt);
0186
0187 void addDiscreteParticleProcess(const std::string& part_name, const std::string& proc_name);
0188
0189
0190
0191
0192
0193 void addPhysicsConstructor(const std::string& physics_name);
0194
0195
0196
0197
0198
0199
0200
0201
0202 void adoptPhysicsConstructor(Geant4Action* action);
0203
0204
0205 virtual void constructPhysics(G4VModularPhysicsList* physics);
0206
0207 virtual void constructParticles(G4VUserPhysicsList* physics);
0208
0209 virtual void constructProcesses(G4VUserPhysicsList* physics);
0210
0211 virtual void enable(G4VUserPhysicsList* physics);
0212 };
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223 class Geant4PhysicsListActionSequence: public Geant4Action {
0224 public:
0225
0226 protected:
0227
0228 CallbackSequence m_physics;
0229
0230 CallbackSequence m_process;
0231
0232 CallbackSequence m_particle;
0233
0234 Actors<Geant4PhysicsList> m_actors;
0235
0236
0237 virtual void constructDecays(G4VUserPhysicsList* physics);
0238 public:
0239
0240 bool m_transportation { false };
0241
0242 bool m_decays { false };
0243
0244 std::string m_extends;
0245
0246 double m_rangecut;
0247
0248 public:
0249
0250 Geant4PhysicsListActionSequence(Geant4Context* context, const std::string& nam);
0251
0252 virtual ~Geant4PhysicsListActionSequence();
0253
0254 void dump();
0255
0256 virtual void installCommandMessenger();
0257
0258 void setTransportation(bool value) {
0259 m_transportation = value;
0260 }
0261
0262 bool transportation() const {
0263 return m_transportation;
0264 }
0265
0266 template <typename Q, typename T>
0267 void constructPhysics(Q* p, void (T::*f)(G4VModularPhysicsList*)) {
0268 m_physics.add(p, f);
0269 }
0270
0271 template <typename Q, typename T>
0272 void constructProcess(Q* p, void (T::*f)(G4VUserPhysicsList*)) {
0273 m_process.add(p, f);
0274 }
0275
0276 template <typename Q, typename T>
0277 void constructParticle(Q* p, void (T::*f)(G4VUserPhysicsList*)) {
0278 m_particle.add(p, f);
0279 }
0280
0281 void adopt(Geant4PhysicsList* action);
0282
0283
0284 virtual void constructProcesses(G4VUserPhysicsList* physics);
0285
0286 virtual void constructParticles(G4VUserPhysicsList* physics);
0287
0288 virtual void constructPhysics(G4VModularPhysicsList* physics);
0289
0290 virtual void enable(G4VUserPhysicsList* physics);
0291
0292 G4VUserPhysicsList* extensionList();
0293 };
0294
0295 }
0296 }
0297
0298 #endif