Geant4  10.00.p01
G4IsotopeMagneticMomentTable.cc
Go to the documentation of this file.
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
37 
38 //
40 
41 #include "G4ios.hh"
42 #include "globals.hh"
43 #include "G4PhysicalConstants.hh"
44 #include "G4SystemOfUnits.hh"
45 #include <iomanip>
46 #include <fstream>
47 #include <sstream>
48 
50 // 0.1% torelance for excitation energy
51 
52 const G4double G4IsotopeMagneticMomentTable::nuclearMagneton = eplus*hbar_Planck/2./(proton_mass_c2 /c_squared);
53 // Nuclear Magneton
54 
57  :G4VIsotopeTable("MagneticMoment")
58 {
59  if ( !getenv("G4IONMAGNETICMOMENT")) {
60 #ifdef G4VERBOSE
61  if (GetVerboseLevel()>1) {
62  G4cout << "G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable(): "
63  << "Please setenv G4IONMAGNETICMOMENT for the magnetic moment data."
64  << G4endl;
65  G4Exception( "G4IsotopeMagneticMomentTable",
66  "File Not Found",
67  JustWarning,
68  "Please setenv G4IONMAGNETICMOMENT");
69  }
70 #endif
71  G4Exception( "G4IsotopeMagneticMomentTable",
72  "File Not Found",
73  JustWarning,
74  "Please setenv G4IONMAGNETICMOMENT");
75  return;
76  }
77 
78  G4String file = getenv("G4IONMAGNETICMOMENT");
79  std::ifstream DataFile(file);
80 
81  if (!DataFile ) {
82 #ifdef G4VERBOSE
83  if (GetVerboseLevel()>0) {
84  G4cout << "G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable(): "
85  << file << " is not found " << G4endl;
86  }
87 #endif
88  G4Exception( "G4IsotopeMagneticMomentTable",
89  "File Not Found",
90  JustWarning,
91  "Can not open G4IONMAGNETICMOMENT file");
92  return;
93  }
94 
95  char inputChars[80]={' '};
96 
97  while ( !DataFile.eof() ) {
98  DataFile.getline(inputChars, 80);
99  G4String inputLine = inputChars;
100  G4int ionA, ionZ, ionJ, isomer;
101  G4double ionE, ionMu, ionLife;
102  G4String ionName, ionLifeUnit;
103 
104  if (inputChars[0] != '#' && inputLine.length() != 0) {
105  std::istringstream tmpstream(inputLine);
106  tmpstream >> ionZ >> ionName >> ionA
107  >> isomer >> ionE
108  >> ionLife >> ionLifeUnit
109  >> ionJ >> ionMu;
110 
111  G4IsotopeProperty* fProperty = new G4IsotopeProperty();
112  // Set Isotope Property
113  fProperty->SetAtomicNumber(ionZ);
114  fProperty->SetAtomicMass(ionA);
115  fProperty->SetIsomerLevel(isomer);
116  fProperty->SetEnergy(ionE * MeV);
117  fProperty->SetiSpin(ionJ);
118  fProperty->SetMagneticMoment(ionMu*nuclearMagneton);
119 
120  fIsotopeList.push_back(fProperty);
121 
122  //if (GetVerboseLevel()>2) {
123  // fProperty->DumpInfo();
124  //}
125 
126  }
127  }
128 
129  DataFile.close();
130 }
131 
134 {
135  for (size_t i = 0 ; i< fIsotopeList.size(); i++) {
136  delete fIsotopeList[i];
137  }
138  fIsotopeList.clear();
139 }
140 
143  :G4VIsotopeTable(right),
144  fIsotopeList(0)
145 {
146 }
147 
150 {
151  return *this;
152 }
153 
156 {
157  for (size_t i = 0 ; i< fIsotopeList.size(); ++i) {
159 
160  // check Z
161  if ( fP->GetAtomicNumber() > pP->GetAtomicNumber()) {
162  // Not Found
163  break;
164  }
165  if ( fP->GetAtomicNumber() < pP->GetAtomicNumber()) {
166  // next
167  continue;
168  }
169 
170  // check A
171  if ( fP->GetAtomicMass() != pP->GetAtomicMass()) {
172  // next
173  continue;
174  }
175 
176  //check isomerLevel
177  if (fP->GetIsomerLevel() != pP->GetIsomerLevel()) {
178  // next
179  continue;
180  }
181 
182  //check E
183  if (std::fabs(fP->GetEnergy() - pP->GetEnergy()) < levelTolerance) {
184  // Found
185  return true;
186  }
187 
188  }
189  return false;
190 }
192 //
195 {
196  G4IsotopeProperty* fProperty = 0;
197  for (size_t i = 0 ; i< fIsotopeList.size(); ++i) {
199 
200  // check Z
201  if ( fP->GetAtomicNumber() > Z) {
202  // Not Found
203  break;
204  }
205  if ( fP->GetAtomicNumber() < Z) {
206  // next
207  continue;
208  }
209 
210  // check A
211  if ( fP->GetAtomicMass() != A ) {
212  // next
213  continue;
214  }
215 
216  //check E
217  if (std::fabs(fP->GetEnergy() - E) < levelTolerance) {
218  // Found
219  fProperty = fP;
220  // fP->DumpInfo();
221  break;
222  }
223 
224  }
225 
226  return fProperty;
227 
228 }
229 
233 {
234  G4IsotopeProperty* fProperty = 0;
235  for (size_t i = 0 ; i< fIsotopeList.size(); ++i) {
237 
238  // check Z
239  if ( fP->GetAtomicNumber() > Z) {
240  // Not Found
241  break;
242  }
243  if ( fP->GetAtomicNumber() < Z) {
244  // next
245  continue;
246  }
247  // check A
248  if ( fP->GetAtomicMass() != A ) {
249  // next
250  continue;
251  }
252 
253 
254  //check isomerLevel
255  if (fP->GetIsomerLevel() == lvl) {
256  // Found
257  fProperty = fP;
258  //fP->DumpInfo();
259  break;
260  }
261 
262  }
263 
264  return fProperty;
265 
266 }
static const double MeV
Definition: G4SIunits.hh:193
void SetAtomicMass(G4int A)
virtual G4IsotopeProperty * GetIsotopeByIsoLvl(G4int Z, G4int A, G4int lvl=0)
G4int GetAtomicNumber() const
G4IsotopeMagneticMomentTable & operator=(const G4IsotopeMagneticMomentTable &right)
G4int GetIsomerLevel() const
int G4int
Definition: G4Types.hh:78
void SetiSpin(G4int J)
void SetMagneticMoment(G4double M)
virtual G4IsotopeProperty * GetIsotope(G4int Z, G4int A, G4double E)
G4GLOB_DLL std::ostream G4cout
G4double GetEnergy() const
bool G4bool
Definition: G4Types.hh:79
static const G4double A[nN]
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void SetEnergy(G4double E)
virtual G4bool FindIsotope(G4IsotopeProperty *property)
#define G4endl
Definition: G4ios.hh:61
static const double keV
Definition: G4SIunits.hh:195
double G4double
Definition: G4Types.hh:76
static const double eplus
Definition: G4SIunits.hh:178
void SetAtomicNumber(G4int Z)
G4int GetAtomicMass() const
void SetIsomerLevel(G4int level)