Belle II Software development
EnergyLossForExtrapolator.h
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#pragma once
10
11#include <CLHEP/Units/SystemOfUnits.h>
12
13#include <globals.hh>
14#include <G4PhysicsTable.hh>
15#include <G4DataVector.hh>
16#include <vector>
17
18class G4ParticleDefinition;
19class G4Material;
20class G4MaterialCutsCouple;
21class G4ProductionCuts;
22
23namespace Belle2 {
28
29 namespace Simulation {
30
33
34 public:
35
38
41
43 G4double ComputeDEDX(G4double kinEnergy, const G4ParticleDefinition*);
44
46 G4double ComputeRange(G4double kinEnergy, const G4ParticleDefinition*);
47
49 G4double ComputeEnergy(G4double range, const G4ParticleDefinition*);
50
52 G4double EnergyAfterStep(G4double kinEnergy, G4double step,
53 const G4Material*, const G4ParticleDefinition*);
54
56 G4double EnergyBeforeStep(G4double kinEnergy, G4double step,
57 const G4Material*, const G4ParticleDefinition*);
58
60 G4double TrueStepLength(G4double kinEnergy, G4double step,
61 const G4Material*, const G4ParticleDefinition* part);
62
64 //- inline G4double EnergyAfterStep(G4double kinEnergy, G4double step,
65 //- const G4Material*, const G4String& particleName);
66
68 //- inline G4double EnergyBeforeStep(G4double kinEnergy, G4double step,
69 //- const G4Material*, const G4String& particleName);
70
72 inline G4double AverageScatteringAngle(G4double kinEnergy, G4double step,
73 const G4Material*,
74 const G4ParticleDefinition* part);
75
77 //- inline G4double AverageScatteringAngle(G4double kinEnergy, G4double step,
78 //- const G4Material*,
79 //- const G4String& particleName);
80
82 inline G4double ComputeTrueStep(const G4Material*, const G4ParticleDefinition* part,
83 G4double kinEnergy, G4double stepLength);
84
86 //- inline G4double EnergyDispersion(G4double kinEnergy, G4double step,
87 //- const G4Material*, const G4ParticleDefinition*);
88
90 //- inline G4double EnergyDispersion(G4double kinEnergy, G4double step,
91 //- const G4Material*, const G4String& particleName);
92
94 //- inline void SetVerbose(G4int val);
95
97 inline void SetMinKinEnergy(G4double);
98
100 inline void SetMaxKinEnergy(G4double);
101
103 inline void SetMaxEnergyTransfer(G4double);
104
105 private:
106
109 void Initialisation();
110
112 G4bool SetupKinematics(const G4ParticleDefinition*, const G4Material*,
113 G4double kinEnergy);
114
116 G4PhysicsTable* PrepareTable();
117
119 const G4ParticleDefinition* FindParticle(const G4String& name);
120
122 void ComputeElectronDEDX(const G4ParticleDefinition* part, G4PhysicsTable* table);
123
125 void ComputeMuonDEDX(const G4ParticleDefinition* part, G4PhysicsTable* table);
126
128 void ComputeHadronDEDX(const G4ParticleDefinition* part, G4PhysicsTable* table);
129
131 void ComputeTransportXS(const G4ParticleDefinition* part, G4PhysicsTable* table);
132
134 inline G4double ComputeValue(G4double x, const G4PhysicsTable* table);
135
138
141
143 const G4ParticleDefinition* m_Particle;
144
146 const G4ParticleDefinition* m_Electron;
147
149 const G4ParticleDefinition* m_Positron;
150
152 const G4ParticleDefinition* m_MuonPlus;
153
155 const G4ParticleDefinition* m_MuonMinus;
156
158 const G4ParticleDefinition* m_PionPlus;
159
161 const G4ParticleDefinition* m_PionMinus;
162
164 const G4ParticleDefinition* m_KaonPlus;
165
167 const G4ParticleDefinition* m_KaonMinus;
168
170 const G4ParticleDefinition* m_Proton;
171
173 const G4ParticleDefinition* m_AntiProton;
174
176 const G4ParticleDefinition* m_Deuteron;
177
179 const G4ParticleDefinition* m_AntiDeuteron;
180
182 G4DataVector m_Cuts;
183
185 G4ProductionCuts* m_ProductionCuts;
186
188 std::vector<const G4MaterialCutsCouple*> m_Couples;
189
191 G4PhysicsTable* m_DedxElectron;
192
194 G4PhysicsTable* m_DedxPositron;
195
197 G4PhysicsTable* m_DedxMuon;
198
200 G4PhysicsTable* m_DedxPion;
201
203 G4PhysicsTable* m_DedxKaon;
204
206 G4PhysicsTable* m_DedxProton;
207
209 G4PhysicsTable* m_DedxDeuteron;
210
212 G4PhysicsTable* m_RangeElectron;
213
215 G4PhysicsTable* m_RangePositron;
216
218 G4PhysicsTable* m_RangeMuon;
219
221 G4PhysicsTable* m_RangePion;
222
224 G4PhysicsTable* m_RangeKaon;
225
227 G4PhysicsTable* m_RangeProton;
228
230 G4PhysicsTable* m_RangeDeuteron;
231
233 G4PhysicsTable* m_InvRangeElectron;
234
236 G4PhysicsTable* m_InvRangePositron;
237
239 G4PhysicsTable* m_InvRangeMuon;
240
242 G4PhysicsTable* m_InvRangePion;
243
245 G4PhysicsTable* m_InvRangeKaon;
246
248 G4PhysicsTable* m_InvRangeProton;
249
251 G4PhysicsTable* m_InvRangeDeuteron;
252
254 G4PhysicsTable* m_MscatElectron;
255
257 const G4Material* m_Material;
258
261
264
266 G4double m_RadLength;
267
269 G4double m_Mass;
270
272 G4double m_ChargeSq;
273
276
278 G4double m_Gamma;
279
282
284 G4double m_BetaSq;
285
287 G4double m_Tmax;
288
291
293 G4double m_UserTmin;
294
296 G4double m_UserTmax;
297
300
302 G4int m_Nbins;
303
306
309 };
310
311 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
312
313 //- inline G4double EnergyLossForExtrapolator::EnergyAfterStep(G4double kinEnergy,
314 //- G4double step,
315 //- const G4Material* mat,
316 //- const G4String& name)
317 //- {
318 //- return EnergyAfterStep(kinEnergy, step, mat, FindParticle(name));
319 //- }
320
321 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
322
323 //- inline G4double EnergyLossForExtrapolator::EnergyBeforeStep(G4double kinEnergy,
324 //- G4double step,
325 //- const G4Material* mat,
326 //- const G4String& name)
327 //- {
328 //- return EnergyBeforeStep(kinEnergy, step, mat, FindParticle(name));
329 //- }
330
331 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
332
333 //- inline G4double EnergyLossForExtrapolator::AverageScatteringAngle(G4double kinEnergy,
334 //- G4double step,
335 //- const G4Material* mat,
336 //- const G4String& name)
337 //- {
338 //- return AverageScatteringAngle(kinEnergy, step, mat, FindParticle(name));
339 //- }
340 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
341
342 //- inline G4double
343 //- EnergyLossForExtrapolator::EnergyDispersion(G4double kinEnergy,
344 //- G4double step,
345 //- const G4Material* mat,
346 //- const G4String& name)
347 //- {
348 //- return EnergyDispersion(kinEnergy, step, mat, FindParticle(name));
349 //- }
350
351 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
352
353 inline G4double
355 G4double stepLength,
356 const G4Material* mat,
357 const G4ParticleDefinition* part)
358 {
359 G4double theta = 0.0;
360 if (SetupKinematics(part, mat, kinEnergy)) {
361 G4double t = stepLength / m_RadLength;
362 G4double y = std::max(0.001, t);
363 theta = 19.23 * CLHEP::MeV * std::sqrt(m_ChargeSq * t) * (1.0 + 0.038 * std::log(y)) / (m_BetaSq * m_Gamma * m_Mass);
364 }
365 return theta;
366 }
367
368 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
369
370 inline G4double
372 const G4ParticleDefinition* part,
373 G4double kinEnergy,
374 G4double stepLength)
375 {
376 G4double theta = AverageScatteringAngle(kinEnergy, stepLength, mat, part);
377 return stepLength * std::sqrt(1.0 + 0.625 * theta * theta);
378 }
379
380 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
381
382 //- inline
383 //- G4double EnergyLossForExtrapolator::EnergyDispersion(G4double kinEnergy,
384 //- G4double stepLength,
385 //- const G4Material* mat,
386 //- const G4ParticleDefinition* part)
387 //- {
388 //- G4double sig2 = 0.0;
389 //- if (SetupKinematics(part, mat, kinEnergy)) {
390 //- G4double step = ComputeTrueStep(mat, part, kinEnergy, stepLength);
391 //- sig2 = (1.0 / beta2 - 0.5) * CLHEP::twopi_mc2_rcl2 * tmax * step * electronDensity * charge2;
392 //- }
393 //- return sig2;
394 //- }
395
396 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
397
398 inline G4double EnergyLossForExtrapolator::ComputeValue(G4double x,
399 const G4PhysicsTable* table)
400 {
401 G4double res = 0.0;
402 G4bool b;
403 if (table) res = ((*table)[m_MaterialIndex])->GetValue(x, b);
404 return res;
405 }
406
407 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
408
409 //- inline void EnergyLossForExtrapolator::SetVerbose(G4int val)
410 //- {
411 //- verbose = val;
412 //- }
413
414 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
415
417 {
418 m_UserTmin = val;
419 }
420
421 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
422
424 {
425 m_UserTmax = val;
426 }
427
428 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
429
431 {
433 }
434
435 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
436
437 } //end namespace Simulation
438
440} //end Belle2 namespace
const G4ParticleDefinition * m_Particle
Pointer to definition of the currently cached particle.
const G4ParticleDefinition * m_KaonPlus
Pointer to definition of the positive kaon.
G4PhysicsTable * m_DedxPion
Pointer to the pion's specific ionization energy loss vs KE table.
void Initialisation()
Initialize tables used to calculate energy loss, fluctuation, and scattering for electrons,...
G4PhysicsTable * m_DedxPositron
Pointer to the positron's specific ionization energy loss vs KE table.
G4double m_RadLength
Cached material radiation length.
void ComputeTransportXS(const G4ParticleDefinition *part, G4PhysicsTable *table)
Fill the table with the multiple-scattering cross section of a particle.
G4double m_KineticEnergy
Cached particle kinetic energy.
G4PhysicsTable * m_MscatElectron
Pointer to the electron's multiple-scattering cross section vs KE table.
G4PhysicsTable * PrepareTable()
Create a new table to store one type of kinematics data for a particle.
G4double m_UserMaxEnergyTransfer
User's upper limit on maximum kinetic-energy loss (default infinity)
G4PhysicsTable * m_InvRangeKaon
Pointer to the kaon's inverse-range vs KE table.
EnergyLossForExtrapolator & operator=(const EnergyLossForExtrapolator &right)
Hide assignment operator.
const G4ParticleDefinition * FindParticle(const G4String &name)
Get the particle definition of the named particle.
G4PhysicsTable * m_RangePositron
Pointer to the positron's range vs KE table.
G4PhysicsTable * m_DedxMuon
Pointer to the muon's specific ionization energy loss vs KE table.
G4int m_Nbins
Number of bins in each energy loss, fluctuation, and multiple-scattering table (70,...
G4PhysicsTable * m_RangeProton
Pointer to the proton's range vs KE table.
G4PhysicsTable * m_DedxKaon
Pointer to the kaon's specific ionization energy loss vs KE table.
G4PhysicsTable * m_InvRangeElectron
Pointer to the electron's inverse-range vs KE table.
const G4ParticleDefinition * m_MuonMinus
Pointer to definition of the negative muon.
G4double ComputeDEDX(G4double kinEnergy, const G4ParticleDefinition *)
Get specific ionization energy loss for the given kinetic energy and particle.
G4double m_ChargeSq
Cached charge-squared (in units of e)
G4PhysicsTable * m_RangeKaon
Pointer to the kaon's range vs KE table.
void ComputeElectronDEDX(const G4ParticleDefinition *part, G4PhysicsTable *table)
Fill the table with the specific ionization energy loss of an electron.
const G4ParticleDefinition * m_Electron
Pointer to definition of the electron.
G4double m_Tmax
Cached particle's maximum kinetic-energy loss.
G4double m_ElectronDensity
Cached material electron density.
G4double m_LinLossLimit
Step-length limit in units of range (0.01); not modifiable by user.
G4PhysicsTable * m_RangePion
Pointer to the pion's range vs KE table.
G4double EnergyAfterStep(G4double kinEnergy, G4double step, const G4Material *, const G4ParticleDefinition *)
Get kinetic energy after a step in given material by given particle.
G4double m_Gamma
Cached particle's gamma value.
const G4ParticleDefinition * m_AntiDeuteron
Pointer to definition of the antideuteron.
G4PhysicsTable * m_DedxProton
Pointer to the proton's specific ionization energy loss vs KE table.
const G4ParticleDefinition * m_Proton
Pointer to definition of the proton.
G4PhysicsTable * m_InvRangeDeuteron
Pointer to the deuteron's inverse-range vs KE table.
void SetMaxKinEnergy(G4double)
Change the maximum particle kinetic energy for this class (default is 10 TeV)
G4PhysicsTable * m_InvRangePositron
Pointer to the positron's inverse-range vs KE table.
G4double TrueStepLength(G4double kinEnergy, G4double step, const G4Material *, const G4ParticleDefinition *part)
Get true step length for given particle and kinetic energy.
const G4ParticleDefinition * m_AntiProton
Pointer to definition of the antiproton.
G4bool m_Initialised
UNUSED Flag to indicate that Initialisation() method has been called.
G4PhysicsTable * m_InvRangeMuon
Pointer to the muon's inverse-range vs KE table.
const G4ParticleDefinition * m_KaonMinus
Pointer to definition of the negative kaon.
const G4Material * m_Material
Pointer to internally cached material.
G4PhysicsTable * m_RangeElectron
Pointer to the electron's range vs KE table.
const G4ParticleDefinition * m_PionMinus
Pointer to definition of the negative pion.
void ComputeHadronDEDX(const G4ParticleDefinition *part, G4PhysicsTable *table)
Fill the table with the specific ionization energy loss of a hadron.
G4PhysicsTable * m_InvRangePion
Pointer to the pion's inverse-range vs KE table.
G4PhysicsTable * m_InvRangeProton
Pointer to the proton's inverse-range vs KE table.
void ComputeMuonDEDX(const G4ParticleDefinition *part, G4PhysicsTable *table)
Fill the table with the specific ionization energy loss of a muon.
G4PhysicsTable * m_DedxElectron
Pointer to the electron's specific ionization energy loss vs KE table.
G4double ComputeEnergy(G4double range, const G4ParticleDefinition *)
Get kinetic energy corresponding to the given range and particle.
EnergyLossForExtrapolator()
Constructor (WITHOUT GEANT4 verbosity flag)
const G4ParticleDefinition * m_Deuteron
Pointer to definition of the deuteron.
const G4ParticleDefinition * m_MuonPlus
Pointer to definition of the positive muon.
G4double ComputeValue(G4double x, const G4PhysicsTable *table)
Get the tabulated energy-loss, fluctuation, or scattering value for the given input.
G4bool SetupKinematics(const G4ParticleDefinition *, const G4Material *, G4double kinEnergy)
Save current particle properties, kinetic energy and material in internal cached state.
G4PhysicsTable * m_RangeMuon
Pointer to the muon's range vs KE table.
G4double m_UserTmin
User's minimum kinetic energy for particles (default 1 MeV)
G4double ComputeTrueStep(const G4Material *, const G4ParticleDefinition *part, G4double kinEnergy, G4double stepLength)
Get average scattering angle after a step in given material by given particle.
G4double EnergyBeforeStep(G4double kinEnergy, G4double step, const G4Material *, const G4ParticleDefinition *)
Get kinetic energy before a step in given material by given particle.
G4PhysicsTable * m_DedxDeuteron
Pointer to the deuteron's specific ionization energy loss vs KE table.
G4int m_NMaterials
Number of materials in current geometry.
void SetMaxEnergyTransfer(G4double)
Change the maximum energy loss or gain for this class (default is infinity)
std::vector< const G4MaterialCutsCouple * > m_Couples
List of material-cuts pairings.
void SetMinKinEnergy(G4double)
Get energy dispersion for a step in given material by given particle.
EnergyLossForExtrapolator(const EnergyLossForExtrapolator &)
Hide copy-assignment operator.
G4double m_BetaSq
Cached particle's beta squared.
const G4ParticleDefinition * m_Positron
Pointer to definition of the positron.
G4double AverageScatteringAngle(G4double kinEnergy, G4double step, const G4Material *, const G4ParticleDefinition *part)
Get kinetic energy after a step in given material by given particle.
G4double ComputeRange(G4double kinEnergy, const G4ParticleDefinition *)
Get range for the given kinetic energy and particle.
G4PhysicsTable * m_RangeDeuteron
Pointer to the deuteron's range vs KE table.
const G4ParticleDefinition * m_PionPlus
Pointer to definition of the positive pion.
G4ProductionCuts * m_ProductionCuts
Pointer to the internal cache of default G4ProductionCuts.
G4double m_UserTmax
User's maximum kinetic energy for particles (default 10 TeV)
G4double m_BetaGammaSq
Cached particle's beta*gamma squared.
Abstract base class for different kinds of events.