DD4hep  1.30.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:
96  public:
98  PhysicsConstructor() = default;
102  PhysicsConstructor(const std::string& s) : std::string(s), pointer(0) {}
105  };
106  typedef std::vector<PhysicsConstructor> PhysicsConstructors;
107 
113 
114  public:
116  Geant4PhysicsList(Geant4Context* context, const std::string& nam);
118  virtual ~Geant4PhysicsList();
119 
121  void dump();
122 
124  virtual void installCommandMessenger() override;
127  return m_processes;
128  }
130  const PhysicsProcesses& processes() const {
131  return m_processes;
132  }
134  ParticleProcesses& processes(const std::string& part_name);
136  const ParticleProcesses& processes(const std::string& part_name) const;
137 
140  return m_discreteProcesses;
141  }
144  return m_discreteProcesses;
145  }
147  ParticleProcesses& discreteProcesses(const std::string& part_name);
149  const ParticleProcesses& discreteProcesses(const std::string& part_name) const;
150 
152  PhysicsConstructor physics(const std::string& name) const;
153 
156  return m_particles;
157  }
160  return m_particles;
161  }
164  return m_particlegroups;
165  }
168  return m_particlegroups;
169  }
172  return m_physics;
173  }
175  const PhysicsConstructors& physics() const {
176  return m_physics;
177  }
178 
180  void addParticleConstructor(const std::string& part_name);
182  void addParticleGroup(const std::string& part_name);
184  void addParticleProcess(const std::string& part_name, const std::string& proc_name,
185  int ordAtRestDoIt,int ordAlongSteptDoIt,int ordPostStepDoIt);
187  void addDiscreteParticleProcess(const std::string& part_name, const std::string& proc_name);
189 
193  void addPhysicsConstructor(const std::string& physics_name);
195 
203 
205  virtual void constructPhysics(G4VModularPhysicsList* physics);
207  virtual void constructParticles(G4VUserPhysicsList* physics);
209  virtual void constructProcesses(G4VUserPhysicsList* physics);
211  virtual void enable(G4VUserPhysicsList* physics);
212  };
213 
215 
224  public:
225 
226  protected:
235 
237  virtual void constructDecays(G4VUserPhysicsList* physics);
238  public:
240  bool m_transportation { false };
242  bool m_decays { false };
244  std::string m_extends;
246  double m_rangecut;
248  int m_verbosity = 1;
249 
250  public:
252  Geant4PhysicsListActionSequence(Geant4Context* context, const std::string& nam);
256  void dump();
258  virtual void installCommandMessenger() override;
260  void setTransportation(bool value) {
261  m_transportation = value;
262  }
264  bool transportation() const {
265  return m_transportation;
266  }
268  template <typename Q, typename T>
269  void constructPhysics(Q* p, void (T::*f)(G4VModularPhysicsList*)) {
270  m_physics.add(p, f);
271  }
273  template <typename Q, typename T>
274  void constructProcess(Q* p, void (T::*f)(G4VUserPhysicsList*)) {
275  m_process.add(p, f);
276  }
278  template <typename Q, typename T>
279  void constructParticle(Q* p, void (T::*f)(G4VUserPhysicsList*)) {
280  m_particle.add(p, f);
281  }
283  void adopt(Geant4PhysicsList* action);
284 
286  virtual void constructProcesses(G4VUserPhysicsList* physics);
288  virtual void constructParticles(G4VUserPhysicsList* physics);
290  virtual void constructPhysics(G4VModularPhysicsList* physics);
292  virtual void enable(G4VUserPhysicsList* physics);
294  G4VUserPhysicsList* extensionList();
295  };
296 
297  } // End namespace sim
298 } // End namespace dd4hep
299 
300 #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:163
dd4hep::sim::Geant4PhysicsList::PhysicsConstructor::PhysicsConstructor
PhysicsConstructor(const std::string &s)
Initalizing constructor.
Definition: Geant4PhysicsList.h:102
dd4hep::sim::Geant4PhysicsList::constructPhysics
virtual void constructPhysics(G4VModularPhysicsList *physics)
constructPhysics callback
Definition: Geant4PhysicsList.cpp:230
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:245
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:228
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:340
dd4hep::sim::Geant4PhysicsListActionSequence::constructProcess
void constructProcess(Q *p, void(T::*f)(G4VUserPhysicsList *))
Register process construction callback.
Definition: Geant4PhysicsList.h:274
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:416
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:394
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:367
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:234
dd4hep::sim::Geant4PhysicsListActionSequence::constructParticles
virtual void constructParticles(G4VUserPhysicsList *physics)
Execute sequence of G4 particle constructors.
Definition: Geant4PhysicsList.cpp:404
dd4hep::sim::Geant4PhysicsListActionSequence::constructPhysics
void constructPhysics(Q *p, void(T::*f)(G4VModularPhysicsList *))
Register physics construction callback.
Definition: Geant4PhysicsList.h:269
dd4hep::sim::Geant4PhysicsList::ParticleProcesses
std::vector< Process > ParticleProcesses
Definition: Geant4PhysicsList.h:64
dd4hep::sim::Geant4PhysicsListActionSequence::m_transportation
bool m_transportation
Flag if particle transportation is to be added.
Definition: Geant4PhysicsList.h:240
dd4hep::sim::Geant4PhysicsList::particles
ParticleConstructors & particles()
Access all physics particles.
Definition: Geant4PhysicsList.h:155
dd4hep::sim::Geant4PhysicsListActionSequence::installCommandMessenger
virtual void installCommandMessenger() override
Install command control messenger if wanted.
Definition: Geant4PhysicsList.cpp:378
dd4hep::CallbackSequence
Definition of an actor on sequences of callbacks.
Definition: Callback.h:339
dd4hep::sim::Geant4PhysicsListActionSequence::m_rangecut
double m_rangecut
global range cut for secondary productions
Definition: Geant4PhysicsList.h:246
dd4hep::sim::Geant4PhysicsList::PhysicsConstructors
std::vector< PhysicsConstructor > PhysicsConstructors
Definition: Geant4PhysicsList.h:106
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:425
dd4hep::sim::Geant4PhysicsListActionSequence::m_particle
CallbackSequence m_particle
Callback sequence for G4 particle constructors.
Definition: Geant4PhysicsList.h:232
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:171
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:111
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:230
dd4hep::sim::Geant4PhysicsList::processes
PhysicsProcesses & processes()
Access all physics processes.
Definition: Geant4PhysicsList.h:126
dd4hep::sim::Geant4PhysicsListActionSequence
The implementation of the single Geant4 physics list action sequence.
Definition: Geant4PhysicsList.h:223
dd4hep::sim::Geant4PhysicsList::ParticleConstructor::ParticleConstructor
ParticleConstructor(const std::string &s)
Initalizing constructor.
Definition: Geant4PhysicsList.h:80
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:383
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:108
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:109
dd4hep::sim::Geant4PhysicsList::particlegroups
const ParticleConstructors & particlegroups() const
Access all physics particlegroups.
Definition: Geant4PhysicsList.h:167
dd4hep::sim::Geant4PhysicsListActionSequence::m_decays
bool m_decays
Flag if particle decays are to be added.
Definition: Geant4PhysicsList.h:242
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:330
dd4hep::sim::Geant4PhysicsListActionSequence::transportation
bool transportation() const
Access the transportation flag.
Definition: Geant4PhysicsList.h:264
dd4hep::sim::Geant4PhysicsList::processes
const PhysicsProcesses & processes() const
Access all physics processes.
Definition: Geant4PhysicsList.h:130
dd4hep::sim::Geant4PhysicsListActionSequence::Geant4PhysicsListActionSequence
Geant4PhysicsListActionSequence(Geant4Context *context, const std::string &nam)
Standard constructor.
Definition: Geant4PhysicsList.cpp:317
dd4hep::sim::Geant4PhysicsListActionSequence::m_verbosity
int m_verbosity
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:139
dd4hep::sim::Geant4PhysicsList::constructProcesses
virtual void constructProcesses(G4VUserPhysicsList *physics)
Callback to construct processes (uses the G4 particle table)
Definition: Geant4PhysicsList.cpp:271
dd4hep::sim::Geant4PhysicsListActionSequence::constructParticle
void constructParticle(Q *p, void(T::*f)(G4VUserPhysicsList *))
Register particle construction callback.
Definition: Geant4PhysicsList.h:279
std
Definition: Plugins.h:30
dd4hep::sim::Geant4PhysicsListActionSequence::setTransportation
void setTransportation(bool value)
Update transportation flag.
Definition: Geant4PhysicsList.h:260
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:110
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:445
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:112
dd4hep::sim::Geant4PhysicsList::particles
const ParticleConstructors & particles() const
Access all physics particles.
Definition: Geant4PhysicsList.h:159
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:313
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:175
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:143
dd4hep::sim::Geant4PhysicsListActionSequence::m_extends
std::string m_extends
Property: Store name of basic predefined Geant4 physics list.
Definition: Geant4PhysicsList.h:244