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

#include <G4ParticleHPNames.hh>

Public Member Functions

 G4ParticleHPNames ()
 
 G4ParticleHPNames (G4int maxOffSet)
 
 ~G4ParticleHPNames ()
 
G4ParticleHPDataUsed GetName (G4int A, G4int Z, G4String base, G4String rest, G4bool &active)
 
G4ParticleHPDataUsed 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 G4ParticleHPNames.hh.

Constructor & Destructor Documentation

◆ G4ParticleHPNames() [1/2]

G4ParticleHPNames::G4ParticleHPNames ( )
inline

Definition at line 43 of file G4ParticleHPNames.hh.

◆ G4ParticleHPNames() [2/2]

G4ParticleHPNames::G4ParticleHPNames ( G4int  maxOffSet)
inline

Definition at line 44 of file G4ParticleHPNames.hh.

44{theMaxOffSet = maxOffSet;}

◆ ~G4ParticleHPNames()

G4ParticleHPNames::~G4ParticleHPNames ( )
inline

Definition at line 45 of file G4ParticleHPNames.hh.

45{}

Member Function Documentation

◆ GetName() [1/3]

G4ParticleHPDataUsed G4ParticleHPNames::GetName ( G4int  A,
G4int  Z,
G4int  M,
G4String  base,
G4String  rest,
G4bool active 
)

Definition at line 70 of file G4ParticleHPNames.cc.

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 = std::getenv("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}
double A(double temperature)
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#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]
static G4double GetZtoA(G4int Z)

◆ GetName() [2/3]

◆ GetName() [3/3]

G4String G4ParticleHPNames::GetName ( G4int  i)

Definition at line 68 of file G4ParticleHPNames.cc.

68{ return theString[i]; }

◆ itoa()

G4String G4ParticleHPNames::itoa ( int  current)
inline

Definition at line 57 of file G4ParticleHPNames.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); // Loop checking, 11.05.2015, T. Koi
69 return result;
70 }

Referenced by GetName().

◆ SetMaxOffSet()

void G4ParticleHPNames::SetMaxOffSet ( G4int  anOffset)
inline

Definition at line 51 of file G4ParticleHPNames.hh.

51{ theMaxOffSet = anOffset; }

Member Data Documentation

◆ theMaxOffSet

G4int G4ParticleHPNames::theMaxOffSet

Definition at line 56 of file G4ParticleHPNames.hh.

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

◆ theString

const G4String G4ParticleHPNames::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 G4ParticleHPNames.hh.

Referenced by GetName(), and G4FissionProductYieldDist::MakeIsotopeName().


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