53 G4String G4LevelReader::fFloatingLevels[] = {
54 "-",
"+X",
"+Y",
"+Z",
"+U",
"+V",
"+W",
"+R",
"+S",
"+T",
"+A",
"+B",
"+C"};
57 : fData(ptr),fAlphaMax(9.0e9f),fVerbose(0),fLevelMax(632),fTransMax(145)
61 char* directory = getenv(
"G4LEVELGAMMADATA");
63 fDirectory = directory;
66 "Environment variable G4LEVELGAMMADATA is not defined");
69 fFile = fDirectory +
"/z100.a200";
71 for(
G4int i=0; i<10; ++i) { fICC[i] = 0.0f; }
72 for(
G4int i=0; i<nbufmax; ++i) { buffer[i] =
' '; }
73 for(
G4int i=0; i<nbuf1; ++i) { buff1[i] =
' '; }
74 for(
G4int i=0; i<nbuf2; ++i) { buff2[i] =
' '; }
75 bufp[0] = bufp[1] = bufp[2] =
' ';
77 fEnergy = fCurrEnergy = fTrEnergy = 0.0;
78 fTime = fProb = fSpin = fAlpha = fRatio = fNorm1 = 0.0f;
80 vTrans.resize(fTransMax,0);
81 vRatio.resize(fTransMax,0.0f);
82 vGammaCumProbability.resize(fTransMax,0.0f);
83 vGammaProbability.resize(fTransMax,0.0f);
84 vShellProbability.resize(fTransMax,
nullptr);
85 vMpRatio.resize(fTransMax,0.0f);
87 vEnergy.resize(fLevelMax,0.0f);
88 vSpin.resize(fLevelMax,0);
89 vLevel.resize(fLevelMax,
nullptr);
95 std::ostringstream ss;
96 ss <<
"/z" << Z <<
".a" <<
A;
98 fFile = fDirectory + st;
105 vEnergy.resize(1,0.0f);
107 vLevel.resize(1,
nullptr);
110 vGammaCumProbability.clear();
111 vGammaProbability.clear();
112 vShellProbability.clear();
115 std::ifstream infile(filename, std::ios::in);
118 if (!infile.is_open()) {
120 G4cout <<
" G4LevelReader: fail open file for Z= "
122 <<
" <" << filename <<
">" <<
G4endl;
129 G4cout <<
"G4LevelReader: open file for Z= "
131 <<
" <" << filename <<
">" <<
G4endl;
143 G4bool isOK = (ReadDataItem(infile,fEnergy) &&
144 ReadDataItem(infile,fTrEnergy) &&
145 ReadDataItem(infile,fProb) &&
146 ReadDataItem(infile,fPol) &&
147 ReadDataItem(infile,fTime) &&
148 ReadDataItem(infile,fSpin) &&
149 ReadDataItem(infile,fAlpha));
159 for(
G4int i=0; i<10; ++i) {
160 isOK = (isOK && (ReadDataItem(infile,fICC[i])));
168 G4cout <<
"#Line " << nline <<
" " << fEnergy <<
" " << fTrEnergy
169 <<
" " << fProb <<
" " << fPol <<
" " << fTime <<
" "
170 << fSpin <<
" " << fAlpha <<
G4endl;
172 for(
G4int i=0; i<10; ++i) {
G4cout << fICC[i] <<
" "; }
176 if(end || fEnergy > fCurrEnergy) {
177 size_t nn = vTrans.size();
181 G4cout <<
"Reader: new level E= " << fEnergy
182 <<
" Ntransitions= " << nn+1 <<
" fNorm1= " << fNorm1
186 fNorm1 = 1.0f/fNorm1;
187 for(
size_t i=0; i<
nn; ++i) {
188 vGammaCumProbability[i] *= fNorm1;
190 G4cout <<
"Probabilities[" << i
191 <<
"]= " << vGammaCumProbability[i]
192 <<
" idxTrans= " << index
196 vGammaCumProbability[
nn] = 1.0f;
198 G4cout <<
"Probabilities[" << nn <<
"]= "
199 << vGammaCumProbability[
nn]
200 <<
" IdxTrans= " << index
203 vLevel.push_back(
new G4NucLevel(vTrans.size(), fTime,
205 vGammaCumProbability,
213 vLevel.push_back(
nullptr);
216 vLevel.push_back(
nullptr);
218 vSpin.push_back(spin);
220 vGammaCumProbability.clear();
221 vGammaProbability.clear();
222 vShellProbability.clear();
224 if(!end) { next =
true; }
230 G4cout <<
"== Reader: begin of new level E= " << fEnergy
231 <<
" Prob= " << fProb <<
G4endl;
234 size_t nn = vEnergy.size();
235 if(0 < nn && vEnergy[nn-1] > ener) {
236 ener = vEnergy[nn-1];
238 vEnergy.push_back(ener);
239 fCurrEnergy = fEnergy;
240 fTime *= fTimeFactor;
241 if(fSpin > 20.0f) { fSpin = 0.0; }
242 spin = (
G4int)(fSpin+fSpin);
255 size_t nn = vEnergy.size();
259 for(
size_t i=0; i<nn-1; ++i) {
260 G4float ediff = std::abs(efinal - vEnergy[i]);
267 if(ediff < ediffMin) {
271 if(ediff <= x_energy) {
break; }
274 if(std::abs(vEnergy[nn-1] - elevel) < x_energy) { tnum = 1; }
278 vGammaCumProbability.push_back(fNorm1);
279 vGammaProbability.push_back(1.0f/x);
280 vMpRatio.push_back(0.0f);
281 vTrans.push_back(tnum + idxLevel*10000);
282 if(allLevels && fAlpha > 0.0f) {
283 vShellProbability.push_back(NormalizedICCProbability(Z));
285 vShellProbability.push_back(
nullptr);
290 G4cout <<
"G4LevelReader: Line #" << nline <<
" Z= " << Z <<
" A= "
291 <<
" this file is too long - stop loading" <<
G4endl;
300 if(vEnergy.size() >= 2) {
303 G4cout <<
"=== Reader: new manager for Z= " << Z <<
" A= " << A
304 <<
" Nlevels= " << vEnergy.size() <<
" E[0]= "
307 <<
" S: " << vEnergy.size()
308 <<
" " << vSpin.size() <<
" " << vLevel.size()
315 G4bool G4LevelReader::ReadData(std::istringstream& stream,
G4double&
x)
318 return stream.fail() ?
false :
true;
321 G4bool G4LevelReader::ReadDataItem(std::istream& dataFile,
G4double& x)
324 for(
G4int i=0; i<nbufmax; ++i) { buffer[i] =
' '; }
327 if(dataFile.fail()) { okay =
false; }
328 else { x = strtod(buffer, 0); }
333 G4bool G4LevelReader::ReadDataItem(std::istream& dataFile,
G4float& x)
336 for(
G4int i=0; i<nbuf1; ++i) { buff1[i] =
' '; }
339 if(dataFile.fail()) { okay =
false; }
340 else { x = atof(buff1); }
345 G4bool G4LevelReader::ReadDataItem(std::istream& dataFile,
G4int& ix)
348 for(
G4int i=0; i<nbuf2; ++i) { buff2[i] =
' '; }
351 if(dataFile.fail()) { okay =
false; }
352 else { ix = atoi(buff2); }
357 G4bool G4LevelReader::ReadDataItem(std::istream& dataFile,
G4String& x)
360 bufp[0] = bufp[1] =
' ';
362 if(dataFile.fail()) { okay =
false; }
368 const std::vector<G4float>* G4LevelReader::NormalizedICCProbability(
G4int Z)
370 std::vector<G4float>* vec =
nullptr;
394 if(LL < 3) {
for(
G4int i=LL+1; i<=4; ++i) { fICC[i] = 0.0f; } }
395 if(M < 5) {
for(
G4int i=M+4; i<=8; ++i) { fICC[i] = 0.0f; } }
396 if(N < 1) { fICC[9] = 0.0f; }
399 for(
G4int i=0; i<10; ++i) {
403 if(norm == 0.0f && fAlpha > fAlphaMax) {
404 fICC[9] = norm = 1.0f;
408 vec =
new std::vector<G4float>;
410 for(
G4int i=0; i<10; ++i) {
412 if(x > 0.995f || 9 == i) {
413 vec->push_back(1.0f);
420 G4cout <<
"# InternalConv: ";
433 std::ostringstream ss;
434 ss <<
"/correlated_gamma/z" << Z <<
".a" <<
A;
436 fFile = fDirectory + st;
437 std::ifstream infile(fFile, std::ios::in);
440 if (!infile.is_open()) {
443 ed <<
" for Z= " << Z <<
" A= " << A
444 <<
" <" << fFile <<
"> is not opened!";
445 G4Exception(
"G4LevelReader::CreateLevelManagerNEW(..)",
"had014",
451 G4cout <<
"G4LevelReader: open file for Z= "
453 <<
" <" << fFile <<
">" <<
G4endl;
455 return LevelManager(Z, A, 0, infile);
462 std::ifstream infile(filename, std::ios::in);
465 if (!infile.is_open()) {
466 if(Z < 6 || fVerbose > 0) {
468 ed <<
" for Z= " << Z <<
" A= " << A
469 <<
" data file <" << filename <<
"> is not opened!";
470 G4Exception(
"G4LevelReader::MakeLevelManagerNEW(..)",
"had014",
476 G4cout <<
"G4LevelReader: open file for Z= "
478 <<
" <" << filename <<
">" <<
G4endl;
480 return LevelManager(Z, A, 0, infile);
485 std::ifstream& infile)
490 G4int nlevels = (0 == nlev) ? fLevelMax : nlev;
492 G4cout <<
"## New isotope Z= " << Z <<
" A= " <<
A;
493 if(nlevels < fLevelMax) {
G4cout <<
" Nlevels= " << nlevels; }
496 if(nlevels > fLevelMax) {
498 vEnergy.resize(fLevelMax,0.0f);
499 vSpin.resize(fLevelMax,0);
500 vLevel.resize(fLevelMax,
nullptr);
502 G4int ntrans(0), i1, i, k;
508 for(i=0; i<nlevels; ++i) {
513 G4cout <<
"### End of file Z= " << Z <<
" A= " << A
514 <<
" Nlevels= " << i <<
G4endl;
520 ed <<
" G4LevelReader: wrong data file for Z= " << Z <<
" A= " << A
521 <<
" level #" << i <<
" has index " << i1 <<
G4endl;
522 G4Exception(
"G4LevelReader::LevelManager(..)",
"had014",
526 if(!(ReadDataItem(infile,ener) &&
527 ReadDataItem(infile,fTime) &&
528 ReadDataItem(infile,fSpin) &&
529 ReadDataItem(infile,ntrans))) {
531 G4cout <<
"### End of file Z= " << Z <<
" A= " << A
532 <<
" Nlevels= " << i <<
G4endl;
537 for(k=0; k<nfloting; ++k) {
538 if(xf == fFloatingLevels[k]) {
545 if(ener < vEnergy[i-1]) {
546 G4cout <<
"### G4LevelReader: broken level " << i
547 <<
" E(MeV)= " << ener <<
" < " << vEnergy[i-1]
548 <<
" for isotope Z= " << Z <<
" A= "
549 << A <<
" level energy increased" <<
G4endl;
554 if(fTime > 0.0) { fTime *= fTimeFactor; }
555 if(fSpin > 20.0f) { fSpin = 0.0f; }
556 vSpin[i] = (
G4int)(100 + fSpin + fSpin) + k*100000;
559 <<
" LTime(s)= " << fTime <<
" 2S= " << vSpin[i]
560 <<
" meta= " << vSpin[i]/100000 <<
" idx= " << i
561 <<
" ntr= " << ntrans <<
G4endl;
564 if(ntrans == 0 && fTime < 0.0) {
567 vGammaCumProbability,
571 }
else if(ntrans > 0) {
574 if(ntrans > fTransMax) {
576 vTrans.resize(fTransMax);
577 vRatio.resize(fTransMax);
578 vGammaCumProbability.resize(fTransMax);
579 vGammaProbability.resize(fTransMax);
580 vShellProbability.resize(fTransMax);
581 vMpRatio.resize(fTransMax);
584 for(
G4int j=0; j<ntrans; ++j) {
586 if(!(ReadDataItem(infile,i2) &&
587 ReadDataItem(infile,tener) &&
588 ReadDataItem(infile,fProb) &&
589 ReadDataItem(infile,tnum) &&
590 ReadDataItem(infile,vRatio[j]) &&
591 ReadDataItem(infile,fAlpha))) {
595 G4cout <<
"### Fail to read transition j= " << j
596 <<
" Z= " << Z <<
" A= " << A <<
G4endl;
601 G4cout <<
"### G4LevelReader: broken transition " << j
602 <<
" from level " << i <<
" to " << i2
603 <<
" for isotope Z= " << Z <<
" A= "
604 << A <<
" - use ground level" <<
G4endl;
607 vTrans[j] = i2*10000 + tnum;
608 if(fAlpha < fAlphaMax) {
611 vGammaCumProbability[j] = fNorm1;
612 vGammaProbability[j] = 1.0f/
x;
616 vGammaCumProbability[j] = fNorm1;
617 vGammaProbability[j] = 0.0f;
619 vShellProbability[j] =
nullptr;
622 G4cout <<
"### Transition #" << j <<
" to level " << i2
623 <<
" i2= " << i2 <<
" Etrans(MeV)= " << tener*fkev
624 <<
" fProb= " << fProb <<
" MultiP= " << tnum
625 <<
" fMpRatio= " << fRatio <<
" fAlpha= " << fAlpha
630 for(k=0; k<10; ++k) {
632 if(!ReadDataItem(infile,fICC[k])) {
635 G4cout <<
"### Fail to read convertion coeff k= " << k
636 <<
" for transition j= " << j
637 <<
" Z= " << Z <<
" A= " << A <<
G4endl;
643 vShellProbability[j] = NormalizedICCProbability(Z);
644 if(!vShellProbability[j]) { vGammaProbability[j] = 1.0f; }
648 if(0.0f < fNorm1) { fNorm1 = 1.0f/fNorm1; }
649 G4int nt = ntrans - 1;
650 for(k=0; k<nt; ++k) {
651 vGammaCumProbability[k] *= fNorm1;
653 G4cout <<
"Probabilities[" << k
654 <<
"]= " << vGammaCumProbability[k]
655 <<
" " << vGammaProbability[k]
656 <<
" idxTrans= " << vTrans[k]/10000
660 vGammaCumProbability[nt] = 1.0f;
662 G4cout <<
"Probabilities[" << nt <<
"]= "
663 << vGammaCumProbability[nt]
664 <<
" " << vGammaProbability[nt]
665 <<
" IdxTrans= " << vTrans[nt]/10000
669 G4cout <<
" New G4NucLevel: Ntrans= " << ntrans
670 <<
" Time(ns)= " << fTime <<
G4endl;
672 vLevel[i] =
new G4NucLevel((
size_t)ntrans, fTime,
674 vGammaCumProbability,
684 G4cout <<
"=== Reader: new manager for Z= " << Z <<
" A= " << A
685 <<
" Nlevels= " << i <<
" E[0]= "
static G4Pow * GetInstance()
std::ostringstream G4ExceptionDescription
static constexpr double keV
G4LevelReader(G4NuclearLevelData *)
const G4LevelManager * MakeLevelManager(G4int Z, G4int A, const G4String &filename)
const G4LevelManager * CreateLevelManagerNEW(G4int Z, G4int A)
G4double logZ(G4int Z) const
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
static constexpr double MeV
G4DeexPrecoParameters * GetParameters()
G4bool StoreAllLevels() const
static constexpr double eV
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
static const G4int LL[nN]
static constexpr double second
const G4LevelManager * MakeLevelManagerNEW(G4int Z, G4int A, const G4String &filename)
const G4LevelManager * CreateLevelManager(G4int Z, G4int A)
G4float MaxLevelEnergy() const