64 : fMaxZet(-1), fNumElEnergy(-1), fNumKappa(-1), fUsedLowEenergy(-1.),
65 fUsedHighEenergy(-1.), fLogMinElEnergy(-1.), fILDeltaElEnergy(-1.)
88 const G4int matCutIndx,
103 G4String msg =
" Gamma cut="+std::to_string(gcut) +
" [MeV] was not found ";
104 msg +=
"in case of Z = " + std::to_string(iZet) +
". ";
118 elEnergyIndx = (
G4int)val;
123 pIndxH = (lElEnergy-lGCut)/(
fLElEnergyVect[elEnergyIndx+1]-lGCut);
127 if (rndmEngine->
flat()<pIndxH) {
129 }
else if (isCorner) {
142 const std::vector<STPoint>& pVect = st->
fSTable;
143 const G4double minVal = cVect[gamCutIndx];
150 const G4double lCurKappaC = lGCut - leekin;
160 const G4double cumRV = rndm[0]*(1.-minVal)+minVal;
167 const STPoint& stPL = pVect[cumLIndx];
171 const G4double cumH = pVect[cumLIndx+1].fCum;
174 const G4double dm1 = (cumRV-cumL)/(cumH-cumL);
175 const G4double dm2 = (1.+pA+pB)*dm1;
176 const G4double dm3 = 1.+dm1*(pA+pB*dm1);
178 const G4double lKappa = lKL+dm2/dm3*(lKH-lKL);
180 kappa =
G4Exp(lKappa*lCurKappaC/lUsedKappaC);
184 kappa = 1.-rndm[0]*(1.-gcut/eekin);
187 eGamma = kappa*eekin;
188 const G4double invEGamma = 1./eGamma;
190 suppression = 1./(1.+dielSupConst*invEGamma*invEGamma);
199 const G4double dum = kAlpha2Pi*zet*(iBeta1 - iBeta2);
200 suppression = (dum > -12.) ? suppression*
G4Exp(dum) : 0.;
202 }
while (rndm[1] > suppression);
218 std::vector<size_t> vtmp(1,0);
220 for (
size_t imc=0; imc<numMatCuts; ++imc) {
229 const size_t numElems = elemVect->size();
230 for (
size_t ielem=0; ielem<numElems; ++ielem) {
243 size_t indx = std::find(cVect.begin(), cVect.end(), gamCut)-cVect.begin();
244 if (indx==cVect.size()) {
303 if (elEnergy>gamCut) {
307 const G4int iKLow = (cutKappa>1.e-12)
319 const G4double dum = pA*(alph-1.)-1.-pB;
324 val = -(dum+std::sqrt(dum*dum-4.*pB*alph*alph))/(2.*pB*alph);
325 val = val*(etaH-etaL)+etaL;
336 char* path = std::getenv(
"G4LEDATA");
338 G4Exception(
"G4SBBremTable::LoadSTGrid()",
"em0006",
343 std::ifstream infile(
fname,std::ios::in);
344 if (!infile.is_open()) {
346 G4Exception(
"G4SBBremTable::LoadSTGrid()",
"em0006",
394 char* path = std::getenv(
"G4LEDATA");
396 G4Exception(
"G4SBBremTable::LoadSamplingTables()",
"em0006",
401 + std::to_string(iz);
402 std::istringstream infile(std::ios::in);
444 infile >> dum; infile >> dum; infile >> dum;
505 while (i + 3 < size) {
506 if (vect [i + 0].fCum > val)
return i + 0;
507 if (vect [i + 1].fCum > val)
return i + 1;
508 if (vect [i + 2].fCum > val)
return i + 2;
509 if (vect [i + 3].fCum > val)
return i + 3;
513 if (vect [i].fCum > val)
522 std::istringstream &iss) {
523 std::string *dataString =
nullptr;
524 std::string compfilename(
fname+
".z");
527 std::ifstream in(compfilename, std::ios::binary | std::ios::ate);
530 int fileSize = in.tellg();
532 in.seekg(0,std::ios::beg);
534 Bytef *compdata =
new Bytef[fileSize];
536 in.read((
char*)compdata, fileSize);
539 uLongf complen = (uLongf)(fileSize*4);
540 Bytef *uncompdata =
new Bytef[complen];
541 while (
Z_OK!=
uncompress(uncompdata, &complen, compdata, fileSize)) {
545 uncompdata =
new Bytef[complen];
550 dataString =
new std::string((
char*)uncompdata, (
long)complen);
552 delete [] uncompdata;
554 std::string msg =
" Problem while trying to read "
555 + compfilename +
" data file.\n";
556 G4Exception(
"G4SBBremTable::ReadCompressedFile",
"em0006",
562 iss.str(*dataString);
static const G4double e1[44]
static const G4double e2[44]
std::vector< const G4Element * > G4ElementVector
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)
virtual void flatArray(const int size, double *vect)=0
const G4Material * GetMaterial() const
const G4ElementVector * GetElementVector() const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
std::size_t GetTableSize() const
const std::vector< G4double > * GetEnergyCutsVector(std::size_t pcIdx) const
static G4ProductionCutsTable * GetProductionCutsTable()
void ReadCompressedFile(const G4String &fname, std::istringstream &iss)
G4double fUsedHighEenergy
std::vector< SamplingTablePerZ * > fSBSamplingTables
std::vector< G4double > fElEnergyVect
std::vector< G4double > fKappaVect
void BuildSamplingTables()
G4int LinSearch(const std::vector< STPoint > &vect, const G4int size, const G4double val)
std::vector< G4double > fLKappaVect
double SampleEnergyTransfer(const G4double eekin, const G4double leekin, const G4double gcut, const G4double dielSupConst, const G4int izet, const G4int matCutIndx, const bool iselectron)
void LoadSamplingTables(G4int iz)
void Initialize(const G4double lowe, const G4double highe)
std::vector< G4double > fLElEnergyVect
void ClearSamplingTables()
void InitSamplingTables()
G4double fILDeltaElEnergy
static constexpr double electron_mass_c2
static constexpr double GeV
static constexpr double fine_structure_const
static constexpr double twopi
static constexpr double MeV
static constexpr double eV
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4bool isElectron(G4int ityp)
std::vector< G4double > fCumCutValues
std::vector< STPoint > fSTable
std::vector< std::vector< size_t > > fGamCutIndxToMatCutIndx
std::vector< G4double > fGammaECuts
std::vector< size_t > fMatCutIndxToGamCutIndx
std::vector< G4double > fLogGammaECuts
std::vector< STable * > fTablesPerEnergy
int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)