DD4hep  1.35.0
Detector Description Toolkit for High Energy Physics
Geant4PhysicsList.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
14 #ifndef DDG4_GEANT4PHYSICSLIST_H
15 #define DDG4_GEANT4PHYSICSLIST_H
16 
17 // Framework include files
18 #include <DDG4/Geant4Action.h>
19 
20 // C/C++ include files
21 #include <map>
22 #include <vector>
23 
24 // Forward declarations
26 class G4VModularPhysicsList;
27 class G4VUserPhysicsList;
28 
30 namespace dd4hep {
31 
33  namespace sim {
34 
36 
42  public:
43 
45 
53  class Process {
54  public:
55  std::string name;
58  Process();
60  Process(const Process& p);
62  Process& operator=(const Process& p);
63  };
64  typedef std::vector<Process> ParticleProcesses;
65  typedef std::map<std::string, ParticleProcesses> PhysicsProcesses;
66 
68 
73  class ParticleConstructor : public std::string {
74  public:
76  ParticleConstructor() = default;
80  ParticleConstructor(const std::string& s) : std::string(s) { }
83  };
84  typedef std::vector<ParticleConstructor> ParticleConstructors;
85 
87 
92  class PhysicsConstructor: public std::string {
93  public:
97  G4VModularPhysicsList* physics_list { nullptr };
98  public:
100  PhysicsConstructor() = default;
104  PhysicsConstructor(const std::string& s) : std::string(s), pointer(0) {}
107  };
108  typedef std::vector<PhysicsConstructor> PhysicsConstructors;
109 
115 
116  public:
118  Geant4PhysicsList(Geant4Context* context, const std::string& nam);
120  virtual ~Geant4PhysicsList();
121 
123  void dump();
124 
126  virtual void installCommandMessenger() override;
129  return m_processes;
130  }
132  const PhysicsProcesses& processes() const {
133  return m_processes;
134  }
136  ParticleProcesses& processes(const std::string& part_name);
138  const ParticleProcesses& processes(const std::string& part_name) const;
139 
142  return m_discreteProcesses;
143  }
146  return m_discreteProcesses;
147  }
149  ParticleProcesses& discreteProcesses(const std::string& part_name);
151  const ParticleProcesses& discreteProcesses(const std::string& part_name) const;
152 
154  PhysicsConstructor physics(const std::string& name) const;
155 
158  return m_particles;
159  }
162  return m_particles;
163  }
166  return m_particlegroups;
167  }
170  return m_particlegroups;
171  }
174  return m_physics;
175  }
177  const PhysicsConstructors& physics() const {
178  return m_physics;
179  }
180 
182  void addParticleConstructor(const std::string& part_name);
184  void addParticleGroup(const std::string& part_name);
186  void addParticleProcess(const std::string& part_name, const std::string& proc_name,
187  int ordAtRestDoIt,int ordAlongSteptDoIt,int ordPostStepDoIt);
189  void addDiscreteParticleProcess(const std::string& part_name, const std::string& proc_name);
191 
195  void addPhysicsConstructor(const std::string& physics_name);
197 
206  G4VPhysicsConstructor* addPhysicsConstructorType(const std::string& physics_name);
207 
209  virtual void constructPhysics(G4VModularPhysicsList* physics);
211  virtual void constructParticles(G4VUserPhysicsList* physics);
213  virtual void constructProcesses(G4VUserPhysicsList* physics);
215  virtual void enable(G4VUserPhysicsList* physics);
216  };
217 
219 
228  public:
229 
230  protected:
239 
241  virtual void constructDecays(G4VUserPhysicsList* physics);
242  public:
244  bool m_transportation { false };
246  bool m_decays { false };
248  int m_verbosity { 1 };
252  double m_rangecut;
254  std::string m_extends;
255 
256  public:
258  Geant4PhysicsListActionSequence(Geant4Context* context, const std::string& nam);
262  void dump();
264  virtual void installCommandMessenger() override;
266  void setTransportation(bool value) {
267  m_transportation = value;
268  }
270  bool transportation() const {
271  return m_transportation;
272  }
274  template <typename Q, typename T>
275  void constructPhysics(Q* p, void (T::*f)(G4VModularPhysicsList*)) {
276  m_physics.add(p, f);
277  }
279  template <typename Q, typename T>
280  void constructProcess(Q* p, void (T::*f)(G4VUserPhysicsList*)) {
281  m_process.add(p, f);
282  }
284  template <typename Q, typename T>
285  void constructParticle(Q* p, void (T::*f)(G4VUserPhysicsList*)) {
286  m_particle.add(p, f);
287  }
289  void adopt(Geant4PhysicsList* action);
290 
292  virtual void constructProcesses(G4VUserPhysicsList* physics);
294  virtual void constructParticles(G4VUserPhysicsList* physics);
296  virtual void constructPhysics(G4VModularPhysicsList* physics);
298  virtual void enable(G4VUserPhysicsList* physics);
300  G4VUserPhysicsList* extensionList();
301  };
302 
303  } // End namespace sim
304 } // End namespace dd4hep
305 
306 #endif // DDG4_GEANT4PHYSICSLIST_H
dd4hep::sim::Geant4PhysicsList::PhysicsConstructor::pointer
G4VPhysicsConstructor * pointer
Pointer to physics constructor object.
Definition: Geant4PhysicsList.h:95
dd4hep::sim::Geant4PhysicsList::particlegroups
ParticleConstructors & particlegroups()
Access all physics particlegroups.
Definition: Geant4PhysicsList.h:165
dd4hep::sim::Geant4PhysicsList::PhysicsConstructor::PhysicsConstructor
PhysicsConstructor(const std::string &s)
Initalizing constructor.
Definition: Geant4PhysicsList.h:104
dd4hep::sim::Geant4PhysicsList::constructPhysics
virtual void constructPhysics(G4VModularPhysicsList *physics)
constructPhysics callback
Definition: Geant4PhysicsList.cpp:231
dd4hep::sim::Geant4PhysicsList::addParticleGroup
void addParticleGroup(const std::string &part_name)
Add physics particle group constructor by name (Leptons, Bosons, Mesons, etc.)
Definition: Geant4PhysicsList.cpp:136
dd4hep::sim::Geant4PhysicsList::constructParticles
virtual void constructParticles(G4VUserPhysicsList *physics)
Callback to construct particles.
Definition: Geant4PhysicsList.cpp:273
dd4hep::sim::Geant4PhysicsList::Process
Structure describing a G4 process.
Definition: Geant4PhysicsList.h:53
dd4hep::sim::Geant4PhysicsListActionSequence::m_physics
CallbackSequence m_physics
Callback sequence for G4 physics constructors.
Definition: Geant4PhysicsList.h:232
dd4hep::sim::Geant4PhysicsList::Process::ordPostStepDoIt
int ordPostStepDoIt
Definition: Geant4PhysicsList.h:56
dd4hep::sim::Geant4PhysicsList::Process::operator=
Process & operator=(const Process &p)
Assignment operator.
Definition: Geant4PhysicsList.cpp:78
dd4hep::sim::Geant4PhysicsListActionSequence::extensionList
G4VUserPhysicsList * extensionList()
Extend physics list from factory:
Definition: Geant4PhysicsList.cpp:369
dd4hep::sim::Geant4PhysicsListActionSequence::constructProcess
void constructProcess(Q *p, void(T::*f)(G4VUserPhysicsList *))
Register process construction callback.
Definition: Geant4PhysicsList.h:280
dd4hep::sim::Geant4PhysicsList::PhysicsConstructor::physics_list
G4VModularPhysicsList * physics_list
Pointer to the physics list the constructor belongs.
Definition: Geant4PhysicsList.h:97
dd4hep::sim::Geant4PhysicsList::installCommandMessenger
virtual void installCommandMessenger() override
Install command control messenger if wanted.
Definition: Geant4PhysicsList.cpp:100
dd4hep::sim::Geant4PhysicsList::ParticleConstructor::operator=
ParticleConstructor & operator=(const ParticleConstructor &c)=default
Assignment operator.
dd4hep::sim::Geant4PhysicsListActionSequence::constructProcesses
virtual void constructProcesses(G4VUserPhysicsList *physics)
Execute sequence of G4 physics constructors.
Definition: Geant4PhysicsList.cpp:445
dd4hep::sim::Geant4PhysicsList::Process::ordAtRestDoIt
int ordAtRestDoIt
Definition: Geant4PhysicsList.h:56
dd4hep::sim::Geant4PhysicsListActionSequence::adopt
void adopt(Geant4PhysicsList *action)
Add an actor responding to all callbacks. Sequence takes ownership.
Definition: Geant4PhysicsList.cpp:423
dd4hep::CallbackSequence::add
void add(const Callback &cb, Location where)
Generically Add a new callback to the sequence depending on the location arguments.
Definition: Callback.h:366
dd4hep::sim::Geant4PhysicsList::Process::Process
Process()
Default constructor.
Definition: Geant4PhysicsList.cpp:69
dd4hep::sim::Geant4PhysicsListActionSequence::m_actors
Actors< Geant4PhysicsList > m_actors
The list of action objects to be called.
Definition: Geant4PhysicsList.h:238
dd4hep::sim::Geant4PhysicsListActionSequence::constructParticles
virtual void constructParticles(G4VUserPhysicsList *physics)
Execute sequence of G4 particle constructors.
Definition: Geant4PhysicsList.cpp:433
dd4hep::sim::Geant4PhysicsListActionSequence::constructPhysics
void constructPhysics(Q *p, void(T::*f)(G4VModularPhysicsList *))
Register physics construction callback.
Definition: Geant4PhysicsList.h:275
dd4hep::sim::Geant4PhysicsList::ParticleProcesses
std::vector< Process > ParticleProcesses
Definition: Geant4PhysicsList.h:64
dd4hep::sim::Geant4PhysicsListActionSequence::m_transportation
bool m_transportation
Property: Flag if particle transportation is to be added.
Definition: Geant4PhysicsList.h:244
dd4hep::sim::Geant4PhysicsListActionSequence::m_physics_verbosity
int m_physics_verbosity
Property: Verbosity level for G4VUserPhysicsList instance (See G4VUserPhysicsList....
Definition: Geant4PhysicsList.h:250
dd4hep::sim::Geant4PhysicsList::particles
ParticleConstructors & particles()
Access all physics particles.
Definition: Geant4PhysicsList.h:157
dd4hep::sim::Geant4PhysicsListActionSequence::installCommandMessenger
virtual void installCommandMessenger() override
Install command control messenger if wanted.
Definition: Geant4PhysicsList.cpp:407
dd4hep::CallbackSequence
Definition of an actor on sequences of callbacks.
Definition: Callback.h:338
dd4hep::sim::Geant4PhysicsListActionSequence::m_rangecut
double m_rangecut
Property: global range cut for secondary productions.
Definition: Geant4PhysicsList.h:252
dd4hep::sim::Geant4PhysicsList::PhysicsConstructors
std::vector< PhysicsConstructor > PhysicsConstructors
Definition: Geant4PhysicsList.h:108
dd4hep::sim::Geant4PhysicsList::Geant4PhysicsList
Geant4PhysicsList(Geant4Context *context, const std::string &nam)
Standard constructor with initailization parameters.
Definition: Geant4PhysicsList.cpp:89
dd4hep::sim::Geant4PhysicsListActionSequence::constructDecays
virtual void constructDecays(G4VUserPhysicsList *physics)
Callback to construct particle decays.
Definition: Geant4PhysicsList.cpp:454
dd4hep::sim::Geant4PhysicsListActionSequence::m_particle
CallbackSequence m_particle
Callback sequence for G4 particle constructors.
Definition: Geant4PhysicsList.h:236
dd4hep::sim::Geant4PhysicsList::PhysicsProcesses
std::map< std::string, ParticleProcesses > PhysicsProcesses
Definition: Geant4PhysicsList.h:65
dd4hep::sim::Geant4PhysicsList::addPhysicsConstructor
void addPhysicsConstructor(const std::string &physics_name)
Add PhysicsConstructor by name.
Definition: Geant4PhysicsList.cpp:165
dd4hep::sim::Geant4PhysicsList::physics
PhysicsConstructors & physics()
Access all physics constructors.
Definition: Geant4PhysicsList.h:173
dd4hep::sim::Geant4PhysicsList::dump
void dump()
Dump content to stdout.
Definition: Geant4PhysicsList.cpp:105
dd4hep::sim::Geant4PhysicsList::m_particles
ParticleConstructors m_particles
Definition: Geant4PhysicsList.h:113
dd4hep::sim::Geant4PhysicsList::Process::ordAlongSteptDoIt
int ordAlongSteptDoIt
Definition: Geant4PhysicsList.h:56
dd4hep::sim::Geant4PhysicsListActionSequence::m_process
CallbackSequence m_process
Callback sequence for G4 process constructors.
Definition: Geant4PhysicsList.h:234
dd4hep::sim::Geant4PhysicsList::processes
PhysicsProcesses & processes()
Access all physics processes.
Definition: Geant4PhysicsList.h:128
dd4hep::sim::Geant4PhysicsListActionSequence
The implementation of the single Geant4 physics list action sequence.
Definition: Geant4PhysicsList.h:227
dd4hep::sim::Geant4PhysicsList::ParticleConstructor::ParticleConstructor
ParticleConstructor(const std::string &s)
Initalizing constructor.
Definition: Geant4PhysicsList.h:80
dd4hep::sim::Geant4PhysicsList::addPhysicsConstructorType
G4VPhysicsConstructor * addPhysicsConstructorType(const std::string &physics_name)
Callback to add a physics type to the physics list.
Definition: Geant4PhysicsList.cpp:252
dd4hep::sim::Geant4PhysicsList::ParticleConstructor::ParticleConstructor
ParticleConstructor(const ParticleConstructor &copy)=default
Default constructor.
dd4hep::sim::Geant4Action
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:113
dd4hep::sim::Geant4PhysicsList::~Geant4PhysicsList
virtual ~Geant4PhysicsList()
Default destructor.
Definition: Geant4PhysicsList.cpp:95
dd4hep::sim::Geant4Action::name
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:280
dd4hep::sim::Geant4PhysicsListActionSequence::dump
void dump()
Dump content to stdout.
Definition: Geant4PhysicsList.cpp:412
dd4hep::sim::Geant4PhysicsList::addParticleProcess
void addParticleProcess(const std::string &part_name, const std::string &proc_name, int ordAtRestDoIt, int ordAlongSteptDoIt, int ordPostStepDoIt)
Add particle process by name with arguments.
Definition: Geant4PhysicsList.cpp:141
dd4hep::sim::Geant4PhysicsList::m_processes
PhysicsProcesses m_processes
Definition: Geant4PhysicsList.h:110
dd4hep::sim::Geant4PhysicsList::PhysicsConstructor
Structure describing a G4 physics constructor.
Definition: Geant4PhysicsList.h:92
G4VPhysicsConstructor
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:51
dd4hep::sim::Geant4PhysicsList::ParticleConstructor
Structure describing a G4 particle constructor.
Definition: Geant4PhysicsList.h:73
dd4hep::sim::Geant4PhysicsList::m_discreteProcesses
PhysicsProcesses m_discreteProcesses
Definition: Geant4PhysicsList.h:111
dd4hep::sim::Geant4PhysicsList::particlegroups
const ParticleConstructors & particlegroups() const
Access all physics particlegroups.
Definition: Geant4PhysicsList.h:169
dd4hep::sim::Geant4PhysicsListActionSequence::m_decays
bool m_decays
Property: Flag if particle decays are to be added.
Definition: Geant4PhysicsList.h:246
dd4hep::sim::Geant4PhysicsList
Concrete basic implementation of a Geant4 physics list action.
Definition: Geant4PhysicsList.h:41
dd4hep::sim::Geant4PhysicsList::PhysicsConstructor::operator=
PhysicsConstructor & operator=(const PhysicsConstructor &c)=default
Assignment operator.
dd4hep::sim::Geant4PhysicsListActionSequence::~Geant4PhysicsListActionSequence
virtual ~Geant4PhysicsListActionSequence()
Default destructor.
Definition: Geant4PhysicsList.cpp:359
dd4hep::sim::Geant4PhysicsListActionSequence::transportation
bool transportation() const
Access the transportation flag.
Definition: Geant4PhysicsList.h:270
dd4hep::sim::Geant4PhysicsList::processes
const PhysicsProcesses & processes() const
Access all physics processes.
Definition: Geant4PhysicsList.h:132
dd4hep::sim::Geant4PhysicsListActionSequence::Geant4PhysicsListActionSequence
Geant4PhysicsListActionSequence(Geant4Context *context, const std::string &nam)
Standard constructor.
Definition: Geant4PhysicsList.cpp:345
dd4hep::sim::Geant4PhysicsListActionSequence::m_verbosity
int m_verbosity
Property: verbosity level for the physics list.
Definition: Geant4PhysicsList.h:248
dd4hep::sim::Geant4PhysicsList::adoptPhysicsConstructor
void adoptPhysicsConstructor(Geant4Action *action)
Add PhysicsConstructor as Geant4Action object.
Definition: Geant4PhysicsList.cpp:215
dd4hep::sim::Geant4PhysicsList::discreteProcesses
PhysicsProcesses & discreteProcesses()
Access all physics discrete processes.
Definition: Geant4PhysicsList.h:141
dd4hep::sim::Geant4PhysicsList::constructProcesses
virtual void constructProcesses(G4VUserPhysicsList *physics)
Callback to construct processes (uses the G4 particle table)
Definition: Geant4PhysicsList.cpp:299
dd4hep::sim::Geant4PhysicsListActionSequence::constructParticle
void constructParticle(Q *p, void(T::*f)(G4VUserPhysicsList *))
Register particle construction callback.
Definition: Geant4PhysicsList.h:285
std
Definition: Plugins.h:29
dd4hep::sim::Geant4PhysicsListActionSequence::setTransportation
void setTransportation(bool value)
Update transportation flag.
Definition: Geant4PhysicsList.h:266
dd4hep::sim::Geant4PhysicsList::addDiscreteParticleProcess
void addDiscreteParticleProcess(const std::string &part_name, const std::string &proc_name)
Add discrete particle process by name with arguments.
Definition: Geant4PhysicsList.cpp:156
dd4hep::sim::Geant4PhysicsList::PhysicsConstructor::PhysicsConstructor
PhysicsConstructor(const PhysicsConstructor &c)=default
Copy constructor.
dd4hep::sim::Geant4PhysicsList::m_physics
PhysicsConstructors m_physics
Definition: Geant4PhysicsList.h:112
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4PhysicsListActionSequence::enable
virtual void enable(G4VUserPhysicsList *physics)
Enable physics list: actions necessary to be propagated to Geant4.
Definition: Geant4PhysicsList.cpp:474
dd4hep::sim::Geant4PhysicsList::addParticleConstructor
void addParticleConstructor(const std::string &part_name)
Add physics particle constructor by name.
Definition: Geant4PhysicsList.cpp:131
dd4hep::sim::Geant4Action::Actors
Actor class to manipulate action groups.
Definition: Geant4Action.h:168
dd4hep::sim::Geant4PhysicsList::m_particlegroups
ParticleConstructors m_particlegroups
Definition: Geant4PhysicsList.h:114
dd4hep::sim::Geant4PhysicsList::particles
const ParticleConstructors & particles() const
Access all physics particles.
Definition: Geant4PhysicsList.h:161
dd4hep::sim::Geant4PhysicsList::ParticleConstructor::ParticleConstructor
ParticleConstructor()=default
Default constructor.
dd4hep::sim::Geant4PhysicsList::enable
virtual void enable(G4VUserPhysicsList *physics)
Enable physics list: actions necessary to be propagated to Geant4.
Definition: Geant4PhysicsList.cpp:341
dd4hep::detail::tools::copy
void copy(Alignment from, Alignment to)
Copy alignment object from source object.
Definition: AlignmentTools.cpp:43
dd4hep::sim::Geant4PhysicsList::PhysicsConstructor::PhysicsConstructor
PhysicsConstructor()=default
Default constructor.
dd4hep::sim::Geant4PhysicsList::physics
const PhysicsConstructors & physics() const
Access all physics constructors.
Definition: Geant4PhysicsList.h:177
dd4hep::sim::Geant4PhysicsList::ParticleConstructors
std::vector< ParticleConstructor > ParticleConstructors
Definition: Geant4PhysicsList.h:84
dd4hep::sim::Geant4PhysicsList::Process::name
std::string name
Definition: Geant4PhysicsList.h:55
Geant4Action.h
dd4hep::sim::Geant4Context
Generic context to extend user, run and event information.
Definition: Geant4Context.h:201
dd4hep::sim::Geant4Action::context
Geant4Context * context() const
Access the context.
Definition: Geant4Action.h:270
dd4hep::sim::Geant4PhysicsList::discreteProcesses
const PhysicsProcesses & discreteProcesses() const
Access all physics discrete processes.
Definition: Geant4PhysicsList.h:145
dd4hep::sim::Geant4PhysicsListActionSequence::m_extends
std::string m_extends
Property: Store name of basic predefined Geant4 physics list.
Definition: Geant4PhysicsList.h:254