Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54///////////////////////////////////////////////////////////////////////////////
55//
56#include "G4DecayTable.hh"
57#include "G4SystemOfUnits.hh"
58#include "G4ParticleTable.hh"
59#include "G4IsotopeProperty.hh"
60#include "G4RIsotopeTable.hh"
61
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
80const G4double G4RIsotopeTable::levelTolerance = 2.0*keV;
81
82///////////////////////////////////////////////////////////////////////////////
83//
85{//
86 //Reset the list of user define data file
87 //
88 theUserRadioactiveDataFiles.clear();
89}
90
91///////////////////////////////////////////////////////////////////////////////
92//
94{
95 fIsotopeList.clear();
96 fIsotopeNameList.clear();
97}
98///////////////////////////////////////////////////////////////////////////////
99//
100G4int G4RIsotopeTable::GetVerboseLevel() const
101{
103}
104///////////////////////////////////////////////////////////////////////////////
105//
107{
108 // do nothing, it is here just for the compiler
109 // it is required by the base class
110 return true;
111}
112///////////////////////////////////////////////////////////////////////////////
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}
158///////////////////////////////////////////////////////////////////////////////
159//
160G4String G4RIsotopeTable::GetIsotopeName(G4int Z, G4int A, G4double E)
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
174G4double G4RIsotopeTable::GetMeanLifeTime(G4int Z, G4int A, G4double& aE)
175{
176
177 G4double lifetime = -1.0;
178
179
180 //Check if data have been provided by the user
181 G4String file= theUserRadioactiveDataFiles[1000*A+Z];
182 if (file ==""){
183 if (!getenv("G4RADIOACTIVEDATA")) {
184 G4cout << "Please setenv G4RADIOACTIVEDATA to point to the radioactive decay data files." << G4endl;
185 throw G4HadronicException(__FILE__, __LINE__,
186 "Please setenv G4RADIOACTIVEDATA to point to the radioactive decay data files.");
187 }
188 G4String dirName = getenv("G4RADIOACTIVEDATA");
189
190 std::ostringstream os;
191 os <<dirName <<"/z" <<Z <<".a" <<A ;
192 file = os.str();
193 }
194 std::ifstream DecaySchemeFile(file);
195
196 G4bool found_in_raddecay_data(false);
197 if (!DecaySchemeFile) {
198 if (GetVerboseLevel()>1) {
199 G4cout <<"G4RIsotopeTable::GetMeanLife() : "
200 <<"cannot find ion radioactive decay file: "
201 <<file <<G4endl;
202 }
203 } else {
204 char inputChars[100]={' '};
205 G4String inputLine;
206 G4String recordType("");
207 G4double a(0.0);
208 G4double b(0.0);
209
210 while (!found_in_raddecay_data && !DecaySchemeFile.getline(inputChars, 100).eof()) {
211 inputLine = inputChars;
212 inputLine = inputLine.strip(1);
213
214 if (inputChars[0] != '#' && inputLine.length() != 0) {
215 std::istringstream tmpstream(inputLine);
216 tmpstream >> recordType >> a >> b;
217 if (recordType == "P") {
218 if (std::abs(a*keV-aE) < levelTolerance) {
219 found_in_raddecay_data = true;
220 lifetime = b/0.693147*s ;
221 }
222 }
223 }
224 }
225 DecaySchemeFile.close();
226 }
227
228 if (!found_in_raddecay_data && aE) {
229 G4double half_life=-1.;
230 lifetime = 1.0E-20*s;
231
232
233 //added by L.Desorgher If the life time is not found in raddecay database
234 // then it is deduced from photo-evaporation level
235 const G4NuclearLevel* aLevel =
237 ->NearestLevel(aE,levelTolerance);
238 if (aLevel) {
239 half_life = aLevel->HalfLife();
240 lifetime = half_life/0.693147;
241 }
242
243 if (GetVerboseLevel()>1 && half_life<0) {
244 G4cout << "G4RIsotopeTable::GetMeanLife() : ";
245 G4cout << "cannot find ion of required excitation E = " << aE << G4endl;
246 G4cout << "state in radioactive or photoevaporation data file " << G4endl;
247 G4cout <<"The nucleus is assumed to be IT decayed with life = 1E-20 s" << G4endl;
248 G4cout <<" -----------* THIS MAY CAUSE PROBLEM IN ITS DECAY-----------" << G4endl;
249 }
250 }
251
252 if (!found_in_raddecay_data && !aE) {
253 if (GetVerboseLevel()>1) {
254 G4cout <<"G4RIsotopeTable::GetMeanLife() : ";
255 G4cout <<"cannot find ion of required excitation E = " << aE << G4endl;
256 G4cout <<"state in radioactive or photoevaporation data file" <<G4endl;
257 G4cout <<"The nucleus is assumed to be stable" <<G4endl;
258 lifetime = -1.0;
259 }
260 }
261
262 if (GetVerboseLevel()>1) {
263 G4cout <<"G4RIsotopeTable::GetMeanLifeTime: ";
264 G4cout <<lifetime << " for " << GetIsotopeName(Z, A, aE) <<G4endl;
265 }
266 return lifetime;
267}
268////////////////////////////////////////////////////////////////////
269//
271{ if (Z<1 || A<2) {
272 G4cout<<"Z and A not valid!"<<G4endl;
273 }
274
275 std::ifstream DecaySchemeFile(filename);
276 if (DecaySchemeFile){
277 G4int ID_ion=A*1000+Z;
278 theUserRadioactiveDataFiles[ID_ion]=filename;
279 }
280 else {
281 G4cout<<"The file "<<filename<<" does not exist!"<<G4endl;
282 }
283}
284
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
void SetAtomicMass(G4int A)
void SetDecayTable(G4DecayTable *table)
void SetEnergy(G4double E)
void SetiSpin(G4int J)
void SetAtomicNumber(G4int Z)
void SetLifeTime(G4double T)
const G4NuclearLevel * NearestLevel(G4double energy, G4double eDiffMax=9999.*CLHEP::GeV) const
G4NuclearLevelManager * GetManager(G4int Z, G4int A)
static G4NuclearLevelStore * GetInstance()
G4double HalfLife() const
G4int GetVerboseLevel() const
static G4ParticleTable * GetParticleTable()
virtual G4bool FindIsotope(G4IsotopeProperty *property)
virtual G4IsotopeProperty * GetIsotope(G4int Z, G4int A, G4double E)
void AddUserDecayDataFile(G4int Z, G4int A, G4String filename)
virtual ~G4RIsotopeTable()
G4String strip(G4int strip_Type=trailing, char c=' ')