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