Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4LevelReader.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: G4LevelReader.cc 88407 2015-02-18 09:18:44Z vnivanch $
27 //
28 // -------------------------------------------------------------------
29 //
30 // GEANT4 header file
31 //
32 // File name: G4NucLevel
33 //
34 // Author: V.Ivanchenko (M.Kelsey reading method is used)
35 //
36 // Creation date: 4 January 2012
37 //
38 // Modifications:
39 //
40 // -------------------------------------------------------------------
41 
42 #include "G4LevelReader.hh"
43 #include "G4NucleiProperties.hh"
44 #include "G4NucLevel.hh"
45 #include "G4NuclearLevelData.hh"
46 #include "G4DeexPrecoParameters.hh"
47 #include "G4SystemOfUnits.hh"
48 #include "G4Pow.hh"
49 #include <vector>
50 #include <fstream>
51 #include <sstream>
52 
54  "-", "+X", "+Y", "+Z", "+U", "+V", "+W", "+R", "+S", "+T", "+A", "+B", "+C"};
55 
57  : fData(ptr),fAlphaMax(9.0e9f),fVerbose(0),fLevelMax(632),fTransMax(145)
58 {
59  //G4cout << "### G4LevelReader AlphaMax= " << fAlphaMax << G4endl;
62  char* directory = getenv("G4LEVELGAMMADATA");
63  if(directory) {
64  fDirectory = directory;
65  } else {
66  G4Exception("G4LevelReader()","had0707",FatalException,
67  "Environment variable G4LEVELGAMMADATA is not defined");
68  fDirectory = "";
69  }
70  fFile = fDirectory + "/z100.a200";
71  fPol = " ";
72  for(G4int i=0; i<10; ++i) { fICC[i] = 0.0f; }
73  for(G4int i=0; i<nbufmax; ++i) { buffer[i] = ' '; }
74  for(G4int i=0; i<nbuf1; ++i) { buff1[i] = ' '; }
75  for(G4int i=0; i<nbuf2; ++i) { buff2[i] = ' '; }
76  bufp[0] = bufp[1] = bufp[2] = ' ';
77 
78  fEnergy = fCurrEnergy = fTrEnergy = fTime = 0.0;
79  fProb = fSpin = fAlpha = fRatio = fNorm1 = 0.0f;
80 
81  vTrans.resize(fTransMax,0);
82  vRatio.resize(fTransMax,0.0f);
83  vGammaCumProbability.resize(fTransMax,0.0f);
84  vGammaProbability.resize(fTransMax,0.0f);
85  vShellProbability.resize(fTransMax,nullptr);
86 
87  vEnergy.resize(fLevelMax,0.0);
88  vSpin.resize(fLevelMax,0);
89  vLevel.resize(fLevelMax,nullptr);
90 }
91 
92 G4bool G4LevelReader::ReadData(std::istringstream& stream, G4double& x)
93 {
94  stream >> x;
95  return stream.fail() ? false : true;
96 }
97 
98 G4bool G4LevelReader::ReadDataItem(std::istream& dataFile, G4double& x)
99 {
100  x = 0.0;
101  for(G4int i=0; i<nbufmax; ++i) { buffer[i] = ' '; }
102  G4bool okay = true;
103  dataFile >> buffer;
104  if(dataFile.fail()) { okay = false; }
105  else { x = strtod(buffer, 0); }
106 
107  return okay;
108 }
109 
110 G4bool G4LevelReader::ReadDataItem(std::istream& dataFile, G4float& x)
111 {
112  x = 0.0f;
113  for(G4int i=0; i<nbuf1; ++i) { buff1[i] = ' '; }
114  G4bool okay = true;
115  dataFile >> buff1;
116  if(dataFile.fail()) { okay = false; }
117  else { x = atof(buff1); }
118 
119  return okay;
120 }
121 
122 G4bool G4LevelReader::ReadDataItem(std::istream& dataFile, G4int& ix)
123 {
124  ix = 0;
125  for(G4int i=0; i<nbuf2; ++i) { buff2[i] = ' '; }
126  G4bool okay = true;
127  dataFile >> buff2;
128  if(dataFile.fail()) { okay = false; }
129  else { ix = atoi(buff2); }
130 
131  return okay;
132 }
133 
134 G4bool G4LevelReader::ReadDataItem(std::istream& dataFile, G4String& x)
135 {
136  G4bool okay = true;
137  bufp[0] = bufp[1] = ' ';
138  dataFile >> bufp;
139  if(dataFile.fail()) { okay = false; }
140  else { x = G4String(bufp, 2); }
141 
142  return okay;
143 }
144 
145 const std::vector<G4float>* G4LevelReader::NormalizedICCProbability(G4int Z)
146 {
147  std::vector<G4float>* vec = nullptr;
148  G4int LL = 3;
149  G4int M = 5;
150  G4int N = 1;
151  if(Z <= 27) {
152  M = N = 0;
153  if(Z <= 4) {
154  LL = 1;
155  } else if(Z <= 6) {
156  LL = 2;
157  } else if(Z <= 10) {
158  } else if(Z <= 12) {
159  M = 1;
160  } else if(Z <= 17) {
161  M = 2;
162  } else if(Z == 18) {
163  M = 3;
164  } else if(Z <= 20) {
165  M = 3;
166  N = 1;
167  } else {
168  M = 4;
169  N = 1;
170  }
171  if(LL < 3) { for(G4int i=LL+1; i<=4; ++i) { fICC[i] = 0.0f; } }
172  if(M < 5) { for(G4int i=M+4; i<=8; ++i) { fICC[i] = 0.0f; } }
173  if(N < 1) { fICC[9] = 0.0f; }
174  }
175  G4float norm = 0.0f;
176  for(G4int i=0; i<10; ++i) {
177  norm += fICC[i];
178  fICC[i] = norm;
179  }
180  if(norm == 0.0f && fAlpha > fAlphaMax) {
181  fICC[9] = norm = 1.0f;
182  }
183  if(norm > 0.0f) {
184  norm = 1.0f/norm;
185  vec = new std::vector<G4float>;
186  G4float x;
187  for(G4int i=0; i<10; ++i) {
188  x = fICC[i]*norm;
189  if(x > 0.995f || 9 == i) {
190  vec->push_back(1.0f);
191  break;
192  }
193  vec->push_back(x);
194  }
195  if (fVerbose > 2) {
196  G4int prec = G4cout.precision(3);
197  G4cout << "# InternalConv: ";
198  G4int nn = vec->size();
199  for(G4int i=0; i<nn; ++i) { G4cout << " " << (*vec)[i]; }
200  G4cout << G4endl;
201  G4cout.precision(prec);
202  }
203  }
204  return vec;
205 }
206 
207 const G4LevelManager*
209 {
210  std::ostringstream ss;
211  ss << "/z" << Z << ".a" << A;
212  G4String st = G4String(ss.str());
213  fFile = fDirectory + st;
214  std::ifstream infile(fFile, std::ios::in);
215 
216  return LevelManager(Z, A, 0, infile);
217 }
218 
219 const G4LevelManager*
221 {
222  fFile = filename;
223  std::ifstream infile(filename, std::ios::in);
224  if (!infile.is_open()) {
226  ed << "User file for Z= " << Z << " A= " << A
227  << " <" << fFile << "> is not opened!";
228  G4Exception("G4LevelReader::MakeLevelManager(..)","had014",
229  FatalException, ed, "");
230  return nullptr;
231  }
232  return LevelManager(Z, A, 0, infile);
233 }
234 
235 const G4LevelManager*
237  std::ifstream& infile)
238 {
239  // file is not opened
240  if (!infile.is_open()) {
241  if(Z < 6 || fVerbose > 0) {
243  ed << " for Z= " << Z << " A= " << A
244  << " <" << fFile << "> is not opened!";
245  G4Exception("G4LevelReader::LevelManager(..)","had014",
246  FatalException, ed, "");
247  }
248  return nullptr;
249  }
250  if (fVerbose > 0) {
251  G4cout << "G4LevelReader: open file for Z= "
252  << Z << " A= " << A
253  << " <" << fFile << ">" << G4endl;
254  }
255 
256  G4bool allLevels = fParam->StoreICLevelData();
257 
258  G4int nlevels = (0 == nlev) ? fLevelMax : nlev;
259  if(fVerbose > 0) {
260  G4cout << "## New isotope Z= " << Z << " A= " << A;
261  if(nlevels < fLevelMax) { G4cout << " Nlevels= " << nlevels; }
262  G4cout << G4endl;
263  }
264  if(nlevels > fLevelMax) {
265  fLevelMax = nlevels;
266  vEnergy.resize(fLevelMax,0.0);
267  vSpin.resize(fLevelMax,0);
268  vLevel.resize(fLevelMax,nullptr);
269  }
270  G4int ntrans(0), i1, i, k;
271  G4int i2; // Level number at which transition ends
272  G4int tnum; // Multipolarity index
273  G4String xf(" ");
274  G4double ener, tener;
275 
276  for(i=0; i<nlevels; ++i) {
277  infile >> i1 >> xf; // Level number and floating level
278  //G4cout << "New line: i1= " << i1 << " xf= <" << xf << "> " << G4endl;
279  if(infile.eof()) {
280  if(fVerbose > 1) {
281  G4cout << "### End of file Z= " << Z << " A= " << A
282  << " Nlevels= " << i << G4endl;
283  }
284  break;
285  }
286  if(i1 != i) {
288  ed << " G4LevelReader: wrong data file for Z= " << Z << " A= " << A
289  << " level #" << i << " has index " << i1 << G4endl;
290  G4Exception("G4LevelReader::LevelManager(..)","had014",
291  FatalException, ed, "Check G4LEVELGAMMADATA");
292  }
293 
294  if(!(ReadDataItem(infile,ener) &&
295  ReadDataItem(infile,fTime) &&
296  ReadDataItem(infile,fSpin) &&
297  ReadDataItem(infile,ntrans))) {
298  if(fVerbose > 1) {
299  G4cout << "### End of file Z= " << Z << " A= " << A
300  << " Nlevels= " << i << G4endl;
301  }
302  break;
303  }
304  ener *= CLHEP::keV;
305  for(k=0; k<nfloting; ++k) {
306  if(xf == fFloatingLevels[k]) {
307  break;
308  }
309  }
310  // if a previous level has not transitions it may be ignored
311  if(0 < i) {
312  // protection
313  if(ener < vEnergy[i-1]) {
314  G4cout << "### G4LevelReader: broken level " << i
315  << " E(MeV)= " << ener << " < " << vEnergy[i-1]
316  << " for isotope Z= " << Z << " A= "
317  << A << " level energy increased" << G4endl;
318  ener = vEnergy[i-1];
319  }
320  }
321  vEnergy[i] = ener;
322  if(fTime > 0.0f) { fTime *= fTimeFactor; }
323  if(fSpin > 48.0f) { fSpin = 0.0f; }
324  vSpin[i] = (G4int)(100 + fSpin + fSpin) + k*100000;
325  if(fVerbose > 1) {
326  G4cout << " Level #" << i1 << " E(MeV)= " << ener/CLHEP::MeV
327  << " LTime(s)= " << fTime << " 2S= " << vSpin[i]
328  << " meta= " << vSpin[i]/100000 << " idx= " << i
329  << " ntr= " << ntrans << G4endl;
330  }
331  vLevel[i] = nullptr;
332  if(ntrans == 0 && fTime < 0.0) {
333  vLevel[i] = new G4NucLevel(0, fTime,
334  vTrans,
337  vRatio,
339  } else if(ntrans > 0) {
340 
341  // there are transitions
342  if(ntrans > fTransMax) {
343  fTransMax = ntrans;
344  vTrans.resize(fTransMax);
345  vRatio.resize(fTransMax);
349  }
350  fNorm1 = 0.0f;
351  for(G4int j=0; j<ntrans; ++j) {
352 
353  if(!(ReadDataItem(infile,i2) &&
354  ReadDataItem(infile,tener) &&
355  ReadDataItem(infile,fProb) &&
356  ReadDataItem(infile,tnum) &&
357  ReadDataItem(infile,vRatio[j]) &&
358  ReadDataItem(infile,fAlpha))) {
359  //infile >>i2 >> tener >> fProb >> vTrans[j] >> fRatio >> fAlpha;
360  //if(infile.fail()) {
361  if(fVerbose > 0) {
362  G4cout << "### Fail to read transition j= " << j
363  << " Z= " << Z << " A= " << A << G4endl;
364  }
365  break;
366  }
367  if(i2 >= i) {
368  G4cout << "### G4LevelReader: broken transition " << j
369  << " from level " << i << " to " << i2
370  << " for isotope Z= " << Z << " A= "
371  << A << " - use ground level" << G4endl;
372  i2 = 0;
373  }
374  vTrans[j] = i2*10000 + tnum;
375  if(fAlpha < fAlphaMax) {
376  G4float x = 1.0f + fAlpha;
377  fNorm1 += x*fProb;
379  vGammaProbability[j] = 1.0f/x;
380  } else {
381  // only internal conversion case - no gamma conversion at all
382  fNorm1 += fProb;
384  vGammaProbability[j] = 0.0f;
385  }
386  vShellProbability[j] = nullptr;
387  if(fVerbose > 1) {
388  G4int prec = G4cout.precision(4);
389  G4cout << "### Transition #" << j << " to level " << i2
390  << " i2= " << i2 << " Etrans(MeV)= " << tener*CLHEP::keV
391  << " fProb= " << fProb << " MultiP= " << tnum
392  << " fMpRatio= " << fRatio << " fAlpha= " << fAlpha
393  << G4endl;
394  G4cout.precision(prec);
395  }
396  if(fAlpha > 0.0f) {
397  for(k=0; k<10; ++k) {
398  //infile >> fICC[k];
399  if(!ReadDataItem(infile,fICC[k])) {
400  //if(infile.fail()) {
401  if(fVerbose > 0) {
402  G4cout << "### Fail to read convertion coeff k= " << k
403  << " for transition j= " << j
404  << " Z= " << Z << " A= " << A << G4endl;
405  }
406  break;
407  }
408  }
409  if(allLevels) {
411  if(!vShellProbability[j]) { vGammaProbability[j] = 1.0f; }
412  }
413  }
414  }
415  if(0.0f < fNorm1) { fNorm1 = 1.0f/fNorm1; }
416  G4int nt = ntrans - 1;
417  for(k=0; k<nt; ++k) {
419  if(fVerbose > 2) {
420  G4cout << "Probabilities[" << k
421  << "]= " << vGammaCumProbability[k]
422  << " " << vGammaProbability[k]
423  << " idxTrans= " << vTrans[k]/10000
424  << G4endl;
425  }
426  }
427  vGammaCumProbability[nt] = 1.0f;
428  if(fVerbose > 2) {
429  G4cout << "Probabilities[" << nt << "]= "
430  << vGammaCumProbability[nt]
431  << " " << vGammaProbability[nt]
432  << " IdxTrans= " << vTrans[nt]/10000
433  << G4endl;
434  }
435  if(fVerbose > 1) {
436  G4cout << " New G4NucLevel: Ntrans= " << ntrans
437  << " Time(ns)= " << fTime << G4endl;
438  }
439  vLevel[i] = new G4NucLevel((size_t)ntrans, fTime,
440  vTrans,
443  vRatio,
445  }
446  }
447  G4LevelManager* lman = nullptr;
448  if(1 <= i) {
449  lman = new G4LevelManager((size_t)i,vEnergy,vSpin,vLevel);
450  if(fVerbose > 0) {
451  G4cout << "=== Reader: new manager for Z= " << Z << " A= " << A
452  << " Nlevels= " << i << " E[0]= "
453  << vEnergy[0]/CLHEP::MeV << " MeV E1= "
454  << vEnergy[i-1]/CLHEP::MeV << " MeV "
455  << G4endl;
456  }
457  }
458 
459  return lman;
460 }
Float_t x
Definition: compare.C:6
G4double fCurrEnergy
G4double fEnergy
static const double prec
Definition: RanecuEngine.cc:58
G4double logZ(G4int Z) const
Definition: G4Pow.hh:149
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:45
std::vector< G4float > vGammaProbability
const G4LevelManager * MakeLevelManager(G4int Z, G4int A, const G4String &filename)
static const G4int LL[nN]
G4DeexPrecoParameters * fParam
G4DeexPrecoParameters * GetParameters()
#define G4endl
Definition: G4ios.hh:61
const std::vector< G4float > * NormalizedICCProbability(G4int Z)
float G4float
Definition: G4Types.hh:77
G4bool ReadDataItem(std::istream &dataFile, G4double &x)
G4double fTrEnergy
static const G4int nfloting
static const G4int nbuf2
Float_t Z
std::vector< G4int > vTrans
static const G4int nbufmax
std::vector< G4double > vEnergy
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
static G4Pow * GetInstance()
Definition: G4Pow.cc:57
**D E S C R I P T I O N
const G4LevelManager * CreateLevelManager(G4int Z, G4int A)
std::vector< G4float > vRatio
const G4LevelManager * LevelManager(G4int Z, G4int A, G4int nlev, std::ifstream &infile)
char buff2[nbuf2]
char buff1[nbuf1]
static constexpr double MeV
static const G4int nbuf1
double A(double temperature)
char buffer[nbufmax]
G4LevelReader(G4NuclearLevelData *)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
int G4int
Definition: G4Types.hh:78
ifstream in
Definition: comparison.C:7
Float_t norm
G4NuclearLevelData * fData
std::vector< G4int > vSpin
G4GLOB_DLL std::ostream G4cout
G4double fTimeFactor
std::vector< G4float > vGammaCumProbability
std::vector< const std::vector< G4float > * > vShellProbability
static constexpr double second
G4String fDirectory
static constexpr double keV
static G4String fFloatingLevels[nfloting]
G4float fICC[10]
G4bool ReadData(std::istringstream &dataFile, G4double &x)
std::vector< const G4NucLevel * > vLevel