Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4MuPairProductionModel.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// $Id$
27//
28// -------------------------------------------------------------------
29//
30// GEANT4 Class file
31//
32//
33// File name: G4MuPairProductionModel
34//
35// Author: Vladimir Ivanchenko on base of Laszlo Urban code
36//
37// Creation date: 24.06.2002
38//
39// Modifications:
40//
41// 04-12-02 Change G4DynamicParticle constructor in PostStep (V.Ivanchenko)
42// 23-12-02 Change interface in order to move to cut per region (V.Ivanchenko)
43// 24-01-03 Fix for compounds (V.Ivanchenko)
44// 27-01-03 Make models region aware (V.Ivanchenko)
45// 13-02-03 Add model (V.Ivanchenko)
46// 06-06-03 Fix in cross section calculation for high energy (V.Ivanchenko)
47// 20-10-03 2*xi in ComputeDDMicroscopicCrossSection (R.Kokoulin)
48// 8 integration points in ComputeDMicroscopicCrossSection
49// 12-01-04 Take min cut of e- and e+ not its sum (V.Ivanchenko)
50// 10-02-04 Update parameterisation using R.Kokoulin model (V.Ivanchenko)
51// 28-04-04 For complex materials repeat calculation of max energy for each
52// material (V.Ivanchenko)
53// 01-11-04 Fix bug inside ComputeDMicroscopicCrossSection (R.Kokoulin)
54// 08-04-05 Major optimisation of internal interfaces (V.Ivantchenko)
55// 03-08-05 Add SetParticle method (V.Ivantchenko)
56// 23-10-05 Add protection in sampling of e+e- pair energy needed for
57// low cuts (V.Ivantchenko)
58// 13-02-06 Add ComputeCrossSectionPerAtom (mma)
59// 24-04-07 Add protection in SelectRandomAtom method (V.Ivantchenko)
60// 12-05-06 Updated sampling (use cut) in SelectRandomAtom (A.Bogdanov)
61// 11-10-07 Add ignoreCut flag (V.Ivanchenko)
62
63//
64// Class Description:
65//
66//
67// -------------------------------------------------------------------
68//
69//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71
74#include "G4SystemOfUnits.hh"
75#include "G4Electron.hh"
76#include "G4Positron.hh"
77#include "G4MuonMinus.hh"
78#include "G4MuonPlus.hh"
79#include "Randomize.hh"
80#include "G4Material.hh"
81#include "G4Element.hh"
82#include "G4ElementVector.hh"
86
87//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
88
89// static members
90//
91G4double G4MuPairProductionModel::zdat[]={1., 4., 13., 29., 92.};
92G4double G4MuPairProductionModel::adat[]={1.01, 9.01, 26.98, 63.55, 238.03};
93G4double G4MuPairProductionModel::tdat[]={1.e3, 1.e4, 1.e5, 1.e6, 1.e7, 1.e8,
94 1.e9, 1.e10};
95G4double G4MuPairProductionModel::xgi[]={ 0.0199, 0.1017, 0.2372, 0.4083,
96 0.5917, 0.7628, 0.8983, 0.9801 };
97G4double G4MuPairProductionModel::wgi[]={ 0.0506, 0.1112, 0.1569, 0.1813,
98 0.1813, 0.1569, 0.1112, 0.0506 };
99
100//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
101
102using namespace std;
103
105 const G4String& nam)
106 : G4VEmModel(nam),
107 particle(0),
108 factorForCross(4.*fine_structure_const*fine_structure_const
109 *classic_electr_radius*classic_electr_radius/(3.*pi)),
110 sqrte(sqrt(exp(1.))),
111 currentZ(0),
112 fParticleChange(0),
113 minPairEnergy(4.*electron_mass_c2),
114 lowestKinEnergy(GeV),
115 nzdat(5),
116 ntdat(8),
117 nbiny(1000),
118 nmaxElements(0),
119 ymin(-5.),
120 ymax(0.),
121 dy((ymax-ymin)/nbiny),
122 samplingTablesAreFilled(false)
123{
124 SetLowEnergyLimit(minPairEnergy);
126
127 theElectron = G4Electron::Electron();
128 thePositron = G4Positron::Positron();
129
130 particleMass = lnZ = z13 = z23 = 0;
131
132 for(size_t i=0; i<1001; ++i) { ya[i] = 0.0; }
133
134 if(p) { SetParticle(p); }
135}
136
137//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
138
140{}
141
142//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
143
145 const G4MaterialCutsCouple* )
146{
147 return minPairEnergy;
148}
149
150//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
151
153 G4double kineticEnergy)
154{
155 G4double maxPairEnergy = kineticEnergy + particleMass*(1.0 - 0.75*sqrte*z13);
156 return maxPairEnergy;
157}
158
159//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
160
162 const G4DataVector&)
163{
164 if (!samplingTablesAreFilled) {
165 if(p) { SetParticle(p); }
166 MakeSamplingTables();
167 }
168 if(!fParticleChange) { fParticleChange = GetParticleChangeForLoss(); }
169}
170
171//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
172
174 const G4Material* material,
176 G4double kineticEnergy,
177 G4double cutEnergy)
178{
179 G4double dedx = 0.0;
180 if (cutEnergy <= minPairEnergy || kineticEnergy <= lowestKinEnergy)
181 { return dedx; }
182
183 const G4ElementVector* theElementVector = material->GetElementVector();
184 const G4double* theAtomicNumDensityVector =
185 material->GetAtomicNumDensityVector();
186
187 // loop for elements in the material
188 for (size_t i=0; i<material->GetNumberOfElements(); ++i) {
189 G4double Z = (*theElementVector)[i]->GetZ();
191 G4double tmax = MaxSecondaryEnergy(particle, kineticEnergy);
192 G4double loss = ComputMuPairLoss(Z, kineticEnergy, cutEnergy, tmax);
193 dedx += loss*theAtomicNumDensityVector[i];
194 }
195 if (dedx < 0.) { dedx = 0.; }
196 return dedx;
197}
198
199//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
200
202 G4double tkin,
203 G4double cutEnergy,
204 G4double tmax)
205{
207 G4double loss = 0.0;
208
209 G4double cut = std::min(cutEnergy,tmax);
210 if(cut <= minPairEnergy) { return loss; }
211
212 // calculate the rectricted loss
213 // numerical integration in log(PairEnergy)
214 G4double ak1=6.9;
215 G4double ak2=1.0;
216 G4double aaa = log(minPairEnergy);
217 G4double bbb = log(cut);
218 G4int kkk = (G4int)((bbb-aaa)/ak1+ak2);
219 if (kkk > 8) kkk = 8;
220 G4double hhh = (bbb-aaa)/(G4double)kkk;
221 G4double x = aaa;
222
223 for (G4int l=0 ; l<kkk; l++)
224 {
225
226 for (G4int ll=0; ll<8; ll++)
227 {
228 G4double ep = exp(x+xgi[ll]*hhh);
229 loss += wgi[ll]*ep*ep*ComputeDMicroscopicCrossSection(tkin, Z, ep);
230 }
231 x += hhh;
232 }
233 loss *= hhh;
234 if (loss < 0.) loss = 0.;
235 return loss;
236}
237
238//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
239
241 G4double tkin,
242 G4double Z,
243 G4double cut)
244{
245 G4double cross = 0.;
248 if (tmax <= cut) { return cross; }
249
250 G4double ak1=6.9 ;
251 G4double ak2=1.0 ;
252 G4double aaa = log(cut);
253 G4double bbb = log(tmax);
254 G4int kkk = (G4int)((bbb-aaa)/ak1 + ak2);
255 if(kkk > 8) { kkk = 8; }
256 G4double hhh = (bbb-aaa)/G4double(kkk);
257 G4double x = aaa;
258
259 for(G4int l=0; l<kkk; ++l)
260 {
261 for(G4int i=0; i<8; ++i)
262 {
263 G4double ep = exp(x + xgi[i]*hhh);
264 cross += ep*wgi[i]*ComputeDMicroscopicCrossSection(tkin, Z, ep);
265 }
266 x += hhh;
267 }
268
269 cross *= hhh;
270 if(cross < 0.0) { cross = 0.0; }
271 return cross;
272}
273
275 G4double tkin,
276 G4double Z,
277 G4double pairEnergy)
278 // Calculates the differential (D) microscopic cross section
279 // using the cross section formula of R.P. Kokoulin (18/01/98)
280 // Code modified by R.P. Kokoulin, V.N. Ivanchenko (27/01/04)
281{
282 G4double bbbtf= 183. ;
283 G4double bbbh = 202.4 ;
284 G4double g1tf = 1.95e-5 ;
285 G4double g2tf = 5.3e-5 ;
286 G4double g1h = 4.4e-5 ;
287 G4double g2h = 4.8e-5 ;
288
289 G4double totalEnergy = tkin + particleMass;
290 G4double residEnergy = totalEnergy - pairEnergy;
291 G4double massratio = particleMass/electron_mass_c2 ;
292 G4double massratio2 = massratio*massratio ;
293 G4double cross = 0.;
294
296
297 G4double c3 = 0.75*sqrte*particleMass;
298 if (residEnergy <= c3*z13) { return cross; }
299
300 G4double c7 = 4.*electron_mass_c2;
302 G4double alf = c7/pairEnergy;
303 G4double a3 = 1. - alf;
304 if (a3 <= 0.) { return cross; }
305
306 // zeta calculation
307 G4double bbb,g1,g2;
308 if( Z < 1.5 ) { bbb = bbbh ; g1 = g1h ; g2 = g2h ; }
309 else { bbb = bbbtf; g1 = g1tf; g2 = g2tf; }
310
311 G4double zeta = 0;
312 G4double zeta1 = 0.073*log(totalEnergy/(particleMass+g1*z23*totalEnergy))-0.26;
313 if ( zeta1 > 0.)
314 {
315 G4double zeta2 = 0.058*log(totalEnergy/(particleMass+g2*z13*totalEnergy))-0.14;
316 zeta = zeta1/zeta2 ;
317 }
318
319 G4double z2 = Z*(Z+zeta);
320 G4double screen0 = 2.*electron_mass_c2*sqrte*bbb/(z13*pairEnergy);
321 G4double a0 = totalEnergy*residEnergy;
322 G4double a1 = pairEnergy*pairEnergy/a0;
323 G4double bet = 0.5*a1;
324 G4double xi0 = 0.25*massratio2*a1;
325 G4double del = c8/a0;
326
327 G4double rta3 = sqrt(a3);
328 G4double tmnexp = alf/(1. + rta3) + del*rta3;
329 if(tmnexp >= 1.0) return cross;
330
331 G4double tmn = log(tmnexp);
332 G4double sum = 0.;
333
334 // Gaussian integration in ln(1-ro) ( with 8 points)
335 for (G4int i=0; i<8; ++i)
336 {
337 G4double a4 = exp(tmn*xgi[i]); // a4 = (1.-asymmetry)
338 G4double a5 = a4*(2.-a4) ;
339 G4double a6 = 1.-a5 ;
340 G4double a7 = 1.+a6 ;
341 G4double a9 = 3.+a6 ;
342 G4double xi = xi0*a5 ;
343 G4double xii = 1./xi ;
344 G4double xi1 = 1.+xi ;
345 G4double screen = screen0*xi1/a5 ;
346 G4double yeu = 5.-a6+4.*bet*a7 ;
347 G4double yed = 2.*(1.+3.*bet)*log(3.+xii)-a6-a1*(2.-a6) ;
348 G4double ye1 = 1.+yeu/yed ;
349 G4double ale=log(bbb/z13*sqrt(xi1*ye1)/(1.+screen*ye1)) ;
350 G4double cre = 0.5*log(1.+2.25*z23*xi1*ye1/massratio2) ;
351 G4double be;
352
353 if (xi <= 1.e3) be = ((2.+a6)*(1.+bet)+xi*a9)*log(1.+xii)+(a5-bet)/xi1-a9;
354 else be = (3.-a6+a1*a7)/(2.*xi);
355
356 G4double fe = (ale-cre)*be;
357 if ( fe < 0.) fe = 0. ;
358
359 G4double ymu = 4.+a6 +3.*bet*a7 ;
360 G4double ymd = a7*(1.5+a1)*log(3.+xi)+1.-1.5*a6 ;
361 G4double ym1 = 1.+ymu/ymd ;
362 G4double alm_crm = log(bbb*massratio/(1.5*z23*(1.+screen*ym1)));
363 G4double a10,bm;
364 if ( xi >= 1.e-3)
365 {
366 a10 = (1.+a1)*a5 ;
367 bm = (a7*(1.+1.5*bet)-a10*xii)*log(xi1)+xi*(a5-bet)/xi1+a10;
368 } else {
369 bm = (5.-a6+bet*a9)*(xi/2.);
370 }
371
372 G4double fm = alm_crm*bm;
373 if ( fm < 0.) fm = 0. ;
374
375 sum += wgi[i]*a4*(fe+fm/massratio2);
376 }
377
378 cross = -tmn*sum*factorForCross*z2*residEnergy/(totalEnergy*pairEnergy);
379
380 return cross;
381}
382
383//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
384
387 G4double kineticEnergy,
389 G4double cutEnergy,
390 G4double maxEnergy)
391{
392 G4double cross = 0.0;
393 if (kineticEnergy <= lowestKinEnergy) { return cross; }
394
396
397 G4double maxPairEnergy = MaxSecondaryEnergy(particle,kineticEnergy);
398 G4double tmax = std::min(maxEnergy, maxPairEnergy);
399 G4double cut = std::max(cutEnergy, minPairEnergy);
400 if (cut >= tmax) return cross;
401
402 cross = ComputeMicroscopicCrossSection (kineticEnergy, Z, cut);
403 if(tmax < kineticEnergy) {
404 cross -= ComputeMicroscopicCrossSection(kineticEnergy, Z, tmax);
405 }
406 return cross;
407}
408
409//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
410
411void G4MuPairProductionModel::MakeSamplingTables()
412{
413 for (G4int iz=0; iz<nzdat; ++iz)
414 {
415 G4double Z = zdat[iz];
417
418 for (G4int it=0; it<ntdat; ++it) {
419
420 G4double kineticEnergy = tdat[it];
421 G4double maxPairEnergy = MaxSecondaryEnergy(particle,kineticEnergy);
422 // G4cout << "Z= " << currentZ << " z13= " << z13
423 //<< " mE= " << maxPairEnergy << G4endl;
424 G4double xSec = 0.0 ;
425
426 if(maxPairEnergy > minPairEnergy) {
427
428 G4double y = ymin - 0.5*dy ;
429 G4double yy = ymin - dy ;
430 G4double x = exp(y);
431 G4double fac = exp(dy);
432 G4double dx = exp(yy)*(fac - 1.0);
433
434 G4double c = log(maxPairEnergy/minPairEnergy);
435
436 for (G4int i=0 ; i<nbiny; ++i) {
437 y += dy ;
438 if(c > 0.0) {
439 x *= fac;
440 dx*= fac;
441 G4double ep = minPairEnergy*exp(c*x) ;
442 xSec +=
443 ep*dx*ComputeDMicroscopicCrossSection(kineticEnergy, Z, ep);
444 }
445 ya[i] = y;
446 proba[iz][it][i] = xSec;
447 }
448
449 } else {
450 for (G4int i=0 ; i<nbiny; ++i) {
451 proba[iz][it][i] = xSec;
452 }
453 }
454
455 ya[nbiny]=ymax;
456 proba[iz][it][nbiny] = xSec;
457
458 }
459 }
460 samplingTablesAreFilled = true;
461}
462
463//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
464
465void
466G4MuPairProductionModel::SampleSecondaries(std::vector<G4DynamicParticle*>* vdp,
467 const G4MaterialCutsCouple* couple,
468 const G4DynamicParticle* aDynamicParticle,
469 G4double tmin,
470 G4double tmax)
471{
472 G4double kineticEnergy = aDynamicParticle->GetKineticEnergy();
473 G4double totalEnergy = kineticEnergy + particleMass;
474 G4double totalMomentum =
475 sqrt(kineticEnergy*(kineticEnergy + 2.0*particleMass));
476
477 G4ThreeVector partDirection = aDynamicParticle->GetMomentumDirection();
478
479 G4int it;
480 for(it=1; it<ntdat; ++it) { if(kineticEnergy <= tdat[it]) { break; } }
481 if(it == ntdat) { --it; }
482 G4double dt = log(kineticEnergy/tdat[it-1])/log(tdat[it]/tdat[it-1]);
483
484 // select randomly one element constituing the material
485 const G4Element* anElement =
486 SelectRandomAtom(kineticEnergy, dt, it, couple, tmin);
487 SetCurrentElement(anElement->GetZ());
488
489 // define interval of enegry transfer
490 G4double maxPairEnergy = MaxSecondaryEnergy(particle,kineticEnergy);
491 G4double maxEnergy = std::min(tmax, maxPairEnergy);
492 G4double minEnergy = std::max(tmin, minPairEnergy);
493
494 if(minEnergy >= maxEnergy) { return; }
495 //G4cout << "emin= " << minEnergy << " emax= " << maxEnergy
496 // << " minPair= " << minPairEnergy << " maxpair= " << maxPairEnergy
497 // << " ymin= " << ymin << " dy= " << dy << G4endl;
498
499 G4double logmaxmin = log(maxPairEnergy/minPairEnergy);
500
501 // select bins
502 G4int iymin = 0;
503 G4int iymax = nbiny-1;
504 if( minEnergy > minPairEnergy)
505 {
506 G4double xc = log(minEnergy/minPairEnergy)/logmaxmin;
507 iymin = (G4int)((log(xc) - ymin)/dy);
508 if(iymin >= nbiny) iymin = nbiny-1;
509 else if(iymin < 0) iymin = 0;
510 xc = log(maxEnergy/minPairEnergy)/logmaxmin;
511 iymax = (G4int)((log(xc) - ymin)/dy) + 1;
512 if(iymax >= nbiny) iymax = nbiny-1;
513 else if(iymax < 0) iymax = 0;
514 }
515
516 // sample e-e+ energy, pair energy first
517 G4int iz, iy;
518
519 for(iz=1; iz<nzdat; ++iz) { if(currentZ <= zdat[iz]) { break; } }
520 if(iz == nzdat) { --iz; }
521
522 G4double dz = log(currentZ/zdat[iz-1])/log(zdat[iz]/zdat[iz-1]);
523
524 G4double pmin = InterpolatedIntegralCrossSection(dt,dz,iz,it,iymin,currentZ);
525 G4double pmax = InterpolatedIntegralCrossSection(dt,dz,iz,it,iymax,currentZ);
526
527 G4double p = pmin+G4UniformRand()*(pmax - pmin);
528
529 // interpolate sampling vector;
530 G4double p1 = pmin;
531 G4double p2 = pmin;
532 for(iy=iymin+1; iy<=iymax; ++iy) {
533 p1 = p2;
534 p2 = InterpolatedIntegralCrossSection(dt, dz, iz, it, iy, currentZ);
535 if(p <= p2) { break; }
536 }
537 // G4cout << "iy= " << iy << " iymin= " << iymin << " iymax= "
538 // << iymax << " Z= " << currentZ << G4endl;
539 G4double y = ya[iy-1] + dy*(p - p1)/(p2 - p1);
540
541 G4double PairEnergy = minPairEnergy*exp( exp(y)*logmaxmin );
542
543 if(PairEnergy < minEnergy) { PairEnergy = minEnergy; }
544 if(PairEnergy > maxEnergy) { PairEnergy = maxEnergy; }
545
546 // sample r=(E+-E-)/PairEnergy ( uniformly .....)
547 G4double rmax =
548 (1.-6.*particleMass*particleMass/(totalEnergy*(totalEnergy-PairEnergy)))
549 *sqrt(1.-minPairEnergy/PairEnergy);
550 G4double r = rmax * (-1.+2.*G4UniformRand()) ;
551
552 // compute energies from PairEnergy,r
553 G4double ElectronEnergy = (1.-r)*PairEnergy*0.5;
554 G4double PositronEnergy = PairEnergy - ElectronEnergy;
555
556 // The angle of the emitted virtual photon is sampled
557 // according to the muon bremsstrahlung model
558
559 G4double gam = totalEnergy/particleMass;
560 G4double gmax = gam*std::min(1.0, totalEnergy/PairEnergy - 1.0);
561 G4double gmax2= gmax*gmax;
562 G4double x = G4UniformRand()*gmax2/(1.0 + gmax2);
563
564 G4double theta = sqrt(x/(1.0 - x))/gam;
565 G4double sint = sin(theta);
566 G4double phi = twopi * G4UniformRand() ;
567 G4double dirx = sint*cos(phi), diry = sint*sin(phi), dirz = cos(theta) ;
568
569 G4ThreeVector gDirection(dirx, diry, dirz);
570 gDirection.rotateUz(partDirection);
571
572 // the angles of e- and e+ assumed to be the same as virtual gamma
573
574 // create G4DynamicParticle object for the particle1
575 G4DynamicParticle* aParticle1 =
576 new G4DynamicParticle(theElectron, gDirection,
577 ElectronEnergy - electron_mass_c2);
578
579 // create G4DynamicParticle object for the particle2
580 G4DynamicParticle* aParticle2 =
581 new G4DynamicParticle(thePositron, gDirection,
582 PositronEnergy - electron_mass_c2);
583
584 // primary change
585 kineticEnergy -= (ElectronEnergy + PositronEnergy);
586 fParticleChange->SetProposedKineticEnergy(kineticEnergy);
587
588 partDirection *= totalMomentum;
589 partDirection -= (aParticle1->GetMomentum() + aParticle2->GetMomentum());
590 partDirection = partDirection.unit();
591 fParticleChange->SetProposedMomentumDirection(partDirection);
592
593 // add secondary
594 vdp->push_back(aParticle1);
595 vdp->push_back(aParticle2);
596}
597
598//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
599
600const G4Element* G4MuPairProductionModel::SelectRandomAtom(
601 G4double kinEnergy, G4double dt, G4int it,
602 const G4MaterialCutsCouple* couple, G4double tmin)
603{
604 // select randomly 1 element within the material
605
606 const G4Material* material = couple->GetMaterial();
607 size_t nElements = material->GetNumberOfElements();
608 const G4ElementVector* theElementVector = material->GetElementVector();
609 if (nElements == 1) { return (*theElementVector)[0]; }
610
611 if(nElements > nmaxElements) {
612 nmaxElements = nElements;
613 partialSum.resize(nmaxElements);
614 }
615
616 const G4double* theAtomNumDensityVector=material->GetAtomicNumDensityVector();
617
618 G4double sum = 0.0;
619 G4double dl;
620
621 size_t i;
622 for (i=0; i<nElements; ++i) {
623 G4double Z = ((*theElementVector)[i])->GetZ();
625 G4double maxPairEnergy = MaxSecondaryEnergy(particle,kinEnergy);
626 G4double minEnergy = std::max(tmin, minPairEnergy);
627 dl = 0.0;
628 if(minEnergy < maxPairEnergy) {
629
630 G4int iz;
631 for(iz=1; iz<nzdat; ++iz) {if(Z <= zdat[iz]) { break; } }
632 if(iz == nzdat) { --iz; }
633 G4double dz = log(Z/zdat[iz-1])/log(zdat[iz]/zdat[iz-1]);
634
635 G4double sigcut;
636 if(minEnergy <= minPairEnergy)
637 sigcut = 0.;
638 else
639 {
640 G4double xc = log(minEnergy/minPairEnergy)/log(maxPairEnergy/minPairEnergy);
641 G4int iy = (G4int)((log(xc) - ymin)/dy);
642 if(iy < 0) { iy = 0; }
643 if(iy >= nbiny) { iy = nbiny-1; }
644 sigcut = InterpolatedIntegralCrossSection(dt,dz,iz,it,iy, Z);
645 }
646
647 G4double sigtot = InterpolatedIntegralCrossSection(dt,dz,iz,it,nbiny,Z);
648 dl = (sigtot - sigcut)*theAtomNumDensityVector[i];
649 }
650 // protection
651 if(dl < 0.0) { dl = 0.0; }
652 sum += dl;
653 partialSum[i] = sum;
654 }
655
656 G4double rval = G4UniformRand()*sum;
657 for (i=0; i<nElements; ++i) {
658 if(rval<=partialSum[i]) { return (*theElementVector)[i]; }
659 }
660
661 return (*theElementVector)[nElements - 1];
662
663}
664
665//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
666
667
std::vector< G4Element * > G4ElementVector
G4fissionEvent * fe
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
#define G4UniformRand()
Definition: Randomize.hh:53
Hep3Vector unit() const
Hep3Vector & rotateUz(const Hep3Vector &)
Definition: ThreeVector.cc:72
const G4ThreeVector & GetMomentumDirection() const
G4double GetKineticEnergy() const
G4ThreeVector GetMomentum() const
static G4Electron * Electron()
Definition: G4Electron.cc:94
G4double GetZ() const
Definition: G4Element.hh:131
const G4Material * GetMaterial() const
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:189
size_t GetNumberOfElements() const
Definition: G4Material.hh:185
const G4double * GetAtomicNumDensityVector() const
Definition: G4Material.hh:215
G4double ComputeMicroscopicCrossSection(G4double tkin, G4double Z, G4double cut)
void SetParticle(const G4ParticleDefinition *)
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy)
G4double ComputMuPairLoss(G4double Z, G4double tkin, G4double cut, G4double tmax)
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
virtual G4double ComputeDMicroscopicCrossSection(G4double tkin, G4double Z, G4double pairEnergy)
virtual G4double MinEnergyCut(const G4ParticleDefinition *, const G4MaterialCutsCouple *)
const G4ParticleDefinition * particle
G4MuPairProductionModel(const G4ParticleDefinition *p=0, const G4String &nam="muPairProd")
virtual G4double ComputeDEDXPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy)
virtual G4double MaxSecondaryEnergy(const G4ParticleDefinition *, G4double kineticEnergy)
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double kineticEnergy, G4double Z, G4double A, G4double cutEnergy, G4double maxEnergy)
static G4NistManager * Instance()
void SetProposedKineticEnergy(G4double proposedKinEnergy)
void SetProposedMomentumDirection(const G4ThreeVector &dir)
static G4Positron * Positron()
Definition: G4Positron.cc:94
void SetLowEnergyLimit(G4double)
Definition: G4VEmModel.hh:592
G4ParticleChangeForLoss * GetParticleChangeForLoss()
Definition: G4VEmModel.cc:95