00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "G4NeutronHPNames.hh"
00039 #include "G4SandiaTable.hh"
00040 #include "G4HadronicException.hh"
00041 #include <fstream>
00042
00043 const G4String G4NeutronHPNames::theString[100] = {"Hydrogen", "Helium",
00044 "Lithium", "Berylium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine",
00045 "Neon", "Sodium", "Magnesium", "Aluminum", "Silicon", "Phosphorous",
00046 "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium",
00047 "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel",
00048 "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine",
00049 "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium",
00050 "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver",
00051 "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon",
00052 "Cesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium",
00053 "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium",
00054 "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium",
00055 "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinium", "Gold",
00056 "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon",
00057 "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium",
00058 "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium",
00059 "Einsteinium","Fermium"};
00060
00061
00062 G4String G4NeutronHPNames::GetName(G4int i) { return theString[i]; }
00063
00064
00065 G4NeutronHPDataUsed G4NeutronHPNames::GetName(G4int A, G4int Z, G4int M, G4String base, G4String rest, G4bool & aFlag)
00066 {
00067
00068
00069
00070
00071 std::stringstream ss;
00072 G4String sM;
00073 if ( M > 0 )
00074 {
00075 ss << "m";
00076 ss << M;
00077 ss >> sM;
00078 ss.clear();
00079 }
00080
00081 G4NeutronHPDataUsed result;
00082 aFlag = true;
00083 if(getenv("NeutronHPNames")) G4cout << "Names::GetName entered for Z = " << Z << ", A = " << A <<G4endl;
00084
00085 G4int myA = A;
00086 G4int myZ = Z;
00087
00088 if(Z>92.5&&!getenv("AllowForHeavyElements") )
00089 {
00090
00091 G4cerr << "Please contact Geant4 Hadron Group Coordinator"<<G4endl;
00092 throw G4HadronicException(__FILE__, __LINE__, "G4NeutronHPNames::GetName - data with Z>92 are not provided");
00093 }
00094
00095 G4String * theName = 0;
00096 G4String theFileName("");
00097
00098
00099
00100 G4int flip_Z = 1;
00101 G4int delta_Z = 0;
00102
00103 G4int flip_A = 1;
00104 G4int delta_A = 0;
00105
00106 std::ifstream * check = new std::ifstream(".dummy");
00107 G4bool first = true;
00108 if(getenv("NeutronHPNames")) G4cout << "entered GetName!!!"<<G4endl;
00109 do
00110 {
00111 aFlag = true;
00112 G4String * biff = new G4String();
00113 *biff = base+"/CrossSection/"+itoa(myZ)+"_"+itoa(myA)+sM+"_"+theString[myZ-1];
00114
00115 if(theName!=0) delete theName;
00116 theName = biff;
00117 result.SetName(*theName);
00118 result.SetA(myA);
00119 result.SetZ(myZ);
00120 result.SetM(M);
00121 if(getenv("NeutronHPNames")) G4cout <<"HPWD 1 "<<*theName<<G4endl;
00122
00123
00124 if ( check != 0 )
00125 {
00126 check->close();
00127 delete check;
00128 }
00129 check = new std::ifstream(*theName);
00130 if ( !(*check) )
00131 {
00132 check->close();
00133 delete check;
00134 check = 0;
00135 aFlag = false;
00136 if ( first )
00137 {
00138 aFlag = true;
00139 first = false;
00140 biff = new G4String();
00141 *biff = base+"/CrossSection/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1];
00142 if(theName!=0) delete theName;
00143 theName = biff;
00144 if(getenv("NeutronHPNames")) G4cout <<"HPWD 2 "<<*theName<<G4endl;
00145 result.SetName(*theName);
00146 G4double natA = myZ/G4SandiaTable::GetZtoA(myZ);
00147 result.SetA(natA);
00148 result.SetZ(myZ);
00149 result.SetM(M);
00150 check = new std::ifstream(*theName);
00151 if ( !(*check) )
00152 {
00153 check->close();
00154 delete check;
00155 check = 0;
00156 aFlag = false;
00157 }
00158 else
00159 {
00160 biff = new G4String();
00161 if(theName!=0) delete theName;
00162 *biff = base+"/"+rest+"/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1];
00163 if ( rest=="/CrossSection" ) *biff = base+rest+"/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1];
00164 theName = biff;
00165 if(getenv("NeutronHPNames")) G4cout <<"HPWD 3 "<<*theName<<G4endl;
00166 result.SetName(*theName);
00167 natA = myZ/G4SandiaTable::GetZtoA(myZ);
00168 result.SetA(natA);
00169 result.SetZ(myZ);
00170 result.SetM(M);
00171 result.SetNaturalAbundanceFlag();
00172 }
00173 }
00174 }
00175 else
00176 {
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189 G4double tmpA = myA;
00190 std::ifstream* file = NULL;
00191 G4String fileName;
00192
00193 if ( rest == "/CrossSection" )
00194 {
00195
00196
00197 fileName = base+rest+"/"+itoa(myZ)+"_"+itoa(myA)+sM+"_"+theString[myZ-1];
00198 if(getenv("NeutronHPNames")) G4cout <<"HPWD 4a "<<*theName<<G4endl;
00199
00200 }
00201 else
00202 {
00203
00204
00205 fileName = base+"/"+rest+"/"+itoa(myZ)+"_"+itoa(myA)+sM+"_"+theString[myZ-1];
00206 file = new std::ifstream(fileName);
00207
00208 if ( *file )
00209 {
00210
00211
00212 if(getenv("NeutronHPNames")) G4cout <<"HPWD 4b1 "<<*theName<<G4endl;
00213 }
00214 else
00215 {
00216
00217
00218 fileName = base+"/"+rest+"/"+itoa(myZ)+"_"+"nat"+"_"+theString[myZ-1];
00219
00220 delete file;
00221 file = new std::ifstream(fileName);
00222 if ( *file )
00223 {
00224
00225
00226 if(getenv("NeutronHPNames")) G4cout <<"HPWD 4b2a "<<*theName<<G4endl;
00227 G4double natA = myZ/G4SandiaTable::GetZtoA(myZ);
00228 tmpA = natA;
00229 }
00230 else
00231 {
00232 if(getenv("NeutronHPNames")) G4cout <<"HPWD 4b2c "<<*theName<<G4endl;
00233 fileName="INVALID";
00234 }
00235 }
00236
00237 delete file;
00238
00239 }
00240
00241 result.SetName(fileName);
00242 result.SetA(tmpA);
00243 result.SetZ(myZ);
00244 result.SetM(M);
00245
00246 }
00247
00248 do
00249 {
00250
00251 if ( delta_Z > theMaxOffSet )
00252 {
00253
00254
00255
00256
00257
00258
00259
00260
00261 G4cout <<"G4NeutronHPNames: Sorry, this material does not come near to any data."<<G4endl;
00262 G4cout <<"G4NeutronHPNames: Please make sure G4NEUTRONHPDATA points to the" << G4endl;
00263 G4cout <<" directory, the neutron scattering data are located in." << G4endl;
00264 G4cout << "G4NeutronHPNames: The material was: A="<<A<<", Z="<<Z<<G4endl;
00265
00266 throw G4HadronicException(__FILE__, __LINE__, "In case the data sets are at present not available in the neutron data library, please contact Hadron Group Coordinator");
00267 delete theName;
00268 theFileName = "";
00269 return result;
00270
00271 }
00272
00273
00274 if ( delta_A > 2*theMaxOffSet )
00275 {
00276 delta_A = 0;
00277 flip_A = 1;
00278
00279 first = true;
00280
00281 if ( flip_Z > 0 )
00282 {
00283 delta_Z +=1;
00284 }
00285 myZ = Z + flip_Z * delta_Z;
00286 flip_Z *= -1;
00287
00288 myA = A;
00289 if ( myZ > 100 )
00290 {
00291 myZ = 100;
00292 }
00293 if ( myZ < 1 )
00294 {
00295 myZ = 1;
00296 }
00297
00298
00299 }
00300 else
00301 {
00302 if ( flip_A > 0 )
00303 {
00304 delta_A += 1;
00305 }
00306 myA = A + flip_A * delta_A;
00307 flip_A *= -1;
00308
00309 if ( myA < 1 )
00310 {
00311 myA = 1;
00312 }
00313
00314
00315 }
00316
00317 }
00318 while( myZ == 0 || myA == 0 );
00319
00320 }
00321 while((!check) || (!(*check)));
00322
00323 if(getenv("NeutronHPNamesLogging") || getenv("NeutronHPNames"))
00324 {
00325 G4cout << "Names::GetName: last theName proposal = "<< G4endl;
00326 G4cout << *theName <<" "<<A<<" "<<Z<<" "<<result.GetName()<<G4endl;
00327 }
00328
00329
00330 if ( Z != result.GetZ() || A != result.GetA() )
00331 {
00332 if ( rest == "/CrossSection" )
00333 {
00334 G4String reac = base;
00335 G4String dir = getenv("G4NEUTRONHPDATA");
00336 reac.erase ( 0 , dir.length() );
00337 if ( getenv ( "G4NEUTRONHP_SKIP_MISSING_ISOTOPES" ) && !( Z == result.GetZ() && result.IsThisNaturalAbundance() ) )
00338 {
00339 G4cout << "NeutronHP: " << reac << " file for Z = " << Z << ", A = " << A << " is not found and CrossSection set to 0." << G4endl;
00340 G4String new_name = base+"/"+rest+"/"+"0_0_Zero";
00341 result.SetName( new_name );
00342 }
00343 else
00344 {
00345
00346 if ( ( reac.find("Inelastic") != reac.size() && ( (Z == 1 && A == 1) || (Z == 2 && A == 4) ) )
00347 || ( reac.find("Capture") != reac.size() && ( (Z == 1 && A == 3) || (Z == 2 && A == 4) ) )
00348 || ( reac.find("Fission") != reac.size() && ( (Z == 88 && A == 224) || (Z == 88 && A == 225) || (Z == 89 && A == 225) || (Z == 88 && A == 226) ) ) )
00349
00350 {
00351 G4String new_name = base+"/"+rest+"/"+"0_0_Zero";
00352 result.SetName( new_name );
00353 }
00354 else
00355 {
00356 G4cout << "NeutronHP: " << reac << " file for Z = " << Z << ", A = " << A << " is not found and NeutronHP will use " << result.GetName() << G4endl;
00357 }
00358 }
00359 }
00360 }
00361
00362 delete theName;
00363 if(aFlag)
00364 {
00365 check->close();
00366 delete check;
00367 check = 0;
00368 }
00369 return result;
00370 }