65 :
G4VEmModel(nam),fParticleChange(nullptr),fParticle(nullptr),
66 fAtomDeexcitation(nullptr),
67 fOscManager(nullptr),fIsInitialised(false)
69 fIntrinsicLowEnergyLimit = 100.0*eV;
70 fIntrinsicHighEnergyLimit = 100.0*GeV;
102 if (fVerboseLevel > 3)
103 G4cout <<
"Calling G4PenelopeComptonModel::Initialise()" <<
G4endl;
107 if (!fAtomDeexcitation)
110 G4cout <<
"WARNING from G4PenelopeComptonModel " <<
G4endl;
111 G4cout <<
"Atomic de-excitation module is not instantiated, so there will not be ";
113 G4cout <<
"Please make sure this is intended" <<
G4endl;
121 if (fVerboseLevel > 0)
123 G4cout <<
"Penelope Compton model v2008 is initialized " <<
G4endl
133 ed <<
"Using the Penelope Compton model outside its intrinsic validity range. "
136 ed <<
"-> Instrinsic low-energy limit = " << fIntrinsicLowEnergyLimit/keV <<
"keV "
138 ed <<
"Result of the simulation have to be taken with care" <<
G4endl;
139 G4Exception(
"G4PenelopeComptonModel::Initialise()",
144 if(fIsInitialised)
return;
146 fIsInitialised =
true;
155 if (fVerboseLevel > 3)
156 G4cout <<
"Calling G4PenelopeComptonModel::InitialiseLocal()" <<
G4endl;
168 fVerboseLevel = theModel->fVerboseLevel;
193 if (fVerboseLevel > 3)
194 G4cout <<
"Calling CrossSectionPerVolume() of G4PenelopeComptonModel" <<
G4endl;
207 size_t numberOfOscillators = theTable->size();
208 for (
size_t i=0;i<numberOfOscillators;i++)
212 cs += OscillatorTotalCrossSection(energy,theOsc);
216 cs = KleinNishinaCrossSection(energy,material);
219 cs *= pi*classic_electr_radius*classic_electr_radius;
226 if (fVerboseLevel > 3)
227 G4cout <<
"Material " << material->
GetName() <<
" has " << atPerMol <<
228 "atoms per molecule" <<
G4endl;
233 moleculeDensity = atomDensity/atPerMol;
235 G4double csvolume = cs*moleculeDensity;
237 if (fVerboseLevel > 2)
238 G4cout <<
"Compton mean free path at " << energy/keV <<
" keV for material " <<
239 material->
GetName() <<
" = " << (1./csvolume)/mm <<
" mm" <<
G4endl;
255 G4cout <<
"*** G4PenelopeComptonModel -- WARNING ***" <<
G4endl;
256 G4cout <<
"Penelope Compton model v2008 does not calculate cross section _per atom_ " <<
G4endl;
257 G4cout <<
"so the result is always zero. For physics values, please invoke " <<
G4endl;
258 G4cout <<
"GetCrossSectionPerVolume() or GetMeanFreePath() via the G4EmCalculator" <<
G4endl;
290 if (fVerboseLevel > 3)
291 G4cout <<
"Calling SampleSecondaries() of G4PenelopeComptonModel" <<
G4endl;
305 const G4int nmax = 64;
314 size_t numberOfOscillators = theTable->size();
315 size_t targetOscillator = 0;
318 G4double ek = photonEnergy0/electron_mass_c2;
327 static G4double taumax = std::nexttoward(1.0,0.0);
328 if (fVerboseLevel > 3)
329 G4cout <<
"G4PenelopeComptonModel: maximum value of tau: 1 - " << 1.-taumax <<
G4endl;
332 G4double a2 = a1+2.0*ek*(1.0+ek)/(ek2*ek2);
339 if (photonEnergy0 > 5*MeV)
348 TST = (1.0+tau*(ek1+tau*(ek2+tau*eks)))/(eks*tau*(1.0+tau*tau));
350 if (tau > taumax) tau = taumax;
352 cosTheta = 1.0 - (1.0-tau)/(ek*tau);
356 targetOscillator = numberOfOscillators-1;
358 G4bool levelFound =
false;
359 for (
size_t j=0;j<numberOfOscillators && !levelFound; j++)
361 S += (*theTable)[j]->GetOscillatorStrength();
364 targetOscillator = j;
369 ionEnergy = (*theTable)[targetOscillator]->GetIonisationEnergy();
370 }
while((
epsilon*photonEnergy0-photonEnergy0+ionEnergy) >0);
379 for (
size_t i=0;i<numberOfOscillators;i++)
381 ionEnergy = (*theTable)[i]->GetIonisationEnergy();
382 if (photonEnergy0 > ionEnergy)
384 G4double aux2 = photonEnergy0*(photonEnergy0-ionEnergy)*2.0;
385 hartreeFunc = (*theTable)[i]->GetHartreeFactor();
386 oscStren = (*theTable)[i]->GetOscillatorStrength();
387 pzomc = hartreeFunc*(aux2-electron_mass_c2*ionEnergy)/
388 (electron_mass_c2*std::sqrt(2.0*aux2+ionEnergy*ionEnergy));
390 rni = 1.0-0.5*
G4Exp(0.5-(std::sqrt(0.5)+std::sqrt(2.0)*pzomc)*
391 (std::sqrt(0.5)+std::sqrt(2.0)*pzomc));
393 rni = 0.5*
G4Exp(0.5-(std::sqrt(0.5)-std::sqrt(2.0)*pzomc)*
394 (std::sqrt(0.5)-std::sqrt(2.0)*pzomc));
406 if (tau > taumax) tau = taumax;
407 cdt1 = (1.0-tau)/(ek*tau);
410 for (
size_t i=0;i<numberOfOscillators;i++)
412 ionEnergy = (*theTable)[i]->GetIonisationEnergy();
413 if (photonEnergy0 > ionEnergy)
415 aux = photonEnergy0*(photonEnergy0-ionEnergy)*cdt1;
416 hartreeFunc = (*theTable)[i]->GetHartreeFactor();
417 oscStren = (*theTable)[i]->GetOscillatorStrength();
418 pzomc = hartreeFunc*(aux-electron_mass_c2*ionEnergy)/
419 (electron_mass_c2*std::sqrt(2.0*aux+ionEnergy*ionEnergy));
421 rn[i] = 1.0-0.5*
G4Exp(0.5-(std::sqrt(0.5)+std::sqrt(2.0)*pzomc)*
422 (std::sqrt(0.5)+std::sqrt(2.0)*pzomc));
424 rn[i] = 0.5*
G4Exp(0.5-(std::sqrt(0.5)-std::sqrt(2.0)*pzomc)*
425 (std::sqrt(0.5)-std::sqrt(2.0)*pzomc));
433 TST =
S*(1.0+tau*(ek1+tau*(ek2+tau*eks)))/(eks*tau*(1.0+tau*tau));
436 cosTheta = 1.0 - cdt1;
445 targetOscillator = numberOfOscillators-1;
446 G4bool levelFound =
false;
447 for (
size_t i=0;i<numberOfOscillators && !levelFound;i++)
451 targetOscillator = i;
456 hartreeFunc = (*theTable)[targetOscillator]->GetHartreeFactor();
457 oscStren = (*theTable)[targetOscillator]->GetOscillatorStrength();
459 pzomc = (std::sqrt(0.5)-std::sqrt(0.5-
G4Log(2.0*
A)))/
460 (std::sqrt(2.0)*hartreeFunc);
462 pzomc = (std::sqrt(0.5-
G4Log(2.0-2.0*
A))-std::sqrt(0.5))/
463 (std::sqrt(2.0)*hartreeFunc);
464 }
while (pzomc < -1);
467 G4double XQC = 1.0+tau*(tau-2.0*cosTheta);
468 G4double AF = std::sqrt(XQC)*(1.0+tau*(tau-cosTheta)/XQC);
473 fpz = 1.0+AF*std::max(std::min(pzomc,0.2),-0.2);
481 epsilon = (tau/b1)*(b2+std::sqrt(std::abs(b2*b2-b1*(1.0-T))));
483 epsilon = (tau/b1)*(b2-std::sqrt(std::abs(b2*b2-b1*(1.0-T))));
487 G4double sinTheta = std::sqrt(1-cosTheta*cosTheta);
489 G4double dirx = sinTheta * std::cos(phi);
490 G4double diry = sinTheta * std::sin(phi);
495 photonDirection1.
rotateUz(photonDirection0);
500 if (photonEnergy1 > 0.)
510 ionEnergy = (*theTable)[targetOscillator]->GetIonisationEnergy();
513 photonEnergy0*photonEnergy0+photonEnergy1*(photonEnergy1-2.0*photonEnergy0*cosTheta);
517 cosThetaE = (photonEnergy0-photonEnergy1*cosTheta)/std::sqrt(Q2);
520 G4double sinThetaE = std::sqrt(1-cosThetaE*cosThetaE);
524 G4int shFlag = (*theTable)[targetOscillator]->GetShellFlag();
525 G4int Z = (
G4int) (*theTable)[targetOscillator]->GetParentZ();
532 if (Z > 0 && shFlag<30)
534 shell = fTransitionManager->
Shell(Z,shFlag-1);
538 G4double ionEnergyInPenelopeDatabase = ionEnergy;
540 ionEnergy = std::max(bindingEnergy,ionEnergyInPenelopeDatabase);
544 G4double eKineticEnergy = diffEnergy - ionEnergy;
545 G4double localEnergyDeposit = ionEnergy;
549 if (eKineticEnergy < 0)
555 localEnergyDeposit = diffEnergy;
556 eKineticEnergy = 0.0;
562 if (fAtomDeexcitation && shell)
567 size_t nBefore = fvect->size();
569 size_t nAfter = fvect->size();
571 if (nAfter > nBefore)
573 for (
size_t j=nBefore;j<nAfter;j++)
575 G4double itsEnergy = ((*fvect)[j])->GetKineticEnergy();
576 if (itsEnergy < localEnergyDeposit)
578 localEnergyDeposit -= itsEnergy;
580 energyInFluorescence += itsEnergy;
581 else if (((*fvect)[j])->GetParticleDefinition() ==
583 energyInAuger += itsEnergy;
588 (*fvect)[j] =
nullptr;
599 G4double xEl = sinThetaE * std::cos(phi+pi);
600 G4double yEl = sinThetaE * std::sin(phi+pi);
603 eDirection.
rotateUz(photonDirection0);
605 eDirection,eKineticEnergy) ;
606 fvect->push_back(electron);
608 if (localEnergyDeposit < 0)
610 G4Exception(
"G4PenelopeComptonModel::SampleSecondaries()",
611 "em2099",
JustWarning,
"WARNING: Negative local energy deposit");
612 localEnergyDeposit=0.;
618 electronEnergy = eKineticEnergy;
619 if (fVerboseLevel > 1)
621 G4cout <<
"-----------------------------------------------------------" <<
G4endl;
622 G4cout <<
"Energy balance from G4PenelopeCompton" <<
G4endl;
623 G4cout <<
"Incoming photon energy: " << photonEnergy0/keV <<
" keV" <<
G4endl;
624 G4cout <<
"-----------------------------------------------------------" <<
G4endl;
625 G4cout <<
"Scattered photon: " << photonEnergy1/keV <<
" keV" <<
G4endl;
626 G4cout <<
"Scattered electron " << electronEnergy/keV <<
" keV" <<
G4endl;
627 if (energyInFluorescence)
628 G4cout <<
"Fluorescence x-rays: " << energyInFluorescence/keV <<
" keV" <<
G4endl;
630 G4cout <<
"Auger electrons: " << energyInAuger/keV <<
" keV" <<
G4endl;
631 G4cout <<
"Local energy deposit " << localEnergyDeposit/keV <<
" keV" <<
G4endl;
632 G4cout <<
"Total final state: " << (photonEnergy1+electronEnergy+energyInFluorescence+
633 localEnergyDeposit+energyInAuger)/keV <<
635 G4cout <<
"-----------------------------------------------------------" <<
G4endl;
637 if (fVerboseLevel > 0)
639 G4double energyDiff = std::fabs(photonEnergy1+
640 electronEnergy+energyInFluorescence+
641 localEnergyDeposit+energyInAuger-photonEnergy0);
642 if (energyDiff > 0.05*keV)
643 G4cout <<
"Warning from G4PenelopeCompton: problem with energy conservation: " <<
644 (photonEnergy1+electronEnergy+energyInFluorescence+energyInAuger+localEnergyDeposit)/keV <<
645 " keV (final) vs. " <<
646 photonEnergy0/keV <<
" keV (initial)" <<
G4endl;
669 static const G4double k2 = std::sqrt(2.);
672 if (energy < ionEnergy)
677 G4double EOEC = 1.0+(energy/electron_mass_c2)*cdt1;
681 G4double aux = energy*(energy-ionEnergy)*cdt1;
683 (aux - electron_mass_c2*ionEnergy)/(electron_mass_c2*std::sqrt(2*aux+ionEnergy*ionEnergy));
687 sia = 1.0-0.5*
G4Exp(0.5-(k1+k2*x)*(k1+k2*x));
689 sia = 0.5*
G4Exp(0.5-(k1-k2*x)*(k1-k2*x));
694 if (std::fabs(Pzimax) < pf)
696 G4double QCOE2 = 1.0+ECOE*ECOE-2.0*ECOE*cosTheta;
699 (1.0+ECOE*(ECOE-cosTheta)/QCOE2)*harFunc
700 *0.25*(2*p2-(p2*p2)/(pf*pf)-(pf*pf));
701 sia += std::max(dspz,-1.0*sia);
704 G4double XKN = EOEC+ECOE-1.0+cosTheta*cosTheta;
707 G4double diffCS = ECOE*ECOE*XKN*sia;
724 const G4int npoints=10;
725 const G4int ncallsmax=20000;
727 static const G4double Abscissas[10] = {7.652651133497334e-02,2.2778585114164508e-01,3.7370608871541956e-01,
728 5.1086700195082710e-01,6.3605368072651503e-01,7.4633190646015079e-01,
729 8.3911697182221882e-01,9.1223442825132591e-01,9.6397192727791379e-01,
730 9.9312859918509492e-01};
731 static const G4double Weights[10] = {1.5275338713072585e-01,1.4917298647260375e-01,1.4209610931838205e-01,
732 1.3168863844917663e-01,1.1819453196151842e-01,1.0193011981724044e-01,
733 8.3276741576704749e-02,6.2672048334109064e-02,4.0601429800386941e-02,
734 1.7614007139152118e-02};
738 G4double Ctol = std::min(std::max(MaxError,1e-13),1e-02);
748 G4double a=0.5*(HighPoint-LowPoint);
749 G4double b=0.5*(HighPoint+LowPoint);
752 (DifferentialCrossSection(b+c,energy,osc)+DifferentialCrossSection(b-c,energy,osc));
753 for (
G4int i=2;i<=npoints;i++)
757 (DifferentialCrossSection(b+c,energy,osc)+DifferentialCrossSection(b-c,energy,osc));
759 G4int icall = 2*npoints;
774 for (
G4int i=1;i<=LH;i++){
783 (DifferentialCrossSection(b+c,energy,osc)+DifferentialCrossSection(b-c,energy,osc));
785 for (
G4int j=1;j<npoints;j++)
788 dLocal += Weights[j]*
789 (DifferentialCrossSection(b+c,energy,osc)+DifferentialCrossSection(b-c,energy,osc));
796 (DifferentialCrossSection(b+c,energy,osc)+DifferentialCrossSection(b-c,energy,osc));
798 for (
G4int j=1;j<npoints;j++)
801 dLocal += Weights[j]*
802 (DifferentialCrossSection(b+c,energy,osc)+DifferentialCrossSection(b-c,energy,osc));
805 icall=icall+4*npoints;
807 if (std::abs(s12-si)<std::max(Ptol*std::abs(s12),1e-35))
819 if (icall>ncallsmax || LHN>nst)
822 G4cout <<
"LowPoint: " << LowPoint <<
", High Point: " << HighPoint <<
G4endl;
824 G4cout <<
"Calls: " << icall <<
", Integral: " << sumga <<
", Error: " << Err <<
G4endl;
825 G4cout <<
"Number of open subintervals: " << LHN <<
G4endl;
826 G4cout <<
"WARNING: the required accuracy has not been attained" <<
G4endl;
830 Err=std::abs(sumr)/std::max(std::abs(sumr+sumga),1e-35);
831 if (Err < Ctol || LHN == 0)
834 for (
G4int i=0;i<LH;i++)
839 }
while(Ctol < 1.0 && loopAgain);
865 for (
size_t i=0;i<theTable->size();i++)
872 G4double csu = 0.5*eks*tau*tau+ek2*tau+ek1*
G4Log(tau)-(1.0/tau);
875 cs += stre*(csu-csl);
G4double epsilon(G4double density, G4double temperature)
G4double S(G4double temp)
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.
G4double G4Log(G4double x)
std::vector< G4PenelopeOscillator * > G4PenelopeOscillatorTable
G4GLOB_DLL std::ostream G4cout
Hep3Vector & rotateUz(const Hep3Vector &)
G4double BindingEnergy() const
G4AtomicShell * Shell(G4int Z, size_t shellIndex) const
static G4AtomicTransitionManager * Instance()
const G4ThreeVector & GetMomentumDirection() const
G4double GetKineticEnergy() const
static G4Electron * Definition()
static G4Electron * Electron()
static G4Gamma * Definition()
static G4LossTableManager * Instance()
G4VAtomDeexcitation * AtomDeexcitation()
const G4Material * GetMaterial() const
G4double GetTotNbOfAtomsPerVolume() const
const G4String & GetName() const
void SetProposedKineticEnergy(G4double proposedKinEnergy)
void ProposeMomentumDirection(const G4ThreeVector &Pfinal)
virtual ~G4PenelopeComptonModel()
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
G4double GetAtomsPerMolecule(const G4Material *)
Returns the total number of atoms per molecule.
G4PenelopeOscillatorTable * GetOscillatorTableCompton(const G4Material *)
static G4PenelopeOscillatorManager * GetOscillatorManager()
G4double GetTotalZ(const G4Material *)
G4double GetIonisationEnergy()
G4double GetHartreeFactor()
G4double GetOscillatorStrength()
G4bool CheckDeexcitationActiveRegion(G4int coupleIndex)
void GenerateParticles(std::vector< G4DynamicParticle * > *secVect, const G4AtomicShell *, G4int Z, G4int coupleIndex)
void SetHighEnergyLimit(G4double)
G4ParticleChangeForGamma * GetParticleChangeForGamma()
G4double LowEnergyLimit() const
G4double HighEnergyLimit() const
virtual void SetupForMaterial(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
void SetDeexcitationFlag(G4bool val)
void ProposeTrackStatus(G4TrackStatus status)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
G4double energy(const ThreeVector &p, const G4double m)