Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PenelopeComptonModel.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//
27// Author: Luciano Pandola
28//
29// History:
30// --------
31// 15 Feb 2010 L Pandola Implementation
32// 18 Mar 2010 L Pandola Removed GetAtomsPerMolecule(), now demanded
33// to G4PenelopeOscillatorManager
34// 01 Feb 2011 L Pandola Suppress fake energy-violation warning when Auger is
35// active.
36// Make sure that fluorescence/Auger is generated only
37// if above threshold
38// 24 May 2011 L Pandola Renamed (make v2008 as default Penelope)
39// 10 Jun 2011 L Pandola Migrate atomic deexcitation interface
40// 09 Oct 2013 L Pandola Migration to MT
41// 25 Jul 2023 D Iuso Fix for possible infinite loops due to FP
42//
45#include "G4SystemOfUnits.hh"
48#include "G4DynamicParticle.hh"
49#include "G4VEMDataSet.hh"
50#include "G4PhysicsTable.hh"
51#include "G4PhysicsLogVector.hh"
53#include "G4AtomicShell.hh"
54#include "G4Gamma.hh"
55#include "G4Electron.hh"
58#include "G4LossTableManager.hh"
59#include "G4Exp.hh"
60
61//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
62
64 const G4String& nam)
65 :G4VEmModel(nam),fParticleChange(nullptr),fParticle(nullptr),
66 fAtomDeexcitation(nullptr),
67 fOscManager(nullptr),fIsInitialised(false)
68{
69 fIntrinsicLowEnergyLimit = 100.0*eV;
70 fIntrinsicHighEnergyLimit = 100.0*GeV;
71 SetHighEnergyLimit(fIntrinsicHighEnergyLimit);
72 //
74
75 if (part)
76 SetParticle(part);
77
78 fVerboseLevel= 0;
79 // Verbosity scale:
80 // 0 = nothing
81 // 1 = warning for energy non-conservation
82 // 2 = details of energy budget
83 // 3 = calculation of cross sections, file openings, sampling of atoms
84 // 4 = entering in methods
85
86 //Mark this model as "applicable" for atomic deexcitation
88
89 fTransitionManager = G4AtomicTransitionManager::Instance();
90}
91
92//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
93
96
97//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
98
100 const G4DataVector&)
101{
102 if (fVerboseLevel > 3)
103 G4cout << "Calling G4PenelopeComptonModel::Initialise()" << G4endl;
104
105 fAtomDeexcitation = G4LossTableManager::Instance()->AtomDeexcitation();
106 //Issue warning if the AtomicDeexcitation has not been declared
107 if (!fAtomDeexcitation)
108 {
109 G4cout << G4endl;
110 G4cout << "WARNING from G4PenelopeComptonModel " << G4endl;
111 G4cout << "Atomic de-excitation module is not instantiated, so there will not be ";
112 G4cout << "any fluorescence/Auger emission." << G4endl;
113 G4cout << "Please make sure this is intended" << G4endl;
114 }
115
116 SetParticle(part);
117
118 if (IsMaster() && part == fParticle)
119 {
120
121 if (fVerboseLevel > 0)
122 {
123 G4cout << "Penelope Compton model v2008 is initialized " << G4endl
124 << "Energy range: "
125 << LowEnergyLimit() / keV << " keV - "
126 << HighEnergyLimit() / GeV << " GeV";
127 }
128 //Issue a warning, if the model is going to be used down to a
129 //energy which is outside the validity of the model itself
130 if (LowEnergyLimit() < fIntrinsicLowEnergyLimit)
131 {
133 ed << "Using the Penelope Compton model outside its intrinsic validity range. "
134 << G4endl;
135 ed << "-> LowEnergyLimit() in process = " << LowEnergyLimit()/keV << "keV " << G4endl;
136 ed << "-> Instrinsic low-energy limit = " << fIntrinsicLowEnergyLimit/keV << "keV "
137 << G4endl;
138 ed << "Result of the simulation have to be taken with care" << G4endl;
139 G4Exception("G4PenelopeComptonModel::Initialise()",
140 "em2100",JustWarning,ed);
141 }
142 }
143
144 if(fIsInitialised) return;
146 fIsInitialised = true;
147
148}
149
150//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
151
153 G4VEmModel *masterModel)
154{
155 if (fVerboseLevel > 3)
156 G4cout << "Calling G4PenelopeComptonModel::InitialiseLocal()" << G4endl;
157 //
158 //Check that particle matches: one might have multiple master models (e.g.
159 //for e+ and e-).
160 //
161 if (part == fParticle)
162 {
163 //Get the const table pointers from the master to the workers
164 const G4PenelopeComptonModel* theModel =
165 static_cast<G4PenelopeComptonModel*> (masterModel);
166
167 //Same verbosity for all workers, as the master
168 fVerboseLevel = theModel->fVerboseLevel;
169 }
170 return;
171}
172
173
174//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
175
177 const G4ParticleDefinition* p,
178 G4double energy,
179 G4double,
180 G4double)
181{
182 // Penelope model v2008 to calculate the Compton scattering cross section:
183 // D. Brusa et al., Nucl. Instrum. Meth. A 379 (1996) 167
184 //
185 // The cross section for Compton scattering is calculated according to the Klein-Nishina
186 // formula for energy > 5 MeV.
187 // For E < 5 MeV it is used a parametrization for the differential cross-section dSigma/dOmega,
188 // which is integrated numerically in cos(theta), G4PenelopeComptonModel::DifferentialCrossSection().
189 // The parametrization includes the J(p)
190 // distribution profiles for the atomic shells, that are tabulated from Hartree-Fock calculations
191 // from F. Biggs et al., At. Data Nucl. Data Tables 16 (1975) 201
192 //
193 if (fVerboseLevel > 3)
194 G4cout << "Calling CrossSectionPerVolume() of G4PenelopeComptonModel" << G4endl;
195 SetupForMaterial(p, material, energy);
196
197 G4double cs = 0;
198 //Force null cross-section if below the low-energy edge of the table
199 if (energy < LowEnergyLimit())
200 return cs;
201
202 //Retrieve the oscillator table for this material
203 G4PenelopeOscillatorTable* theTable = fOscManager->GetOscillatorTableCompton(material);
204
205 if (energy < 5*MeV) //explicit calculation for E < 5 MeV
206 {
207 size_t numberOfOscillators = theTable->size();
208 for (size_t i=0;i<numberOfOscillators;i++)
209 {
210 G4PenelopeOscillator* theOsc = (*theTable)[i];
211 //sum contributions coming from each oscillator
212 cs += OscillatorTotalCrossSection(energy,theOsc);
213 }
214 }
215 else //use Klein-Nishina for E>5 MeV
216 cs = KleinNishinaCrossSection(energy,material);
217
218 //cross sections are in units of pi*classic_electr_radius^2
219 cs *= pi*classic_electr_radius*classic_electr_radius;
220
221 //Now, cs is the cross section *per molecule*, let's calculate the
222 //cross section per volume
223 G4double atomDensity = material->GetTotNbOfAtomsPerVolume();
224 G4double atPerMol = fOscManager->GetAtomsPerMolecule(material);
225
226 if (fVerboseLevel > 3)
227 G4cout << "Material " << material->GetName() << " has " << atPerMol <<
228 "atoms per molecule" << G4endl;
229
230 G4double moleculeDensity = 0.;
231
232 if (atPerMol)
233 moleculeDensity = atomDensity/atPerMol;
234
235 G4double csvolume = cs*moleculeDensity;
236
237 if (fVerboseLevel > 2)
238 G4cout << "Compton mean free path at " << energy/keV << " keV for material " <<
239 material->GetName() << " = " <<
240 (csvolume ? (1./csvolume)/mm : DBL_MAX) << " mm" << G4endl;
241 return csvolume;
242}
243
244//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
245
246//This is a dummy method. Never inkoved by the tracking, it just issues
247//a warning if one tries to get Cross Sections per Atom via the
248//G4EmCalculator.
250 G4double,
251 G4double,
252 G4double,
253 G4double,
254 G4double)
255{
256 G4cout << "*** G4PenelopeComptonModel -- WARNING ***" << G4endl;
257 G4cout << "Penelope Compton model v2008 does not calculate cross section _per atom_ " << G4endl;
258 G4cout << "so the result is always zero. For physics values, please invoke " << G4endl;
259 G4cout << "GetCrossSectionPerVolume() or GetMeanFreePath() via the G4EmCalculator" << G4endl;
260 return 0;
261}
262
263//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
264
265void G4PenelopeComptonModel::SampleSecondaries(std::vector<G4DynamicParticle*>* fvect,
266 const G4MaterialCutsCouple* couple,
267 const G4DynamicParticle* aDynamicGamma,
268 G4double,
269 G4double)
270{
271 // Penelope model v2008 to sample the Compton scattering final state.
272 // D. Brusa et al., Nucl. Instrum. Meth. A 379 (1996) 167
273 // The model determines also the original shell from which the electron is expelled,
274 // in order to produce fluorescence de-excitation (from G4DeexcitationManager)
275 //
276 // The final state for Compton scattering is calculated according to the Klein-Nishina
277 // formula for energy > 5 MeV. In this case, the Doppler broadening is negligible and
278 // one can assume that the target electron is at rest.
279 // For E < 5 MeV it is used the parametrization for the differential cross-section dSigma/dOmega,
280 // to sample the scattering angle and the energy of the emerging electron, which is
281 // G4PenelopeComptonModel::DifferentialCrossSection(). The rejection method is
282 // used to sample cos(theta). The efficiency increases monotonically with photon energy and is
283 // nearly independent on the Z; typical values are 35%, 80% and 95% for 1 keV, 1 MeV and 10 MeV,
284 // respectively.
285 // The parametrization includes the J(p) distribution profiles for the atomic shells, that are
286 // tabulated
287 // from Hartree-Fock calculations from F. Biggs et al., At. Data Nucl. Data Tables 16 (1975) 201.
288 // Doppler broadening is included.
289 //
290
291 if (fVerboseLevel > 3)
292 G4cout << "Calling SampleSecondaries() of G4PenelopeComptonModel" << G4endl;
293
294 G4double photonEnergy0 = aDynamicGamma->GetKineticEnergy();
295
296 // do nothing below the threshold
297 // should never get here because the XS is zero below the limit
298 if(photonEnergy0 < LowEnergyLimit())
299 return;
300
301 G4ParticleMomentum photonDirection0 = aDynamicGamma->GetMomentumDirection();
302 const G4Material* material = couple->GetMaterial();
303
304 G4PenelopeOscillatorTable* theTable = fOscManager->GetOscillatorTableCompton(material);
305
306 const G4int nmax = 64;
307 G4double rn[nmax]={0.0};
308 G4double pac[nmax]={0.0};
309
310 G4double S=0.0;
311 G4double epsilon = 0.0;
312 G4double cosTheta = 1.0;
313 G4double hartreeFunc = 0.0;
314 G4double oscStren = 0.0;
315 size_t numberOfOscillators = theTable->size();
316 size_t targetOscillator = 0;
317 G4double ionEnergy = 0.0*eV;
318
319 G4double ek = photonEnergy0/electron_mass_c2;
320 G4double ek2 = 2.*ek+1.0;
321 G4double eks = ek*ek;
322 G4double ek1 = eks-ek2-1.0;
323
324 G4double taumin = 1.0/ek2;
325 //This is meant to fix a possible (rare) floating point exception in the sampling of tau below,
326 //causing an infinite loop. The maximum of tau is not 1., but the closest double which can
327 //be represented (i.e. ~ 1. - 1e-16). Fix by Domenico Iuso
328 static G4double taumax = std::nexttoward(1.0,0.0);
329 if (fVerboseLevel > 3)
330 G4cout << "G4PenelopeComptonModel: maximum value of tau: 1 - " << 1.-taumax << G4endl;
331 //To here.
332 G4double a1 = G4Log(ek2);
333 G4double a2 = a1+2.0*ek*(1.0+ek)/(ek2*ek2);
334
335 G4double TST = 0;
336 G4double tau = 0.;
337
338 //If the incoming photon is above 5 MeV, the quicker approach based on the
339 //pure Klein-Nishina formula is used
340 if (photonEnergy0 > 5*MeV)
341 {
342 do{
343 do{
344 if ((a2*G4UniformRand()) < a1)
345 tau = std::pow(taumin,G4UniformRand());
346 else
347 tau = std::sqrt(1.0+G4UniformRand()*(taumin*taumin-1.0));
348 //rejection function
349 TST = (1.0+tau*(ek1+tau*(ek2+tau*eks)))/(eks*tau*(1.0+tau*tau));
350 }while (G4UniformRand()> TST);
351 if (tau > taumax) tau = taumax; //prevent FP exception causing infinite loop
352 epsilon=tau;
353 cosTheta = 1.0 - (1.0-tau)/(ek*tau);
354
355 //Target shell electrons
356 TST = fOscManager->GetTotalZ(material)*G4UniformRand();
357 targetOscillator = numberOfOscillators-1; //last level
358 S=0.0;
359 G4bool levelFound = false;
360 for (size_t j=0;j<numberOfOscillators && !levelFound; j++)
361 {
362 S += (*theTable)[j]->GetOscillatorStrength();
363 if (S > TST)
364 {
365 targetOscillator = j;
366 levelFound = true;
367 }
368 }
369 //check whether the level is valid
370 ionEnergy = (*theTable)[targetOscillator]->GetIonisationEnergy();
371 }while((epsilon*photonEnergy0-photonEnergy0+ionEnergy) >0);
372 }
373 else //photonEnergy0 < 5 MeV
374 {
375 //Incoherent scattering function for theta=PI
376 G4double s0=0.0;
377 G4double pzomc=0.0;
378 G4double rni=0.0;
379 G4double aux=0.0;
380 for (size_t i=0;i<numberOfOscillators;i++)
381 {
382 ionEnergy = (*theTable)[i]->GetIonisationEnergy();
383 if (photonEnergy0 > ionEnergy)
384 {
385 G4double aux2 = photonEnergy0*(photonEnergy0-ionEnergy)*2.0;
386 hartreeFunc = (*theTable)[i]->GetHartreeFactor();
387 oscStren = (*theTable)[i]->GetOscillatorStrength();
388 pzomc = hartreeFunc*(aux2-electron_mass_c2*ionEnergy)/
389 (electron_mass_c2*std::sqrt(2.0*aux2+ionEnergy*ionEnergy));
390 if (pzomc > 0)
391 rni = 1.0-0.5*G4Exp(0.5-(std::sqrt(0.5)+std::sqrt(2.0)*pzomc)*
392 (std::sqrt(0.5)+std::sqrt(2.0)*pzomc));
393 else
394 rni = 0.5*G4Exp(0.5-(std::sqrt(0.5)-std::sqrt(2.0)*pzomc)*
395 (std::sqrt(0.5)-std::sqrt(2.0)*pzomc));
396 s0 += oscStren*rni;
397 }
398 }
399 //Sampling tau
400 G4double cdt1 = 0.;
401 do
402 {
403 if ((G4UniformRand()*a2) < a1)
404 tau = std::pow(taumin,G4UniformRand());
405 else
406 tau = std::sqrt(1.0+G4UniformRand()*(taumin*taumin-1.0));
407 if (tau > taumax) tau = taumax; //prevent FP exception causing infinite loop
408 cdt1 = (1.0-tau)/(ek*tau);
409 //Incoherent scattering function
410 S = 0.;
411 for (size_t i=0;i<numberOfOscillators;i++)
412 {
413 ionEnergy = (*theTable)[i]->GetIonisationEnergy();
414 if (photonEnergy0 > ionEnergy) //sum only on excitable levels
415 {
416 aux = photonEnergy0*(photonEnergy0-ionEnergy)*cdt1;
417 hartreeFunc = (*theTable)[i]->GetHartreeFactor();
418 oscStren = (*theTable)[i]->GetOscillatorStrength();
419 pzomc = hartreeFunc*(aux-electron_mass_c2*ionEnergy)/
420 (electron_mass_c2*std::sqrt(2.0*aux+ionEnergy*ionEnergy));
421 if (pzomc > 0)
422 rn[i] = 1.0-0.5*G4Exp(0.5-(std::sqrt(0.5)+std::sqrt(2.0)*pzomc)*
423 (std::sqrt(0.5)+std::sqrt(2.0)*pzomc));
424 else
425 rn[i] = 0.5*G4Exp(0.5-(std::sqrt(0.5)-std::sqrt(2.0)*pzomc)*
426 (std::sqrt(0.5)-std::sqrt(2.0)*pzomc));
427 S += oscStren*rn[i];
428 pac[i] = S;
429 }
430 else
431 pac[i] = S-1e-6;
432 }
433 //Rejection function
434 TST = S*(1.0+tau*(ek1+tau*(ek2+tau*eks)))/(eks*tau*(1.0+tau*tau));
435 }while ((G4UniformRand()*s0) > TST);
436
437 cosTheta = 1.0 - cdt1;
438 G4double fpzmax=0.0,fpz=0.0;
439 G4double A=0.0;
440 //Target electron shell
441 do
442 {
443 do
444 {
445 TST = S*G4UniformRand();
446 targetOscillator = numberOfOscillators-1; //last level
447 G4bool levelFound = false;
448 for (size_t i=0;i<numberOfOscillators && !levelFound;i++)
449 {
450 if (pac[i]>TST)
451 {
452 targetOscillator = i;
453 levelFound = true;
454 }
455 }
456 A = G4UniformRand()*rn[targetOscillator];
457 hartreeFunc = (*theTable)[targetOscillator]->GetHartreeFactor();
458 oscStren = (*theTable)[targetOscillator]->GetOscillatorStrength();
459 if (A < 0.5)
460 pzomc = (std::sqrt(0.5)-std::sqrt(0.5-G4Log(2.0*A)))/
461 (std::sqrt(2.0)*hartreeFunc);
462 else
463 pzomc = (std::sqrt(0.5-G4Log(2.0-2.0*A))-std::sqrt(0.5))/
464 (std::sqrt(2.0)*hartreeFunc);
465 } while (pzomc < -1);
466
467 // F(EP) rejection
468 G4double XQC = 1.0+tau*(tau-2.0*cosTheta);
469 G4double AF = std::sqrt(XQC)*(1.0+tau*(tau-cosTheta)/XQC);
470 if (AF > 0)
471 fpzmax = 1.0+AF*0.2;
472 else
473 fpzmax = 1.0-AF*0.2;
474 fpz = 1.0+AF*std::max(std::min(pzomc,0.2),-0.2);
475 }while ((fpzmax*G4UniformRand())>fpz);
476
477 //Energy of the scattered photon
478 G4double T = pzomc*pzomc;
479 G4double b1 = 1.0-T*tau*tau;
480 G4double b2 = 1.0-T*tau*cosTheta;
481 if (pzomc > 0.0)
482 epsilon = (tau/b1)*(b2+std::sqrt(std::abs(b2*b2-b1*(1.0-T))));
483 else
484 epsilon = (tau/b1)*(b2-std::sqrt(std::abs(b2*b2-b1*(1.0-T))));
485 } //energy < 5 MeV
486
487 //Ok, the kinematics has been calculated.
488 G4double sinTheta = std::sqrt(1-cosTheta*cosTheta);
489 G4double phi = twopi * G4UniformRand() ;
490 G4double dirx = sinTheta * std::cos(phi);
491 G4double diry = sinTheta * std::sin(phi);
492 G4double dirz = cosTheta ;
493
494 // Update G4VParticleChange for the scattered photon
495 G4ThreeVector photonDirection1(dirx,diry,dirz);
496 photonDirection1.rotateUz(photonDirection0);
497 fParticleChange->ProposeMomentumDirection(photonDirection1) ;
498
499 G4double photonEnergy1 = epsilon * photonEnergy0;
500
501 if (photonEnergy1 > 0.)
502 fParticleChange->SetProposedKineticEnergy(photonEnergy1) ;
503 else
504 {
505 fParticleChange->SetProposedKineticEnergy(0.) ;
506 fParticleChange->ProposeTrackStatus(fStopAndKill);
507 }
508
509 //Create scattered electron
510 G4double diffEnergy = photonEnergy0*(1-epsilon);
511 ionEnergy = (*theTable)[targetOscillator]->GetIonisationEnergy();
512
513 G4double Q2 =
514 photonEnergy0*photonEnergy0+photonEnergy1*(photonEnergy1-2.0*photonEnergy0*cosTheta);
515 G4double cosThetaE = 0.; //scattering angle for the electron
516
517 if (Q2 > 1.0e-12)
518 cosThetaE = (photonEnergy0-photonEnergy1*cosTheta)/std::sqrt(Q2);
519 else
520 cosThetaE = 1.0;
521 G4double sinThetaE = std::sqrt(1-cosThetaE*cosThetaE);
522
523 //Now, try to handle fluorescence
524 //Notice: merged levels are indicated with Z=0 and flag=30
525 G4int shFlag = (*theTable)[targetOscillator]->GetShellFlag();
526 G4int Z = (G4int) (*theTable)[targetOscillator]->GetParentZ();
527
528 //initialize here, then check photons created by Atomic-Deexcitation, and the final state e-
529 G4double bindingEnergy = 0.*eV;
530 const G4AtomicShell* shell = 0;
531
532 //Real level
533 if (Z > 0 && shFlag<30)
534 {
535 shell = fTransitionManager->Shell(Z,shFlag-1);
536 bindingEnergy = shell->BindingEnergy();
537 }
538
539 G4double ionEnergyInPenelopeDatabase = ionEnergy;
540 //protection against energy non-conservation
541 ionEnergy = std::max(bindingEnergy,ionEnergyInPenelopeDatabase);
542
543 //subtract the excitation energy. If not emitted by fluorescence
544 //the ionization energy is deposited as local energy deposition
545 G4double eKineticEnergy = diffEnergy - ionEnergy;
546 G4double localEnergyDeposit = ionEnergy;
547 G4double energyInFluorescence = 0.; //testing purposes only
548 G4double energyInAuger = 0; //testing purposes
549
550 if (eKineticEnergy < 0)
551 {
552 //It means that there was some problem/mismatch between the two databases.
553 //Try to make it work
554 //In this case available Energy (diffEnergy) < ionEnergy
555 //Full residual energy is deposited locally
556 localEnergyDeposit = diffEnergy;
557 eKineticEnergy = 0.0;
558 }
559
560 //the local energy deposit is what remains: part of this may be spent for fluorescence.
561 //Notice: shell might be nullptr (invalid!) if shFlag=30. Must be protected
562 //Now, take care of fluorescence, if required
563 if (fAtomDeexcitation && shell)
564 {
565 G4int index = couple->GetIndex();
566 if (fAtomDeexcitation->CheckDeexcitationActiveRegion(index))
567 {
568 size_t nBefore = fvect->size();
569 fAtomDeexcitation->GenerateParticles(fvect,shell,Z,index);
570 size_t nAfter = fvect->size();
571
572 if (nAfter > nBefore) //actual production of fluorescence
573 {
574 for (size_t j=nBefore;j<nAfter;j++) //loop on products
575 {
576 G4double itsEnergy = ((*fvect)[j])->GetKineticEnergy();
577 if (itsEnergy < localEnergyDeposit) // valid secondary, generate it
578 {
579 localEnergyDeposit -= itsEnergy;
580 if (((*fvect)[j])->GetParticleDefinition() == G4Gamma::Definition())
581 energyInFluorescence += itsEnergy;
582 else if (((*fvect)[j])->GetParticleDefinition() ==
584 energyInAuger += itsEnergy;
585 }
586 else //invalid secondary: takes more than the available energy: delete it
587 {
588 delete (*fvect)[j];
589 (*fvect)[j] = nullptr;
590 }
591 }
592 }
593
594 }
595 }
596
597 //Always produce explicitly the electron
598 G4DynamicParticle* electron = 0;
599
600 G4double xEl = sinThetaE * std::cos(phi+pi);
601 G4double yEl = sinThetaE * std::sin(phi+pi);
602 G4double zEl = cosThetaE;
603 G4ThreeVector eDirection(xEl,yEl,zEl); //electron direction
604 eDirection.rotateUz(photonDirection0);
605 electron = new G4DynamicParticle (G4Electron::Electron(),
606 eDirection,eKineticEnergy) ;
607 fvect->push_back(electron);
608
609 if (localEnergyDeposit < 0) //Should not be: issue a G4Exception (warning)
610 {
611 G4Exception("G4PenelopeComptonModel::SampleSecondaries()",
612 "em2099",JustWarning,"WARNING: Negative local energy deposit");
613 localEnergyDeposit=0.;
614 }
615 fParticleChange->ProposeLocalEnergyDeposit(localEnergyDeposit);
616
617 G4double electronEnergy = 0.;
618 if (electron)
619 electronEnergy = eKineticEnergy;
620 if (fVerboseLevel > 1)
621 {
622 G4cout << "-----------------------------------------------------------" << G4endl;
623 G4cout << "Energy balance from G4PenelopeCompton" << G4endl;
624 G4cout << "Incoming photon energy: " << photonEnergy0/keV << " keV" << G4endl;
625 G4cout << "-----------------------------------------------------------" << G4endl;
626 G4cout << "Scattered photon: " << photonEnergy1/keV << " keV" << G4endl;
627 G4cout << "Scattered electron " << electronEnergy/keV << " keV" << G4endl;
628 if (energyInFluorescence)
629 G4cout << "Fluorescence x-rays: " << energyInFluorescence/keV << " keV" << G4endl;
630 if (energyInAuger)
631 G4cout << "Auger electrons: " << energyInAuger/keV << " keV" << G4endl;
632 G4cout << "Local energy deposit " << localEnergyDeposit/keV << " keV" << G4endl;
633 G4cout << "Total final state: " << (photonEnergy1+electronEnergy+energyInFluorescence+
634 localEnergyDeposit+energyInAuger)/keV <<
635 " keV" << G4endl;
636 G4cout << "-----------------------------------------------------------" << G4endl;
637 }
638 if (fVerboseLevel > 0)
639 {
640 G4double energyDiff = std::fabs(photonEnergy1+
641 electronEnergy+energyInFluorescence+
642 localEnergyDeposit+energyInAuger-photonEnergy0);
643 if (energyDiff > 0.05*keV)
644 G4cout << "Warning from G4PenelopeCompton: problem with energy conservation: " <<
645 (photonEnergy1+electronEnergy+energyInFluorescence+energyInAuger+localEnergyDeposit)/keV <<
646 " keV (final) vs. " <<
647 photonEnergy0/keV << " keV (initial)" << G4endl;
648 }
649}
650
651//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
652
653G4double G4PenelopeComptonModel::DifferentialCrossSection(G4double cosTheta,G4double energy,
655{
656 //
657 // Penelope model v2008. Single differential cross section *per electron*
658 // for photon Compton scattering by
659 // electrons in the given atomic oscillator, differential in the direction of the
660 // scattering photon. This is in units of pi*classic_electr_radius**2
661 //
662 // D. Brusa et al., Nucl. Instrum. Meth. A 379 (1996) 167
663 // The parametrization includes the J(p) distribution profiles for the atomic shells,
664 // that are tabulated from Hartree-Fock calculations
665 // from F. Biggs et al., At. Data Nucl. Data Tables 16 (1975) 201
666 //
667 G4double ionEnergy = osc->GetIonisationEnergy();
668 G4double harFunc = osc->GetHartreeFactor();
669
670 static const G4double k2 = std::sqrt(2.);
671 static const G4double k1 = 1./k2;
672
673 if (energy < ionEnergy)
674 return 0;
675
676 //energy of the Compton line
677 G4double cdt1 = 1.0-cosTheta;
678 G4double EOEC = 1.0+(energy/electron_mass_c2)*cdt1;
679 G4double ECOE = 1.0/EOEC;
680
681 //Incoherent scattering function (analytical profile)
682 G4double aux = energy*(energy-ionEnergy)*cdt1;
683 G4double Pzimax =
684 (aux - electron_mass_c2*ionEnergy)/(electron_mass_c2*std::sqrt(2*aux+ionEnergy*ionEnergy));
685 G4double sia = 0.0;
686 G4double x = harFunc*Pzimax;
687 if (x > 0)
688 sia = 1.0-0.5*G4Exp(0.5-(k1+k2*x)*(k1+k2*x));
689 else
690 sia = 0.5*G4Exp(0.5-(k1-k2*x)*(k1-k2*x));
691
692 //1st order correction, integral of Pz times the Compton profile.
693 //Calculated approximately using a free-electron gas profile
694 G4double pf = 3.0/(4.0*harFunc);
695 if (std::fabs(Pzimax) < pf)
696 {
697 G4double QCOE2 = 1.0+ECOE*ECOE-2.0*ECOE*cosTheta;
698 G4double p2 = Pzimax*Pzimax;
699 G4double dspz = std::sqrt(QCOE2)*
700 (1.0+ECOE*(ECOE-cosTheta)/QCOE2)*harFunc
701 *0.25*(2*p2-(p2*p2)/(pf*pf)-(pf*pf));
702 sia += std::max(dspz,-1.0*sia);
703 }
704
705 G4double XKN = EOEC+ECOE-1.0+cosTheta*cosTheta;
706
707 //Differential cross section (per electron, in units of pi*classic_electr_radius**2)
708 G4double diffCS = ECOE*ECOE*XKN*sia;
709
710 return diffCS;
711}
712
713//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
714
715G4double G4PenelopeComptonModel::OscillatorTotalCrossSection(G4double energy,G4PenelopeOscillator* osc)
716{
717 //Total cross section (integrated) for the given oscillator in units of
718 //pi*classic_electr_radius^2
719
720 //Integrate differential cross section for each oscillator
721 G4double stre = osc->GetOscillatorStrength();
722
723 // here one uses the using the 20-point
724 // Gauss quadrature method with an adaptive bipartition scheme
725 const G4int npoints=10;
726 const G4int ncallsmax=20000;
727 const G4int nst=256;
728 static const G4double Abscissas[10] = {7.652651133497334e-02,2.2778585114164508e-01,3.7370608871541956e-01,
729 5.1086700195082710e-01,6.3605368072651503e-01,7.4633190646015079e-01,
730 8.3911697182221882e-01,9.1223442825132591e-01,9.6397192727791379e-01,
731 9.9312859918509492e-01};
732 static const G4double Weights[10] = {1.5275338713072585e-01,1.4917298647260375e-01,1.4209610931838205e-01,
733 1.3168863844917663e-01,1.1819453196151842e-01,1.0193011981724044e-01,
734 8.3276741576704749e-02,6.2672048334109064e-02,4.0601429800386941e-02,
735 1.7614007139152118e-02};
736
737 G4double MaxError = 1e-5;
738 //Error control
739 G4double Ctol = std::min(std::max(MaxError,1e-13),1e-02);
740 G4double Ptol = 0.01*Ctol;
741 G4double Err=1e35;
742
743 //Gauss integration from -1 to 1
744 G4double LowPoint = -1.0;
745 G4double HighPoint = 1.0;
746
747 G4double h=HighPoint-LowPoint;
748 G4double sumga=0.0;
749 G4double a=0.5*(HighPoint-LowPoint);
750 G4double b=0.5*(HighPoint+LowPoint);
751 G4double c=a*Abscissas[0];
752 G4double d= Weights[0]*
753 (DifferentialCrossSection(b+c,energy,osc)+DifferentialCrossSection(b-c,energy,osc));
754 for (G4int i=2;i<=npoints;i++)
755 {
756 c=a*Abscissas[i-1];
757 d += Weights[i-1]*
758 (DifferentialCrossSection(b+c,energy,osc)+DifferentialCrossSection(b-c,energy,osc));
759 }
760 G4int icall = 2*npoints;
761 G4int LH=1;
762 G4double S[nst],x[nst],sn[nst],xrn[nst];
763 S[0]=d*a;
764 x[0]=LowPoint;
765
766 G4bool loopAgain = true;
767
768 //Adaptive bipartition scheme
769 do{
770 G4double h0=h;
771 h=0.5*h; //bipartition
772 G4double sumr=0;
773 G4int LHN=0;
774 G4double si,xa,xb,xc;
775 for (G4int i=1;i<=LH;i++){
776 si=S[i-1];
777 xa=x[i-1];
778 xb=xa+h;
779 xc=xa+h0;
780 a=0.5*(xb-xa);
781 b=0.5*(xb+xa);
782 c=a*Abscissas[0];
783 G4double dLocal = Weights[0]*
784 (DifferentialCrossSection(b+c,energy,osc)+DifferentialCrossSection(b-c,energy,osc));
785
786 for (G4int j=1;j<npoints;j++)
787 {
788 c=a*Abscissas[j];
789 dLocal += Weights[j]*
790 (DifferentialCrossSection(b+c,energy,osc)+DifferentialCrossSection(b-c,energy,osc));
791 }
792 G4double s1=dLocal*a;
793 a=0.5*(xc-xb);
794 b=0.5*(xc+xb);
795 c=a*Abscissas[0];
796 dLocal=Weights[0]*
797 (DifferentialCrossSection(b+c,energy,osc)+DifferentialCrossSection(b-c,energy,osc));
798
799 for (G4int j=1;j<npoints;j++)
800 {
801 c=a*Abscissas[j];
802 dLocal += Weights[j]*
803 (DifferentialCrossSection(b+c,energy,osc)+DifferentialCrossSection(b-c,energy,osc));
804 }
805 G4double s2=dLocal*a;
806 icall=icall+4*npoints;
807 G4double s12=s1+s2;
808 if (std::abs(s12-si)<std::max(Ptol*std::abs(s12),1e-35))
809 sumga += s12;
810 else
811 {
812 sumr += s12;
813 LHN += 2;
814 sn[LHN-1]=s2;
815 xrn[LHN-1]=xb;
816 sn[LHN-2]=s1;
817 xrn[LHN-2]=xa;
818 }
819
820 if (icall>ncallsmax || LHN>nst)
821 {
822 G4cout << "G4PenelopeComptonModel: " << G4endl;
823 G4cout << "LowPoint: " << LowPoint << ", High Point: " << HighPoint << G4endl;
824 G4cout << "Tolerance: " << MaxError << G4endl;
825 G4cout << "Calls: " << icall << ", Integral: " << sumga << ", Error: " << Err << G4endl;
826 G4cout << "Number of open subintervals: " << LHN << G4endl;
827 G4cout << "WARNING: the required accuracy has not been attained" << G4endl;
828 loopAgain = false;
829 }
830 }
831 Err=std::abs(sumr)/std::max(std::abs(sumr+sumga),1e-35);
832 if (Err < Ctol || LHN == 0)
833 loopAgain = false; //end of cycle
834 LH=LHN;
835 for (G4int i=0;i<LH;i++)
836 {
837 S[i]=sn[i];
838 x[i]=xrn[i];
839 }
840 }while(Ctol < 1.0 && loopAgain);
841
842 G4double xs = stre*sumga;
843
844 return xs;
845}
846
847//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
848
849G4double G4PenelopeComptonModel::KleinNishinaCrossSection(G4double energy,
850 const G4Material* material)
851{
852 // use Klein-Nishina formula
853 // total cross section in units of pi*classic_electr_radius^2
854 G4double cs = 0;
855
856 G4double ek =energy/electron_mass_c2;
857 G4double eks = ek*ek;
858 G4double ek2 = 1.0+ek+ek;
859 G4double ek1 = eks-ek2-1.0;
860
861 G4double t0 = 1.0/ek2;
862 G4double csl = 0.5*eks*t0*t0+ek2*t0+ek1*G4Log(t0)-(1.0/t0);
863
864 G4PenelopeOscillatorTable* theTable = fOscManager->GetOscillatorTableCompton(material);
865
866 for (size_t i=0;i<theTable->size();i++)
867 {
868 G4PenelopeOscillator* theOsc = (*theTable)[i];
869 G4double ionEnergy = theOsc->GetIonisationEnergy();
870 G4double tau=(energy-ionEnergy)/energy;
871 if (tau > t0)
872 {
873 G4double csu = 0.5*eks*tau*tau+ek2*tau+ek1*G4Log(tau)-(1.0/tau);
874 G4double stre = theOsc->GetOscillatorStrength();
875
876 cs += stre*(csu-csl);
877 }
878 }
879 cs /= (ek*eks);
880
881 return cs;
882
883}
884
885//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...
886
887void G4PenelopeComptonModel::SetParticle(const G4ParticleDefinition* p)
888{
889 if(!fParticle) {
890 fParticle = p;
891 }
892}
G4double epsilon(G4double density, G4double temperature)
G4double S(G4double temp)
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition G4Exp.hh:132
G4double G4Log(G4double x)
Definition G4Log.hh:169
G4ThreeVector G4ParticleMomentum
std::vector< G4PenelopeOscillator * > G4PenelopeOscillatorTable
CLHEP::Hep3Vector G4ThreeVector
@ fStopAndKill
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
const G4double A[17]
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
#define G4UniformRand()
Definition Randomize.hh:52
Hep3Vector & rotateUz(const Hep3Vector &)
static G4AtomicTransitionManager * Instance()
const G4ThreeVector & GetMomentumDirection() const
G4double GetKineticEnergy() const
static G4Electron * Definition()
Definition G4Electron.cc:45
static G4Electron * Electron()
Definition G4Electron.cc:91
static G4Gamma * Definition()
Definition G4Gamma.cc:43
static G4LossTableManager * Instance()
G4VAtomDeexcitation * AtomDeexcitation()
const G4Material * GetMaterial() const
G4double GetTotNbOfAtomsPerVolume() const
const G4String & GetName() const
G4ParticleChangeForGamma * fParticleChange
void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy) override
const G4ParticleDefinition * fParticle
G4PenelopeComptonModel(const G4ParticleDefinition *p=nullptr, const G4String &processName="PenCompton")
G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double, G4double, G4double, G4double, G4double) override
G4double CrossSectionPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX) override
void InitialiseLocal(const G4ParticleDefinition *, G4VEmModel *masterModel) override
void Initialise(const G4ParticleDefinition *, const G4DataVector &) override
static G4PenelopeOscillatorManager * GetOscillatorManager()
void SetHighEnergyLimit(G4double)
G4ParticleChangeForGamma * GetParticleChangeForGamma()
G4double LowEnergyLimit() const
G4bool IsMaster() const
G4double HighEnergyLimit() const
virtual void SetupForMaterial(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
void SetDeexcitationFlag(G4bool val)
G4VEmModel(const G4String &nam)
Definition G4VEmModel.cc:67
G4double energy(const ThreeVector &p, const G4double m)
#define DBL_MAX
Definition templates.hh:62