Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4eIonisationSpectrum Class Reference

#include <G4eIonisationSpectrum.hh>

Inheritance diagram for G4eIonisationSpectrum:

Public Member Functions

 G4eIonisationSpectrum ()
 ~G4eIonisationSpectrum ()
G4double Probability (G4int Z, G4double tMin, G4double tMax, G4double kineticEnergy, G4int shell, const G4ParticleDefinition *pd=0) const
G4double AverageEnergy (G4int Z, G4double tMin, G4double tMax, G4double kineticEnergy, G4int shell, const G4ParticleDefinition *pd=0) const
G4double SampleEnergy (G4int Z, G4double tMin, G4double tMax, G4double kineticEnergy, G4int shell, const G4ParticleDefinition *pd=0) const
G4double MaxEnergyOfSecondaries (G4double kineticEnergy, G4int Z=0, const G4ParticleDefinition *pd=0) const
G4double Excitation (G4int Z, G4double e) const
void PrintData () const
Public Member Functions inherited from G4VEnergySpectrum
 G4VEnergySpectrum ()
virtual ~G4VEnergySpectrum ()
 G4VEnergySpectrum (const G4VEnergySpectrum &)=delete
G4VEnergySpectrumoperator= (const G4VEnergySpectrum &right)=delete

Detailed Description

Definition at line 63 of file G4eIonisationSpectrum.hh.

Constructor & Destructor Documentation

◆ G4eIonisationSpectrum()

G4eIonisationSpectrum::G4eIonisationSpectrum ( )

Definition at line 61 of file G4eIonisationSpectrum.cc.

62 lowestE(0.1*eV),
63 factor(1.3),
64 iMax(24),
65 verbose(0)
66{
67 theParam = new G4eIonisationParameters();
68}

◆ ~G4eIonisationSpectrum()

G4eIonisationSpectrum::~G4eIonisationSpectrum ( )

Definition at line 71 of file G4eIonisationSpectrum.cc.

72{
73 delete theParam;
74}

Member Function Documentation

◆ AverageEnergy()

G4double G4eIonisationSpectrum::AverageEnergy ( G4int Z,
G4double tMin,
G4double tMax,
G4double kineticEnergy,
G4int shell,
const G4ParticleDefinition * pd = 0 ) const
virtual

Implements G4VEnergySpectrum.

Definition at line 169 of file G4eIonisationSpectrum.cc.

175{
176 // Please comment what AverageEnergy does and what are the three
177 // functions mentioned below
178 // Describe the algorithms used
179
181 G4double t0 = std::max(tMin, lowestE);
182 G4double tm = std::min(tMax, eMax);
183 if(t0 >= tm) return 0.0;
184
186 Shell(Z, shell)->BindingEnergy();
187
188 if(e <= bindingEnergy) return 0.0;
189
191
192 G4double x1 = std::min(0.5,(t0 + bindingEnergy)/energy);
193 G4double x2 = std::min(0.5,(tm + bindingEnergy)/energy);
194
195 if(verbose > 1) {
196 G4cout << "G4eIonisationSpectrum::AverageEnergy: Z= " << Z
197 << "; shell= " << shell
198 << "; E(keV)= " << e/keV
199 << "; bindingE(keV)= " << bindingEnergy/keV
200 << "; x1= " << x1
201 << "; x2= " << x2
202 << G4endl;
203 }
204
205 G4DataVector p;
206
207 // Access parameters
208 for (G4int i=0; i<iMax; i++)
209 {
210 G4double x = theParam->Parameter(Z, shell, i, e);
211 if(i<4) x /= energy;
212 p.push_back(x);
213 }
214
215 if(p[3] > 0.5) p[3] = 0.5;
216
217 G4double gLocal2 = energy/electron_mass_c2 + 1.;
218 p.push_back((2.0*gLocal2 - 1.0)/(gLocal2*gLocal2));
219
220
221 //Add protection against division by zero: actually in Function()
222 //parameter p[3] appears in the denominator. Bug report 1042
223 if (p[3] > 0)
224 p[iMax-1] = Function(p[3], p);
225 else
226 {
227 G4cout << "WARNING: G4eIonisationSpectrum::AverageEnergy "
228 << "parameter p[3] <= 0. G4LEDATA dabatase might be corrupted for Z = "
229 << Z << ". Please check and/or update it " << G4endl;
230 }
231
232 G4double val = AverageValue(x1, x2, p);
233 G4double x0 = (lowestE + bindingEnergy)/energy;
234 G4double nor = IntSpectrum(x0, 0.5, p);
235 val *= energy;
236
237 if(verbose > 1) {
238 G4cout << "tcut(MeV)= " << tMin/MeV
239 << "; tMax(MeV)= " << tMax/MeV
240 << "; x0= " << x0
241 << "; x1= " << x1
242 << "; x2= " << x2
243 << "; val= " << val
244 << "; nor= " << nor
245 << "; sum= " << p[0]
246 << "; a= " << p[1]
247 << "; b= " << p[2]
248 << "; c= " << p[3]
249 << G4endl;
250 }
251
252 p.clear();
253
254 if(nor > 0.0) val /= nor;
255 else val = 0.0;
256
257 return val;
258}
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
static G4AtomicTransitionManager * Instance()
G4double MaxEnergyOfSecondaries(G4double kineticEnergy, G4int Z=0, const G4ParticleDefinition *pd=0) const
G4double energy(const ThreeVector &p, const G4double m)
G4double bindingEnergy(G4int A, G4int Z)

◆ Excitation()

G4double G4eIonisationSpectrum::Excitation ( G4int Z,
G4double e ) const
inlinevirtual

Implements G4VEnergySpectrum.

Definition at line 128 of file G4eIonisationSpectrum.hh.

129{
130 return theParam->Excitation(Z, e);
131}

◆ MaxEnergyOfSecondaries()

G4double G4eIonisationSpectrum::MaxEnergyOfSecondaries ( G4double kineticEnergy,
G4int Z = 0,
const G4ParticleDefinition * pd = 0 ) const
virtual

Implements G4VEnergySpectrum.

Definition at line 597 of file G4eIonisationSpectrum.cc.

600{
601 return 0.5 * kineticEnergy;
602}

Referenced by AverageEnergy(), Probability(), and SampleEnergy().

◆ PrintData()

void G4eIonisationSpectrum::PrintData ( ) const
virtual

Implements G4VEnergySpectrum.

Definition at line 592 of file G4eIonisationSpectrum.cc.

593{
594 theParam->PrintData();
595}

◆ Probability()

G4double G4eIonisationSpectrum::Probability ( G4int Z,
G4double tMin,
G4double tMax,
G4double kineticEnergy,
G4int shell,
const G4ParticleDefinition * pd = 0 ) const
virtual

Implements G4VEnergySpectrum.

Definition at line 77 of file G4eIonisationSpectrum.cc.

83{
84 // Please comment what Probability does and what are the three
85 // functions mentioned below
86 // Describe the algorithms used
87
89 G4double t0 = std::max(tMin, lowestE);
90 G4double tm = std::min(tMax, eMax);
91 if(t0 >= tm) return 0.0;
92
94 Shell(Z, shell)->BindingEnergy();
95
96 if(e <= bindingEnergy) return 0.0;
97
99
100 G4double x1 = std::min(0.5,(t0 + bindingEnergy)/energy);
101 G4double x2 = std::min(0.5,(tm + bindingEnergy)/energy);
102
103 if (verbose > 1) {
104 G4cout << "G4eIonisationSpectrum::Probability: Z= " << Z
105 << "; shell= " << shell
106 << "; E(keV)= " << e/keV
107 << "; Eb(keV)= " << bindingEnergy/keV
108 << "; x1= " << x1
109 << "; x2= " << x2
110 << G4endl;
111
112 }
113
114 G4DataVector p;
115
116 // Access parameters
117 for (G4int i=0; i<iMax; i++)
118 {
119 G4double x = theParam->Parameter(Z, shell, i, e);
120 if(i<4) x /= energy;
121 p.push_back(x);
122 }
123
124 if(p[3] > 0.5) p[3] = 0.5;
125
126 G4double gLocal = energy/electron_mass_c2 + 1.;
127 p.push_back((2.0*gLocal - 1.0)/(gLocal*gLocal));
128
129 //Add protection against division by zero: actually in Function()
130 //parameter p[3] appears in the denominator. Bug report 1042
131 if (p[3] > 0)
132 p[iMax-1] = Function(p[3], p);
133 else
134 {
135 G4cout << "WARNING: G4eIonisationSpectrum::Probability "
136 << "parameter p[3] <= 0. G4LEDATA dabatase might be corrupted for Z = "
137 << Z << ". Please check and/or update it " << G4endl;
138 }
139
140 G4double val = IntSpectrum(x1, x2, p);
141 G4double x0 = (lowestE + bindingEnergy)/energy;
142 G4double nor = IntSpectrum(x0, 0.5, p);
143
144 if (verbose > 1) {
145 G4cout << "tcut= " << tMin
146 << "; tMax= " << tMax
147 << "; x0= " << x0
148 << "; x1= " << x1
149 << "; x2= " << x2
150 << "; val= " << val
151 << "; nor= " << nor
152 << "; sum= " << p[0]
153 << "; a= " << p[1]
154 << "; b= " << p[2]
155 << "; c= " << p[3]
156 << G4endl;
157 if(shell == 1) G4cout << "============" << G4endl;
158 }
159
160 p.clear();
161
162 if(nor > 0.0) val /= nor;
163 else val = 0.0;
164
165 return val;
166}

◆ SampleEnergy()

G4double G4eIonisationSpectrum::SampleEnergy ( G4int Z,
G4double tMin,
G4double tMax,
G4double kineticEnergy,
G4int shell,
const G4ParticleDefinition * pd = 0 ) const
virtual

Implements G4VEnergySpectrum.

Definition at line 261 of file G4eIonisationSpectrum.cc.

267{
268 // Please comment what SampleEnergy does
269 G4double tDelta = 0.0;
270 G4double t0 = std::max(tMin, lowestE);
271 G4double tm = std::min(tMax, MaxEnergyOfSecondaries(e));
272 if(t0 > tm) return tDelta;
273
275 Shell(Z, shell)->BindingEnergy();
276
277 if(e <= bindingEnergy) return 0.0;
278
280
281 G4double x1 = std::min(0.5,(t0 + bindingEnergy)/energy);
282 G4double x2 = std::min(0.5,(tm + bindingEnergy)/energy);
283 if(x1 >= x2) return tDelta;
284
285 if(verbose > 1) {
286 G4cout << "G4eIonisationSpectrum::SampleEnergy: Z= " << Z
287 << "; shell= " << shell
288 << "; E(keV)= " << e/keV
289 << G4endl;
290 }
291
292 // Access parameters
293 G4DataVector p;
294
295 // Access parameters
296 for (G4int i=0; i<iMax; i++)
297 {
298 G4double x = theParam->Parameter(Z, shell, i, e);
299 if(i<4) x /= energy;
300 p.push_back(x);
301 }
302
303 if(p[3] > 0.5) p[3] = 0.5;
304
305 G4double gLocal3 = energy/electron_mass_c2 + 1.;
306 p.push_back((2.0*gLocal3 - 1.0)/(gLocal3*gLocal3));
307
308
309 //Add protection against division by zero: actually in Function()
310 //parameter p[3] appears in the denominator. Bug report 1042
311 if (p[3] > 0)
312 p[iMax-1] = Function(p[3], p);
313 else
314 {
315 G4cout << "WARNING: G4eIonisationSpectrum::SampleSpectrum "
316 << "parameter p[3] <= 0. G4LEDATA dabatase might be corrupted for Z = "
317 << Z << ". Please check and/or update it " << G4endl;
318 }
319
320 G4double aria1 = 0.0;
321 G4double a1 = std::max(x1,p[1]);
322 G4double a2 = std::min(x2,p[3]);
323 if(a1 < a2) aria1 = IntSpectrum(a1, a2, p);
324 G4double aria2 = 0.0;
325 G4double a3 = std::max(x1,p[3]);
326 G4double a4 = x2;
327 if(a3 < a4) aria2 = IntSpectrum(a3, a4, p);
328
329 G4double aria = (aria1 + aria2)*G4UniformRand();
330 G4double amaj, fun, q, x, z1, z2, dx, dx1;
331
332 //======= First aria to sample =====
333
334 if(aria <= aria1) {
335
336 amaj = p[4];
337 for (G4int j=5; j<iMax; j++) {
338 if(p[j] > amaj) amaj = p[j];
339 }
340
341 a1 = 1./a1;
342 a2 = 1./a2;
343
344 G4int i;
345 do {
346
347 x = 1./(a2 + G4UniformRand()*(a1 - a2));
348 z1 = p[1];
349 z2 = p[3];
350 dx = (p[2] - p[1]) / 3.0;
351 dx1= G4Exp(std::log(p[3]/p[2]) / 16.0);
352 for (i=4; i<iMax-1; i++) {
353
354 if (i < 7) {
355 z2 = z1 + dx;
356 } else if(iMax-2 == i) {
357 z2 = p[3];
358 break;
359 } else {
360 z2 = z1*dx1;
361 }
362 if(x >= z1 && x <= z2) break;
363 z1 = z2;
364 }
365 fun = p[i] + (x - z1) * (p[i+1] - p[i])/(z2 - z1);
366
367 if(fun > amaj) {
368 G4cout << "WARNING in G4eIonisationSpectrum::SampleEnergy:"
369 << " Majoranta " << amaj
370 << " < " << fun
371 << " in the first aria at x= " << x
372 << G4endl;
373 }
374
375 q = amaj*G4UniformRand();
376
377 } while (q >= fun);
378
379 //======= Second aria to sample =====
380
381 } else {
382
383 amaj = std::max(p[iMax-1], Function(0.5, p)) * factor;
384 a1 = 1./a3;
385 a2 = 1./a4;
386
387 do {
388
389 x = 1./(a2 + G4UniformRand()*(a1 - a2));
390 fun = Function(x, p);
391
392 if(fun > amaj) {
393 G4cout << "WARNING in G4eIonisationSpectrum::SampleEnergy:"
394 << " Majoranta " << amaj
395 << " < " << fun
396 << " in the second aria at x= " << x
397 << G4endl;
398 }
399
400 q = amaj*G4UniformRand();
401
402 } while (q >= fun);
403
404 }
405
406 p.clear();
407
408 tDelta = x*energy - bindingEnergy;
409
410 if(verbose > 1) {
411 G4cout << "tcut(MeV)= " << tMin/MeV
412 << "; tMax(MeV)= " << tMax/MeV
413 << "; x1= " << x1
414 << "; x2= " << x2
415 << "; a1= " << a1
416 << "; a2= " << a2
417 << "; x= " << x
418 << "; be= " << bindingEnergy
419 << "; e= " << e
420 << "; tDelta= " << tDelta
421 << G4endl;
422 }
423
424
425 return tDelta;
426}
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition G4Exp.hh:132
#define G4UniformRand()
Definition Randomize.hh:52

The documentation for this class was generated from the following files: