Geant4  10.00.p03
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 */
74 #include "G4ios.hh"
75 #include "globals.hh"
76 #include <iomanip>
77 #include <fstream>
78 #include <sstream>
79 
81 
82 
84 {
85  // Reset the list of user defined data files
87 }
88 
89 
91 {
92  for (G4int i = 0; i < G4int(fIsotopeList.size()); i++) delete fIsotopeList[i];
93  fIsotopeList.clear();
94  fIsotopeNameList.clear();
95 }
96 
97 
99 {
101 }
102 
103 
105 {
106  // do nothing, it is here just for the compiler
107  // it is required by the base class
108  return true;
109 }
110 
111 
113 {
114  G4String fname = GetIsotopeName(Z, A, E);
115  G4int j = -1;
116  for (G4int i = 0 ; i< Entries(); i++) {
117  if(fIsotopeNameList[i] == fname) j = i;}
118  if (j >=0) {
119  if (GetVerboseLevel() > 1) {
120  G4cout <<"G4RIsotopeTable::GetIsotope No. : ";
121  G4cout <<j<<G4endl;
122  }
123  return GetIsotope(j);
124  // isotope property data has been loaded already - just return the pointer
125 
126  } else {
127  G4double meanlife = GetMeanLifeTime(Z, A, E);
128  // E is passed as a refence hence on entry E is supplied by the user and it
129  // could be slightly different from the returned value which is the one
130  // defined in the database.
131  // this call is to ensure the code uses a consistent E value throughout.
132 
133  G4IsotopeProperty* fProperty = new G4IsotopeProperty();
134  // Set Isotope Property
135  fProperty->SetLifeTime(meanlife);
136  fProperty->SetAtomicNumber(Z);
137  fProperty->SetAtomicMass(A);
138  // Notic that the value of E may have been changed
139  fProperty->SetEnergy(E);
140  // The spin is not being used in the current implementation
141  fProperty->SetiSpin(0);
142  // the decaytable will be loaded later in G4RadioactiveDecay when it is needed
143  fProperty->SetDecayTable(0);
144 
145  fIsotopeList.push_back(fProperty);
146  fname = GetIsotopeName(Z, A, E);
147  fIsotopeNameList.push_back(fname);
148  if (GetVerboseLevel()>1) {
149  G4cout <<"G4RIsotopeTable::GetIsotope create: ";
150  G4cout <<fname <<G4endl;
151  }
152  return fProperty;
153 
154  }
155 }
157 //
159 {
160  std::ostringstream os;
161  os.setf(std::ios::fixed);
162  os <<"A"<< A << "Z" << Z <<'[' << std::setprecision(1) << E/keV << ']';
163  G4String name = os.str();
164  if (GetVerboseLevel()>1) {
165  G4cout <<"G4RIsotopeTable::GetIsotope Name: ";
166  G4cout <<name <<G4endl;
167  }
168  return name;
169 }
170 
171 
173 {
174 
175  G4double lifetime = -1.0;
176 
177  //Check if data have been provided by the user
178  std::map<int,G4String>::iterator it = theUserRadioactiveDataFiles.find(1000*A+Z);
179  G4String file="";
180  if ( it != theUserRadioactiveDataFiles.end() ){
181  file=it->second;
182  }
183  if (file ==""){
184  if (!getenv("G4RADIOACTIVEDATA")) {
185  G4cout << "Please setenv G4RADIOACTIVEDATA to point to the radioactive decay data files." << G4endl;
186  throw G4HadronicException(__FILE__, __LINE__,
187  "Please setenv G4RADIOACTIVEDATA to point to the radioactive decay data files.");
188  }
189  G4String dirName = getenv("G4RADIOACTIVEDATA");
190 
191  std::ostringstream os;
192  os <<dirName <<"/z" <<Z <<".a" <<A ;
193  file = os.str();
194  }
195  std::ifstream DecaySchemeFile(file);
196 
197  G4bool found_in_raddecay_data(false);
198  if (!DecaySchemeFile) {
199  if (GetVerboseLevel()>1) {
200  G4cout <<"G4RIsotopeTable::GetMeanLife() : "
201  <<"cannot find ion radioactive decay file: "
202  <<file <<G4endl;
203  }
204  } else {
205  char inputChars[100]={' '};
206  G4String inputLine;
207  G4String recordType("");
208  G4double a(0.0);
209  G4double b(0.0);
210 
211  while (!found_in_raddecay_data && !DecaySchemeFile.getline(inputChars, 100).eof()) {
212  inputLine = inputChars;
213  inputLine = inputLine.strip(1);
214 
215  if (inputChars[0] != '#' && inputLine.length() != 0) {
216  std::istringstream tmpstream(inputLine);
217  tmpstream >> recordType >> a >> b;
218  if (recordType == "P") {
219  if (std::abs(a*keV-aE) < levelTolerance) {
220  found_in_raddecay_data = true;
221  lifetime = b/0.693147*s ;
222  }
223  }
224  }
225  }
226  DecaySchemeFile.close();
227  }
228 
229  if (!found_in_raddecay_data && aE) {
230  G4double half_life=-1.;
231  lifetime = 1.0E-20*s;
232 
233 
234  //added by L.Desorgher If the life time is not found in raddecay database
235  // then it is deduced from photo-evaporation level
236  const G4NuclearLevel* aLevel =
239  if (aLevel) {
240  half_life = aLevel->HalfLife();
241  lifetime = half_life/0.693147;
242  }
243 
244  if (GetVerboseLevel()>1 && half_life<0) {
245  G4cout << "G4RIsotopeTable::GetMeanLife() : ";
246  G4cout << "cannot find ion of required excitation E = " << aE << G4endl;
247  G4cout << "state in radioactive or photoevaporation data file " << G4endl;
248  G4cout <<"The nucleus is assumed to be IT decayed with life = 1E-20 s" << G4endl;
249  G4cout <<" -----------* THIS MAY CAUSE PROBLEM IN ITS DECAY-----------" << G4endl;
250  }
251  }
252 
253  if (!found_in_raddecay_data && !aE) {
254  if (GetVerboseLevel()>1) {
255  G4cout <<"G4RIsotopeTable::GetMeanLife() : ";
256  G4cout <<"cannot find ion of required excitation E = " << aE << G4endl;
257  G4cout <<"state in radioactive or photoevaporation data file" <<G4endl;
258  G4cout <<"The nucleus is assumed to be stable" <<G4endl;
259  lifetime = -1.0;
260  }
261  }
262 
263  if (GetVerboseLevel()>1) {
264  G4cout <<"G4RIsotopeTable::GetMeanLifeTime: ";
265  G4cout <<lifetime << " for " << GetIsotopeName(Z, A, aE) <<G4endl;
266  }
267  return lifetime;
268 }
270 //
272 { if (Z<1 || A<2) {
273  G4cout<<"Z and A not valid!"<<G4endl;
274  }
275 
276  std::ifstream DecaySchemeFile(filename);
277  if (DecaySchemeFile){
278  G4int ID_ion=A*1000+Z;
279  theUserRadioactiveDataFiles[ID_ion]=filename;
280  }
281  else {
282  G4cout<<"The file "<<filename<<" does not exist!"<<G4endl;
283  }
284 }
285 
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
const G4NuclearLevel * NearestLevel(G4double energy, G4double eDiffMax=9999.*CLHEP::GeV) const
std::map< G4int, G4String > theUserRadioactiveDataFiles
G4int GetVerboseLevel() const
void SetAtomicNumber(G4int Z)
G4String GetIsotopeName(G4int Z, G4int A, G4double E)
G4IsotopeNameList fIsotopeNameList