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