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"),
33{
34}
35
43
45{
46 // Create ext-specific copies of useful particles, in case we are
47 // running the geant4e extrapolator. These particles will have a
48 // limited process list and can coexist with geant4 particles: they
49 // are distinguished by their name having the prefix "g4e_" and their
50 // "PDG code" always being the reserved value of 0 (which means that
51 // the user must use FindParticle(name) rather than FindParticle(#)
52 // to look up these special particles.
53 // Arguments for G4ParticleDefinition() are as follows:
54 // name mass width charge
55 // 2*spin parity C-conjugation
56 // 2*Isospin 2*Isospin3 G-parity
57 // type lepton number baryon number PDG encoding
58 // stable lifetime decay table
59 // shortlived subType anti_encoding
60 // Values copied verbatim from geant4, except our particles don't decay
61 // and the names/PDGcodes are unique.
62
63 static const G4ParticleDefinition* g4eParticle = NULL;
64
65 if (g4eParticle == NULL) {
66 // Bohr Magneton for positron and positive muon
67 G4double muBpositron = 0.5 * CLHEP::eplus * CLHEP::hbar_Planck / (0.51099906 * CLHEP::MeV / CLHEP::c_squared);
68 G4double muBmuon = 0.5 * CLHEP::eplus * CLHEP::hbar_Planck / (0.1056584 * CLHEP::GeV / CLHEP::c_squared);
69 G4double muNucleon = CLHEP::eplus * CLHEP::hbar_Planck / 2. / (CLHEP::proton_mass_c2 / CLHEP::c_squared);
70 // Copied from G4Gamma.cc
71 g4eParticle = new G4ParticleDefinition(
72 "g4e_gamma", 0.0 * CLHEP::MeV, 0.0 * CLHEP::MeV, 0.0,
73 2, -1, -1,
74 0, 0, 0,
75 "gamma", 0, 0, g4ePDGcode,
76 true, 0.0, NULL,
77 false, "photon", g4ePDGcode
78 );
79 // Copied from G4Electron.cc
80 new G4ParticleDefinition(
81 "g4e_e-", 0.51099906 * CLHEP::MeV, 0.0 * CLHEP::MeV, -1.0 * CLHEP::eplus,
82 1, 0, 0,
83 0, 0, 0,
84 "lepton", 1, 0, g4ePDGcode,
85 true, -1.0, NULL,
86 false, "e", g4ePDGcode, -1.0011596521859 * muBpositron
87 );
88 // Copied from G4Positron.cc
89 new G4ParticleDefinition(
90 "g4e_e+", 0.51099906 * CLHEP::MeV, 0.0 * CLHEP::MeV, +1.0 * CLHEP::eplus,
91 1, 0, 0,
92 0, 0, 0,
93 "lepton", -1, 0, g4ePDGcode,
94 true, -1.0, NULL,
95 false, "e", g4ePDGcode, 1.0011596521859 * muBpositron
96 );
97 // Copied from G4MuonPlus.cc
98 new G4ParticleDefinition(
99 "g4e_mu+", 0.1056584 * CLHEP::GeV, 2.99591e-16 * CLHEP::MeV, +1.0 * CLHEP::eplus,
100 1, 0, 0,
101 0, 0, 0,
102 "lepton", -1, 0, g4ePDGcode,
103 true, -1.0, NULL,
104 false, "mu", g4ePDGcode, 1.0011659208 * muBmuon
105 );
106 // Copied from G4MuonMinus.cc
107 new G4ParticleDefinition(
108 "g4e_mu-", 0.1056584 * CLHEP::GeV, 2.99591e-16 * CLHEP::MeV, -1.0 * CLHEP::eplus,
109 1, 0, 0,
110 0, 0, 0,
111 "lepton", 1, 0, g4ePDGcode,
112 true, -1.0, NULL,
113 false, "mu", g4ePDGcode, -1.0011659208 * muBmuon
114 );
115 // Copied from G4PionPlus.cc
116 new G4ParticleDefinition(
117 "g4e_pi+", 0.1395700 * CLHEP::GeV, 2.5284e-14 * CLHEP::MeV, +1.0 * CLHEP::eplus,
118 0, -1, 0,
119 2, +2, -1,
120 "meson", 0, 0, g4ePDGcode,
121 true, -1.0, NULL,
122 false, "pi", g4ePDGcode
123 );
124 // Copied from G4PionMinus.cc
125 new G4ParticleDefinition(
126 "g4e_pi-", 0.1395700 * CLHEP::GeV, 2.5284e-14 * CLHEP::MeV, -1.0 * CLHEP::eplus,
127 0, -1, 0,
128 2, -2, -1,
129 "meson", 0, 0, g4ePDGcode,
130 true, -1.0, NULL,
131 false, "pi", g4ePDGcode
132 );
133 // Copied from G4KaonPlus.cc
134 new G4ParticleDefinition(
135 "g4e_kaon+", 0.493677 * CLHEP::GeV, 5.315e-14 * CLHEP::MeV, +1.0 * CLHEP::eplus,
136 0, -1, 0,
137 1, +1, 0,
138 "meson", 0, 0, g4ePDGcode,
139 true, -1.0, NULL,
140 false, "kaon", g4ePDGcode
141 );
142 // Copied from G4KaonMinus.cc
143 new G4ParticleDefinition(
144 "g4e_kaon-", 0.493677 * CLHEP::GeV, 5.315e-14 * CLHEP::MeV, -1.0 * CLHEP::eplus,
145 0, -1, 0,
146 1, -1, 0,
147 "meson", 0, 0, g4ePDGcode,
148 true, -1.0, NULL,
149 false, "kaon", g4ePDGcode
150 );
151 // Copied from G4Proton.cc except use G4ParticleDefinition instead of G4Ions
152 new G4ParticleDefinition(
153 "g4e_proton", 0.9382723 * CLHEP::GeV, 0.0 * CLHEP::MeV, +1.0 * CLHEP::eplus,
154 1, +1, 0,
155 1, +1, 0,
156 "baryon", 0, +1, g4ePDGcode,
157 true, -1.0, NULL,
158 false, "nucleon", g4ePDGcode, 2.792847351 * muNucleon
159 );
160 // Copied from G4AntiProton.cc except use G4ParticleDefinition instead of G4Ions
161 new G4ParticleDefinition(
162 "g4e_anti_proton", 0.9382723 * CLHEP::GeV, 0.0 * CLHEP::MeV, -1.0 * CLHEP::eplus,
163 1, +1, 0,
164 1, -1, 0,
165 "baryon", 0, -1, g4ePDGcode,
166 true, -1.0, NULL,
167 false, "nucleon", g4ePDGcode, -2.792847351 * muNucleon
168 );
169 // copied from G4Deuteron.hh except use G4ParticleDefinition instead of G4Ions
170 new G4ParticleDefinition(
171 "g4e_deuteron", 1.875613 * CLHEP::GeV, 0.0 * CLHEP::MeV, +1.0 * CLHEP::eplus,
172 2, +1, 0,
173 0, 0, 0,
174 "nucleus", 0, +2, g4ePDGcode,
175 true, -1.0, NULL,
176 false, "static", g4ePDGcode, 0.857438230 * muNucleon
177
178 );
179 // copied from G4AntiDeuteron.hh except use G4ParticleDefinition instead of G4Ions
180 new G4ParticleDefinition(
181 "g4e_anti_deuteron", 1.875613 * CLHEP::GeV, 0.0 * CLHEP::MeV, -1.0 * CLHEP::eplus,
182 2, +1, 0,
183 0, 0, 0,
184 "anti_nucleus", 0, -2, g4ePDGcode,
185 true, -1.0, NULL,
186 false, "static", g4ePDGcode, -0.857438230 * muNucleon
187 );
188
189 }
190}
191
193{
194 // Define the limited set of processes that will be suffered by the
195 // geant4e-specific particles
200 G4ParticleTable* myParticleTable = G4ParticleTable::GetParticleTable();
201 // theParticleIterator is a Geant4 macro since version 10.
202 G4ParticleTable::G4PTblDicIterator* myParticleIterator = myParticleTable->GetIterator();
203 myParticleIterator->reset();
204 while ((*myParticleIterator)()) {
205 G4ParticleDefinition* particle = myParticleIterator->value();
206 G4ProcessManager* pmanager = particle->GetProcessManager();
207 G4String particleName = particle->GetParticleName();
208 if (particleName.compare(0, 4, "g4e_") == 0) {
209 if (particleName == "g4e_gamma") {
210 pmanager->AddDiscreteProcess(new G4GammaConversion());
211 pmanager->AddDiscreteProcess(new G4ComptonScattering());
212 pmanager->AddDiscreteProcess(new G4PhotoElectricEffect());
213 } else {
214 pmanager->AddContinuousProcess(m_ELossProcess, 1);
215 pmanager->AddDiscreteProcess(m_StepLengthLimitProcess, 2);
216 pmanager->AddDiscreteProcess(m_MagFieldLimitProcess, 3);
217 }
218 }
219 }
220}
221
Define physics process to calculate energy loss without fluctuations.
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 ...
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.