Geant4  10.03
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: G4Isotope.cc 96794 2016-05-09 10:09:30Z gcosmo $
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"
48 #include "G4PhysicalConstants.hh"
49 #include "G4SystemOfUnits.hh"
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
57 // Create an isotope
58 //
60  : fName(Name), fZ(Z), fN(N), fA(A), fm(il)
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) {
74  *CLHEP::g/(CLHEP::mole*CLHEP::amu_c2);
75  }
76  theIsotopeTable.push_back(this);
77  fIndexInTable = theIsotopeTable.size() - 1;
78 }
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81 
82 // Fake default constructor - sets only member data and allocates memory
83 // for usage restricted to object persistency
84 
86  : fZ(0), fN(0), fA(0), fm(0), fIndexInTable(0)
87 {
88 }
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
91 
93 {
94  theIsotopeTable[fIndexInTable] = nullptr;
95 }
96 
97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
98 
100 {
101  *this = right;
102 
103  //insert this new isotope in table
104  theIsotopeTable.push_back(this);
105  fIndexInTable = theIsotopeTable.size() - 1;
106 }
107 
108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
109 
111 {
112  if (this != &right)
113  {
114  fName = right.fName;
115  fZ = right.fZ;
116  fN = right.fN;
117  fA = right.fA;
118  fm = right.fm;
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 
139 std::ostream& operator<<(std::ostream& flux, const 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 
159 std::ostream& operator<<(std::ostream& flux, const G4Isotope& isotope)
160 {
161  flux << &isotope;
162  return flux;
163 }
164 
165 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
166 
167 std::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 
196 G4Isotope* 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......
static G4IsotopeTable theIsotopeTable
Definition: G4Isotope.hh:148
G4int operator==(const G4Isotope &) const
Definition: G4Isotope.cc:125
G4String fName
Definition: G4Isotope.hh:141
G4int fm
Definition: G4Isotope.hh:145
const G4String & GetName() const
Definition: G4Isotope.hh:88
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4Isotope & operator=(const G4Isotope &)
Definition: G4Isotope.cc:110
G4String fName
Definition: G4AttUtils.hh:55
G4int fN
Definition: G4Isotope.hh:143
long G4long
Definition: G4Types.hh:80
virtual ~G4Isotope()
Definition: G4Isotope.cc:92
static constexpr double g
Definition: G4SIunits.hh:183
static const G4IsotopeTable * GetIsotopeTable()
Definition: G4Isotope.cc:182
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
static G4Isotope * GetIsotope(const G4String &name, G4bool warning=false)
Definition: G4Isotope.cc:196
std::vector< G4Isotope * > G4IsotopeTable
Definition: G4Isotope.hh:67
static const double prec
Definition: RanecuEngine.cc:58
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
bool G4bool
Definition: G4Types.hh:79
G4int operator!=(const G4Isotope &) const
Definition: G4Isotope.cc:132
G4double fA
Definition: G4Isotope.hh:144
G4Isotope(const G4String &name, G4int z, G4int n, G4double a=0., G4int m=0)
Definition: G4Isotope.cc:59
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4double GetAtomicMass(G4int Z, G4int N) const
static size_t GetNumberOfIsotopes()
Definition: G4Isotope.cc:189
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
size_t fIndexInTable
Definition: G4Isotope.hh:150
static constexpr double mole
Definition: G4SIunits.hh:286
std::ostream & operator<<(std::ostream &flux, const G4Isotope *isotope)
Definition: G4Isotope.cc:139
G4int fZ
Definition: G4Isotope.hh:142