Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4ParticleHPNames.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// neutron_hp -- source file
27// J.P. Wellisch, Nov-1996
28// A prototype of the low energy neutron transport model.
29//
30// 24-Jan-07 Enable to use exact data only and add warnig when substitute file is used T. Koi
31// 30-Jan-07 Modified method of searching substitute isotope data by T. Koi
32// 07-06-12 fix memory leaking by T. Koi
33// 07-06-25 Change data selection logic when G4NEUTRONHP_SKIP_MISSING_ISOTOPES is turn on
34// Natural Abundance data are allowed. by T. Koi
35// 07-07-06 Allow _nat_ final state even for isotoped cross sections by T. Koi
36// 08-09-01 Add protection that deuteron data do not selected for hydrogen and so on by T. Koi
37//
38// P. Arce, June-2014 Conversion neutron_hp to particle_hp
39// June-2019 - E. Mendoza --> Modification to allow using an incomplete data library if the G4NEUTRONHP_SKIP_MISSING_ISOTOPES environmental flag is defined. The missing XS are set to 0.
40// Oct-2019 - E. Mendoza --> remove restriction of using isotopes with Z>92
41
42#include "G4ParticleHPNames.hh"
44#include "G4SandiaTable.hh"
47#include <fstream>
48
49 const G4String G4ParticleHPNames::theString[100] = {"Hydrogen", "Helium",
50 "Lithium", "Berylium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine",
51 "Neon", "Sodium", "Magnesium", "Aluminum", "Silicon", "Phosphorous",
52 "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium",
53 "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel",
54 "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine",
55 "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium",
56 "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver",
57 "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon",
58 "Cesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium",
59 "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium",
60 "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium",
61 "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinium", "Gold",
62 "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon",
63 "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium",
64 "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium",
65 "Einsteinium","Fermium"};
66
67
69
71{
72 #ifdef G4VERBOSE
74 #endif
75
76 //G4cout << Z << " " << A << " " << M << " " << base << " " << rest << G4endl;
77
78 //Excited isomer indicator
79 std::stringstream ss;
80 G4String sM;
81 if (M > 0) {
82 ss << "m";
83 ss << M;
84 ss >> sM;
85 ss.clear();
86 }
87
89 aFlag = true;
90
91 #ifdef G4VERBOSE
92 if (std::getenv("NeutronHPNames") && G4HadronicParameters::Instance()->GetVerboseLevel() > 0)
93 G4cout << "Names::GetName entered for Z = " << Z << ", A = " << A <<G4endl;
94 #endif
95
96 G4int myA = A;
97 G4int myZ = Z;
98
99 G4String * theName = 0;
100 G4String theFileName("");
101
102 //G4int inc = 1;
103
104 G4int flip_Z = 1;
105 G4int delta_Z = 0;
106
107 G4int flip_A = 1;
108 G4int delta_A = 0;
109
110 //std::ifstream * check = new std::ifstream(".dummy");
111 std::istringstream* check = NULL;
112 G4bool first = true;
113
114 #ifdef G4VERBOSE
115 if (std::getenv("NeutronHPNames") && G4HadronicParameters::Instance()->GetVerboseLevel() > 0)
116 G4cout << "entered GetName!!!"<<G4endl;
117 #endif
118
119 do
120 {
121 aFlag = true;
122 G4String * biff = new G4String(); // delete here as theName
123 *biff = base+"/CrossSection/"+itoa(myZ)+"_"+itoa(myA)+sM+"_"+theString[myZ-1];
124
125 if(theName!=0) delete theName;
126 theName = biff;
127 result.SetName(*theName);
128 result.SetA(myA);
129 result.SetZ(myZ);
130 result.SetM(M);
131 //if(std::getenv("NeutronHPNames")) G4cout <<"HPWD 1 "<<*theName<<G4endl;
132
133 // T.K. debug for memory leak
134 if ( check != NULL ) {
135 //check->close();
136 delete check;
137 }
138
139 //check = new std::ifstream(*theName);
140 check = new std::istringstream(std::ios::in);
142 if ( !(*check) )
143 {
144 //check->close();
145 delete check;
146 check = 0;
147 aFlag = false;
148 if ( first )
149 {
150 aFlag = true;
151 first = false;
152 biff = new G4String(); // delete here as theName
153 *biff = base+"/CrossSection/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1];
154 delete theName;
155 theName = biff;
156 //if(std::getenv("NeutronHPNames")) G4cout <<"HPWD 2 "<<*theName<<G4endl;
157 result.SetName(*theName);
158 G4double natA = myZ/G4SandiaTable::GetZtoA(myZ);
159 result.SetA(natA);
160 result.SetZ(myZ);
161 result.SetM(M);
162 //check = new std::ifstream(*theName);
163 check = new std::istringstream(std::ios::in);
165 if ( !(*check) )
166 {
167 //check->close();
168 delete check;
169 check = 0;
170 aFlag = false;
171 }
172 else
173 {
174 biff = new G4String(); // delete here as theName
175 *biff = base+"/"+rest+"/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1];
176 if ( rest=="/CrossSection" ) *biff = base+rest+"/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1];
177 delete theName;
178 theName = biff;
179 //if(std::getenv("NeutronHPNames")) G4cout <<"HPWD 3 "<<*theName<<G4endl;
180 result.SetName(*theName);
181 natA = myZ/G4SandiaTable::GetZtoA(myZ);
182 result.SetA(natA);
183 result.SetZ(myZ);
184 result.SetM(M);
186 }
187 }
188 }
189 else
190 {
191 // 070706 T. Koi Modified
192 /*
193 biff = new G4String(); // delete here as theName
194 *biff = base+"/"+rest+itoa(myZ)+"_"+itoa(myA)+"_"+theString[myZ-1];
195 if(theName!=0) delete theName;
196 theName = biff;
197 if(std::getenv("NeutronHPNames")) G4cout <<"HPWD 4 "<<*theName<<G4endl;
198 result.SetName(*theName);
199 result.SetA(myA);
200 result.SetZ(myZ);
201 */
202
203 G4double tmpA = myA;
204 //std::ifstream* file = NULL;
205 std::istringstream* file = NULL;
206 G4String fileName;
207
208 if ( rest == "/CrossSection" )
209 {
210
211 //fileName = base+"/"+rest+"/"+itoa(myZ)+"_"+itoa(myA)+sM+"_"+theString[myZ-1];
212 fileName = base+rest+"/"+itoa(myZ)+"_"+itoa(myA)+sM+"_"+theString[myZ-1];
213 //if(std::getenv("NeutronHPNames")) G4cout <<"HPWD 4a "<<*theName<<G4endl;
214
215 } else {
216
217 // For FS
218 fileName = base+"/"+rest+"/"+itoa(myZ)+"_"+itoa(myA)+sM+"_"+theString[myZ-1];
219 file = new std::istringstream(std::ios::in);
221
222 if (*file) {
223
224 // isotope FS
225 //if(std::getenv("NeutronHPNames")) G4cout <<"HPWD 4b1 "<<*theName<<G4endl;
226 } else {
227
228 // _nat_ FS
229 fileName = base+"/"+rest+"/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1];
230
231 delete file;
232 //file = new std::ifstream(fileName);
233 file = new std::istringstream(std::ios::in);
235 if (*file) {
236
237 // FS neither isotope nor _nat_
238 //if(std::getenv("NeutronHPNames")) G4cout <<"HPWD 4b2a "<<*theName<<G4endl;
239 G4double natA = myZ/G4SandiaTable::GetZtoA(myZ);
240 tmpA = natA;
241 } else {
242 //if(std::getenv("NeutronHPNames")) G4cout <<"HPWD 4b2c "<<*theName<<G4endl;
243 fileName="INVALID";
244 }
245 }
246
247 delete file;
248 }
249
250 result.SetName(fileName);
251 result.SetA(tmpA);
252 result.SetZ(myZ);
253 result.SetM(M);
254 }
255
256 do
257 {
258 if (delta_Z > theMaxOffSet) {
259 if (!G4ParticleHPManager::GetInstance()->GetSkipMissingIsotopes()) {
260 #ifdef G4VERBOSE
261 if ( G4HadronicParameters::Instance()->GetVerboseLevel() > 0 ) {
262 G4cout << "G4ParticleHPNames: There are no data available for some isotopes in this material " << G4endl;
263 G4cout << "G4ParticleHPNames: nor are there data for nearby isotopes." << G4endl;
264 G4cout << "G4ParticleHPNames: Please make sure G4NEUTRONHPDATA points to the directory " << G4endl;
265 G4cout << "G4ParticleHPNames: in which the neutron scattering data are located." << G4endl;
266 G4cout << "G4ParticleHPNames: The material was A = " << A << ", Z = " << Z << G4endl;
267 }
268 #endif
269 throw G4HadronicException(__FILE__, __LINE__, "In case the data sets are at present not available in the neutron data library, please contact Hadron Group Coordinator");
270 } else {
271 check = new std::istringstream(std::ios::in);
272 break;
273 }
274 }
275
276 //if ( std::abs( myA - A ) > theMaxOffSet )
277 if (delta_A > 2*theMaxOffSet) {
278 delta_A = 0;
279 flip_A = 1;
280
281 first = true;
282
283 if ( flip_Z > 0 )
284 {
285 delta_Z +=1;
286 }
287 myZ = Z + flip_Z * delta_Z;
288 flip_Z *= -1;
289
290 myA = A;
291 if ( myZ > 100 )
292 {
293 myZ = 100;
294 }
295 if ( myZ < 1 )
296 {
297 myZ = 1;
298 }
299
300 //myZ += inc;
301 } else {
302 if ( flip_A > 0 )
303 {
304 delta_A += 1;
305 }
306 myA = A + flip_A * delta_A;
307 flip_A *= -1;
308
309 if ( myA < 1 )
310 {
311 myA = 1;
312 }
313
314 //myA += inc;
315 }
316
317 }
318 while( myZ == 0 || myA == 0 ); // No meaning // Loop checking, 11.05.2015, T. Koi
319
320 }
321 while((!check) || (!(*check))); // Loop checking, 11.05.2015, T. Koi
322
323 #ifdef G4VERBOSE
324 if( (std::getenv("NeutronHPNamesLogging") || std::getenv("NeutronHPNames")) &&
325 G4HadronicParameters::Instance()->GetVerboseLevel() > 0 )
326 {
327 G4cout << "Names::GetName: last theName proposal = "<< G4endl;
328 G4cout << *theName <<" "<<A<<" "<<Z<<" "<<result.GetName()<<G4endl;
329 }
330 #endif
331
332 // administration and anouncement for lacking of exact data in NDL
333 if ( Z != result.GetZ() || A != result.GetA() )
334 {
335 if ( rest == "/CrossSection" )
336 {
337 G4String reac = base;
338 G4String dir = G4FindDataDir("G4NEUTRONHPDATA");
339 reac.erase ( 0 , dir.length() );
340 if ( G4ParticleHPManager::GetInstance()->GetSkipMissingIsotopes() && !( Z == result.GetZ() && result.IsThisNaturalAbundance() ) )
341 {
342 #ifdef G4VERBOSE
343 if ( verboseLevel > 0 && G4HadronicParameters::Instance()->GetVerboseLevel() > 0 ) {
344 G4cout << "NeutronHP: " << reac << " file for Z = " << Z << ", A = " << A << " is not found and CrossSection set to 0." << G4endl;
345 }
346 #endif
347 G4String new_name = base+"/"+rest+"/"+"0_0_Zero";
348 result.SetName( new_name );
349 }
350 else
351 {
352 //080901 Add protection that deuteron data do not selected for hydrogen and so on by T. Koi
353 //160216 Increase protencted isotopes for fixing problem on charged particle HP
354 if ( ( reac.find("Inelastic") != reac.size() && ( (Z == 1 && A == 1) || (Z == 1 && A == 2) || (Z == 1 && A == 3) || (Z == 2 && A == 3) || (Z == 2 && A == 4) ) )
355 || ( reac.find("Capture") != reac.size() && ( (Z == 1 && A == 3) || (Z == 2 && A == 4) ) )
356 || ( reac.find("Fission") != reac.size() && ( (Z == 88 && A == 224) || (Z == 88 && A == 225) || (Z == 89 && A == 225) || (Z == 88 && A == 226) ) ) )
357
358 {
359 G4String new_name = base+"/"+rest+"/"+"0_0_Zero";
360 result.SetName( new_name );
361 }
362 else
363 {
364 #ifdef G4VERBOSE
365 if ( verboseLevel > 0 && G4HadronicParameters::Instance()->GetVerboseLevel() > 0 ) {
366 G4cout << "NeutronHP: " << reac << " file for Z = " << Z << ", A = " << A << " is not found and NeutronHP will use " << result.GetName() << G4endl;
367 }
368 #endif
369 }
370 }
371 }
372 }
373
374 delete theName;
375 if(aFlag)
376 {
377 //check->close();
378 delete check;
379 check = NULL;
380 }
381 return result;
382}
const char * G4FindDataDir(const char *)
#define M(row, col)
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
const G4int Z[17]
const G4double A[17]
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static G4HadronicParameters * Instance()
void SetA(G4double anA)
void SetName(G4String aName)
void GetDataStream2(G4String, std::istringstream &iss)
static G4ParticleHPManager * GetInstance()
G4String itoa(int current)
static const G4String theString[100]
G4ParticleHPDataUsed GetName(G4int A, G4int Z, G4String base, G4String rest, G4bool &active)
static G4double GetZtoA(G4int Z)