Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 // 28 // MODULE: G4IsotopeMagneticMomentTable.cc 29 // 30 // Date: 16/03/07 31 // Author: H.Kurashige 32 // 33 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 34 // 35 // HISTORY 36 ////////////////////////////////////////////////////////////////////////////////// IsomerLevel is 37 /// added 30 Apr. 2013 H.Kurashige 38 39 #include "G4IsotopeMagneticMomentTable.hh" 40 41 #include "G4PhysicalConstants.hh" 42 #include "G4SystemOfUnits.hh" 43 #include "G4ios.hh" 44 #include "globals.hh" 45 46 #include <fstream> 47 48 // 0.1% torelance for excitation energy 49 const G4double G4IsotopeMagneticMomentTable::levelTolerance = 2.0 * keV; 50 51 // Nuclear Magneton 52 const G4double G4IsotopeMagneticMomentTable::nuclearMagneton = 53 eplus * hbar_Planck / 2. / (proton_mass_c2 / c_squared); 54 55 G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable() : G4VIsotopeTable("MagneticMoment") 56 { 57 if (std::getenv("G4IONMAGNETICMOMENT") == nullptr) { 58 #ifdef G4VERBOSE 59 if (GetVerboseLevel() > 1) { 60 G4cout << "G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable(): " 61 << "Please setenv G4IONMAGNETICMOMENT for the magnetic moment data." << G4endl; 62 G4Exception("G4IsotopeMagneticMomentTable", "File Not Found", JustWarning, 63 "Please setenv G4IONMAGNETICMOMENT"); 64 } 65 #endif 66 G4Exception("G4IsotopeMagneticMomentTable", "File Not Found", JustWarning, 67 "Please setenv G4IONMAGNETICMOMENT"); 68 return; 69 } 70 71 G4String file = std::getenv("G4IONMAGNETICMOMENT"); 72 std::ifstream DataFile(file); 73 74 if (!DataFile) { 75 #ifdef G4VERBOSE 76 if (GetVerboseLevel() > 0) { 77 G4cout << "G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable(): " << file 78 << " is not found " << G4endl; 79 } 80 #endif 81 G4Exception("G4IsotopeMagneticMomentTable", "File Not Found", JustWarning, 82 "Can not open G4IONMAGNETICMOMENT file"); 83 return; 84 } 85 86 char inputChars[80] = {' '}; 87 88 while (!DataFile.eof()) { // Loop checking, 09.08.2015, K.Kurashige 89 DataFile.getline(inputChars, 80); 90 G4String inputLine = inputChars; 91 G4int ionA, ionZ, ionJ, isomer; 92 G4double ionE, ionMu, ionLife; 93 G4String ionName, ionLifeUnit; 94 95 if (inputChars[0] != '#' && inputLine.length() != 0) { 96 std::istringstream tmpstream(inputLine); 97 tmpstream >> ionZ >> ionName >> ionA >> isomer >> ionE >> ionLife >> ionLifeUnit >> ionJ 98 >> ionMu; 99 100 auto fProperty = new G4IsotopeProperty(); 101 // Set Isotope Property 102 fProperty->SetAtomicNumber(ionZ); 103 fProperty->SetAtomicMass(ionA); 104 fProperty->SetIsomerLevel(isomer); 105 fProperty->SetEnergy(ionE * MeV); 106 fProperty->SetiSpin(ionJ); 107 fProperty->SetMagneticMoment(ionMu * nuclearMagneton); 108 109 fIsotopeList.push_back(fProperty); 110 111 // if (GetVerboseLevel()>2) { 112 // fProperty->DumpInfo(); 113 // } 114 } 115 } 116 117 DataFile.close(); 118 } 119 120 G4IsotopeMagneticMomentTable::~G4IsotopeMagneticMomentTable() 121 { 122 for (const auto& i : fIsotopeList) { 123 delete i; 124 } 125 fIsotopeList.clear(); 126 } 127 128 G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable( 129 const G4IsotopeMagneticMomentTable& right) 130 : G4VIsotopeTable(right), fIsotopeList(0) 131 {} 132 133 G4IsotopeMagneticMomentTable& 134 G4IsotopeMagneticMomentTable::operator=(const G4IsotopeMagneticMomentTable&) 135 { 136 return *this; 137 } 138 139 G4bool G4IsotopeMagneticMomentTable::FindIsotope(G4IsotopeProperty* pP) 140 { 141 for (const auto fP : fIsotopeList) { 142 // check Z 143 if (fP->GetAtomicNumber() > pP->GetAtomicNumber()) { 144 // Not Found 145 break; 146 } 147 if (fP->GetAtomicNumber() < pP->GetAtomicNumber()) { 148 // next 149 continue; 150 } 151 152 // check A 153 if (fP->GetAtomicMass() != pP->GetAtomicMass()) { 154 // next 155 continue; 156 } 157 158 // check isomerLevel 159 if (fP->GetIsomerLevel() != pP->GetIsomerLevel()) { 160 // next 161 continue; 162 } 163 164 // check E 165 if (std::fabs(fP->GetEnergy() - pP->GetEnergy()) < levelTolerance) { 166 // Found 167 return true; 168 } 169 } 170 return false; 171 } 172 173 G4IsotopeProperty* G4IsotopeMagneticMomentTable::GetIsotope(G4int Z, G4int A, G4double E, 174 G4Ions::G4FloatLevelBase /*flb*/) 175 { 176 G4IsotopeProperty* fProperty = nullptr; 177 for (const auto fP : fIsotopeList) { 178 // check Z 179 if (fP->GetAtomicNumber() > Z) { 180 // Not Found 181 break; 182 } 183 if (fP->GetAtomicNumber() < Z) { 184 // next 185 continue; 186 } 187 188 // check A 189 if (fP->GetAtomicMass() != A) { 190 // next 191 continue; 192 } 193 194 // check E 195 if (std::fabs(fP->GetEnergy() - E) < levelTolerance) { 196 // Found 197 fProperty = fP; 198 // fP->DumpInfo(); 199 break; 200 } 201 } 202 203 return fProperty; 204 } 205 206 G4IsotopeProperty* G4IsotopeMagneticMomentTable::GetIsotopeByIsoLvl(G4int Z, G4int A, G4int lvl) 207 { 208 G4IsotopeProperty* fProperty = nullptr; 209 for (const auto fP : fIsotopeList) { 210 // check Z 211 if (fP->GetAtomicNumber() > Z) { 212 // Not Found 213 break; 214 } 215 if (fP->GetAtomicNumber() < Z) { 216 // next 217 continue; 218 } 219 // check A 220 if (fP->GetAtomicMass() != A) { 221 // next 222 continue; 223 } 224 225 // check isomerLevel 226 if (fP->GetIsomerLevel() == lvl) { 227 // Found 228 fProperty = fP; 229 // fP->DumpInfo(); 230 break; 231 } 232 } 233 234 return fProperty; 235 } 236