47 :XSTableElectron(0),XSTablePositron(0),
48 theDeltaTable(0),energyGrid(0)
52 G4double HighEnergyLimit = 100.0*GeV;
59 theDeltaTable =
new std::map<const G4Material*,G4PhysicsFreeVector*>;
73 for (
auto& item : (*XSTableElectron))
78 delete XSTableElectron;
79 XSTableElectron =
nullptr;
84 for (
auto& item : (*XSTablePositron))
89 delete XSTablePositron;
90 XSTablePositron =
nullptr;
94 for (
auto& item : (*theDeltaTable))
97 theDeltaTable =
nullptr;
102 if (verboseLevel > 2)
103 G4cout <<
"G4PenelopeIonisationXSHandler. Tables have been cleared"
118 G4Exception(
"G4PenelopeIonisationXSHandler::GetCrossSectionTableForCouple()",
125 if (!XSTableElectron)
127 G4Exception(
"G4PenelopeIonisationXSHandler::GetCrossSectionTableForCouple()",
129 "The Cross Section Table for e- was not initialized correctly!");
132 std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
133 if (XSTableElectron->count(theKey))
134 return XSTableElectron->find(theKey)->second;
141 if (!XSTablePositron)
143 G4Exception(
"G4PenelopeIonisationXSHandler::GetCrossSectionTableForCouple()",
145 "The Cross Section Table for e+ was not initialized correctly!");
148 std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
149 if (XSTablePositron->count(theKey))
150 return XSTablePositron->find(theKey)->second;
165 G4Exception(
"G4PenelopeIonisationXSHandler::BuildXSTable()",
174 if (verboseLevel > 2)
176 G4cout <<
"G4PenelopeIonisationXSHandler: going to build cross section table " <<
G4endl;
181 std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
185 if (XSTableElectron->count(theKey))
190 if (XSTablePositron->count(theKey))
195 if (!(theDeltaTable->count(mat)))
196 BuildDeltaTable(mat);
201 size_t numberOfOscillators = theTable->size();
206 ed <<
"Energy Grid looks not initialized" <<
G4endl;
208 G4Exception(
"G4PenelopeIonisationXSHandler::BuildXSTable()",
215 for (
size_t bin=0;bin<nBins;bin++)
222 for (
size_t iosc=0;iosc<numberOfOscillators;iosc++)
229 tempStorage = ComputeShellCrossSectionsElectron(theOsc,energy,cut,delta);
231 tempStorage = ComputeShellCrossSectionsPositron(theOsc,energy,cut,delta);
236 ed <<
"Problem in calculating the shell XS for shell # "
238 G4Exception(
"G4PenelopeIonisationXSHandler::BuildXSTable()",
243 if (tempStorage->size() != 6)
246 ed <<
"Problem in calculating the shell XS " <<
G4endl;
247 ed <<
"Result has dimension " << tempStorage->size() <<
" instead of 6" <<
G4endl;
248 G4Exception(
"G4PenelopeIonisationXSHandler::BuildXSTable()",
253 XH0 += stre*(*tempStorage)[0];
254 XH1 += stre*(*tempStorage)[1];
255 XH2 += stre*(*tempStorage)[2];
256 XS0 += stre*(*tempStorage)[3];
257 XS1 += stre*(*tempStorage)[4];
258 XS2 += stre*(*tempStorage)[5];
273 XSTableElectron->insert(std::make_pair(theKey,XSEntry));
275 XSTablePositron->insert(std::make_pair(theKey,XSEntry));
291 G4Exception(
"G4PenelopeIonisationXSHandler::GetDensityCorrection()",
293 "Delta Table not initialized. Was Initialise() run?");
298 G4cout <<
"G4PenelopeIonisationXSHandler::GetDensityCorrection()" <<
G4endl;
299 G4cout <<
"Invalid energy " << energy/eV <<
" eV " <<
G4endl;
304 if (theDeltaTable->count(mat))
307 result = vec->
Value(logene);
312 ed <<
"Unable to build table for " << mat->
GetName() <<
G4endl;
313 G4Exception(
"G4PenelopeIonisationXSHandler::GetDensityCorrection()",
322void G4PenelopeIonisationXSHandler::BuildDeltaTable(
const G4Material* mat)
327 size_t numberOfOscillators = theTable->size();
332 ed <<
"Energy Grid for Delta table looks not initialized" <<
G4endl;
334 G4Exception(
"G4PenelopeIonisationXSHandler::BuildDeltaTable()",
341 for (
size_t bin=0;bin<nBins;bin++)
350 G4double TST = totalZ/(gamSq*plasmaSq);
355 for (
size_t i=0;i<numberOfOscillators;i++)
374 for (
size_t i=0;i<numberOfOscillators;i++)
390 wl2 = 0.5*(wl2l+wl2u);
392 for (
size_t i=0;i<numberOfOscillators;i++)
402 if ((wl2u-wl2l)>1e-12*wl2)
408 for (
size_t i=0;i<numberOfOscillators;i++)
413 G4Log(1.0+(wl2/(wri*wri)));
415 delta = (delta/totalZ)-wl2/(gamSq*plasmaSq);
417 energy = std::max(1e-9*eV,energy);
420 theDeltaTable->insert(std::make_pair(mat,theVector));
439 for (
size_t i=0;i<6;i++)
440 result->push_back(0.);
444 if (energy < ionEnergy)
453 G4double beta = (gammaSq-1.0)/gammaSq;
454 G4double pielr2 =
pi*classic_electr_radius*classic_electr_radius;
455 G4double constant = pielr2*2.0*electron_mass_c2/beta;
469 G4double cp1Sq = (
energy-resEne)*(energy-resEne+2.0*electron_mass_c2);
474 if (resEne > 1e-6*energy)
475 QM = std::sqrt((cp-cp1)*(cp-cp1)+electron_mass_c2*electron_mass_c2)-electron_mass_c2;
478 QM = resEne*resEne/(beta*2.0*electron_mass_c2);
479 QM = QM*(1.0-0.5*QM/electron_mass_c2);
483 SDL1 =
G4Log(cutoffEne*(QM+2.0*electron_mass_c2)/(QM*(cutoffEne+2.0*electron_mass_c2)));
488 G4double SDT1 = std::max(XHDT0-delta,0.0);
507 G4double wl = std::max(cut,cutoffEne);
510 if (wl < wu-(1e-5*eV))
512 H0 += (1.0/(ee-wu)) - (1.0/(ee-wl)) - (1.0/wu) + (1.0/wl) +
513 (1.0-amol)*
G4Log(((ee-wu)*wl)/((ee-wl)*wu))/ee +
514 amol*(wu-wl)/(ee*ee);
515 H1 +=
G4Log(wu/wl)+(ee/(ee-wu))-(ee/(ee-wl)) +
516 (2.0-amol)*
G4Log((ee-wu)/(ee-wl)) +
517 amol*(wu*wu-wl*wl)/(2.0*ee*ee);
518 H2 += (2.0-amol)*(wu-wl)+(wu*(2.0*ee-wu)/(ee-wu)) -
519 (wl*(2.0*ee-wl)/(ee-wl)) +
520 (3.0-amol)*ee*
G4Log((ee-wu)/(ee-wl)) +
521 amol*(wu*wu*wu-wl*wl*wl)/(3.0*ee*ee);
526 if (wl > wu-(1e-5*eV))
528 (*result)[0] = constant*H0;
529 (*result)[1] = constant*H1;
530 (*result)[2] = constant*H2;
531 (*result)[3] = constant*S0;
532 (*result)[4] = constant*S1;
533 (*result)[5] = constant*S2;
537 S0 += (1.0/(ee-wu))-(1.0/(ee-wl)) - (1.0/wu) + (1.0/wl) +
538 (1.0-amol)*
G4Log(((ee-wu)*wl)/((ee-wl)*wu))/ee +
539 amol*(wu-wl)/(ee*ee);
540 S1 +=
G4Log(wu/wl)+(ee/(ee-wu))-(ee/(ee-wl)) +
541 (2.0-amol)*
G4Log((ee-wu)/(ee-wl)) +
542 amol*(wu*wu-wl*wl)/(2.0*ee*ee);
543 S2 += (2.0-amol)*(wu-wl)+(wu*(2.0*ee-wu)/(ee-wu)) -
544 (wl*(2.0*ee-wl)/(ee-wl)) +
545 (3.0-amol)*ee*
G4Log((ee-wu)/(ee-wl)) +
546 amol*(wu*wu*wu-wl*wl*wl)/(3.0*ee*ee);
548 (*result)[0] = constant*H0;
549 (*result)[1] = constant*H1;
550 (*result)[2] = constant*H2;
551 (*result)[3] = constant*S0;
552 (*result)[4] = constant*S1;
553 (*result)[5] = constant*S2;
571 for (
size_t i=0;i<6;i++)
572 result->push_back(0.);
576 if (energy < ionEnergy)
585 G4double beta = (gammaSq-1.0)/gammaSq;
586 G4double pielr2 =
pi*classic_electr_radius*classic_electr_radius;
587 G4double constant = pielr2*2.0*electron_mass_c2/beta;
593 G4double g12 = (gamma+1.0)*(gamma+1.0);
595 G4double bha1 = amol*(2.0*g12-1.0)/(gammaSq-1.0);
597 G4double bha3 = amol*2.0*gamma*(gamma-1.0)/g12;
598 G4double bha4 = amol*(gamma-1.0)*(gamma-1.0)/g12;
607 G4double cp1Sq = (
energy-resEne)*(energy-resEne+2.0*electron_mass_c2);
612 if (resEne > 1e-6*energy)
613 QM = std::sqrt((cp-cp1)*(cp-cp1)+electron_mass_c2*electron_mass_c2)-electron_mass_c2;
616 QM = resEne*resEne/(beta*2.0*electron_mass_c2);
617 QM = QM*(1.0-0.5*QM/electron_mass_c2);
621 SDL1 =
G4Log(cutoffEne*(QM+2.0*electron_mass_c2)/(QM*(cutoffEne+2.0*electron_mass_c2)));
626 G4double SDT1 = std::max(XHDT0-delta,0.0);
646 G4double wl = std::max(cut,cutoffEne);
649 if (wl < wu-(1e-5*eV))
653 H0 += (1.0/wl) - (1.0/wu)- bha1*
G4Log(wu/wl)/
energy
654 + bha2*(wu-wl)/energySq
655 - bha3*(wuSq-wlSq)/(2.0*energySq*
energy)
656 + bha4*(wuSq*wu-wlSq*wl)/(3.0*energySq*energySq);
657 H1 +=
G4Log(wu/wl) - bha1*(wu-wl)/energy
658 + bha2*(wuSq-wlSq)/(2.0*energySq)
659 - bha3*(wuSq*wu-wlSq*wl)/(3.0*energySq*
energy)
660 + bha4*(wuSq*wuSq-wlSq*wlSq)/(4.0*energySq*energySq);
661 H2 += wu - wl - bha1*(wuSq-wlSq)/(2.0*energy)
662 + bha2*(wuSq*wu-wlSq*wl)/(3.0*energySq)
663 - bha3*(wuSq*wuSq-wlSq*wlSq)/(4.0*energySq*energy)
664 + bha4*(wuSq*wuSq*wu-wlSq*wlSq*wl)/(5.0*energySq*energySq);
669 if (wl > wu-(1e-5*eV))
671 (*result)[0] = constant*H0;
672 (*result)[1] = constant*H1;
673 (*result)[2] = constant*H2;
674 (*result)[3] = constant*S0;
675 (*result)[4] = constant*S1;
676 (*result)[5] = constant*S2;
683 S0 += (1.0/wl) - (1.0/wu) - bha1*
G4Log(wu/wl)/
energy
684 + bha2*(wu-wl)/energySq
685 - bha3*(wuSq-wlSq)/(2.0*energySq*
energy)
686 + bha4*(wuSq*wu-wlSq*wl)/(3.0*energySq*energySq);
688 S1 +=
G4Log(wu/wl) - bha1*(wu-wl)/energy
689 + bha2*(wuSq-wlSq)/(2.0*energySq)
690 - bha3*(wuSq*wu-wlSq*wl)/(3.0*energySq*
energy)
691 + bha4*(wuSq*wuSq-wlSq*wlSq)/(4.0*energySq*energySq);
693 S2 += wu - wl - bha1*(wuSq-wlSq)/(2.0*energy)
694 + bha2*(wuSq*wu-wlSq*wl)/(3.0*energySq)
695 - bha3*(wuSq*wuSq-wlSq*wlSq)/(4.0*energySq*energy)
696 + bha4*(wuSq*wuSq*wu-wlSq*wlSq*wl)/(5.0*energySq*energySq);
698 (*result)[0] = constant*H0;
699 (*result)[1] = constant*H1;
700 (*result)[2] = constant*H2;
701 (*result)[3] = constant*S0;
702 (*result)[4] = constant*S1;
703 (*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(std::size_t index, G4double energy, G4double dValue)
G4double Value(G4double theEnergy, std::size_t &lastidx) const
G4double GetLowEdgeEnergy(std::size_t binNumber) const
std::size_t GetVectorLength() const
static G4Positron * Positron()
G4double energy(const ThreeVector &p, const G4double m)