Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Data Fields | Static Public Attributes
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)
 

Data Fields

G4int theMaxOffSet
 

Static Public Attributes

static const G4String theString [100]
 

Detailed Description

Definition at line 38 of file G4NeutronHPNames.hh.

Constructor & Destructor Documentation

G4NeutronHPNames::G4NeutronHPNames ( )
inline

Definition at line 42 of file G4NeutronHPNames.hh.

References theMaxOffSet.

42 {theMaxOffSet = 5;}
G4NeutronHPNames::G4NeutronHPNames ( G4int  maxOffSet)
inline

Definition at line 43 of file G4NeutronHPNames.hh.

References theMaxOffSet.

43 {theMaxOffSet = maxOffSet;}
G4NeutronHPNames::~G4NeutronHPNames ( )
inline

Definition at line 44 of file G4NeutronHPNames.hh.

44 {}

Member Function Documentation

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

Definition at line 66 of file G4NeutronHPNames.cc.

References G4cerr, G4cout, G4endl, G4NeutronHPDataUsed::GetA(), G4NeutronHPManager::GetDataStream(), G4NeutronHPManager::GetInstance(), G4NeutronHPDataUsed::GetName(), G4NeutronHPManager::GetVerboseLevel(), G4NeutronHPDataUsed::GetZ(), G4SandiaTable::GetZtoA(), G4NeutronHPDataUsed::IsThisNaturalAbundance(), itoa(), G4NeutronHPDataUsed::SetA(), G4NeutronHPDataUsed::SetM(), G4NeutronHPDataUsed::SetName(), G4NeutronHPDataUsed::SetNaturalAbundanceFlag(), G4NeutronHPDataUsed::SetZ(), theMaxOffSet, and theString.

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

Definition at line 63 of file G4NeutronHPNames.cc.

References theString.

63 { return theString[i]; }
static const G4String theString[100]
G4String G4NeutronHPNames::itoa ( int  current)
inline

Definition at line 56 of file G4NeutronHPNames.hh.

Referenced by GetName().

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

Definition at line 50 of file G4NeutronHPNames.hh.

References theMaxOffSet.

50 { theMaxOffSet = anOffset; }

Field Documentation

G4int G4NeutronHPNames::theMaxOffSet

Definition at line 55 of file G4NeutronHPNames.hh.

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

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 54 of file G4NeutronHPNames.hh.

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


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