53 const G4int countmax = 4;
54 const G4int nfloting = 13;
55 const G4double eTolarence = 2*CLHEP::eV;
56 const G4String fFloatingLevels[13] = {
57 "-",
"+X",
"+Y",
"+Z",
"+U",
"+V",
"+W",
"+R",
"+S",
"+T",
"+A",
"+B",
"+C"};
67 vTrans.resize(fTransMax,0);
68 vRatio.resize(fTransMax,0.0f);
69 vGammaCumProbability.resize(fTransMax,0.0f);
70 vGammaProbability.resize(fTransMax,0.0f);
71 vShellProbability.resize(fTransMax,
nullptr);
73 vEnergy.resize(fLevelMax,0.0);
74 vSpin.resize(fLevelMax,0);
75 vLevel.resize(fLevelMax,
nullptr);
78G4bool G4LevelReader::ReadData(std::istringstream& stream,
G4double& x)
81 return !stream.fail();
84G4bool G4LevelReader::ReadDataItem(std::istream& dataFile,
G4double& x)
87 for(
G4int i=0; i<nbufmax; ++i) { buffer[i] =
' '; }
90 if(dataFile.fail()) { okay =
false; }
91 else { x = std::strtod(buffer, 0); }
95G4bool G4LevelReader::ReadDataItem(std::istream& dataFile,
G4float& x)
98 for(
G4int i=0; i<nbuf1; ++i) { buff1[i] =
' '; }
101 if(dataFile.fail()) { okay =
false; }
102 else { x = std::atof(buff1); }
107G4bool G4LevelReader::ReadDataItem(std::istream& dataFile,
G4int& ix)
110 for(
G4int i=0; i<nbuf2; ++i) { buff2[i] =
' '; }
113 if(dataFile.fail()) { okay =
false; }
114 else { ix = std::atoi(buff2); }
119const std::vector<G4float>* G4LevelReader::NormalizedICCProbability(
G4int Z)
121 std::vector<G4float>* vec =
nullptr;
145 if(LL < 3) {
for(
G4int i=LL+1; i<=4; ++i) { fICC[i] = 0.0f; } }
146 if(
M < 5) {
for(
G4int i=
M+4; i<=8; ++i) { fICC[i] = 0.0f; } }
147 if(
N < 1) { fICC[9] = 0.0f; }
150 for(
G4int i=0; i<10; ++i) {
154 if(norm == 0.0f && fAlpha > 0.0f) {
155 fICC[0] = norm = 1.0f;
159 vec =
new std::vector<G4float>;
161 for(
G4int i=0; i<10; ++i) {
163 if(x > 0.995f || 9 == i) {
164 vec->push_back(1.0f);
171 G4cout <<
"# InternalConv: ";
172 std::size_t
nn = vec->size();
173 for(std::size_t i=0; i<
nn; ++i) {
G4cout <<
" " << (*vec)[i]; }
184 std::ostringstream ss;
185 ss << fDirectory <<
"/z" << Z <<
".a" <<
A;
186 std::ifstream infile(ss.str(), std::ios::in);
189 if (!infile.is_open()) {
192 ed <<
"Regular file " << ss.str() <<
" is not opened! Z="
194 G4Exception(
"G4LevelReader::LevelManager(..)",
"had014",
201 G4cout <<
"G4LevelReader: open file " << ss.str() <<
" for Z= "
204 return LevelManager(Z,
A, infile);
210 std::ifstream infile(filename, std::ios::in);
213 if (!infile.is_open()) {
216 ed <<
"External file " << filename <<
" is not opened! Z="
218 G4Exception(
"G4LevelReader::LevelManager(..)",
"had014",
225 G4cout <<
"G4LevelReader: open external file " << filename
226 <<
" for Z= " << Z <<
" A= " <<
A <<
G4endl;
228 return LevelManager(Z,
A, infile);
232G4LevelReader::LevelManager(
G4int Z,
G4int A, std::ifstream& infile)
238 infile >> i1 >> fPol;
242 G4cout <<
"### End of file Z= " << Z <<
" A= " <<
A
243 <<
" Nlevels= " << i <<
G4endl;
250 G4cout <<
"New line: i1= " << i1 <<
" fPol= <" << fPol <<
"> " <<
G4endl;
254 if (!(ReadDataItem(infile, fEnergy) &&
255 ReadDataItem(infile, fTime) &&
256 ReadDataItem(infile, fSpin) &&
257 ReadDataItem(infile, ntrans))) {
259 G4cout <<
"### Incomplete end of file Z= " << Z <<
" A= " <<
A
260 <<
" Nlevels= " << i <<
G4endl;
264 fEnergy *= CLHEP::keV;
265 for (k=0; k<nfloting; ++k) {
266 if (fPol == fFloatingLevels[k]) {
273 if (fEnergy < vEnergy[i-1]) {
276 if (count1 < countmax && fVerbose > 0) {
277 G4cout <<
"### G4LevelReader: broken level " << i
278 <<
" E(MeV)= " << fEnergy <<
" < " << vEnergy[i-1]
279 <<
" for isotope Z= " << Z <<
" A= "
280 <<
A <<
" level energy increased" <<
G4endl;
284 fEnergy = vEnergy[i-1] + eTolarence;
287 vEnergy[i] = fEnergy;
288 if (fTime > 0.0) { fTime *= fTimeFactor; }
289 else if (fTime < 0.0) { fTime =
DBL_MAX; }
292 twos = std::max(twos, -100);
293 vSpin[i] = 100 + twos + k*100000;
296 G4cout <<
" Level #" << i1 <<
" E(MeV)=" << fEnergy/CLHEP::MeV
297 <<
" LTime(s)=" << fTime <<
" 2S=" << vSpin[i]
298 <<
" meta=" << vSpin[i]/100000 <<
" idx=" << i
299 <<
" ntr=" << ntrans <<
G4endl;
304 vLevel[i] =
new G4NucLevel(0, fTime, vTrans,
305 vGammaCumProbability,
309 }
else if (ntrans > 0) {
312 if (ntrans > fTransMax) {
314 vTrans.resize(fTransMax);
315 vRatio.resize(fTransMax);
316 vGammaCumProbability.resize(fTransMax);
317 vGammaProbability.resize(fTransMax);
318 vShellProbability.resize(fTransMax);
321 for (
G4int j=0; j<ntrans; ++j) {
323 if (!(ReadDataItem(infile, i2) &&
324 ReadDataItem(infile, fTransEnergy) &&
325 ReadDataItem(infile, fProb) &&
326 ReadDataItem(infile, tnum) &&
327 ReadDataItem(infile, vRatio[j]) &&
328 ReadDataItem(infile, fAlpha))) {
331 if (count2 < countmax && fVerbose > 0) {
332 G4cout <<
"### Fail to read transition j=" << j
333 <<
" j=" << j <<
" i2=" << i2
334 <<
" Z=" << Z <<
" A=" <<
A <<
G4endl;
342 if (count2 < countmax) {
343 G4cout <<
"### G4LevelReader: broken transition " << j
344 <<
" from level " << i <<
" to " << i2
345 <<
" for isotope Z= " << Z <<
" A= "
346 <<
A <<
"; the transition probability set to zero" <<
G4endl;
352 vTrans[j] = i2*10000 + tnum;
353 fAlpha = std::min(std::max(fAlpha,0.f), fAlphaMax);
356 vGammaCumProbability[j] = fNorm1;
357 vGammaProbability[j] = 1.0f/x;
358 vShellProbability[j] =
nullptr;
361 G4cout <<
"### Transition #" << j <<
" to level " << i2
362 <<
" i2= " << i2 <<
" Etrans(MeV)= " << fTransEnergy*CLHEP::keV
363 <<
" fProb= " << fProb <<
" MultiP= " << tnum
364 <<
" fMpRatio= " << fRatio <<
" fAlpha= " << fAlpha
369 for (k=0; k<10; ++k) {
370 if (!ReadDataItem(infile,fICC[k])) {
374 if (count2 < countmax) {
375 G4cout <<
"### G4LevelReader: fail to read conversion coeff k= " << k
376 <<
" for transition j= " << j
377 <<
" Z= " << Z <<
" A= " <<
A <<
G4endl;
380 for(kk=k; kk<10; ++kk) { fICC[kk] = 0.f; }
384 vShellProbability[j] = NormalizedICCProbability(Z);
389 G4int nt = ntrans - 1;
391 G4cout <<
"=== New G4NucLevel: Ntrans=" << ntrans
392 <<
" Time(ns)=" << fTime
393 <<
" IdxTrans=" << vTrans[nt]/10000
394 <<
" isOK=" << isTransOK
397 if (0.0f < fNorm1) { fNorm1 = 1.0f/fNorm1; }
398 for (k=0; k<nt; ++k) {
399 vGammaCumProbability[k] *= fNorm1;
402 G4cout <<
"Probabilities[" << k
403 <<
"]= " << vGammaCumProbability[k]
404 <<
" " << vGammaProbability[k]
405 <<
" idxTrans= " << vTrans[k]/10000
410 vGammaCumProbability[nt] = 1.0f;
411 vLevel[i] =
new G4NucLevel((std::size_t)ntrans, fTime, vTrans,
412 vGammaCumProbability,
419 if (i == fLevelMax) {
421 vEnergy.resize(fLevelMax, 0.0);
422 vSpin.resize(fLevelMax, 0);
423 vLevel.resize(fLevelMax,
nullptr);
426 G4LevelManager* lman =
nullptr;
428 lman =
new G4LevelManager(Z,
A, (std::size_t)i, vEnergy, vSpin, vLevel);
430 G4cout <<
"=== Reader: new manager for Z=" << Z <<
" A=" <<
A
431 <<
" Nlevels=" << i <<
" E[0]="
432 << vEnergy[0]/CLHEP::MeV <<
" MeV E1="
433 << vEnergy[i-1]/CLHEP::MeV <<
" MeV"
434 <<
" count1,2=" << count1 <<
", " << count2 <<
G4endl;
const char * G4FindDataDir(const char *)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cout
G4bool StoreICLevelData() const
const G4LevelManager * MakeLevelManager(G4int Z, G4int A, const G4String &filename)
const G4LevelManager * CreateLevelManager(G4int Z, G4int A)
G4LevelReader(G4NuclearLevelData *)
G4DeexPrecoParameters * GetParameters()
static G4Pow * GetInstance()
G4double logZ(G4int Z) const