ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Isotope.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4Isotope.cc
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
29 
30 // 26.06.96: Code uses operators (+=, *=, ++, -> etc.) correctly, P. Urban
31 // 29.01.97: Forbidden to create Isotope with Z<1 or N<Z, M.Maire
32 // 03.05.01: flux.precision(prec) at begin/end of operator<<
33 // 17.07.01: migration to STL. M. Verderi.
34 // 13.09.01: suppression of the data member fIndexInTable
35 // 14.09.01: fCountUse: nb of elements which use this isotope
36 // 26.02.02: fIndexInTable renewed
37 // 17.10.06: if fA is not defined in the constructor, it is computed from
38 // NistManager v.Ivanchenko
39 // 25.10.11: new scheme for G4Exception (mma)
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 
43 #include <iomanip>
44 
45 #include "G4Isotope.hh"
46 #include "G4NistManager.hh"
47 #include "G4PhysicalConstants.hh"
48 #include "G4SystemOfUnits.hh"
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51 
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
56 // Create an isotope
57 //
59  : fName(Name), fZ(Z), fN(N), fA(A), fm(il)
60 {
61  if (Z<1) {
63  ed << "Wrong Isotope " << Name << " Z= " << Z << G4endl;
64  G4Exception ("G4Isotope::G4Isotope()", "mat001", FatalException, ed);
65  }
66  if (N<Z) {
68  ed << "Wrong Isotope " << Name << " Z= " << Z << " > N= " << N << G4endl;
69  G4Exception ("G4Isotope::G4Isotope()", "mat002", FatalException, ed);
70  }
71  if (A<=0.0) {
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), fIndexInTable(0)
86 {
87 }
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90 
92 {
93  theIsotopeTable[fIndexInTable] = nullptr;
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 
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  }
119  return *this;
120 }
121 
122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
123 
125 {
126  return (this == (G4Isotope *) &right);
127 }
128 
129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
130 
132 {
133  return (this != (G4Isotope *) &right);
134 }
135 
136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
137 
138 std::ostream& operator<<(std::ostream& flux, const G4Isotope* isotope)
139 {
140  std::ios::fmtflags mode = flux.flags();
141  flux.setf(std::ios::fixed,std::ios::floatfield);
142  G4long prec = flux.precision(3);
143 
144  flux
145  << " Isotope: " << std::setw(5) << isotope->fName
146  << " Z = " << std::setw(2) << isotope->fZ
147  << " N = " << std::setw(3) << isotope->fN
148  << " A = " << std::setw(6) << std::setprecision(2)
149  << (isotope->fA)/(g/mole) << " g/mole";
150 
151  flux.precision(prec);
152  flux.setf(mode,std::ios::floatfield);
153  return flux;
154 }
155 
156 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
157 
158 std::ostream& operator<<(std::ostream& flux, const G4Isotope& isotope)
159 {
160  flux << &isotope;
161  return flux;
162 }
163 
164 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
165 
166 std::ostream& operator<<(std::ostream& flux, G4IsotopeTable IsotopeTable)
167 {
168  //Dump info for all known isotopes
169  flux
170  << "\n***** Table : Nb of isotopes = " << IsotopeTable.size()
171  << " *****\n" << G4endl;
172 
173  for (size_t i=0; i<IsotopeTable.size(); i++)
174  flux << IsotopeTable[i] << G4endl;
175 
176  return flux;
177 }
178 
179 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
180 
182 {
183  return &theIsotopeTable;
184 }
185 
186 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
187 
189 {
190  return theIsotopeTable.size();
191 }
192 
193 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
194 
195 G4Isotope* G4Isotope::GetIsotope(const G4String& isotopeName, G4bool warning)
196 {
197  // search the isotope by its name
198  for (size_t J=0 ; J<theIsotopeTable.size() ; J++)
199  {
200  if (theIsotopeTable[J]->GetName() == isotopeName)
201  { return theIsotopeTable[J]; }
202  }
203 
204  // the isotope does not exist in the table
205  if (warning) {
206  G4cout << "\n---> warning from G4Isotope::GetIsotope(). The isotope: "
207  << isotopeName << " does not exist in the table. Return NULL pointer."
208  << G4endl;
209  }
210  return 0;
211 }
212 
213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......