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