Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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
36////////////////////////////////////////////////////////////////////////////////// IsomerLevel is added 30 Apr. 2013 H.Kurashige
37
38//
40
41#include "G4ios.hh"
42#include "globals.hh"
44#include "G4SystemOfUnits.hh"
45#include <iomanip>
46#include <fstream>
47#include <sstream>
48
49const G4double G4IsotopeMagneticMomentTable::levelTolerance = 2.0*keV;
50// 0.1% torelance for excitation energy
51
52const G4double G4IsotopeMagneticMomentTable::nuclearMagneton = eplus*hbar_Planck/2./(proton_mass_c2 /c_squared);
53// Nuclear Magneton
54
55///////////////////////////////////////////////////////////////////////////////
57 :G4VIsotopeTable("MagneticMoment")
58{
59 if ( !std::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",
68 "Please setenv G4IONMAGNETICMOMENT");
69 }
70#endif
71 G4Exception( "G4IsotopeMagneticMomentTable",
72 "File Not Found",
74 "Please setenv G4IONMAGNETICMOMENT");
75 return;
76 }
77
78 G4String file = std::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",
91 "Can not open G4IONMAGNETICMOMENT file");
92 return;
93 }
94
95 char inputChars[80]={' '};
96
97 while ( !DataFile.eof() ) { // Loop checking, 09.08.2015, K.Kurashige
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
132///////////////////////////////////////////////////////////////////////////////
134{
135 for (size_t i = 0 ; i< fIsotopeList.size(); i++) {
136 delete fIsotopeList[i];
137 }
138 fIsotopeList.clear();
139}
140
141///////////////////////////////////////////////////////////////////////////////
143 :G4VIsotopeTable(right),
144 fIsotopeList(0)
145{
146}
147
148///////////////////////////////////////////////////////////////////////////////
150{
151 return *this;
152}
153
154///////////////////////////////////////////////////////////////////////////////
156{
157 for (size_t i = 0 ; i< fIsotopeList.size(); ++i) {
158 G4IsotopeProperty* fP = fIsotopeList[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}
191///////////////////////////////////////////////////////////////////////////////
192//
196{
197 G4IsotopeProperty* fProperty = 0;
198 for (size_t i = 0 ; i< fIsotopeList.size(); ++i) {
199 G4IsotopeProperty* fP = fIsotopeList[i];
200
201 // check Z
202 if ( fP->GetAtomicNumber() > Z) {
203 // Not Found
204 break;
205 }
206 if ( fP->GetAtomicNumber() < Z) {
207 // next
208 continue;
209 }
210
211 // check A
212 if ( fP->GetAtomicMass() != A ) {
213 // next
214 continue;
215 }
216
217 //check E
218 if (std::fabs(fP->GetEnergy() - E) < levelTolerance) {
219 // Found
220 fProperty = fP;
221 // fP->DumpInfo();
222 break;
223 }
224
225 }
226
227 return fProperty;
228
229}
230
231///////////////////////////////////////////////////////////////////////
234{
235 G4IsotopeProperty* fProperty = 0;
236 for (size_t i = 0 ; i< fIsotopeList.size(); ++i) {
237 G4IsotopeProperty* fP = fIsotopeList[i];
238
239 // check Z
240 if ( fP->GetAtomicNumber() > Z) {
241 // Not Found
242 break;
243 }
244 if ( fP->GetAtomicNumber() < Z) {
245 // next
246 continue;
247 }
248 // check A
249 if ( fP->GetAtomicMass() != A ) {
250 // next
251 continue;
252 }
253
254
255 //check isomerLevel
256 if (fP->GetIsomerLevel() == lvl) {
257 // Found
258 fProperty = fP;
259 //fP->DumpInfo();
260 break;
261 }
262
263 }
264
265 return fProperty;
266
267}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
const G4int Z[17]
const G4double A[17]
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4FloatLevelBase
Definition: G4Ions.hh:83
virtual G4IsotopeProperty * GetIsotopeByIsoLvl(G4int Z, G4int A, G4int lvl=0)
virtual G4bool FindIsotope(G4IsotopeProperty *property)
G4IsotopeMagneticMomentTable & operator=(const G4IsotopeMagneticMomentTable &right)
virtual G4IsotopeProperty * GetIsotope(G4int Z, G4int A, G4double E, G4Ions::G4FloatLevelBase flb=G4Ions::G4FloatLevelBase::no_Float)
void SetAtomicMass(G4int A)
void SetEnergy(G4double E)
void SetiSpin(G4int J)
void SetAtomicNumber(G4int Z)
void SetIsomerLevel(G4int level)
G4double GetEnergy() const
G4int GetAtomicMass() const
G4int GetAtomicNumber() const
G4int GetIsomerLevel() const
void SetMagneticMoment(G4double M)