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 | #include "G4NeutronHPNames.hh" |
---|
39 | #include "G4SandiaTable.hh" |
---|
40 | #include "G4HadronicException.hh" |
---|
41 | #include <fstream> |
---|
42 | |
---|
43 | const G4String G4NeutronHPNames::theString[99] = {"Hydrogen", "Helium", |
---|
44 | "Lithium", "Berylium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", |
---|
45 | "Neon", "Sodium", "Magnesium", "Aluminum", "Silicon", "Phosphorous", |
---|
46 | "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", |
---|
47 | "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", |
---|
48 | "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", |
---|
49 | "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", |
---|
50 | "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", |
---|
51 | "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", |
---|
52 | "Cesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", |
---|
53 | "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", |
---|
54 | "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", |
---|
55 | "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinium", "Gold", |
---|
56 | "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", |
---|
57 | "Francium", "Radium", "Actinium ", "Thorium", "Protactinium", "Uranium", |
---|
58 | "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", |
---|
59 | "Einsteinium"}; |
---|
60 | |
---|
61 | |
---|
62 | G4String G4NeutronHPNames::GetName(G4int i) { return theString[i]; } |
---|
63 | |
---|
64 | G4NeutronHPDataUsed G4NeutronHPNames::GetName(G4int A, G4int Z, G4String base, G4String rest, G4bool & aFlag) |
---|
65 | { |
---|
66 | |
---|
67 | G4NeutronHPDataUsed result; |
---|
68 | aFlag = true; |
---|
69 | if(getenv("NeutronHPNames")) G4cout << "Names::GetName entered for Z = " << Z << ", A = " << A <<G4endl; |
---|
70 | |
---|
71 | G4int myA = A; |
---|
72 | G4int myZ = Z; |
---|
73 | |
---|
74 | if(Z>92.5&&!getenv("AllowForHeavyElements") ) |
---|
75 | { |
---|
76 | G4cerr << "Please contact Hans-Peter.Wellisch@cern.ch"<<G4endl; |
---|
77 | throw G4HadronicException(__FILE__, __LINE__, "G4NeutronHPNames::GetName - data with Z>92 are not provided"); |
---|
78 | } |
---|
79 | |
---|
80 | G4String * theName = 0; |
---|
81 | G4String theFileName(""); |
---|
82 | |
---|
83 | // G4int inc = 1; |
---|
84 | |
---|
85 | G4int flip_Z = 1; |
---|
86 | G4int delta_Z = 0; |
---|
87 | |
---|
88 | G4int flip_A = 1; |
---|
89 | G4int delta_A = 0; |
---|
90 | |
---|
91 | std::ifstream * check = new std::ifstream(".dummy"); |
---|
92 | G4bool first = true; |
---|
93 | if(getenv("NeutronHPNames")) G4cout << "entered GetName!!!"<<G4endl; |
---|
94 | do |
---|
95 | { |
---|
96 | aFlag = true; |
---|
97 | G4String * biff = new G4String(); // delete here as theName |
---|
98 | *biff = base+"/"+"CrossSection/"+itoa(myZ)+"_"+itoa(myA)+"_"+theString[myZ-1]; |
---|
99 | |
---|
100 | if(theName!=0) delete theName; |
---|
101 | theName = biff; |
---|
102 | result.SetName(*theName); |
---|
103 | result.SetA(myA); |
---|
104 | result.SetZ(myZ); |
---|
105 | if(getenv("NeutronHPNames")) G4cout <<"HPWD 1 "<<*theName<<G4endl; |
---|
106 | |
---|
107 | // T.K. debug for memory leak |
---|
108 | if ( check != 0 ) |
---|
109 | { |
---|
110 | check->close(); |
---|
111 | delete check; |
---|
112 | } |
---|
113 | check = new std::ifstream(*theName); |
---|
114 | if ( !(*check) ) |
---|
115 | { |
---|
116 | check->close(); |
---|
117 | delete check; |
---|
118 | check = 0; |
---|
119 | aFlag = false; |
---|
120 | if ( first ) |
---|
121 | { |
---|
122 | aFlag = true; |
---|
123 | first = false; |
---|
124 | biff = new G4String(); // delete here as theName |
---|
125 | *biff = base+"/"+"CrossSection/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1]; |
---|
126 | if(theName!=0) delete theName; |
---|
127 | theName = biff; |
---|
128 | if(getenv("NeutronHPNames")) G4cout <<"HPWD 2 "<<*theName<<G4endl; |
---|
129 | result.SetName(*theName); |
---|
130 | G4double natA = myZ/G4SandiaTable::GetZtoA(myZ); |
---|
131 | result.SetA(natA); |
---|
132 | result.SetZ(myZ); |
---|
133 | check = new std::ifstream(*theName); |
---|
134 | if ( !(*check) ) |
---|
135 | { |
---|
136 | check->close(); |
---|
137 | delete check; |
---|
138 | check = 0; |
---|
139 | aFlag = false; |
---|
140 | } |
---|
141 | else |
---|
142 | { |
---|
143 | biff = new G4String(); // delete here as theName |
---|
144 | if(theName!=0) delete theName; |
---|
145 | *biff = base+"/"+rest+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1]; |
---|
146 | theName = biff; |
---|
147 | if(getenv("NeutronHPNames")) G4cout <<"HPWD 3 "<<*theName<<G4endl; |
---|
148 | result.SetName(*theName); |
---|
149 | G4double natA = myZ/G4SandiaTable::GetZtoA(myZ); |
---|
150 | result.SetA(natA); |
---|
151 | result.SetZ(myZ); |
---|
152 | result.SetNaturalAbundanceFlag(); |
---|
153 | } |
---|
154 | } |
---|
155 | } |
---|
156 | else |
---|
157 | { |
---|
158 | // 070706 T. Koi Modified |
---|
159 | /* |
---|
160 | biff = new G4String(); // delete here as theName |
---|
161 | *biff = base+"/"+rest+itoa(myZ)+"_"+itoa(myA)+"_"+theString[myZ-1]; |
---|
162 | if(theName!=0) delete theName; |
---|
163 | theName = biff; |
---|
164 | if(getenv("NeutronHPNames")) G4cout <<"HPWD 4 "<<*theName<<G4endl; |
---|
165 | result.SetName(*theName); |
---|
166 | result.SetA(myA); |
---|
167 | result.SetZ(myZ); |
---|
168 | */ |
---|
169 | |
---|
170 | G4double tmpA = myA; |
---|
171 | std::ifstream* file = NULL; |
---|
172 | G4String fileName; |
---|
173 | |
---|
174 | if ( rest == "/CrossSection/" ) |
---|
175 | { |
---|
176 | |
---|
177 | fileName = base+"/"+rest+itoa(myZ)+"_"+itoa(myA)+"_"+theString[myZ-1]; |
---|
178 | if(getenv("NeutronHPNames")) G4cout <<"HPWD 4a "<<*theName<<G4endl; |
---|
179 | |
---|
180 | } |
---|
181 | else |
---|
182 | { |
---|
183 | |
---|
184 | // For FS |
---|
185 | fileName = base+"/"+rest+itoa(myZ)+"_"+itoa(myA)+"_"+theString[myZ-1]; |
---|
186 | file = new std::ifstream(fileName); |
---|
187 | |
---|
188 | if ( *file ) |
---|
189 | { |
---|
190 | |
---|
191 | // isotope FS |
---|
192 | if(getenv("NeutronHPNames")) G4cout <<"HPWD 4b1 "<<*theName<<G4endl; |
---|
193 | } |
---|
194 | else |
---|
195 | { |
---|
196 | |
---|
197 | // _nat_ FS |
---|
198 | fileName = base+"/"+rest+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1]; |
---|
199 | |
---|
200 | delete file; |
---|
201 | file = new std::ifstream(fileName); |
---|
202 | if ( *file ) |
---|
203 | { |
---|
204 | |
---|
205 | // FS neither isotope nor _nat_ |
---|
206 | if(getenv("NeutronHPNames")) G4cout <<"HPWD 4b2a "<<*theName<<G4endl; |
---|
207 | G4double natA = myZ/G4SandiaTable::GetZtoA(myZ); |
---|
208 | tmpA = natA; |
---|
209 | } |
---|
210 | else |
---|
211 | { |
---|
212 | if(getenv("NeutronHPNames")) G4cout <<"HPWD 4b2c "<<*theName<<G4endl; |
---|
213 | } |
---|
214 | } |
---|
215 | |
---|
216 | delete file; |
---|
217 | |
---|
218 | } |
---|
219 | |
---|
220 | result.SetName(fileName); |
---|
221 | result.SetA(tmpA); |
---|
222 | result.SetZ(myZ); |
---|
223 | |
---|
224 | } |
---|
225 | |
---|
226 | do |
---|
227 | { |
---|
228 | // if (std::abs(myZ-Z)>theMaxOffSet||myZ==0||myA==0) |
---|
229 | if ( delta_Z > theMaxOffSet ) |
---|
230 | { |
---|
231 | //if ( inc > 0 ) |
---|
232 | //{ |
---|
233 | // inc*= -1; |
---|
234 | // myZ = Z; |
---|
235 | // myA = A; |
---|
236 | //} |
---|
237 | //else |
---|
238 | //{ |
---|
239 | G4cout <<"G4NeutronHPNames: Sorry, this material does not come near to any data."<<G4endl; |
---|
240 | G4cout <<"G4NeutronHPNames: Please make sure G4NEUTRONHPDATA points to the" << G4endl; |
---|
241 | G4cout <<" directory, the neutron scattering data are located in." << G4endl; |
---|
242 | G4cout << "G4NeutronHPNames: The material was: A="<<A<<", Z="<<Z<<G4endl; |
---|
243 | throw G4HadronicException(__FILE__, __LINE__, "In case the data sets are at present not available in the neutron data library, please contact Hans-Peter.Wellisch@cern.ch"); |
---|
244 | delete theName; |
---|
245 | theFileName = ""; |
---|
246 | return result; |
---|
247 | //} |
---|
248 | } |
---|
249 | |
---|
250 | //if ( std::abs( myA - A ) > theMaxOffSet ) |
---|
251 | if ( delta_A > 2*theMaxOffSet ) |
---|
252 | { |
---|
253 | delta_A = 0; |
---|
254 | flip_A = 1; |
---|
255 | |
---|
256 | first = true; |
---|
257 | |
---|
258 | if ( flip_Z > 0 ) |
---|
259 | { |
---|
260 | delta_Z +=1; |
---|
261 | } |
---|
262 | myZ = Z + flip_Z * delta_Z; |
---|
263 | flip_Z *= -1; |
---|
264 | |
---|
265 | myA = A; |
---|
266 | if ( myZ > 99 ) |
---|
267 | { |
---|
268 | myZ = 99; |
---|
269 | } |
---|
270 | if ( myZ < 1 ) |
---|
271 | { |
---|
272 | myZ = 1; |
---|
273 | } |
---|
274 | |
---|
275 | // myZ += inc; |
---|
276 | } |
---|
277 | else |
---|
278 | { |
---|
279 | if ( flip_A > 0 ) |
---|
280 | { |
---|
281 | delta_A += 1; |
---|
282 | } |
---|
283 | myA = A + flip_A * delta_A; |
---|
284 | flip_A *= -1; |
---|
285 | |
---|
286 | if ( myA < 1 ) |
---|
287 | { |
---|
288 | myA = 1; |
---|
289 | } |
---|
290 | |
---|
291 | // myA += inc; |
---|
292 | } |
---|
293 | |
---|
294 | } |
---|
295 | while( myZ == 0 || myA == 0 ); // No meaning |
---|
296 | |
---|
297 | } |
---|
298 | while((!check) || (!(*check))); |
---|
299 | |
---|
300 | if(getenv("NeutronHPNamesLogging") || getenv("NeutronHPNames")) |
---|
301 | { |
---|
302 | G4cout << "Names::GetName: last theName proposal = "<< G4endl; |
---|
303 | G4cout << *theName <<" "<<A<<" "<<Z<<" "<<result.GetName()<<G4endl; |
---|
304 | } |
---|
305 | |
---|
306 | // administration and anouncement for lacking of exact data in NDL |
---|
307 | if ( Z != result.GetZ() || A != result.GetA() ) |
---|
308 | { |
---|
309 | if ( rest == "/CrossSection/" ) |
---|
310 | { |
---|
311 | G4String reac = base; |
---|
312 | G4String dir = getenv("G4NEUTRONHPDATA"); |
---|
313 | reac.erase ( 0 , dir.length() ); |
---|
314 | if ( getenv ( "G4NEUTRONHP_SKIP_MISSING_ISOTOPES" ) && !( Z == result.GetZ() && result.IsThisNaturalAbundance() ) ) |
---|
315 | { |
---|
316 | G4cout << "NeutronHP: " << reac << " file for Z = " << Z << ", A = " << A << " is not found and CrossSection set to 0." << G4endl; |
---|
317 | G4String new_name = base+"/"+rest+"0_0_Zero"; |
---|
318 | result.SetName( new_name ); |
---|
319 | } |
---|
320 | else |
---|
321 | { |
---|
322 | //080901 Add protection that deuteron data do not selected for hydrogen and so on by T. Koi |
---|
323 | if ( (reac.find("Inelastic") != reac.size() && |
---|
324 | ((Z == 1 && A == 1) || (Z == 2 && A == 4) ) ) |
---|
325 | || |
---|
326 | (reac.find("Capture") != reac.size() && (Z == 2 && A == 4) ) ) |
---|
327 | { |
---|
328 | G4String new_name = base+"/"+rest+"0_0_Zero"; |
---|
329 | result.SetName( new_name ); |
---|
330 | } |
---|
331 | else |
---|
332 | { |
---|
333 | G4cout << "NeutronHP: " << reac << " file for Z = " << Z << ", A = " << A << " is not found and NeutronHP will use " << result.GetName() << G4endl; |
---|
334 | } |
---|
335 | } |
---|
336 | } |
---|
337 | } |
---|
338 | |
---|
339 | delete theName; |
---|
340 | if(aFlag) |
---|
341 | { |
---|
342 | check->close(); |
---|
343 | delete check; |
---|
344 | check = 0; |
---|
345 | } |
---|
346 | return result; |
---|
347 | } |
---|