[824] | 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 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 37 | // |
---|
| 38 | #include "G4IsotopeMagneticMomentTable.hh" |
---|
| 39 | |
---|
| 40 | #include "G4ios.hh" |
---|
| 41 | #include "globals.hh" |
---|
| 42 | #include <iomanip> |
---|
| 43 | #include <fstream> |
---|
| 44 | #include <sstream> |
---|
| 45 | |
---|
| 46 | const G4double G4IsotopeMagneticMomentTable::levelTolerance = 0.001; |
---|
| 47 | // 0.1% torelance for excitation energy |
---|
| 48 | |
---|
| 49 | const G4double G4IsotopeMagneticMomentTable::nuclearMagneton = eplus*hbar_Planck/2./(proton_mass_c2 /c_squared); |
---|
| 50 | // Nuclear Magneton |
---|
| 51 | |
---|
| 52 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 53 | G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable() |
---|
| 54 | { |
---|
| 55 | if ( !getenv("G4IONMAGNETICMOMENT")) { |
---|
| 56 | #ifdef G4VERBOSE |
---|
| 57 | if (GetVerboseLevel()>1) { |
---|
| 58 | G4cout << "G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable(): " |
---|
| 59 | << "Please setenv G4IONMAGNETICMOMENT for the magnetic moment data." |
---|
| 60 | << G4endl; |
---|
| 61 | G4Exception( "G4IsotopeMagneticMomentTable", |
---|
| 62 | "File Not Found", |
---|
| 63 | JustWarning, |
---|
| 64 | "Please setenv G4IONMAGNETICMOMENT"); |
---|
| 65 | } |
---|
| 66 | #endif |
---|
| 67 | G4Exception( "G4IsotopeMagneticMomentTable", |
---|
| 68 | "File Not Found", |
---|
| 69 | JustWarning, |
---|
| 70 | "Please setenv G4IONMAGNETICMOMENT"); |
---|
| 71 | return; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | G4String file = getenv("G4IONMAGNETICMOMENT"); |
---|
| 75 | std::ifstream DataFile(file); |
---|
| 76 | |
---|
| 77 | if (!DataFile ) { |
---|
| 78 | #ifdef G4VERBOSE |
---|
| 79 | if (GetVerboseLevel()>0) { |
---|
| 80 | G4cout << "G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable(): " |
---|
| 81 | << file << " is not found " << G4endl; |
---|
| 82 | } |
---|
| 83 | #endif |
---|
| 84 | G4Exception( "G4IsotopeMagneticMomentTable", |
---|
| 85 | "File Not Found", |
---|
| 86 | JustWarning, |
---|
| 87 | "Can not open G4IONMAGNETICMOMENT file"); |
---|
| 88 | return; |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | char inputChars[80]={' '}; |
---|
| 92 | |
---|
| 93 | while ( !DataFile.eof() ) { |
---|
| 94 | DataFile.getline(inputChars, 80); |
---|
| 95 | G4String inputLine = inputChars; |
---|
| 96 | G4int ionA, ionZ, ionJ; |
---|
| 97 | G4double ionE, ionMu, ionLife; |
---|
| 98 | G4String ionName, ionLifeUnit; |
---|
| 99 | |
---|
| 100 | if (inputChars[0] != '#' && inputLine.length() != 0) { |
---|
| 101 | std::istringstream tmpstream(inputLine); |
---|
| 102 | tmpstream >> ionZ >> ionName >> ionA >> ionE |
---|
| 103 | >> ionLife >> ionLifeUnit |
---|
| 104 | >> ionJ >> ionMu; |
---|
| 105 | |
---|
| 106 | G4IsotopeProperty* fProperty = new G4IsotopeProperty(); |
---|
| 107 | // Set Isotope Property |
---|
| 108 | fProperty->SetAtomicNumber(ionZ); |
---|
| 109 | fProperty->SetAtomicMass(ionA); |
---|
| 110 | fProperty->SetEnergy(ionE * MeV); |
---|
| 111 | fProperty->SetiSpin(ionJ); |
---|
| 112 | fProperty->SetMagneticMoment(ionMu*nuclearMagneton); |
---|
| 113 | |
---|
| 114 | fIsotopeList.push_back(fProperty); |
---|
| 115 | |
---|
| 116 | //if (GetVerboseLevel()>2) { |
---|
| 117 | // fProperty->DumpInfo(); |
---|
| 118 | //} |
---|
| 119 | |
---|
| 120 | } |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | DataFile.close(); |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 127 | G4IsotopeMagneticMomentTable::~G4IsotopeMagneticMomentTable() |
---|
| 128 | { |
---|
| 129 | for (size_t i = 0 ; i< fIsotopeList.size(); i++) { |
---|
| 130 | delete fIsotopeList[i]; |
---|
| 131 | } |
---|
| 132 | fIsotopeList.clear(); |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 137 | G4bool G4IsotopeMagneticMomentTable::FindIsotope(G4IsotopeProperty* pP) |
---|
| 138 | { |
---|
| 139 | for (size_t i = 0 ; i< fIsotopeList.size(); ++i) { |
---|
| 140 | G4IsotopeProperty* fP = fIsotopeList[i]; |
---|
| 141 | |
---|
| 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 E |
---|
| 159 | if (std::fabs(fP->GetEnergy() - pP->GetEnergy()) <= fP->GetEnergy()*levelTolerance) { |
---|
| 160 | // Found |
---|
| 161 | return true; |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | } |
---|
| 165 | return false; |
---|
| 166 | } |
---|
| 167 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 168 | // |
---|
| 169 | G4IsotopeProperty* G4IsotopeMagneticMomentTable::GetIsotope(G4int Z, G4int A, G4double E) |
---|
| 170 | { |
---|
| 171 | G4IsotopeProperty* fProperty = 0; |
---|
| 172 | for (size_t i = 0 ; i< fIsotopeList.size(); ++i) { |
---|
| 173 | G4IsotopeProperty* fP = fIsotopeList[i]; |
---|
| 174 | |
---|
| 175 | // check Z |
---|
| 176 | if ( fP->GetAtomicNumber() > Z) { |
---|
| 177 | // Not Found |
---|
| 178 | break; |
---|
| 179 | } |
---|
| 180 | if ( fP->GetAtomicNumber() < Z) { |
---|
| 181 | // next |
---|
| 182 | continue; |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | // check A |
---|
| 186 | if ( fP->GetAtomicMass() != A ) { |
---|
| 187 | // next |
---|
| 188 | continue; |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | //check E |
---|
| 192 | if (std::fabs(fP->GetEnergy() - E) <= fP->GetEnergy()*levelTolerance) { |
---|
| 193 | // Found |
---|
| 194 | fProperty = fP; |
---|
| 195 | fP->DumpInfo(); |
---|
| 196 | break; |
---|
| 197 | } |
---|
| 198 | |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | return fProperty; |
---|
| 202 | |
---|
| 203 | } |
---|