47 :fXSTableElectron(nullptr),fXSTablePositron(nullptr),
48 fDeltaTable(nullptr),fEnergyGrid(nullptr)
52 G4double HighEnergyLimit = 100.0*GeV;
54 fXSTableElectron =
new
56 fXSTablePositron =
new
59 fDeltaTable =
new std::map<const G4Material*,G4PhysicsFreeVector*>;
72 for (
auto& item : (*fXSTableElectron))
77 delete fXSTableElectron;
78 fXSTableElectron =
nullptr;
83 for (
auto& item : (*fXSTablePositron))
88 delete fXSTablePositron;
89 fXSTablePositron =
nullptr;
93 for (
auto& item : (*fDeltaTable))
96 fDeltaTable =
nullptr;
101 if (fVerboseLevel > 2)
102 G4cout <<
"G4PenelopeIonisationXSHandler. Tables have been cleared"
117 G4Exception(
"G4PenelopeIonisationXSHandler::GetCrossSectionTableForCouple()",
124 if (!fXSTableElectron)
126 G4Exception(
"G4PenelopeIonisationXSHandler::GetCrossSectionTableForCouple()",
128 "The Cross Section Table for e- was not initialized correctly!");
131 std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
132 if (fXSTableElectron->count(theKey))
133 return fXSTableElectron->find(theKey)->second;
140 if (!fXSTablePositron)
142 G4Exception(
"G4PenelopeIonisationXSHandler::GetCrossSectionTableForCouple()",
144 "The Cross Section Table for e+ was not initialized correctly!");
147 std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
148 if (fXSTablePositron->count(theKey))
149 return fXSTablePositron->find(theKey)->second;
164 G4Exception(
"G4PenelopeIonisationXSHandler::BuildXSTable()",
173 if (fVerboseLevel > 2)
175 G4cout <<
"G4PenelopeIonisationXSHandler: going to build cross section table " <<
G4endl;
180 std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
184 if (fXSTableElectron->count(theKey))
189 if (fXSTablePositron->count(theKey))
194 if (!(fDeltaTable->count(mat)))
195 BuildDeltaTable(mat);
200 size_t numberOfOscillators = theTable->size();
205 ed <<
"Energy Grid looks not initialized" <<
G4endl;
207 G4Exception(
"G4PenelopeIonisationXSHandler::BuildXSTable()",
214 for (
size_t bin=0;bin<fNBins;bin++)
221 for (
size_t iosc=0;iosc<numberOfOscillators;iosc++)
228 tempStorage = ComputeShellCrossSectionsElectron(theOsc,energy,cut,delta);
230 tempStorage = ComputeShellCrossSectionsPositron(theOsc,energy,cut,delta);
235 ed <<
"Problem in calculating the shell XS for shell # "
237 G4Exception(
"G4PenelopeIonisationXSHandler::BuildXSTable()",
242 if (tempStorage->size() != 6)
245 ed <<
"Problem in calculating the shell XS " <<
G4endl;
246 ed <<
"Result has dimension " << tempStorage->size() <<
" instead of 6" <<
G4endl;
247 G4Exception(
"G4PenelopeIonisationXSHandler::BuildXSTable()",
252 XH0 += stre*(*tempStorage)[0];
253 XH1 += stre*(*tempStorage)[1];
254 XH2 += stre*(*tempStorage)[2];
255 XS0 += stre*(*tempStorage)[3];
256 XS1 += stre*(*tempStorage)[4];
257 XS2 += stre*(*tempStorage)[5];
262 tempStorage =
nullptr;
272 fXSTableElectron->insert(std::make_pair(theKey,XSEntry));
274 fXSTablePositron->insert(std::make_pair(theKey,XSEntry));
290 G4Exception(
"G4PenelopeIonisationXSHandler::GetDensityCorrection()",
292 "Delta Table not initialized. Was Initialise() run?");
297 G4cout <<
"G4PenelopeIonisationXSHandler::GetDensityCorrection()" <<
G4endl;
298 G4cout <<
"Invalid energy " << energy/eV <<
" eV " <<
G4endl;
303 if (fDeltaTable->count(mat))
306 result = vec->
Value(logene);
311 ed <<
"Unable to build table for " << mat->
GetName() <<
G4endl;
312 G4Exception(
"G4PenelopeIonisationXSHandler::GetDensityCorrection()",
321void G4PenelopeIonisationXSHandler::BuildDeltaTable(
const G4Material* mat)
326 size_t numberOfOscillators = theTable->size();
331 ed <<
"Energy Grid for Delta table looks not initialized" <<
G4endl;
333 G4Exception(
"G4PenelopeIonisationXSHandler::BuildDeltaTable()",
340 for (
size_t bin=0;bin<fNBins;bin++)
349 G4double TST = totalZ/(gamSq*plasmaSq);
354 for (
size_t i=0;i<numberOfOscillators;i++)
373 for (
size_t i=0;i<numberOfOscillators;i++)
389 wl2 = 0.5*(wl2l+wl2u);
391 for (
size_t i=0;i<numberOfOscillators;i++)
401 if ((wl2u-wl2l)>1e-12*wl2)
407 for (
size_t i=0;i<numberOfOscillators;i++)
412 G4Log(1.0+(wl2/(wri*wri)));
414 delta = (delta/totalZ)-wl2/(gamSq*plasmaSq);
416 energy = std::max(1e-9*eV,energy);
419 fDeltaTable->insert(std::make_pair(mat,theVector));
438 for (
size_t i=0;i<6;i++)
439 result->push_back(0.);
443 if (energy < ionEnergy)
452 G4double beta = (gammaSq-1.0)/gammaSq;
453 G4double pielr2 =
pi*classic_electr_radius*classic_electr_radius;
454 G4double constant = pielr2*2.0*electron_mass_c2/beta;
468 G4double cp1Sq = (
energy-resEne)*(energy-resEne+2.0*electron_mass_c2);
473 if (resEne > 1e-6*energy)
474 QM = std::sqrt((cp-cp1)*(cp-cp1)+electron_mass_c2*electron_mass_c2)-electron_mass_c2;
477 QM = resEne*resEne/(beta*2.0*electron_mass_c2);
478 QM = QM*(1.0-0.5*QM/electron_mass_c2);
482 SDL1 =
G4Log(cutoffEne*(QM+2.0*electron_mass_c2)/(QM*(cutoffEne+2.0*electron_mass_c2)));
487 G4double SDT1 = std::max(XHDT0-delta,0.0);
506 G4double wl = std::max(cut,cutoffEne);
509 if (wl < wu-(1e-5*eV))
511 H0 += (1.0/(ee-wu)) - (1.0/(ee-wl)) - (1.0/wu) + (1.0/wl) +
512 (1.0-amol)*
G4Log(((ee-wu)*wl)/((ee-wl)*wu))/ee +
513 amol*(wu-wl)/(ee*ee);
514 H1 +=
G4Log(wu/wl)+(ee/(ee-wu))-(ee/(ee-wl)) +
515 (2.0-amol)*
G4Log((ee-wu)/(ee-wl)) +
516 amol*(wu*wu-wl*wl)/(2.0*ee*ee);
517 H2 += (2.0-amol)*(wu-wl)+(wu*(2.0*ee-wu)/(ee-wu)) -
518 (wl*(2.0*ee-wl)/(ee-wl)) +
519 (3.0-amol)*ee*
G4Log((ee-wu)/(ee-wl)) +
520 amol*(wu*wu*wu-wl*wl*wl)/(3.0*ee*ee);
525 if (wl > wu-(1e-5*eV))
527 (*result)[0] = constant*H0;
528 (*result)[1] = constant*H1;
529 (*result)[2] = constant*H2;
530 (*result)[3] = constant*S0;
531 (*result)[4] = constant*S1;
532 (*result)[5] = constant*S2;
536 S0 += (1.0/(ee-wu))-(1.0/(ee-wl)) - (1.0/wu) + (1.0/wl) +
537 (1.0-amol)*
G4Log(((ee-wu)*wl)/((ee-wl)*wu))/ee +
538 amol*(wu-wl)/(ee*ee);
539 S1 +=
G4Log(wu/wl)+(ee/(ee-wu))-(ee/(ee-wl)) +
540 (2.0-amol)*
G4Log((ee-wu)/(ee-wl)) +
541 amol*(wu*wu-wl*wl)/(2.0*ee*ee);
542 S2 += (2.0-amol)*(wu-wl)+(wu*(2.0*ee-wu)/(ee-wu)) -
543 (wl*(2.0*ee-wl)/(ee-wl)) +
544 (3.0-amol)*ee*
G4Log((ee-wu)/(ee-wl)) +
545 amol*(wu*wu*wu-wl*wl*wl)/(3.0*ee*ee);
547 (*result)[0] = constant*H0;
548 (*result)[1] = constant*H1;
549 (*result)[2] = constant*H2;
550 (*result)[3] = constant*S0;
551 (*result)[4] = constant*S1;
552 (*result)[5] = constant*S2;
570 for (
size_t i=0;i<6;i++)
571 result->push_back(0.);
575 if (energy < ionEnergy)
584 G4double beta = (gammaSq-1.0)/gammaSq;
585 G4double pielr2 =
pi*classic_electr_radius*classic_electr_radius;
586 G4double constant = pielr2*2.0*electron_mass_c2/beta;
592 G4double g12 = (gamma+1.0)*(gamma+1.0);
594 G4double bha1 = amol*(2.0*g12-1.0)/(gammaSq-1.0);
596 G4double bha3 = amol*2.0*gamma*(gamma-1.0)/g12;
597 G4double bha4 = amol*(gamma-1.0)*(gamma-1.0)/g12;
606 G4double cp1Sq = (
energy-resEne)*(energy-resEne+2.0*electron_mass_c2);
611 if (resEne > 1e-6*energy)
612 QM = std::sqrt((cp-cp1)*(cp-cp1)+electron_mass_c2*electron_mass_c2)-electron_mass_c2;
615 QM = resEne*resEne/(beta*2.0*electron_mass_c2);
616 QM = QM*(1.0-0.5*QM/electron_mass_c2);
620 SDL1 =
G4Log(cutoffEne*(QM+2.0*electron_mass_c2)/(QM*(cutoffEne+2.0*electron_mass_c2)));
625 G4double SDT1 = std::max(XHDT0-delta,0.0);
644 G4double wl = std::max(cut,cutoffEne);
647 if (wl < wu-(1e-5*eV))
651 H0 += (1.0/wl) - (1.0/wu)- bha1*
G4Log(wu/wl)/
energy
652 + bha2*(wu-wl)/energySq
653 - bha3*(wuSq-wlSq)/(2.0*energySq*
energy)
654 + bha4*(wuSq*wu-wlSq*wl)/(3.0*energySq*energySq);
655 H1 +=
G4Log(wu/wl) - bha1*(wu-wl)/energy
656 + bha2*(wuSq-wlSq)/(2.0*energySq)
657 - bha3*(wuSq*wu-wlSq*wl)/(3.0*energySq*
energy)
658 + bha4*(wuSq*wuSq-wlSq*wlSq)/(4.0*energySq*energySq);
659 H2 += wu - wl - bha1*(wuSq-wlSq)/(2.0*energy)
660 + bha2*(wuSq*wu-wlSq*wl)/(3.0*energySq)
661 - bha3*(wuSq*wuSq-wlSq*wlSq)/(4.0*energySq*energy)
662 + bha4*(wuSq*wuSq*wu-wlSq*wlSq*wl)/(5.0*energySq*energySq);
667 if (wl > wu-(1e-5*eV))
669 (*result)[0] = constant*H0;
670 (*result)[1] = constant*H1;
671 (*result)[2] = constant*H2;
672 (*result)[3] = constant*S0;
673 (*result)[4] = constant*S1;
674 (*result)[5] = constant*S2;
681 S0 += (1.0/wl) - (1.0/wu) - bha1*
G4Log(wu/wl)/
energy
682 + bha2*(wu-wl)/energySq
683 - bha3*(wuSq-wlSq)/(2.0*energySq*
energy)
684 + bha4*(wuSq*wu-wlSq*wl)/(3.0*energySq*energySq);
686 S1 +=
G4Log(wu/wl) - bha1*(wu-wl)/energy
687 + bha2*(wuSq-wlSq)/(2.0*energySq)
688 - bha3*(wuSq*wu-wlSq*wl)/(3.0*energySq*
energy)
689 + bha4*(wuSq*wuSq-wlSq*wlSq)/(4.0*energySq*energySq);
691 S2 += wu - wl - bha1*(wuSq-wlSq)/(2.0*energy)
692 + bha2*(wuSq*wu-wlSq*wl)/(3.0*energySq)
693 - bha3*(wuSq*wuSq-wlSq*wlSq)/(4.0*energySq*energy)
694 + bha4*(wuSq*wuSq*wu-wlSq*wlSq*wl)/(5.0*energySq*energySq);
696 (*result)[0] = constant*H0;
697 (*result)[1] = constant*H1;
698 (*result)[2] = constant*H2;
699 (*result)[3] = constant*S0;
700 (*result)[4] = constant*S1;
701 (*result)[5] = constant*S2;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4double G4Log(G4double x)
std::vector< G4PenelopeOscillator * > G4PenelopeOscillatorTable
G4GLOB_DLL std::ostream G4cout
static G4Electron * Electron()
const G4String & GetName() const
const G4String & GetParticleName() const
void AddShellCrossSectionPoint(size_t binNumber, size_t shellID, G4double energy, G4double xs)
void NormalizeShellCrossSections()
void AddCrossSectionPoint(size_t binNumber, G4double energy, G4double XH0, G4double XH1, G4double XH2, G4double XS0, G4double XS1, G4double XS2)
G4double GetDensityCorrection(const G4Material *, const G4double energy) const
Returns the density coeection for the material at the given energy.
G4PenelopeIonisationXSHandler(size_t nBins=200)
virtual ~G4PenelopeIonisationXSHandler()
Destructor. Clean all tables.
void BuildXSTable(const G4Material *, G4double cut, const G4ParticleDefinition *, G4bool isMaster=true)
This can be inkoved only by the master.
const G4PenelopeCrossSection * GetCrossSectionTableForCouple(const G4ParticleDefinition *, const G4Material *, const G4double cut) const
static G4PenelopeOscillatorManager * GetOscillatorManager()
G4PenelopeOscillatorTable * GetOscillatorTableIonisation(const G4Material *)
G4double GetPlasmaEnergySquared(const G4Material *)
Returns the squared plasma energy.
G4double GetTotalZ(const G4Material *)
G4double GetIonisationEnergy()
G4double GetResonanceEnergy() const
G4double GetCutoffRecoilResonantEnergy()
G4double GetOscillatorStrength()
void PutValue(const std::size_t index, const G4double e, const G4double value)
G4double GetLowEdgeEnergy(const std::size_t index) const
G4double Value(const G4double energy, std::size_t &lastidx) const
std::size_t GetVectorLength() const
static G4Positron * Positron()
G4double energy(const ThreeVector &p, const G4double m)