Geant4  10.01.p02
G4RIsotopeTable.cc
Go to the documentation of this file.
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 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 //
28 // MODULE: G4RIsotopeTable.cc
29 //
30 // Version: 0.b.4
31 // Date: 14/04/00
32 // Author: F Lei & P R Truscott
33 // Organisation: DERA UK
34 // Customer: ESA/ESTEC, NOORDWIJK
35 // Contract: 12115/96/JG/NL Work Order No. 3
36 //
37 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 //
39 // CHANGE HISTORY
40 // --------------
41 //
42 // 29 February 2000, P R Truscott, DERA UK
43 // 0.b.3 release.
44 //
45 // 14 April 2000, F Lei, DERA UK
46 // 0.b.4 release. Minor changes to
47 // 1) levelTolerance = 2.0 keV
48 // 2) changes to verbose control
49 //
50 // 18,July 2001 F.Lei
51 // tidy up the print out at run level
52 //
53 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55 //
56 #include "G4DecayTable.hh"
57 #include "G4SystemOfUnits.hh"
58 #include "G4ParticleTable.hh"
59 #include "G4IsotopeProperty.hh"
60 #include "G4RIsotopeTable.hh"
61 
62 #include "G4HadronicException.hh"
63 #include "G4NuclearLevelStore.hh"
64 
65 /*
66 #include "G4RadioactiveDecayMode.hh"
67 #include "G4ITDecayChannel.hh"
68 #include "G4BetaMinusDecayChannel.hh"
69 #include "G4BetaPlusDecayChannel.hh"
70 #include "G4KshellECDecayChannel.hh"
71 #include "G4LshellECDecayChannel.hh"
72 #include "G4AlphaDecayChannel.hh"
73 #include "G4ProtonDecayChannel.hh"
74 */
75 #include "G4ios.hh"
76 #include "globals.hh"
77 #include <iomanip>
78 #include <fstream>
79 #include <sstream>
80 
82 
83 
85 {
86  // Reset the list of user defined data files
88 }
89 
90 
92 {
93  for (G4int i = 0; i < G4int(fIsotopeList.size()); i++) delete fIsotopeList[i];
94  fIsotopeList.clear();
95  fIsotopeNameList.clear();
96 }
97 
98 
100 {
102 }
103 
104 
106 {
107  // do nothing, it is here just for the compiler
108  // it is required by the base class
109  return true;
110 }
111 
112 
114 {
115  G4String fname = GetIsotopeName(Z, A, E);
116  G4int j = -1;
117  for (G4int i = 0 ; i< Entries(); i++) {
118  if(fIsotopeNameList[i] == fname) j = i;}
119  if (j >=0) {
120  if (GetVerboseLevel() > 1) {
121  G4cout <<"G4RIsotopeTable::GetIsotope No. : ";
122  G4cout <<j<<G4endl;
123  }
124  return GetIsotope(j);
125  // isotope property data has been loaded already - just return the pointer
126 
127  } else {
128  G4double meanlife = GetMeanLifeTime(Z, A, E);
129  // E is passed as a refence hence on entry E is supplied by the user and it
130  // could be slightly different from the returned value which is the one
131  // defined in the database.
132  // this call is to ensure the code uses a consistent E value throughout.
133 
134  G4IsotopeProperty* fProperty = new G4IsotopeProperty();
135  // Set Isotope Property
136  fProperty->SetLifeTime(meanlife);
137  fProperty->SetAtomicNumber(Z);
138  fProperty->SetAtomicMass(A);
139  // Notic that the value of E may have been changed
140  fProperty->SetEnergy(E);
141  // The spin is not being used in the current implementation
142  fProperty->SetiSpin(0);
143  // the decaytable will be loaded later in G4RadioactiveDecay when it is needed
144  fProperty->SetDecayTable(0);
145 
146  fIsotopeList.push_back(fProperty);
147  fname = GetIsotopeName(Z, A, E);
148  fIsotopeNameList.push_back(fname);
149  if (GetVerboseLevel()>1) {
150  G4cout <<"G4RIsotopeTable::GetIsotope create: ";
151  G4cout <<fname <<G4endl;
152  }
153  return fProperty;
154 
155  }
156 }
158 //
160 {
161  std::ostringstream os;
162  os.setf(std::ios::fixed);
163  os <<"A"<< A << "Z" << Z <<'[' << std::setprecision(1) << E/keV << ']';
164  G4String name = os.str();
165  if (GetVerboseLevel()>1) {
166  G4cout <<"G4RIsotopeTable::GetIsotope Name: ";
167  G4cout <<name <<G4endl;
168  }
169  return name;
170 }
171 
172 
174 {
175 
176  G4double lifetime = -1.0;
177 
178  //Check if data have been provided by the user
179  std::map<int,G4String>::iterator it = theUserRadioactiveDataFiles.find(1000*A+Z);
180  G4String file="";
181  if ( it != theUserRadioactiveDataFiles.end() ){
182  file=it->second;
183  }
184  if (file ==""){
185  if (!getenv("G4RADIOACTIVEDATA")) {
186  G4cout << "Please setenv G4RADIOACTIVEDATA to point to the radioactive decay data files." << G4endl;
187  throw G4HadronicException(__FILE__, __LINE__,
188  "Please setenv G4RADIOACTIVEDATA to point to the radioactive decay data files.");
189  }
190  G4String dirName = getenv("G4RADIOACTIVEDATA");
191 
192  std::ostringstream os;
193  os <<dirName <<"/z" <<Z <<".a" <<A ;
194  file = os.str();
195  }
196  std::ifstream DecaySchemeFile(file);
197 
198  G4bool found_in_raddecay_data(false);
199  if (!DecaySchemeFile) {
200  if (GetVerboseLevel()>1) {
201  G4cout <<"G4RIsotopeTable::GetMeanLife() : "
202  <<"cannot find ion radioactive decay file: "
203  <<file <<G4endl;
204  }
205  } else {
206  char inputChars[100]={' '};
207  G4String inputLine;
208  G4String recordType("");
209  G4double a(0.0);
210  G4double b(0.0);
211 
212  while (!found_in_raddecay_data && !DecaySchemeFile.getline(inputChars, 100).eof()) {
213  inputLine = inputChars;
214  inputLine = inputLine.strip(1);
215 
216  if (inputChars[0] != '#' && inputLine.length() != 0) {
217  std::istringstream tmpstream(inputLine);
218  tmpstream >> recordType >> a >> b;
219  if (recordType == "P") {
220  if (std::abs(a*keV-aE) < levelTolerance) {
221  found_in_raddecay_data = true;
222  lifetime = b/0.693147*s ;
223  }
224  }
225  }
226  }
227  DecaySchemeFile.close();
228  }
229 
230  if (!found_in_raddecay_data && aE) {
231  G4double half_life=-1.;
232  lifetime = 1.0E-20*s;
233 
234 
235  //added by L.Desorgher If the life time is not found in raddecay database
236  // then it is deduced from photo-evaporation level
237  const G4NuclearLevel* aLevel =
240  if (aLevel) {
241  half_life = aLevel->HalfLife();
242  lifetime = half_life/0.693147;
243  }
244 
245  if (GetVerboseLevel()>1 && half_life<0) {
246  G4cout << "G4RIsotopeTable::GetMeanLife() : ";
247  G4cout << "cannot find ion of required excitation E = " << aE << G4endl;
248  G4cout << "state in radioactive or photoevaporation data file " << G4endl;
249  G4cout <<"The nucleus is assumed to be IT decayed with life = 1E-20 s" << G4endl;
250  G4cout <<" -----------* THIS MAY CAUSE PROBLEM IN ITS DECAY-----------" << G4endl;
251  }
252  }
253 
254  if (!found_in_raddecay_data && !aE) {
255  if (GetVerboseLevel()>1) {
256  G4cout <<"G4RIsotopeTable::GetMeanLife() : ";
257  G4cout <<"cannot find ion of required excitation E = " << aE << G4endl;
258  G4cout <<"state in radioactive or photoevaporation data file" <<G4endl;
259  G4cout <<"The nucleus is assumed to be stable" <<G4endl;
260  lifetime = -1.0;
261  }
262  }
263 
264  if (GetVerboseLevel()>1) {
265  G4cout <<"G4RIsotopeTable::GetMeanLifeTime: ";
266  G4cout <<lifetime << " for " << GetIsotopeName(Z, A, aE) <<G4endl;
267  }
268  return lifetime;
269 }
271 //
273 { if (Z<1 || A<2) {
274  G4cout<<"Z and A not valid!"<<G4endl;
275  }
276 
277  std::ifstream DecaySchemeFile(filename);
278  if (DecaySchemeFile){
279  G4int ID_ion=A*1000+Z;
280  theUserRadioactiveDataFiles[ID_ion]=filename;
281  }
282  else {
283  G4cout<<"The file "<<filename<<" does not exist!"<<G4endl;
284  }
285 }
286 
void SetAtomicMass(G4int A)
virtual G4IsotopeProperty * GetIsotope(G4int Z, G4int A, G4double E)
virtual ~G4RIsotopeTable()
G4double HalfLife() const
G4String strip(G4int strip_Type=trailing, char c=' ')
void AddUserDecayDataFile(G4int Z, G4int A, G4String filename)
G4String name
Definition: TRTMaterials.hh:40
virtual G4bool FindIsotope(G4IsotopeProperty *property)
static G4NuclearLevelStore * GetInstance()
G4double a
Definition: TRTMaterials.hh:39
static const G4double levelTolerance
int G4int
Definition: G4Types.hh:78
void SetiSpin(G4int J)
static const double s
Definition: G4SIunits.hh:150
G4int GetVerboseLevel() const
void SetLifeTime(G4double T)
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
static const G4double A[nN]
G4NuclearLevelManager * GetManager(G4int Z, G4int A)
G4int Entries() const
void SetEnergy(G4double E)
void SetDecayTable(G4DecayTable *table)
static G4ParticleTable * GetParticleTable()
G4double GetMeanLifeTime(G4int Z, G4int A, G4double &E)
#define G4endl
Definition: G4ios.hh:61
static const double keV
Definition: G4SIunits.hh:195
double G4double
Definition: G4Types.hh:76
G4IsotopeList fIsotopeList
std::map< G4int, G4String > theUserRadioactiveDataFiles
G4int GetVerboseLevel() const
void SetAtomicNumber(G4int Z)
G4String GetIsotopeName(G4int Z, G4int A, G4double E)
const G4NuclearLevel * NearestLevel(G4double energy, G4double eDiffMax=1.e+8) const
G4IsotopeNameList fIsotopeNameList