Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4NeutronHPNames Class Reference

#include <G4NeutronHPNames.hh>

Public Member Functions

 G4NeutronHPNames ()
 
 G4NeutronHPNames (G4int maxOffSet)
 
 ~G4NeutronHPNames ()
 
G4NeutronHPDataUsed GetName (G4int A, G4int Z, G4String base, G4String rest, G4bool &active)
 
G4NeutronHPDataUsed GetName (G4int A, G4int Z, G4int M, G4String base, G4String rest, G4bool &active)
 
G4String GetName (G4int i)
 
void SetMaxOffSet (G4int anOffset)
 
G4String itoa (int current)
 

Public Attributes

G4int theMaxOffSet
 

Static Public Attributes

static const G4String theString [100]
 

Detailed Description

Definition at line 39 of file G4NeutronHPNames.hh.

Constructor & Destructor Documentation

◆ G4NeutronHPNames() [1/2]

G4NeutronHPNames::G4NeutronHPNames ( )
inline

Definition at line 43 of file G4NeutronHPNames.hh.

◆ G4NeutronHPNames() [2/2]

G4NeutronHPNames::G4NeutronHPNames ( G4int  maxOffSet)
inline

Definition at line 44 of file G4NeutronHPNames.hh.

44{theMaxOffSet = maxOffSet;}

◆ ~G4NeutronHPNames()

G4NeutronHPNames::~G4NeutronHPNames ( )
inline

Definition at line 45 of file G4NeutronHPNames.hh.

45{}

Member Function Documentation

◆ GetName() [1/3]

G4NeutronHPDataUsed G4NeutronHPNames::GetName ( G4int  A,
G4int  Z,
G4int  M,
G4String  base,
G4String  rest,
G4bool active 
)

Definition at line 65 of file G4NeutronHPNames.cc.

66{
67
68 //G4cout << Z << " " << A << " " << M << " " << base << " " << rest << G4endl;
69
70 //Excited isomer indicator
71 std::stringstream ss;
72 G4String sM;
73 if ( M > 0 )
74 {
75 ss << "m";
76 ss << M;
77 ss >> sM;
78 ss.clear();
79 }
80
82 aFlag = true;
83if(getenv("NeutronHPNames")) G4cout << "Names::GetName entered for Z = " << Z << ", A = " << A <<G4endl;
84
85 G4int myA = A;
86 G4int myZ = Z;
87
88 if(Z>92.5&&!getenv("AllowForHeavyElements") )
89 {
90 //G4cerr << "Please contact [email protected]"<<G4endl;
91 G4cerr << "Please contact Geant4 Hadron Group Coordinator"<<G4endl;
92 throw G4HadronicException(__FILE__, __LINE__, "G4NeutronHPNames::GetName - data with Z>92 are not provided");
93 }
94
95 G4String * theName = 0;
96 G4String theFileName("");
97
98// G4int inc = 1;
99
100 G4int flip_Z = 1;
101 G4int delta_Z = 0;
102
103 G4int flip_A = 1;
104 G4int delta_A = 0;
105
106 std::ifstream * check = new std::ifstream(".dummy");
107 G4bool first = true;
108if(getenv("NeutronHPNames")) G4cout << "entered GetName!!!"<<G4endl;
109 do
110 {
111 aFlag = true;
112 G4String * biff = new G4String(); // delete here as theName
113 *biff = base+"/CrossSection/"+itoa(myZ)+"_"+itoa(myA)+sM+"_"+theString[myZ-1];
114
115 if(theName!=0) delete theName;
116 theName = biff;
117 result.SetName(*theName);
118 result.SetA(myA);
119 result.SetZ(myZ);
120 result.SetM(M);
121if(getenv("NeutronHPNames")) G4cout <<"HPWD 1 "<<*theName<<G4endl;
122
123 // T.K. debug for memory leak
124 if ( check != 0 )
125 {
126 check->close();
127 delete check;
128 }
129 check = new std::ifstream(*theName);
130 if ( !(*check) )
131 {
132 check->close();
133 delete check;
134 check = 0;
135 aFlag = false;
136 if ( first )
137 {
138 aFlag = true;
139 first = false;
140 biff = new G4String(); // delete here as theName
141 *biff = base+"/CrossSection/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1];
142 if(theName!=0) delete theName;
143 theName = biff;
144if(getenv("NeutronHPNames")) G4cout <<"HPWD 2 "<<*theName<<G4endl;
145 result.SetName(*theName);
146 G4double natA = myZ/G4SandiaTable::GetZtoA(myZ);
147 result.SetA(natA);
148 result.SetZ(myZ);
149 result.SetM(M);
150 check = new std::ifstream(*theName);
151 if ( !(*check) )
152 {
153 check->close();
154 delete check;
155 check = 0;
156 aFlag = false;
157 }
158 else
159 {
160 biff = new G4String(); // delete here as theName
161 if(theName!=0) delete theName;
162 *biff = base+"/"+rest+"/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1];
163 if ( rest=="/CrossSection" ) *biff = base+rest+"/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1];
164 theName = biff;
165if(getenv("NeutronHPNames")) G4cout <<"HPWD 3 "<<*theName<<G4endl;
166 result.SetName(*theName);
167 natA = myZ/G4SandiaTable::GetZtoA(myZ);
168 result.SetA(natA);
169 result.SetZ(myZ);
170 result.SetM(M);
172 }
173 }
174 }
175 else
176 {
177// 070706 T. Koi Modified
178/*
179 biff = new G4String(); // delete here as theName
180 *biff = base+"/"+rest+itoa(myZ)+"_"+itoa(myA)+"_"+theString[myZ-1];
181 if(theName!=0) delete theName;
182 theName = biff;
183if(getenv("NeutronHPNames")) G4cout <<"HPWD 4 "<<*theName<<G4endl;
184 result.SetName(*theName);
185 result.SetA(myA);
186 result.SetZ(myZ);
187*/
188
189 G4double tmpA = myA;
190 std::ifstream* file = NULL;
191 G4String fileName;
192
193 if ( rest == "/CrossSection" )
194 {
195
196 //fileName = base+"/"+rest+"/"+itoa(myZ)+"_"+itoa(myA)+sM+"_"+theString[myZ-1];
197 fileName = base+rest+"/"+itoa(myZ)+"_"+itoa(myA)+sM+"_"+theString[myZ-1];
198if(getenv("NeutronHPNames")) G4cout <<"HPWD 4a "<<*theName<<G4endl;
199
200 }
201 else
202 {
203
204// For FS
205 fileName = base+"/"+rest+"/"+itoa(myZ)+"_"+itoa(myA)+sM+"_"+theString[myZ-1];
206 file = new std::ifstream(fileName);
207
208 if ( *file )
209 {
210
211// isotope FS
212if(getenv("NeutronHPNames")) G4cout <<"HPWD 4b1 "<<*theName<<G4endl;
213 }
214 else
215 {
216
217// _nat_ FS
218 fileName = base+"/"+rest+"/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1];
219
220 delete file;
221 file = new std::ifstream(fileName);
222 if ( *file )
223 {
224
225// FS neither isotope nor _nat_
226if(getenv("NeutronHPNames")) G4cout <<"HPWD 4b2a "<<*theName<<G4endl;
227 G4double natA = myZ/G4SandiaTable::GetZtoA(myZ);
228 tmpA = natA;
229 }
230 else
231 {
232if(getenv("NeutronHPNames")) G4cout <<"HPWD 4b2c "<<*theName<<G4endl;
233 fileName="INVALID";
234 }
235 }
236
237 delete file;
238
239 }
240
241 result.SetName(fileName);
242 result.SetA(tmpA);
243 result.SetZ(myZ);
244 result.SetM(M);
245
246 }
247
248 do
249 {
250// if (std::abs(myZ-Z)>theMaxOffSet||myZ==0||myA==0)
251 if ( delta_Z > theMaxOffSet )
252 {
253 //if ( inc > 0 )
254 //{
255 // inc*= -1;
256 // myZ = Z;
257 // myA = A;
258 //}
259 //else
260 //{
261 G4cout <<"G4NeutronHPNames: Sorry, this material does not come near to any data."<<G4endl;
262 G4cout <<"G4NeutronHPNames: Please make sure G4NEUTRONHPDATA points to the" << G4endl;
263 G4cout <<" directory, the neutron scattering data are located in." << G4endl;
264 G4cout << "G4NeutronHPNames: The material was: A="<<A<<", Z="<<Z<<G4endl;
265 //throw G4HadronicException(__FILE__, __LINE__, "In case the data sets are at present not available in the neutron data library, please contact [email protected]");
266 throw G4HadronicException(__FILE__, __LINE__, "In case the data sets are at present not available in the neutron data library, please contact Hadron Group Coordinator");
267 delete theName;
268 theFileName = "";
269 return result;
270 //}
271 }
272
273 //if ( std::abs( myA - A ) > theMaxOffSet )
274 if ( delta_A > 2*theMaxOffSet )
275 {
276 delta_A = 0;
277 flip_A = 1;
278
279 first = true;
280
281 if ( flip_Z > 0 )
282 {
283 delta_Z +=1;
284 }
285 myZ = Z + flip_Z * delta_Z;
286 flip_Z *= -1;
287
288 myA = A;
289 if ( myZ > 100 )
290 {
291 myZ = 100;
292 }
293 if ( myZ < 1 )
294 {
295 myZ = 1;
296 }
297
298// myZ += inc;
299 }
300 else
301 {
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
319
320 }
321 while((!check) || (!(*check)));
322
323 if(getenv("NeutronHPNamesLogging") || getenv("NeutronHPNames"))
324 {
325 G4cout << "Names::GetName: last theName proposal = "<< G4endl;
326 G4cout << *theName <<" "<<A<<" "<<Z<<" "<<result.GetName()<<G4endl;
327 }
328
329// administration and anouncement for lacking of exact data in NDL
330 if ( Z != result.GetZ() || A != result.GetA() )
331 {
332 if ( rest == "/CrossSection" )
333 {
334 G4String reac = base;
335 G4String dir = getenv("G4NEUTRONHPDATA");
336 reac.erase ( 0 , dir.length() );
337 if ( getenv ( "G4NEUTRONHP_SKIP_MISSING_ISOTOPES" ) && !( Z == result.GetZ() && result.IsThisNaturalAbundance() ) )
338 {
339 G4cout << "NeutronHP: " << reac << " file for Z = " << Z << ", A = " << A << " is not found and CrossSection set to 0." << G4endl;
340 G4String new_name = base+"/"+rest+"/"+"0_0_Zero";
341 result.SetName( new_name );
342 }
343 else
344 {
345 //080901 Add protection that deuteron data do not selected for hydrogen and so on by T. Koi
346 if ( ( reac.find("Inelastic") != reac.size() && ( (Z == 1 && A == 1) || (Z == 2 && A == 4) ) )
347 || ( reac.find("Capture") != reac.size() && ( (Z == 1 && A == 3) || (Z == 2 && A == 4) ) )
348 || ( reac.find("Fission") != reac.size() && ( (Z == 88 && A == 224) || (Z == 88 && A == 225) || (Z == 89 && A == 225) || (Z == 88 && A == 226) ) ) )
349
350 {
351 G4String new_name = base+"/"+rest+"/"+"0_0_Zero";
352 result.SetName( new_name );
353 }
354 else
355 {
356 G4cout << "NeutronHP: " << reac << " file for Z = " << Z << ", A = " << A << " is not found and NeutronHP will use " << result.GetName() << G4endl;
357 }
358 }
359 }
360 }
361
362 delete theName;
363 if(aFlag)
364 {
365 check->close();
366 delete check;
367 check = 0;
368 }
369 return result;
370 }
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 G4cerr
G4DLLIMPORT std::ostream G4cout
void SetName(G4String aName)
void SetA(G4double anA)
static const G4String theString[100]
G4String itoa(int current)
static G4double GetZtoA(G4int Z)

◆ GetName() [2/3]

◆ GetName() [3/3]

G4String G4NeutronHPNames::GetName ( G4int  i)

Definition at line 62 of file G4NeutronHPNames.cc.

62{ return theString[i]; }

◆ itoa()

G4String G4NeutronHPNames::itoa ( int  current)
inline

Definition at line 57 of file G4NeutronHPNames.hh.

58 {
59 const char theDigits[11] = "0123456789";
60 G4String result;
61 int digit;
62 do
63 {
64 digit = current-10*(current/10);
65 result=theDigits[digit]+result;
66 current/=10;
67 }
68 while(current!=0);
69 return result;
70 }

Referenced by GetName().

◆ SetMaxOffSet()

void G4NeutronHPNames::SetMaxOffSet ( G4int  anOffset)
inline

Definition at line 51 of file G4NeutronHPNames.hh.

51{ theMaxOffSet = anOffset; }

Referenced by G4NeutronIsoIsoCrossSections::Init().

Member Data Documentation

◆ theMaxOffSet

G4int G4NeutronHPNames::theMaxOffSet

Definition at line 56 of file G4NeutronHPNames.hh.

Referenced by G4NeutronHPNames(), GetName(), and SetMaxOffSet().

◆ theString

const G4String G4NeutronHPNames::theString
static
Initial value:
= {"Hydrogen", "Helium",
"Lithium", "Berylium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine",
"Neon", "Sodium", "Magnesium", "Aluminum", "Silicon", "Phosphorous",
"Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium",
"Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel",
"Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine",
"Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium",
"Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver",
"Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon",
"Cesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium",
"Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium",
"Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium",
"Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinium", "Gold",
"Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon",
"Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium",
"Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium",
"Einsteinium","Fermium"}

Definition at line 55 of file G4NeutronHPNames.hh.

Referenced by GetName().


The documentation for this class was generated from the following files: