G4IsotopeMagneticMomentTable.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 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00027 //
00028 // MODULE:              G4IsotopeMagneticMomentTable.cc
00029 //
00030 // Date:                16/03/07
00031 // Author:              H.Kurashige
00032 //
00033 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00034 //
00035 // HISTORY
00037 //
00038 #include "G4IsotopeMagneticMomentTable.hh"
00039 
00040 #include "G4ios.hh"
00041 #include "globals.hh"
00042 #include "G4PhysicalConstants.hh"
00043 #include "G4SystemOfUnits.hh"
00044 #include <iomanip>
00045 #include <fstream>
00046 #include <sstream>
00047 
00048 const G4double G4IsotopeMagneticMomentTable::levelTolerance = 0.001;
00049 // 0.1% torelance for excitation energy
00050   
00051 const G4double G4IsotopeMagneticMomentTable::nuclearMagneton = eplus*hbar_Planck/2./(proton_mass_c2 /c_squared);
00052 // Nuclear Magneton
00053  
00055 G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable()
00056   :G4VIsotopeTable("MagneticMoment")
00057 {
00058   if ( !getenv("G4IONMAGNETICMOMENT")) {
00059 #ifdef G4VERBOSE
00060     if (GetVerboseLevel()>1) {
00061       G4cout << "G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable():  " 
00062              <<  "Please setenv G4IONMAGNETICMOMENT for the magnetic moment data." 
00063              << G4endl;
00064       G4Exception( "G4IsotopeMagneticMomentTable",
00065                    "File Not Found",
00066                    JustWarning, 
00067                    "Please setenv G4IONMAGNETICMOMENT");
00068     }
00069 #endif
00070     G4Exception( "G4IsotopeMagneticMomentTable",
00071                  "File Not Found",
00072                  JustWarning, 
00073                  "Please setenv G4IONMAGNETICMOMENT");
00074     return;
00075   }
00076   
00077   G4String file = getenv("G4IONMAGNETICMOMENT");
00078   std::ifstream DataFile(file);
00079 
00080   if (!DataFile ) {
00081 #ifdef G4VERBOSE
00082     if (GetVerboseLevel()>0) {
00083       G4cout << "G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable():  " 
00084             << file << " is not found " << G4endl;
00085     }
00086 #endif
00087     G4Exception( "G4IsotopeMagneticMomentTable",
00088                  "File Not Found",
00089                  JustWarning, 
00090                  "Can not open G4IONMAGNETICMOMENT file");
00091     return;
00092   }
00093   
00094   char inputChars[80]={' '};
00095    
00096   while ( !DataFile.eof() ) {
00097     DataFile.getline(inputChars, 80);
00098     G4String inputLine = inputChars;
00099     G4int ionA, ionZ, ionJ;
00100     G4double ionE, ionMu, ionLife;
00101     G4String ionName, ionLifeUnit;
00102  
00103     if (inputChars[0] != '#' && inputLine.length() != 0) {
00104       std::istringstream tmpstream(inputLine);
00105       tmpstream >> ionZ >>  ionName >> ionA >>  ionE 
00106                 >> ionLife >> ionLifeUnit
00107                 >> ionJ >> ionMu;
00108           
00109       G4IsotopeProperty* fProperty = new G4IsotopeProperty();   
00110       // Set Isotope Property
00111       fProperty->SetAtomicNumber(ionZ);
00112       fProperty->SetAtomicMass(ionA);
00113       fProperty->SetEnergy(ionE * MeV);
00114       fProperty->SetiSpin(ionJ);
00115       fProperty->SetMagneticMoment(ionMu*nuclearMagneton);
00116       
00117       fIsotopeList.push_back(fProperty);
00118 
00119       //if (GetVerboseLevel()>2) {
00120       // fProperty->DumpInfo();
00121       //}
00122         
00123     }
00124   }
00125 
00126   DataFile.close();
00127 }
00128 
00130 G4IsotopeMagneticMomentTable::~G4IsotopeMagneticMomentTable()
00131 {
00132   for (size_t i = 0 ; i< fIsotopeList.size(); i++) {
00133     delete fIsotopeList[i];
00134   }
00135   fIsotopeList.clear();
00136 }
00137 
00139 G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable(const  G4IsotopeMagneticMomentTable & right)   
00140   :G4VIsotopeTable(right),
00141    fIsotopeList(0)
00142 {
00143 }
00144 
00146 G4IsotopeMagneticMomentTable & G4IsotopeMagneticMomentTable::operator= (const  G4IsotopeMagneticMomentTable &)
00147 {
00148   return *this;
00149 }
00150 
00152 G4bool G4IsotopeMagneticMomentTable::FindIsotope(G4IsotopeProperty* pP)
00153 {
00154   for (size_t i = 0 ; i< fIsotopeList.size(); ++i) {
00155     G4IsotopeProperty*  fP = fIsotopeList[i];
00156     
00157     // check Z
00158     if ( fP->GetAtomicNumber() > pP->GetAtomicNumber()) {
00159       // Not Found
00160       break;
00161     }
00162     if ( fP->GetAtomicNumber() < pP->GetAtomicNumber()) {
00163       // next
00164       continue;
00165     }
00166     
00167     // check A
00168     if ( fP->GetAtomicMass() != pP->GetAtomicMass()) {
00169       // next
00170       continue;
00171     }
00172     
00173     //check E
00174     if (std::fabs(fP->GetEnergy() - pP->GetEnergy()) <= fP->GetEnergy()*levelTolerance) {
00175       // Found
00176       return true;     
00177     }
00178     
00179   }
00180   return false;
00181 }
00183 //
00184 G4IsotopeProperty* G4IsotopeMagneticMomentTable::GetIsotope(G4int Z, G4int A, G4double E)
00185 {
00186   G4IsotopeProperty* fProperty = 0;
00187   for (size_t i = 0 ; i< fIsotopeList.size(); ++i) {
00188     G4IsotopeProperty*  fP = fIsotopeList[i];
00189  
00190      // check Z
00191     if ( fP->GetAtomicNumber() > Z) {
00192       // Not Found
00193       break;
00194     }
00195     if ( fP->GetAtomicNumber() < Z) {
00196       // next
00197       continue;
00198     }
00199     
00200     // check A
00201     if ( fP->GetAtomicMass() != A ) {
00202       // next
00203       continue;
00204     }
00205     
00206     //check E
00207     if (std::fabs(fP->GetEnergy() - E) <= fP->GetEnergy()*levelTolerance) {
00208       // Found
00209       fProperty = fP;
00210       fP->DumpInfo();
00211       break;     
00212     }
00213     
00214   }
00215 
00216   return fProperty;
00217   
00218 }

Generated on Mon May 27 17:48:41 2013 for Geant4 by  doxygen 1.4.7