52G4String G4LevelReader::fFloatingLevels[] = {
53 "-",
"+X",
"+Y",
"+Z",
"+U",
"+V",
"+W",
"+R",
"+S",
"+T",
"+A",
"+B",
"+C"};
56 : fData(ptr),fVerbose(1),fLevelMax(632),fTransMax(145)
61 char* directory = std::getenv(
"G4LEVELGAMMADATA");
63 fDirectory = directory;
66 "Environment variable G4LEVELGAMMADATA is not defined");
70 for(
G4int i=0; i<10; ++i) { fICC[i] = 0.0f; }
71 for(
G4int i=0; i<nbufmax; ++i) { buffer[i] =
' '; }
72 for(
G4int i=0; i<nbuf1; ++i) { buff1[i] =
' '; }
73 for(
G4int i=0; i<nbuf2; ++i) { buff2[i] =
' '; }
74 bufp[0] = bufp[1] = bufp[2] =
' ';
76 fEnergy = fCurrEnergy = fTrEnergy = fTime = 0.0;
77 fProb = fSpin = fAlpha = fRatio = fNorm1 = 0.0f;
79 ntrans = i1 = i2 = k = kk = tnum = 0;
82 vTrans.resize(fTransMax,0);
83 vRatio.resize(fTransMax,0.0f);
84 vGammaCumProbability.resize(fTransMax,0.0f);
85 vGammaProbability.resize(fTransMax,0.0f);
86 vShellProbability.resize(fTransMax,
nullptr);
88 vEnergy.resize(fLevelMax,0.0);
89 vSpin.resize(fLevelMax,0);
90 vLevel.resize(fLevelMax,
nullptr);
93G4bool G4LevelReader::ReadData(std::istringstream& stream,
G4double& x)
96 return stream.fail() ? false :
true;
99G4bool G4LevelReader::ReadDataItem(std::istream& dataFile,
G4double& x)
102 for(
G4int i=0; i<nbufmax; ++i) { buffer[i] =
' '; }
105 if(dataFile.fail()) { okay =
false; }
106 else { x = strtod(buffer, 0); }
111G4bool G4LevelReader::ReadDataItem(std::istream& dataFile,
G4float& x)
114 for(
G4int i=0; i<nbuf1; ++i) { buff1[i] =
' '; }
117 if(dataFile.fail()) { okay =
false; }
118 else { x = atof(buff1); }
123G4bool G4LevelReader::ReadDataItem(std::istream& dataFile,
G4int& ix)
126 for(
G4int i=0; i<nbuf2; ++i) { buff2[i] =
' '; }
129 if(dataFile.fail()) { okay =
false; }
130 else { ix = atoi(buff2); }
135G4bool G4LevelReader::ReadDataItem(std::istream& dataFile,
G4String& x)
138 bufp[0] = bufp[1] =
' ';
140 if(dataFile.fail()) { okay =
false; }
146const std::vector<G4float>* G4LevelReader::NormalizedICCProbability(
G4int Z)
148 std::vector<G4float>* vec =
nullptr;
172 if(LL < 3) {
for(
G4int i=LL+1; i<=4; ++i) { fICC[i] = 0.0f; } }
173 if(M < 5) {
for(
G4int i=M+4; i<=8; ++i) { fICC[i] = 0.0f; } }
174 if(N < 1) { fICC[9] = 0.0f; }
177 for(
G4int i=0; i<10; ++i) {
181 if(norm == 0.0f && fAlpha > 0.0f) {
182 fICC[0] = norm = 1.0f;
186 vec =
new std::vector<G4float>;
188 for(
G4int i=0; i<10; ++i) {
190 if(x > 0.995f || 9 == i) {
191 vec->push_back(1.0f);
198 G4cout <<
"# InternalConv: ";
211 std::ostringstream ss;
212 ss << fDirectory <<
"/z" << Z <<
".a" <<
A;
213 std::ifstream infile(ss.str(), std::ios::in);
215 return LevelManager(Z,
A, 0, infile);
221 std::ifstream infile(filename, std::ios::in);
222 if (!infile.is_open()) {
224 ed <<
"User file for Z= " << Z <<
" A= " <<
A
225 <<
" is not opened!";
226 G4Exception(
"G4LevelReader::MakeLevelManager(..)",
"had014",
230 return LevelManager(Z,
A, 0, infile);
235 std::ifstream& infile)
238 if (!infile.is_open()) {
241 ed <<
" for Z= " << Z <<
" A= " <<
A
242 <<
" is not opened!";
243 G4Exception(
"G4LevelReader::LevelManager(..)",
"had014",
249 G4cout <<
"G4LevelReader: open file for Z= "
255 G4int nlevels = (0 == nlev) ? fLevelMax : nlev;
257 G4cout <<
"## New isotope Z= " << Z <<
" A= " <<
A;
258 if(nlevels < fLevelMax) {
G4cout <<
" Nlevels= " << nlevels; }
261 if(nlevels > fLevelMax) {
263 vEnergy.resize(fLevelMax,0.0);
264 vSpin.resize(fLevelMax,0);
265 vLevel.resize(fLevelMax,
nullptr);
273 for(i=0; i<nlevels; ++i) {
274 infile >> i1 >> fPol;
278 G4cout <<
"### End of file Z= " << Z <<
" A= " <<
A
279 <<
" Nlevels= " << i <<
G4endl;
285 ed <<
" G4LevelReader: wrong data file for Z= " << Z <<
" A= " <<
A
286 <<
" level #" << i <<
" has index " << i1 <<
G4endl;
287 G4Exception(
"G4LevelReader::LevelManager(..)",
"had014",
292 if(!(ReadDataItem(infile,ener) &&
293 ReadDataItem(infile,fTime) &&
294 ReadDataItem(infile,fSpin) &&
295 ReadDataItem(infile,ntrans))) {
297 G4cout <<
"### End of file Z= " << Z <<
" A= " <<
A
298 <<
" Nlevels= " << i <<
G4endl;
303 for(k=0; k<nfloting; ++k) {
304 if(fPol == fFloatingLevels[k]) {
311 if(ener < vEnergy[i-1]) {
312 G4cout <<
"### G4LevelReader: broken level " << i
313 <<
" E(MeV)= " << ener <<
" < " << vEnergy[i-1]
314 <<
" for isotope Z= " << Z <<
" A= "
315 <<
A <<
" level energy increased" <<
G4endl;
320 if(fTime > 0.0f) { fTime *= fTimeFactor; }
321 if(fSpin > 48.0f) { fSpin = 0.0f; }
322 vSpin[i] = (
G4int)(100 + fSpin + fSpin) + k*100000;
324 G4cout <<
" Level #" << i1 <<
" E(MeV)= " << ener/CLHEP::MeV
325 <<
" LTime(s)= " << fTime <<
" 2S= " << vSpin[i]
326 <<
" meta= " << vSpin[i]/100000 <<
" idx= " << i
327 <<
" ntr= " << ntrans <<
G4endl;
330 if(ntrans == 0 && fTime < 0.0) {
333 vGammaCumProbability,
337 }
else if(ntrans > 0) {
340 if(ntrans > fTransMax) {
342 vTrans.resize(fTransMax);
343 vRatio.resize(fTransMax);
344 vGammaCumProbability.resize(fTransMax);
345 vGammaProbability.resize(fTransMax);
346 vShellProbability.resize(fTransMax);
349 for(
G4int j=0; j<ntrans; ++j) {
351 if(!(ReadDataItem(infile,i2) &&
352 ReadDataItem(infile,tener) &&
353 ReadDataItem(infile,fProb) &&
354 ReadDataItem(infile,tnum) &&
355 ReadDataItem(infile,vRatio[j]) &&
356 ReadDataItem(infile,fAlpha))) {
360 G4cout <<
"### Fail to read transition j= " << j
361 <<
" Z= " << Z <<
" A= " <<
A <<
G4endl;
366 G4cout <<
"### G4LevelReader: broken transition " << j
367 <<
" from level " << i <<
" to " << i2
368 <<
" for isotope Z= " << Z <<
" A= "
369 <<
A <<
" - use ground level" <<
G4endl;
372 vTrans[j] = i2*10000 + tnum;
373 fAlpha = std::min(std::max(fAlpha,0.f), fAlphaMax);
376 vGammaCumProbability[j] = fNorm1;
377 vGammaProbability[j] = 1.0f/x;
378 vShellProbability[j] =
nullptr;
381 G4cout <<
"### Transition #" << j <<
" to level " << i2
382 <<
" i2= " << i2 <<
" Etrans(MeV)= " << tener*CLHEP::keV
383 <<
" fProb= " << fProb <<
" MultiP= " << tnum
384 <<
" fMpRatio= " << fRatio <<
" fAlpha= " << fAlpha
389 for(k=0; k<10; ++k) {
391 if(!ReadDataItem(infile,fICC[k])) {
394 G4cout <<
"### Fail to read conversion coeff k= " << k
395 <<
" for transition j= " << j
396 <<
" Z= " << Z <<
" A= " <<
A <<
G4endl;
398 for(kk=k; kk<10; ++kk) { fICC[kk] = 0.f; }
403 vShellProbability[j] = NormalizedICCProbability(Z);
404 if(!vShellProbability[j]) { vGammaProbability[j] = 1.0f; }
408 if(0.0f < fNorm1) { fNorm1 = 1.0f/fNorm1; }
409 G4int nt = ntrans - 1;
410 for(k=0; k<nt; ++k) {
411 vGammaCumProbability[k] *= fNorm1;
413 G4cout <<
"Probabilities[" << k
414 <<
"]= " << vGammaCumProbability[k]
415 <<
" " << vGammaProbability[k]
416 <<
" idxTrans= " << vTrans[k]/10000
420 vGammaCumProbability[nt] = 1.0f;
422 G4cout <<
"Probabilities[" << nt <<
"]= "
423 << vGammaCumProbability[nt]
424 <<
" " << vGammaProbability[nt]
425 <<
" IdxTrans= " << vTrans[nt]/10000
429 G4cout <<
" New G4NucLevel: Ntrans= " << ntrans
430 <<
" Time(ns)= " << fTime <<
G4endl;
432 vLevel[i] =
new G4NucLevel((
size_t)ntrans, fTime,
434 vGammaCumProbability,
444 G4cout <<
"=== Reader: new manager for Z= " << Z <<
" A= " <<
A
445 <<
" Nlevels= " << i <<
" E[0]= "
446 << vEnergy[0]/CLHEP::MeV <<
" MeV E1= "
447 << vEnergy[i-1]/CLHEP::MeV <<
" MeV "
double A(double temperature)
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