Belle II Software development
ExtPhysicsConstructor.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <simulation/kernel/ExtPhysicsConstructor.h>
10
11#include <CLHEP/Units/PhysicalConstants.h>
12#include <CLHEP/Units/SystemOfUnits.h>
13
14#include <G4ParticleTable.hh>
15#include <G4ParticleDefinition.hh>
16#include <G4ProcessManager.hh>
17#include <G4ComptonScattering.hh>
18#include <G4GammaConversion.hh>
19#include <G4PhotoElectricEffect.hh>
20#include <simulation/kernel/ExtStepLengthLimitProcess.h>
21#include <simulation/kernel/ExtMagFieldLimitProcess.h>
22#include <simulation/kernel/ExtEnergyLoss.h>
23#include <simulation/kernel/ExtMessenger.h>
24
25#define g4ePDGcode 0
26
27using namespace std;
28using namespace Belle2;
29using namespace Belle2::Simulation;
30
31ExtPhysicsConstructor::ExtPhysicsConstructor() : G4VPhysicsConstructor("ExtPhysicsConstructor"),
32 m_StepLengthLimitProcess(NULL), m_MagFieldLimitProcess(NULL), m_ELossProcess(NULL), m_Messenger(NULL)
33{
34 if (false) {
37 }
38}
39
41{
45 if (m_Messenger) delete m_Messenger;
46}
47
49{
50 // Create ext-specific copies of useful particles, in case we are
51 // running the geant4e extrapolator. These particles will have a
52 // limited process list and can coexist with geant4 particles: they
53 // are distinguished by their name having the prefix "g4e_" and their
54 // "PDG code" always being the reserved value of 0 (which means that
55 // the user must use FindParticle(name) rather than FindParticle(#)
56 // to look up these special particles.
57 // Arguments for G4ParticleDefinition() are as follows:
58 // name mass width charge
59 // 2*spin parity C-conjugation
60 // 2*Isospin 2*Isospin3 G-parity
61 // type lepton number baryon number PDG encoding
62 // stable lifetime decay table
63 // shortlived subType anti_encoding
64 // Values copied verbatim from geant4, except our particles don't decay
65 // and the names/PDGcodes are unique.
66
67 static G4ParticleDefinition* g4eParticle = NULL;
68
69 if (g4eParticle == NULL) {
70 // Bohr Magneton for positron and positive muon
71 G4double muBpositron = 0.5 * CLHEP::eplus * CLHEP::hbar_Planck / (0.51099906 * CLHEP::MeV / CLHEP::c_squared);
72 G4double muBmuon = 0.5 * CLHEP::eplus * CLHEP::hbar_Planck / (0.1056584 * CLHEP::GeV / CLHEP::c_squared);
73 G4double muNucleon = CLHEP::eplus * CLHEP::hbar_Planck / 2. / (CLHEP::proton_mass_c2 / CLHEP::c_squared);
74 // Copied from G4Gamma.cc
75 g4eParticle = new G4ParticleDefinition(
76 "g4e_gamma", 0.0 * CLHEP::MeV, 0.0 * CLHEP::MeV, 0.0,
77 2, -1, -1,
78 0, 0, 0,
79 "gamma", 0, 0, g4ePDGcode,
80 true, 0.0, NULL,
81 false, "photon", g4ePDGcode
82 );
83 // Copied from G4Electron.cc
84 new G4ParticleDefinition(
85 "g4e_e-", 0.51099906 * CLHEP::MeV, 0.0 * CLHEP::MeV, -1.0 * CLHEP::eplus,
86 1, 0, 0,
87 0, 0, 0,
88 "lepton", 1, 0, g4ePDGcode,
89 true, -1.0, NULL,
90 false, "e", g4ePDGcode, -1.0011596521859 * muBpositron
91 );
92 // Copied from G4Positron.cc
93 new G4ParticleDefinition(
94 "g4e_e+", 0.51099906 * CLHEP::MeV, 0.0 * CLHEP::MeV, +1.0 * CLHEP::eplus,
95 1, 0, 0,
96 0, 0, 0,
97 "lepton", -1, 0, g4ePDGcode,
98 true, -1.0, NULL,
99 false, "e", g4ePDGcode, 1.0011596521859 * muBpositron
100 );
101 // Copied from G4MuonPlus.cc
102 new G4ParticleDefinition(
103 "g4e_mu+", 0.1056584 * CLHEP::GeV, 2.99591e-16 * CLHEP::MeV, +1.0 * CLHEP::eplus,
104 1, 0, 0,
105 0, 0, 0,
106 "lepton", -1, 0, g4ePDGcode,
107 true, -1.0, NULL,
108 false, "mu", g4ePDGcode, 1.0011659208 * muBmuon
109 );
110 // Copied from G4MuonMinus.cc
111 new G4ParticleDefinition(
112 "g4e_mu-", 0.1056584 * CLHEP::GeV, 2.99591e-16 * CLHEP::MeV, -1.0 * CLHEP::eplus,
113 1, 0, 0,
114 0, 0, 0,
115 "lepton", 1, 0, g4ePDGcode,
116 true, -1.0, NULL,
117 false, "mu", g4ePDGcode, -1.0011659208 * muBmuon
118 );
119 // Copied from G4PionPlus.cc
120 new G4ParticleDefinition(
121 "g4e_pi+", 0.1395700 * CLHEP::GeV, 2.5284e-14 * CLHEP::MeV, +1.0 * CLHEP::eplus,
122 0, -1, 0,
123 2, +2, -1,
124 "meson", 0, 0, g4ePDGcode,
125 true, -1.0, NULL,
126 false, "pi", g4ePDGcode
127 );
128 // Copied from G4PionMinus.cc
129 new G4ParticleDefinition(
130 "g4e_pi-", 0.1395700 * CLHEP::GeV, 2.5284e-14 * CLHEP::MeV, -1.0 * CLHEP::eplus,
131 0, -1, 0,
132 2, -2, -1,
133 "meson", 0, 0, g4ePDGcode,
134 true, -1.0, NULL,
135 false, "pi", g4ePDGcode
136 );
137 // Copied from G4KaonPlus.cc
138 new G4ParticleDefinition(
139 "g4e_kaon+", 0.493677 * CLHEP::GeV, 5.315e-14 * CLHEP::MeV, +1.0 * CLHEP::eplus,
140 0, -1, 0,
141 1, +1, 0,
142 "meson", 0, 0, g4ePDGcode,
143 true, -1.0, NULL,
144 false, "kaon", g4ePDGcode
145 );
146 // Copied from G4KaonMinus.cc
147 new G4ParticleDefinition(
148 "g4e_kaon-", 0.493677 * CLHEP::GeV, 5.315e-14 * CLHEP::MeV, -1.0 * CLHEP::eplus,
149 0, -1, 0,
150 1, -1, 0,
151 "meson", 0, 0, g4ePDGcode,
152 true, -1.0, NULL,
153 false, "kaon", g4ePDGcode
154 );
155 // Copied from G4Proton.cc except use G4ParticleDefinition instead of G4Ions
156 new G4ParticleDefinition(
157 "g4e_proton", 0.9382723 * CLHEP::GeV, 0.0 * CLHEP::MeV, +1.0 * CLHEP::eplus,
158 1, +1, 0,
159 1, +1, 0,
160 "baryon", 0, +1, g4ePDGcode,
161 true, -1.0, NULL,
162 false, "nucleon", g4ePDGcode, 2.792847351 * muNucleon
163 );
164 // Copied from G4AntiProton.cc except use G4ParticleDefinition instead of G4Ions
165 new G4ParticleDefinition(
166 "g4e_anti_proton", 0.9382723 * CLHEP::GeV, 0.0 * CLHEP::MeV, -1.0 * CLHEP::eplus,
167 1, +1, 0,
168 1, -1, 0,
169 "baryon", 0, -1, g4ePDGcode,
170 true, -1.0, NULL,
171 false, "nucleon", g4ePDGcode, -2.792847351 * muNucleon
172 );
173 // copied from G4Deuteron.hh except use G4ParticleDefinition instead of G4Ions
174 new G4ParticleDefinition(
175 "g4e_deuteron", 1.875613 * CLHEP::GeV, 0.0 * CLHEP::MeV, +1.0 * CLHEP::eplus,
176 2, +1, 0,
177 0, 0, 0,
178 "nucleus", 0, +2, g4ePDGcode,
179 true, -1.0, NULL,
180 false, "static", g4ePDGcode, 0.857438230 * muNucleon
181
182 );
183 // copied from G4AntiDeuteron.hh except use G4ParticleDefinition instead of G4Ions
184 new G4ParticleDefinition(
185 "g4e_anti_deuteron", 1.875613 * CLHEP::GeV, 0.0 * CLHEP::MeV, -1.0 * CLHEP::eplus,
186 2, +1, 0,
187 0, 0, 0,
188 "anti_nucleus", 0, -2, g4ePDGcode,
189 true, -1.0, NULL,
190 false, "static", g4ePDGcode, -0.857438230 * muNucleon
191 );
192
193 }
194}
195
197{
198 // Define the limited set of processes that will be suffered by the
199 // geant4e-specific particles
204 G4ParticleTable* myParticleTable = G4ParticleTable::GetParticleTable();
205 // theParticleIterator is a Geant4 macro since version 10.
206 G4ParticleTable::G4PTblDicIterator* myParticleIterator = myParticleTable->GetIterator();
207 myParticleIterator->reset();
208 while ((*myParticleIterator)()) {
209 G4ParticleDefinition* particle = myParticleIterator->value();
210 G4ProcessManager* pmanager = particle->GetProcessManager();
211 G4String particleName = particle->GetParticleName();
212 if (particleName.compare(0, 4, "g4e_") == 0) {
213 if (particleName == "g4e_gamma") {
214 pmanager->AddDiscreteProcess(new G4GammaConversion());
215 pmanager->AddDiscreteProcess(new G4ComptonScattering());
216 pmanager->AddDiscreteProcess(new G4PhotoElectricEffect());
217 } else {
218 pmanager->AddContinuousProcess(m_ELossProcess, 1);
219 pmanager->AddDiscreteProcess(m_StepLengthLimitProcess, 2);
220 pmanager->AddDiscreteProcess(m_MagFieldLimitProcess, 3);
221 }
222 }
223 }
224}
225
Define physics process to calculate energy loss without fluctuations.
Definition: ExtEnergyLoss.h:32
Defines the physics process that avoids hit invocation in sensitive volumes.
Define the mechanism by which the user can communicate with the geant4e extrapolator using geant4 UI ...
Definition: ExtMessenger.h:36
void ConstructProcess()
ConstructProcess() defines the geant4e-specific processes.
ExtStepLengthLimitProcess * m_StepLengthLimitProcess
Process that limits the geant4e step length.
ExtMagFieldLimitProcess * m_MagFieldLimitProcess
Process that limits the geant4e step length in magnetic field.
ExtMessenger * m_Messenger
Pointer to the ExtMessenger that is used to control geant4e.
virtual ~ExtPhysicsConstructor()
The ExtPhysicsConstructor destructor.
ExtPhysicsConstructor()
The ExtPhysicsConstructor constructor.
ExtEnergyLoss * m_ELossProcess
Process that limits the geant4e step length due to energy loss.
void ConstructParticle()
ConstructParticle() defines the geant4e-specific particles.
Defines the physics process that avoids hit invocation in sensitive volumes.
Abstract base class for different kinds of events.
STL namespace.