56const std::string G4GSPWACorrections::gElemSymbols[] = {
"H",
"He",
"Li",
"Be",
"B" ,
57 "C" ,
"N" ,
"O" ,
"F" ,
"Ne",
"Na",
"Mg",
"Al",
"Si",
"P" ,
"S",
"Cl",
"Ar",
"K" ,
"Ca",
"Sc",
58 "Ti",
"V" ,
"Cr",
"Mn",
"Fe",
"Co",
"Ni",
"Cu",
"Zn",
"Ga",
"Ge",
"As",
"Se",
"Br",
"Kr",
"Rb",
59 "Sr",
"Y" ,
"Zr",
"Nb",
"Mo",
"Tc",
"Ru",
"Rh",
"Pd",
"Ag",
"Cd",
"In",
"Sn",
"Sb",
"Te",
"I" ,
60 "Xe",
"Cs",
"Ba",
"La",
"Ce",
"Pr",
"Nd",
"Pm",
"Sm",
"Eu",
"Gd",
"Tb",
"Dy",
"Ho",
"Er",
"Tm",
61 "Yb",
"Lu",
"Hf",
"Ta",
"W" ,
"Re",
"Os",
"Ir",
"Pt",
"Au",
"Hg",
"Tl",
"Pb",
"Bi",
"Po",
"At",
62 "Rn",
"Fr",
"Ra",
"Ac",
"Th",
"Pa",
"U" ,
"Np",
"Pu",
"Am",
"Cm",
"Bk",
"Cf"};
66 fMaxEkin = CLHEP::electron_mass_c2*(1./std::sqrt(1.-gMaxBeta2)-1.);
67 fLogMinEkin =
G4Log(gMinEkin);
68 fInvLogDelEkin = (gNumEkin-gNumBeta2)/
G4Log(gMidEkin/gMinEkin);
69 G4double pt2 = gMidEkin*(gMidEkin+2.0*CLHEP::electron_mass_c2);
70 fMinBeta2 = pt2/(pt2+CLHEP::electron_mass_c2*CLHEP::electron_mass_c2);
71 fInvDelBeta2 = (gNumBeta2-1.)/(gMaxBeta2-fMinBeta2);
76 ClearDataPerElement();
77 ClearDataPerMaterial();
83 G4int ekinIndxLow = 0;
85 if (beta2>=gMaxBeta2) {
86 ekinIndxLow = gNumEkin - 1;
88 }
else if (beta2>=fMinBeta2) {
89 remRfaction = (beta2 - fMinBeta2) * fInvDelBeta2;
90 ekinIndxLow = (
G4int)remRfaction;
91 remRfaction -= ekinIndxLow;
92 ekinIndxLow += (gNumEkin - gNumBeta2);
93 }
else if (logekin>=fLogMinEkin) {
94 remRfaction = (logekin - fLogMinEkin) * fInvLogDelEkin;
95 ekinIndxLow = (
G4int)remRfaction;
96 remRfaction -= ekinIndxLow;
99 DataPerMaterial *data = fDataPerMaterial[matindx];
100 corToScr = data->fCorScreening[ekinIndxLow];
101 corToQ1 = data->fCorFirstMoment[ekinIndxLow];
102 corToG2PerG1 = data->fCorSecondMoment[ekinIndxLow];
103 if (remRfaction>0.) {
104 corToScr += remRfaction*(data->fCorScreening[ekinIndxLow+1] - data->fCorScreening[ekinIndxLow]);
105 corToQ1 += remRfaction*(data->fCorFirstMoment[ekinIndxLow+1] - data->fCorFirstMoment[ekinIndxLow]);
106 corToG2PerG1 += remRfaction*(data->fCorSecondMoment[ekinIndxLow+1] - data->fCorSecondMoment[ekinIndxLow]);
113 InitDataPerElement();
115 ClearDataPerMaterial();
117 InitDataPerMaterials();
121void G4GSPWACorrections::InitDataPerElement() {
123 if (fDataPerElement.size()<gMaxZet+1) {
124 fDataPerElement.resize(gMaxZet+1,
nullptr);
130 for (
G4int imc=0; imc<numMatCuts; ++imc) {
138 std::size_t numElems = elemVect->size();
139 for (std::size_t ielem=0; ielem<numElems; ++ielem) {
145 if (!fDataPerElement[izet]) {
146 LoadDataElement(
elem);
153void G4GSPWACorrections::InitDataPerMaterials() {
156 if (fDataPerMaterial.size()!=numMaterials) {
157 fDataPerMaterial.resize(numMaterials);
162 for (
G4int imc=0; imc<numMatCuts; ++imc) {
168 if (!fDataPerMaterial[mat->
GetIndex()]) {
169 InitDataMaterial(mat);
176void G4GSPWACorrections::LoadDataElement(
const G4Element *
elem) {
185 G4Exception(
"G4GSPWACorrection::LoadDataElement()",
"em0006",
187 "Environment variable G4LEDATA not defined");
190 std::string path(tmppath);
192 path +=
"/msc_GS/PWACor/el/";
194 path +=
"/msc_GS/PWACor/pos/";
196 std::string fname = path+
"cf_"+gElemSymbols[izet-1];
197 std::ifstream infile(fname,std::ios::in);
198 if (!infile.is_open()) {
199 std::string msg =
" Problem while trying to read " + fname +
" data file.\n";
204 auto perElem =
new DataPerMaterial();
205 perElem->fCorScreening.resize(gNumEkin,0.0);
206 perElem->fCorFirstMoment.resize(gNumEkin,0.0);
207 perElem->fCorSecondMoment.resize(gNumEkin,0.0);
208 fDataPerElement[izet] = perElem;
210 for (
G4int iek=0; iek<gNumEkin; ++iek) {
212 infile >> perElem->fCorScreening[iek];
213 infile >> perElem->fCorFirstMoment[iek];
214 infile >> perElem->fCorSecondMoment[iek];
220void G4GSPWACorrections::InitDataMaterial(
const G4Material *mat) {
223 constexpr G4double finstrc2 = 5.325135453E-5;
225 G4double constFactor = CLHEP::electron_mass_c2*CLHEP::fine_structure_const/0.88534;
226 constFactor *= constFactor;
228 auto perMat =
new DataPerMaterial();
229 perMat->fCorScreening.resize(gNumEkin,0.0);
230 perMat->fCorFirstMoment.resize(gNumEkin,0.0);
231 perMat->fCorSecondMoment.resize(gNumEkin,0.0);
232 fDataPerMaterial[mat->
GetIndex()] = perMat;
248 for (
G4int ielem=0; ielem<numElems; ++ielem) {
249 G4double zet = (*elemVect)[ielem]->GetZ();
253 G4double iwa = (*elemVect)[ielem]->GetN();
254 G4double ipz = nbAtomsPerVolVect[ielem]/totNbAtomsPerVol;
257 ze += dum*(-2.0/3.0)*
G4Log(zet);
258 zx += dum*
G4Log(1.0+3.34*finstrc2*zet*zet);
263 moliereBc = const1*density*zs/sa*
G4Exp(ze/zs)/
G4Exp(zx/zs);
264 moliereXc2 = const2*density*zs/sa;
266 moliereBc *= 1.0/CLHEP::cm;
267 moliereXc2 *= CLHEP::MeV*CLHEP::MeV/CLHEP::cm;
270 for (
G4int iek=0; iek<gNumEkin; ++iek) {
273 G4double pt2 = ekin*(ekin+2.0*CLHEP::electron_mass_c2);
275 G4double b2 = fMinBeta2+(iek-(gNumEkin-gNumBeta2))/fInvDelBeta2;
276 ekin = CLHEP::electron_mass_c2*(1./std::sqrt(1.-b2)-1.);
277 pt2 = ekin*(ekin+2.0*CLHEP::electron_mass_c2);
280 for (
G4int ielem=0; ielem<numElems; ++ielem) {
288 DataPerMaterial *perElem = fDataPerElement[izet];
291 G4double nZZPlus1 = nbAtomsPerVolVect[ielem]*zet*(zet+1.0)/totNbAtomsPerVol;
295 G4double mcScrCF = perElem->fCorScreening[iek];
300 perMat->fCorScreening[iek] += nZZPlus1*
G4Log(Z23*mcScrCF);
303 mcScrCF *= constFactor*Z23/(4.*pt2);
313 perMat->fCorFirstMoment[iek] += nZZPlus1*(
G4Log(1.+1./mcScrCF)-1./(1.+mcScrCF))*perElem->fCorFirstMoment[iek];
318 perMat->fCorSecondMoment[iek] += nZZPlus1*perElem->fCorSecondMoment[iek];
321 if (ielem==numElems-1) {
326 perMat->fCorScreening[iek] = constFactor*dumScr*moliereBc/moliereXc2;
330 G4double scrCorTed = constFactor*dumScr/(4.*pt2);
332 perMat->fCorFirstMoment[iek] = perMat->fCorFirstMoment[iek]/(zs*(dum0-1./(1.+scrCorTed)));
336 G4double G2PerG1 = 3.*(1.+scrCorTed)*((1.+2.*scrCorTed)*dum0-2.)/((1.+scrCorTed)*dum0-1.);
337 perMat->fCorSecondMoment[iek] = perMat->fCorSecondMoment[iek]/(zs*G2PerG1);
345void G4GSPWACorrections::ClearDataPerElement() {
346 for (std::size_t i=0; i<fDataPerElement.size(); ++i) {
347 if (fDataPerElement[i]) {
348 fDataPerElement[i]->fCorScreening.clear();
349 fDataPerElement[i]->fCorFirstMoment.clear();
350 fDataPerElement[i]->fCorSecondMoment.clear();
351 delete fDataPerElement[i];
354 fDataPerElement.clear();
358void G4GSPWACorrections::ClearDataPerMaterial() {
359 for (std::size_t i=0; i<fDataPerMaterial.size(); ++i) {
360 if (fDataPerMaterial[i]) {
361 fDataPerMaterial[i]->fCorScreening.clear();
362 fDataPerMaterial[i]->fCorFirstMoment.clear();
363 fDataPerMaterial[i]->fCorSecondMoment.clear();
364 delete fDataPerMaterial[i];
367 fDataPerMaterial.clear();
std::vector< const G4Element * > G4ElementVector
const char * G4FindDataDir(const char *)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
G4double G4Log(G4double x)
G4GSPWACorrections(G4bool iselectron=true)
void GetPWACorrectionFactors(G4double logekin, G4double beta2, G4int matindx, G4double &corToScr, G4double &corToQ1, G4double &corToG2PerG1)
const G4Material * GetMaterial() const
G4double GetDensity() const
const G4ElementVector * GetElementVector() const
G4double GetTotNbOfAtomsPerVolume() const
static size_t GetNumberOfMaterials()
size_t GetNumberOfElements() const
const G4double * GetVecNbOfAtomsPerVolume() const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
std::size_t GetTableSize() const
static G4ProductionCutsTable * GetProductionCutsTable()