Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4LevelReader Class Reference

#include <G4LevelReader.hh>

Public Member Functions

 G4LevelReader (G4NuclearLevelData *)
 
const G4LevelManagerCreateLevelManager (G4int Z, G4int A)
 
const G4LevelManagerCreateLevelManagerNEW (G4int Z, G4int A)
 
const G4LevelManagerMakeLevelManager (G4int Z, G4int A, const G4String &filename)
 
const G4LevelManagerMakeLevelManagerNEW (G4int Z, G4int A, const G4String &filename)
 
void SetVerbose (G4int val)
 

Detailed Description

Definition at line 55 of file G4LevelReader.hh.

Constructor & Destructor Documentation

G4LevelReader::G4LevelReader ( G4NuclearLevelData ptr)
explicit

Definition at line 56 of file G4LevelReader.cc.

57  : fData(ptr),fAlphaMax(9.0f+9),fVerbose(0),fLevelMax(632),fTransMax(80)
58 {
59  fParam = fData->GetParameters();
60  fTimeFactor = (G4float)(CLHEP::second/G4Pow::GetInstance()->logZ(2));
61  char* directory = getenv("G4LEVELGAMMADATA");
62  if(directory) {
63  fDirectory = directory;
64  } else {
65  G4Exception("G4LevelReader()","had0707",FatalException,
66  "Environment variable G4LEVELGAMMADATA is not defined");
67  fDirectory = "";
68  }
69  fFile = fDirectory + "/z100.a200";
70  fPol = " ";
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] = ' ';
76 
77  fEnergy = fCurrEnergy = fTrEnergy = 0.0;
78  fTime = fProb = fSpin = fAlpha = fRatio = fNorm1 = 0.0f;
79 
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);
86 
87  vEnergy.resize(fLevelMax,0.0f);
88  vSpin.resize(fLevelMax,0);
89  vLevel.resize(fLevelMax,nullptr);
90 }
static G4Pow * GetInstance()
Definition: G4Pow.cc:55
float G4float
Definition: G4Types.hh:77
int G4int
Definition: G4Types.hh:78
G4double logZ(G4int Z) const
Definition: G4Pow.hh:166
G4DeexPrecoParameters * GetParameters()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static constexpr double second

Here is the call graph for this function:

Member Function Documentation

const G4LevelManager * G4LevelReader::CreateLevelManager ( G4int  Z,
G4int  A 
)

Definition at line 93 of file G4LevelReader.cc.

94 {
95  std::ostringstream ss;
96  ss << "/z" << Z << ".a" << A;
97  G4String st = G4String(ss.str());
98  fFile = fDirectory + st;
99  return MakeLevelManager(Z, A, fFile);
100 }
const G4LevelManager * MakeLevelManager(G4int Z, G4int A, const G4String &filename)
double A(double temperature)

Here is the call graph for this function:

const G4LevelManager * G4LevelReader::CreateLevelManagerNEW ( G4int  Z,
G4int  A 
)

Definition at line 431 of file G4LevelReader.cc.

432 {
433  std::ostringstream ss;
434  ss << "/correlated_gamma/z" << Z << ".a" << A;
435  G4String st = G4String(ss.str());
436  fFile = fDirectory + st;
437  std::ifstream infile(fFile, std::ios::in);
438 
439  // file is not opened
440  if (!infile.is_open()) {
441  if(fVerbose > 0) {
443  ed << " for Z= " << Z << " A= " << A
444  << " <" << fFile << "> is not opened!";
445  G4Exception("G4LevelReader::CreateLevelManagerNEW(..)","had014",
446  JustWarning, ed, "");
447  }
448  return nullptr;
449  }
450  if (fVerbose > 0) {
451  G4cout << "G4LevelReader: open file for Z= "
452  << Z << " A= " << A
453  << " <" << fFile << ">" << G4endl;
454  }
455  return LevelManager(Z, A, 0, infile);
456 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

const G4LevelManager * G4LevelReader::MakeLevelManager ( G4int  Z,
G4int  A,
const G4String filename 
)

Definition at line 103 of file G4LevelReader.cc.

104 {
105  vEnergy.resize(1,0.0f);
106  vSpin.resize(1,0);
107  vLevel.resize(1,nullptr);
108 
109  vTrans.clear();
110  vGammaCumProbability.clear();
111  vGammaProbability.clear();
112  vShellProbability.clear();
113  vMpRatio.clear();
114 
115  std::ifstream infile(filename, std::ios::in);
116 
117  // file is not opened
118  if (!infile.is_open()) {
119  if (fVerbose > 0) {
120  G4cout << " G4LevelReader: fail open file for Z= "
121  << Z << " A= " << A
122  << " <" << filename << ">" << G4endl;
123  }
124 
125  } else {
126 
127  G4bool allLevels = fParam->StoreAllLevels();
128  if (fVerbose > 0) {
129  G4cout << "G4LevelReader: open file for Z= "
130  << Z << " A= " << A
131  << " <" << filename << ">" << G4endl;
132  }
133  // read line by line
134  G4bool end = false;
135  G4bool next = true;
136  G4int nline = -1;
137  G4int spin;
138  G4int index(0);
139  fCurrEnergy = DBL_MAX;
140  do {
141  fPol = " ";
142  ++nline;
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));
150  /*
151  G4cout << fEnergy << " " << fTrEnergy << " " << fProb << " "
152  << fPol << " " << fTime << " " << fSpin << " " << fAlpha
153  << " " << isOK << " " << fVerbose << G4endl;
154  */
155  fEnergy *= CLHEP::keV;
156  fTrEnergy *= CLHEP::keV;
157 
158  if(isOK) {
159  for(G4int i=0; i<10; ++i) {
160  isOK = (isOK && (ReadDataItem(infile,fICC[i])));
161  }
162  }
163  if(!isOK) {
164  end = true;
165  next = false;
166  }
167  if(fVerbose > 1) {
168  G4cout << "#Line " << nline << " " << fEnergy << " " << fTrEnergy
169  << " " << fProb << " " << fPol << " " << fTime << " "
170  << fSpin << " " << fAlpha << G4endl;
171  G4cout << " ";
172  for(G4int i=0; i<10; ++i) { G4cout << fICC[i] << " "; }
173  G4cout << G4endl;
174  }
175  // end of nuclear level data
176  if(end || fEnergy > fCurrEnergy) {
177  size_t nn = vTrans.size();
178  if(nn > 0) {
179  --nn;
180  if(fVerbose > 1) {
181  G4cout << "Reader: new level E= " << fEnergy
182  << " Ntransitions= " << nn+1 << " fNorm1= " << fNorm1
183  << G4endl;
184  }
185  if(fNorm1 > 0.0f) {
186  fNorm1 = 1.0f/fNorm1;
187  for(size_t i=0; i<nn; ++i) {
188  vGammaCumProbability[i] *= fNorm1;
189  if(fVerbose > 2) {
190  G4cout << "Probabilities[" << i
191  << "]= " << vGammaCumProbability[i]
192  << " idxTrans= " << index
193  << G4endl;
194  }
195  }
196  vGammaCumProbability[nn] = 1.0f;
197  if(fVerbose > 2) {
198  G4cout << "Probabilities[" << nn << "]= "
199  << vGammaCumProbability[nn]
200  << " IdxTrans= " << index
201  << G4endl;
202  }
203  vLevel.push_back(new G4NucLevel(vTrans.size(), fTime,
204  vTrans,
205  vGammaCumProbability,
206  vGammaProbability,
207  vMpRatio,
208  vShellProbability));
209  //case of X-level
210  } else {
211  spin += 100000;
212  fTime = 0.0f;
213  vLevel.push_back(nullptr);
214  }
215  } else {
216  vLevel.push_back(nullptr);
217  }
218  vSpin.push_back(spin);
219  vTrans.clear();
220  vGammaCumProbability.clear();
221  vGammaProbability.clear();
222  vShellProbability.clear();
223  vMpRatio.clear();
224  if(!end) { next = true; }
225  }
226  G4float ener = (G4float)fEnergy;
227  // begin nuclear level data
228  if(next) {
229  if(fVerbose > 1) {
230  G4cout << "== Reader: begin of new level E= " << fEnergy
231  << " Prob= " << fProb << G4endl;
232  }
233  // protection for bad level energy
234  size_t nn = vEnergy.size();
235  if(0 < nn && vEnergy[nn-1] > ener) {
236  ener = vEnergy[nn-1];
237  }
238  vEnergy.push_back(ener);
239  fCurrEnergy = fEnergy;
240  fTime *= fTimeFactor;
241  if(fSpin > 20.0f) { fSpin = 0.0; }
242  spin = (G4int)(fSpin+fSpin);
243  fNorm1 = 0.0f;
244  next = false;
245  }
246  // continue filling level data
247  if(!end) {
248  if(fProb > 0.0f) {
249  // by default transition to a ground state
250  G4float efinal = (G4float)std::max(fEnergy - fTrEnergy,0.0);
251  G4float elevel = 0.0f;
252  size_t idxLevel = 0;
253  G4int tnum = 0;
254  // do not check initial energy
255  size_t nn = vEnergy.size();
256  static const G4float x_energy = (G4float)(0.1*CLHEP::eV);
257  if(1 < nn) {
258  G4float ediffMin = (G4float)fEnergy;
259  for(size_t i=0; i<nn-1; ++i) {
260  G4float ediff = std::abs(efinal - vEnergy[i]);
261  /*
262  G4cout << "Elevel[" << i << "]= " << vEnergy[i]
263  << " Efinal= " << efinal
264  << " Ediff= " << ediff
265  << " EdiffMin= " << ediffMin << G4endl;
266  */
267  if(ediff < ediffMin) {
268  ediffMin = ediff;
269  elevel = vEnergy[i];
270  idxLevel = i;
271  if(ediff <= x_energy) { break; }
272  }
273  }
274  if(std::abs(vEnergy[nn-1] - elevel) < x_energy) { tnum = 1; }
275  }
276  G4float x = 1.0f + fAlpha;
277  fNorm1 += x*fProb;
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));
284  } else {
285  vShellProbability.push_back(nullptr);
286  }
287  }
288  }
289  if(nline > 10000) {
290  G4cout << "G4LevelReader: Line #" << nline << " Z= " << Z << " A= "
291  << " this file is too long - stop loading" << G4endl;
292  end = true;
293  }
294  // Loop checking, 05-Aug-2015, Vladimir Ivanchenko
295  } while (!end);
296  infile.close();
297  }
298 
299  G4LevelManager* man = nullptr;
300  if(vEnergy.size() >= 2) {
301  man = new G4LevelManager(vEnergy.size(),vEnergy,vSpin,vLevel);
302  if(fVerbose > 0) {
303  G4cout << "=== Reader: new manager for Z= " << Z << " A= " << A
304  << " Nlevels= " << vEnergy.size() << " E[0]= "
305  << vEnergy[0]/CLHEP::MeV << " MeV Emax= "
306  << man->MaxLevelEnergy()/CLHEP::MeV << " MeV "
307  << " S: " << vEnergy.size()
308  << " " << vSpin.size() << " " << vLevel.size()
309  << G4endl;
310  }
311  }
312  return man;
313 }
static constexpr double keV
float G4float
Definition: G4Types.hh:77
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
bool G4bool
Definition: G4Types.hh:79
static constexpr double MeV
static constexpr double eV
T max(const T t1, const T t2)
brief Return the largest of the two arguments
#define G4endl
Definition: G4ios.hh:61
#define DBL_MAX
Definition: templates.hh:83
G4float MaxLevelEnergy() const

Here is the call graph for this function:

Here is the caller graph for this function:

const G4LevelManager * G4LevelReader::MakeLevelManagerNEW ( G4int  Z,
G4int  A,
const G4String filename 
)

Definition at line 459 of file G4LevelReader.cc.

461 {
462  std::ifstream infile(filename, std::ios::in);
463 
464  // file is not opened
465  if (!infile.is_open()) {
467  ed << " for Z= " << Z << " A= " << A
468  << " data file <" << filename << "> is not opened!";
469  G4Exception("G4LevelReader::MakeLevelManagerNEW(..)","had014",
470  JustWarning, ed, "Check G4LEVELGAMMADATA");
471  return nullptr;
472  }
473  if (fVerbose > 0) {
474  G4cout << "G4LevelReader: open file for Z= "
475  << Z << " A= " << A
476  << " <" << filename << ">" << G4endl;
477  }
478  return LevelManager(Z, A, 0, infile);
479 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

void G4LevelReader::SetVerbose ( G4int  val)
inline

Definition at line 149 of file G4LevelReader.hh.

150 {
151  fVerbose = val;
152 }

The documentation for this class was generated from the following files: