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
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
00050
00051 const G4double G4IsotopeMagneticMomentTable::nuclearMagneton = eplus*hbar_Planck/2./(proton_mass_c2 /c_squared);
00052
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
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
00120
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
00158 if ( fP->GetAtomicNumber() > pP->GetAtomicNumber()) {
00159
00160 break;
00161 }
00162 if ( fP->GetAtomicNumber() < pP->GetAtomicNumber()) {
00163
00164 continue;
00165 }
00166
00167
00168 if ( fP->GetAtomicMass() != pP->GetAtomicMass()) {
00169
00170 continue;
00171 }
00172
00173
00174 if (std::fabs(fP->GetEnergy() - pP->GetEnergy()) <= fP->GetEnergy()*levelTolerance) {
00175
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
00191 if ( fP->GetAtomicNumber() > Z) {
00192
00193 break;
00194 }
00195 if ( fP->GetAtomicNumber() < Z) {
00196
00197 continue;
00198 }
00199
00200
00201 if ( fP->GetAtomicMass() != A ) {
00202
00203 continue;
00204 }
00205
00206
00207 if (std::fabs(fP->GetEnergy() - E) <= fP->GetEnergy()*levelTolerance) {
00208
00209 fProperty = fP;
00210 fP->DumpInfo();
00211 break;
00212 }
00213
00214 }
00215
00216 return fProperty;
00217
00218 }