Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Isotope.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// $Id$
28//
29//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30
31// 26.06.96: Code uses operators (+=, *=, ++, -> etc.) correctly, P. Urban
32// 29.01.97: Forbidden to create Isotope with Z<1 or N<Z, M.Maire
33// 03.05.01: flux.precision(prec) at begin/end of operator<<
34// 17.07.01: migration to STL. M. Verderi.
35// 13.09.01: suppression of the data member fIndexInTable
36// 14.09.01: fCountUse: nb of elements which use this isotope
37// 26.02.02: fIndexInTable renewed
38// 17.10.06: if fA is not defined in the constructor, it is computed from
39// NistManager v.Ivanchenko
40// 25.10.11: new scheme for G4Exception (mma)
41
42//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43
44#include <iomanip>
45
46#include "G4Isotope.hh"
47#include "G4NistManager.hh"
49#include "G4SystemOfUnits.hh"
50
51//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52
53G4IsotopeTable G4Isotope::theIsotopeTable;
54
55//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56
57// Create an isotope
58//
60: fName(Name), fZ(Z), fN(N), fA(A), fm(il), fCountUse(0)
61{
62 if (Z<1) {
64 ed << "Wrong Isotope " << Name << " Z= " << Z << G4endl;
65 G4Exception ("G4Isotope::G4Isotope()", "mat001", FatalException, ed);
66 }
67 if (N<Z) {
69 ed << "Wrong Isotope " << Name << " Z= " << Z << " > N= " << N << G4endl;
70 G4Exception ("G4Isotope::G4Isotope()", "mat002", FatalException, ed);
71 }
72 if (A<=0.0) {
73 fA = (G4NistManager::Instance()->GetAtomicMass(Z,N))*g/(mole*amu_c2);
74 }
75 theIsotopeTable.push_back(this);
76 fIndexInTable = theIsotopeTable.size() - 1;
77}
78
79//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
80
81// Fake default constructor - sets only member data and allocates memory
82// for usage restricted to object persistency
83
85 : fZ(0), fN(0), fA(0), fm(0), fCountUse(0), fIndexInTable(0)
86{
87}
88
89//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90
92{
93 theIsotopeTable[fIndexInTable] = 0;
94}
95
96//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
97
99{
100 *this = right;
101
102 //insert this new isotope in table
103 theIsotopeTable.push_back(this);
104 fIndexInTable = theIsotopeTable.size() - 1;
105}
106
107//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
108
109G4Isotope & G4Isotope::operator=(const G4Isotope& right)
110{
111 if (this != &right)
112 {
113 fName = right.fName;
114 fZ = right.fZ;
115 fN = right.fN;
116 fA = right.fA;
117 fm = right.fm;
118 fCountUse = right.fCountUse;
119 }
120 return *this;
121}
122
123//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
124
126{
127 return (this == (G4Isotope *) &right);
128}
129
130//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
131
133{
134 return (this != (G4Isotope *) &right);
135}
136
137//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
138
139std::ostream& operator<<(std::ostream& flux, G4Isotope* isotope)
140{
141 std::ios::fmtflags mode = flux.flags();
142 flux.setf(std::ios::fixed,std::ios::floatfield);
143 G4long prec = flux.precision(3);
144
145 flux
146 << " Isotope: " << std::setw(5) << isotope->fName
147 << " Z = " << std::setw(2) << isotope->fZ
148 << " N = " << std::setw(3) << isotope->fN
149 << " A = " << std::setw(6) << std::setprecision(2)
150 << (isotope->fA)/(g/mole) << " g/mole";
151
152 flux.precision(prec);
153 flux.setf(mode,std::ios::floatfield);
154 return flux;
155}
156
157//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
158
159std::ostream& operator<<(std::ostream& flux, G4Isotope& isotope)
160{
161 flux << &isotope;
162 return flux;
163}
164
165//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
166
167std::ostream& operator<<(std::ostream& flux, G4IsotopeTable IsotopeTable)
168{
169 //Dump info for all known isotopes
170 flux
171 << "\n***** Table : Nb of isotopes = " << IsotopeTable.size()
172 << " *****\n" << G4endl;
173
174 for (size_t i=0; i<IsotopeTable.size(); i++)
175 flux << IsotopeTable[i] << G4endl;
176
177 return flux;
178}
179
180//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
181
183{
184 return &theIsotopeTable;
185}
186
187//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
188
190{
191 return theIsotopeTable.size();
192}
193
194//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
195
196G4Isotope* G4Isotope::GetIsotope(const G4String& isotopeName, G4bool warning)
197{
198 // search the isotope by its name
199 for (size_t J=0 ; J<theIsotopeTable.size() ; J++)
200 {
201 if (theIsotopeTable[J]->GetName() == isotopeName)
202 { return theIsotopeTable[J]; }
203 }
204
205 // the isotope does not exist in the table
206 if (warning) {
207 G4cout << "\n---> warning from G4Isotope::GetIsotope(). The isotope: "
208 << isotopeName << " does not exist in the table. Return NULL pointer."
209 << G4endl;
210 }
211 return 0;
212}
213
214//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@ FatalException
std::ostream & operator<<(std::ostream &flux, G4Isotope *isotope)
Definition: G4Isotope.cc:139
std::vector< G4Isotope * > G4IsotopeTable
Definition: G4Isotope.hh:68
double G4double
Definition: G4Types.hh:64
long G4long
Definition: G4Types.hh:68
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
static const G4IsotopeTable * GetIsotopeTable()
Definition: G4Isotope.cc:182
G4Isotope(const G4String &name, G4int z, G4int n, G4double a=0., G4int m=0)
Definition: G4Isotope.cc:59
virtual ~G4Isotope()
Definition: G4Isotope.cc:91
static size_t GetNumberOfIsotopes()
Definition: G4Isotope.cc:189
static G4Isotope * GetIsotope(const G4String &name, G4bool warning=false)
Definition: G4Isotope.cc:196
G4int operator!=(const G4Isotope &) const
Definition: G4Isotope.cc:132
G4int operator==(const G4Isotope &) const
Definition: G4Isotope.cc:125
const G4String & GetName() const
Definition: G4Isotope.hh:88
G4double GetAtomicMass(G4int Z, G4int N) const
static G4NistManager * Instance()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76