Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4IsotopeMagneticMomentTable Class Reference

#include <G4IsotopeMagneticMomentTable.hh>

+ Inheritance diagram for G4IsotopeMagneticMomentTable:

Public Types

typedef std::vector< G4IsotopeProperty * > G4IsotopeList
 
typedef std::vector< G4StringG4IsotopeNameList
 

Public Member Functions

 G4IsotopeMagneticMomentTable ()
 
virtual ~G4IsotopeMagneticMomentTable ()
 
virtual G4bool FindIsotope (G4IsotopeProperty *property)
 
virtual G4IsotopePropertyGetIsotope (G4int Z, G4int A, G4double E)
 
- Public Member Functions inherited from G4VIsotopeTable
 G4VIsotopeTable ()
 
 G4VIsotopeTable (const G4String &)
 
 G4VIsotopeTable (const G4VIsotopeTable &)
 
G4VIsotopeTableoperator= (const G4VIsotopeTable &)
 
virtual ~G4VIsotopeTable ()
 
virtual G4bool FindIsotope (G4IsotopeProperty *property)=0
 
virtual G4IsotopePropertyGetIsotope (G4int Z, G4int A, G4double E)=0
 
G4int GetVerboseLevel () const
 
void SetVerboseLevel (G4int level)
 

Protected Member Functions

 G4IsotopeMagneticMomentTable (const G4IsotopeMagneticMomentTable &right)
 
G4IsotopeMagneticMomentTableoperator= (const G4IsotopeMagneticMomentTable &right)
 

Detailed Description

Definition at line 52 of file G4IsotopeMagneticMomentTable.hh.

Member Typedef Documentation

◆ G4IsotopeList

◆ G4IsotopeNameList

Constructor & Destructor Documentation

◆ G4IsotopeMagneticMomentTable() [1/2]

G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable ( )

Definition at line 55 of file G4IsotopeMagneticMomentTable.cc.

56 :G4VIsotopeTable("MagneticMoment")
57{
58 if ( !getenv("G4IONMAGNETICMOMENT")) {
59#ifdef G4VERBOSE
60 if (GetVerboseLevel()>1) {
61 G4cout << "G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable(): "
62 << "Please setenv G4IONMAGNETICMOMENT for the magnetic moment data."
63 << G4endl;
64 G4Exception( "G4IsotopeMagneticMomentTable",
65 "File Not Found",
67 "Please setenv G4IONMAGNETICMOMENT");
68 }
69#endif
70 G4Exception( "G4IsotopeMagneticMomentTable",
71 "File Not Found",
73 "Please setenv G4IONMAGNETICMOMENT");
74 return;
75 }
76
77 G4String file = getenv("G4IONMAGNETICMOMENT");
78 std::ifstream DataFile(file);
79
80 if (!DataFile ) {
81#ifdef G4VERBOSE
82 if (GetVerboseLevel()>0) {
83 G4cout << "G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable(): "
84 << file << " is not found " << G4endl;
85 }
86#endif
87 G4Exception( "G4IsotopeMagneticMomentTable",
88 "File Not Found",
90 "Can not open G4IONMAGNETICMOMENT file");
91 return;
92 }
93
94 char inputChars[80]={' '};
95
96 while ( !DataFile.eof() ) {
97 DataFile.getline(inputChars, 80);
98 G4String inputLine = inputChars;
99 G4int ionA, ionZ, ionJ;
100 G4double ionE, ionMu, ionLife;
101 G4String ionName, ionLifeUnit;
102
103 if (inputChars[0] != '#' && inputLine.length() != 0) {
104 std::istringstream tmpstream(inputLine);
105 tmpstream >> ionZ >> ionName >> ionA >> ionE
106 >> ionLife >> ionLifeUnit
107 >> ionJ >> ionMu;
108
109 G4IsotopeProperty* fProperty = new G4IsotopeProperty();
110 // Set Isotope Property
111 fProperty->SetAtomicNumber(ionZ);
112 fProperty->SetAtomicMass(ionA);
113 fProperty->SetEnergy(ionE * MeV);
114 fProperty->SetiSpin(ionJ);
115 fProperty->SetMagneticMoment(ionMu*nuclearMagneton);
116
117 fIsotopeList.push_back(fProperty);
118
119 //if (GetVerboseLevel()>2) {
120 // fProperty->DumpInfo();
121 //}
122
123 }
124 }
125
126 DataFile.close();
127}
@ JustWarning
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
void SetAtomicMass(G4int A)
void SetEnergy(G4double E)
void SetiSpin(G4int J)
void SetAtomicNumber(G4int Z)
void SetMagneticMoment(G4double M)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

◆ G4IsotopeMagneticMomentTable() [2/2]

G4IsotopeMagneticMomentTable::G4IsotopeMagneticMomentTable ( const G4IsotopeMagneticMomentTable right)
protected

Definition at line 139 of file G4IsotopeMagneticMomentTable.cc.

140 :G4VIsotopeTable(right),
141 fIsotopeList(0)
142{
143}

◆ ~G4IsotopeMagneticMomentTable()

G4IsotopeMagneticMomentTable::~G4IsotopeMagneticMomentTable ( )
virtual

Definition at line 130 of file G4IsotopeMagneticMomentTable.cc.

131{
132 for (size_t i = 0 ; i< fIsotopeList.size(); i++) {
133 delete fIsotopeList[i];
134 }
135 fIsotopeList.clear();
136}

Member Function Documentation

◆ FindIsotope()

G4bool G4IsotopeMagneticMomentTable::FindIsotope ( G4IsotopeProperty property)
virtual

Implements G4VIsotopeTable.

Definition at line 152 of file G4IsotopeMagneticMomentTable.cc.

153{
154 for (size_t i = 0 ; i< fIsotopeList.size(); ++i) {
155 G4IsotopeProperty* fP = fIsotopeList[i];
156
157 // check Z
158 if ( fP->GetAtomicNumber() > pP->GetAtomicNumber()) {
159 // Not Found
160 break;
161 }
162 if ( fP->GetAtomicNumber() < pP->GetAtomicNumber()) {
163 // next
164 continue;
165 }
166
167 // check A
168 if ( fP->GetAtomicMass() != pP->GetAtomicMass()) {
169 // next
170 continue;
171 }
172
173 //check E
174 if (std::fabs(fP->GetEnergy() - pP->GetEnergy()) <= fP->GetEnergy()*levelTolerance) {
175 // Found
176 return true;
177 }
178
179 }
180 return false;
181}
G4double GetEnergy() const
G4int GetAtomicMass() const
G4int GetAtomicNumber() const

◆ GetIsotope()

G4IsotopeProperty * G4IsotopeMagneticMomentTable::GetIsotope ( G4int  Z,
G4int  A,
G4double  E 
)
virtual

Implements G4VIsotopeTable.

Definition at line 184 of file G4IsotopeMagneticMomentTable.cc.

185{
186 G4IsotopeProperty* fProperty = 0;
187 for (size_t i = 0 ; i< fIsotopeList.size(); ++i) {
188 G4IsotopeProperty* fP = fIsotopeList[i];
189
190 // check Z
191 if ( fP->GetAtomicNumber() > Z) {
192 // Not Found
193 break;
194 }
195 if ( fP->GetAtomicNumber() < Z) {
196 // next
197 continue;
198 }
199
200 // check A
201 if ( fP->GetAtomicMass() != A ) {
202 // next
203 continue;
204 }
205
206 //check E
207 if (std::fabs(fP->GetEnergy() - E) <= fP->GetEnergy()*levelTolerance) {
208 // Found
209 fProperty = fP;
210 fP->DumpInfo();
211 break;
212 }
213
214 }
215
216 return fProperty;
217
218}

◆ operator=()

G4IsotopeMagneticMomentTable & G4IsotopeMagneticMomentTable::operator= ( const G4IsotopeMagneticMomentTable right)
protected

Definition at line 146 of file G4IsotopeMagneticMomentTable.cc.

147{
148 return *this;
149}

The documentation for this class was generated from the following files: