G4NeutronHPNames.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // neutron_hp -- source file
00027 // J.P. Wellisch, Nov-1996
00028 // A prototype of the low energy neutron transport model.
00029 //
00030 // 24-Jan-07 Enable to use exact data only and add warnig when substitute file is used T. Koi
00031 // 30-Jan-07 Modified method of searching substitute isotope data by T. Koi
00032 // 07-06-12 fix memory leaking by T. Koi
00033 // 07-06-25 Change data selection logic when G4NEUTRONHP_SKIP_MISSING_ISOTOPES is turn on
00034 //          Natural Abundance data are allowed. by T. Koi
00035 // 07-07-06 Allow _nat_ final state even for isotoped cross sections by T. Koi
00036 // 08-09-01 Add protection that deuteron data do not selected for hydrogen and so on by T. Koi
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 //G4NeutronHPDataUsed G4NeutronHPNames::GetName(G4int A, G4int Z, G4String base, G4String rest, G4bool & aFlag)
00065 G4NeutronHPDataUsed G4NeutronHPNames::GetName(G4int A, G4int Z, G4int M, G4String base, G4String rest, G4bool & aFlag)
00066 {
00067 
00068    //G4cout << Z << " " << A << " " << M << " " << base << " " << rest << G4endl;
00069 
00070    //Excited isomer indicator
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       //G4cerr << "Please contact Hans-Peter.Wellisch@cern.ch"<<G4endl;
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 //    G4int inc = 1;
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(); // delete here as theName
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      // T.K. debug for memory leak
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(); // delete here as theName
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(); // delete here as theName
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 // 070706 T. Koi Modified 
00178 /*
00179           biff = new G4String(); // delete here as theName
00180           *biff = base+"/"+rest+itoa(myZ)+"_"+itoa(myA)+"_"+theString[myZ-1];  
00181           if(theName!=0) delete theName;
00182           theName = biff;
00183 if(getenv("NeutronHPNames"))    G4cout <<"HPWD 4 "<<*theName<<G4endl;
00184           result.SetName(*theName);
00185           result.SetA(myA);
00186           result.SetZ(myZ);
00187 */
00188 
00189           G4double tmpA = myA;
00190           std::ifstream* file = NULL;
00191           G4String fileName;
00192 
00193           if ( rest == "/CrossSection" )
00194           {
00195 
00196              //fileName = base+"/"+rest+"/"+itoa(myZ)+"_"+itoa(myA)+sM+"_"+theString[myZ-1];
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 // For FS
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 // isotope FS
00212 if(getenv("NeutronHPNames"))    G4cout <<"HPWD 4b1 "<<*theName<<G4endl;
00213              }
00214              else
00215              {
00216 
00217 // _nat_ FS
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 // FS neither isotope nor _nat_
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 //        if (std::abs(myZ-Z)>theMaxOffSet||myZ==0||myA==0)
00251           if ( delta_Z > theMaxOffSet )
00252           { 
00253              //if ( inc > 0 )
00254              //{
00255              //   inc*= -1;
00256              //   myZ = Z;
00257              //   myA = A;
00258              //}
00259              //else
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                 //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");
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           //if ( std::abs( myA - A ) > theMaxOffSet )
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 //             myZ += inc;
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 //             myA += inc;
00315           }
00316 
00317        }
00318        while( myZ == 0 || myA == 0 );  // No meaning 
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 // administration and anouncement for lacking of exact data in NDL 
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              //080901 Add protection that deuteron data do not selected for hydrogen and so on by T. Koi
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   }

Generated on Mon May 27 17:49:03 2013 for Geant4 by  doxygen 1.4.7