53 G4String G4LevelReader::fFloatingLevels[] = {
54 "-",
"+X",
"+Y",
"+Z",
"+U",
"+V",
"+W",
"+R",
"+S",
"+T",
"+A",
"+B",
"+C"};
57 : fData(ptr),fAlphaMax(9.0f+9),fVerbose(0),fLevelMax(632),fTransMax(80)
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()) {
467 ed <<
" for Z= " << Z <<
" A= " << A
468 <<
" data file <" << filename <<
"> is not opened!";
469 G4Exception(
"G4LevelReader::MakeLevelManagerNEW(..)",
"had014",
474 G4cout <<
"G4LevelReader: open file for Z= "
476 <<
" <" << filename <<
">" <<
G4endl;
478 return LevelManager(Z, A, 0, infile);
483 std::ifstream& infile)
488 G4int nlevels = (0 == nlev) ? fLevelMax : nlev;
490 G4cout <<
"## New isotope Z= " << Z <<
" A= " <<
A;
491 if(nlevels < fLevelMax) {
G4cout <<
" Nlevels= " << nlevels; }
494 if(nlevels > fLevelMax) {
496 vEnergy.resize(fLevelMax,0.0f);
497 vSpin.resize(fLevelMax,0);
498 vLevel.resize(fLevelMax,
nullptr);
500 G4int ntrans(0), i1, i, k;
506 for(i=0; i<nlevels; ++i) {
511 G4cout <<
"### End of file Z= " << Z <<
" A= " << A
512 <<
" Nlevels= " << i <<
G4endl;
518 ed <<
" G4LevelReader: wrong data file for Z= " << Z <<
" A= " << A
519 <<
" level #" << i <<
" has index " << i1 <<
G4endl;
520 G4Exception(
"G4LevelReader::LevelManager(..)",
"had014",
524 if(!(ReadDataItem(infile,ener) &&
525 ReadDataItem(infile,fTime) &&
526 ReadDataItem(infile,fSpin) &&
527 ReadDataItem(infile,ntrans))) {
529 G4cout <<
"### End of file Z= " << Z <<
" A= " << A
530 <<
" Nlevels= " << i <<
G4endl;
536 for(k=0; k<nfloting; ++k) {
537 if(xf == fFloatingLevels[k]) {
544 if(ener < vEnergy[i-1]) {
545 G4cout <<
"### G4LevelReader: broken level " << i
546 <<
" E(MeV)= " << ener <<
" < " << vEnergy[i-1]
547 <<
" for isotope Z= " << Z <<
" A= "
548 << A <<
" level energy increased" <<
G4endl;
553 fTime *= fTimeFactor;
554 if(fSpin > 20.0f) { fSpin = 0.0f; }
555 vSpin[i] = (
G4int)(100 + fSpin + fSpin) + k*100000;
558 <<
" LTime(s)= " << fTime <<
" 2S= " << vSpin[i]
559 <<
" meta= " << vSpin[i]/100000 <<
" idx= " << i
560 <<
" ntr= " << ntrans <<
G4endl;
566 if(ntrans > fTransMax) {
568 vTrans.resize(fTransMax);
569 vRatio.resize(fTransMax);
570 vGammaCumProbability.resize(fTransMax);
571 vGammaProbability.resize(fTransMax);
572 vShellProbability.resize(fTransMax);
573 vMpRatio.resize(fTransMax);
576 for(
G4int j=0; j<ntrans; ++j) {
578 if(!(ReadDataItem(infile,i2) &&
579 ReadDataItem(infile,tener) &&
580 ReadDataItem(infile,fProb) &&
581 ReadDataItem(infile,tnum) &&
582 ReadDataItem(infile,vRatio[j]) &&
583 ReadDataItem(infile,fAlpha))) {
587 G4cout <<
"### Fail to read transition j= " << j
588 <<
" Z= " << Z <<
" A= " << A <<
G4endl;
593 G4cout <<
"### G4LevelReader: broken transition " << j
594 <<
" from level " << i <<
" to " << i2
595 <<
" for isotope Z= " << Z <<
" A= "
596 << A <<
" - use ground level" <<
G4endl;
599 vTrans[j] = i2*10000 + tnum;
600 if(fAlpha < fAlphaMax) {
603 vGammaCumProbability[j] = fNorm1;
604 vGammaProbability[j] = 1.0f/x;
608 vGammaCumProbability[j] = fNorm1;
609 vGammaProbability[j] = 0.0f;
611 vShellProbability[j] =
nullptr;
614 G4cout <<
"### Transition #" << j <<
" to level " << i2
615 <<
" i2= " << i2 <<
" Etrans(MeV)= " << tener*fkev
616 <<
" fProb= " << fProb <<
" MultiP= " << tnum
617 <<
" fMpRatio= " << fRatio <<
" fAlpha= " << fAlpha
622 for(k=0; k<10; ++k) {
624 if(!ReadDataItem(infile,fICC[k])) {
627 G4cout <<
"### Fail to read convertion coeff k= " << k
628 <<
" for transition j= " << j
629 <<
" Z= " << Z <<
" A= " << A <<
G4endl;
635 vShellProbability[j] = NormalizedICCProbability(Z);
636 if(!vShellProbability[j]) { vGammaProbability[j] = 1.0f; }
640 if(0.0f < fNorm1) { fNorm1 = 1.0f/fNorm1; }
641 G4int nt = ntrans - 1;
642 for(k=0; k<nt; ++k) {
643 vGammaCumProbability[k] *= fNorm1;
645 G4cout <<
"Probabilities[" << k
646 <<
"]= " << vGammaCumProbability[k]
647 <<
" " << vGammaProbability[k]
648 <<
" idxTrans= " << vTrans[k]/10000
652 vGammaCumProbability[nt] = 1.0f;
654 G4cout <<
"Probabilities[" << nt <<
"]= "
655 << vGammaCumProbability[nt]
656 <<
" " << vGammaProbability[nt]
657 <<
" IdxTrans= " << vTrans[nt]/10000
661 G4cout <<
" New G4NucLevel: Ntrans= " << ntrans
662 <<
" Time(ns)= " << fTime <<
G4endl;
664 vLevel[i] =
new G4NucLevel((
size_t)ntrans, fTime,
666 vGammaCumProbability,
676 G4cout <<
"=== Reader: new manager for Z= " << Z <<
" A= " << A
677 <<
" 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