Geant4-11
G4NistManager.hh
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//
29// GEANT4 Class header file
30//
31// File name: G4NistManager
32//
33// Author: Vladimir Ivanchenko
34//
35// Creation date: 23.12.2004
36//
37// Modifications:
38// 27.02.06 V.Ivanchneko add GetAtomicMassAmu and ConstructNewGasMaterial
39// 11.05.06 V.Ivanchneko add warning flag to FindMaterial method
40// 17.10.06 V.Ivanchneko add methods: GetAtomicMass, GetNistElementNames,
41// GetNistMaterialNames
42// 02.05.07 V.Ivanchneko add GetNistFirstIsotopeN and GetNumberOfNistIsotopes
43// 28.07.07 V.Ivanchneko make simple methods inline
44// 28.10.07 V.Ivanchneko add state, T, P to maetrial build
45// 29.04.10 V.Ivanchneko add GetMeanIonisationEnergy method
46// 01.11.10 V.Ivanchneko add G4Pow for fast computations
47// 09.02.12 P.Gumplinger add ConstructNewIdealGasMaterial
48//
49// Class Description:
50//
51// A utility static class
52//
53
54// -------------------------------------------------------------------
55//
56// Class Description:
57//
58// Element data from the NIST DB on Atomic Weights and Isotope Compositions
59// http://physics.nist.gov/PhysRefData/Compositions/index.html
60//
61// -------------------------------------------------------------------
62//
63
64#ifndef G4NistManager_h
65#define G4NistManager_h 1
66
67#include <vector>
69
70#include "globals.hh"
71#include "G4Material.hh"
75#include "G4Pow.hh"
76#include "G4Threading.hh"
77
78class G4NistMessenger;
79
80//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
81//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
82
84{
85
86public:
87
88 static G4NistManager* Instance();
90
91 // Get G4Element by index
92 //
93 inline G4Element* GetElement(size_t index) const;
94
95 // Find or build G4Element by atomic number
96 //
97 inline G4Element* FindElement(G4int Z) const;
98 inline G4Element* FindOrBuildElement(G4int Z, G4bool isotopes=true);
99
100 // Find or build G4Element by symbol
101 //
102 inline G4Element* FindOrBuildElement(const G4String& symb,
103 G4bool isotopes=true);
104
105 // Get number of elements
106 //
107 inline size_t GetNumberOfElements() const;
108
109 // Get atomic number by element symbol
110 //
111 inline G4int GetZ(const G4String& symb) const;
112
113 // Get atomic weight by element symbol - mean mass in units of amu of
114 // an atom with electron shell for the natural isotope composition
115 //
116 inline G4double GetAtomicMassAmu(const G4String& symb) const;
117
118 // Get atomic weight in atomic units - mean mass in units of amu of an atom
119 // with electron shell for the natural isotope composition
120 //
121 inline G4double GetAtomicMassAmu(G4int Z) const;
122
123 // Get mass of isotope without electron shell in Geant4 energy units
124 //
125 inline G4double GetIsotopeMass(G4int Z, G4int N) const;
126
127 // Get mass in Geant4 energy units of an atom of a particular isotope
128 // with the electron shell
129 //
130 inline G4double GetAtomicMass(G4int Z, G4int N) const;
131
132 // Get total ionisation energy of an atom
133 //
135
136 // Get N for the first natural isotope
137 //
138 inline G4int GetNistFirstIsotopeN(G4int Z) const;
139
140 // Get number of natural isotopes
141 //
142 inline G4int GetNumberOfNistIsotopes(G4int Z) const;
143
144 // Get natural isotope abundance
145 //
146 inline G4double GetIsotopeAbundance(G4int Z, G4int N) const;
147
148 // Print element by Z
149 //
150 inline void PrintElement(G4int Z) const;
151
152 // Print element from internal DB by symbol, if "all" - print all elements
153 //
154 void PrintElement(const G4String&) const;
155
156 // Print G4Element by name, if "all" - print all G4Elements
157 //
158 void PrintG4Element(const G4String&) const;
159
160 // Access to the vector of Geant4 predefined element names
161 //
162 inline const std::vector<G4String>& GetNistElementNames() const;
163
164 // Access mean ionisation energy for atoms (Z <= 98) by its index
165 //
167
168 // Access nominal density by atomic number for simple materials and
169 // by the index for other NIST materials
170 //
171 inline G4double GetNominalDensity(G4int Z) const;
172
173 // Get G4Material by index
174 //
175 inline G4Material* GetMaterial(size_t index) const;
176
177 // Find or build a G4Material by name, from the Geant4 dataBase
178 //
179 inline G4Material* FindMaterial(const G4String& name) const;
181 G4bool isotopes=true,
182 G4bool warning=false);
183
184 // Find or build a simple material via atomic number
185 //
186 inline G4Material* FindSimpleMaterial(G4int Z) const;
188 G4bool warning=false);
189
190 // Build G4Material with user defined name and density on base
191 // of a material from Geant4 dataBase
192 //
194 const G4String& basename,
195 G4double density = 0.0,
198
199 // Construct a G4Material from scratch by atome count
200 // temperature and pressure should be consistent with the density
201 //
203 const G4String& name,
204 const std::vector<G4String>& elm,
205 const std::vector<G4int>& nbAtoms,
206 G4double dens,
207 G4bool isotopes=true,
208 G4State state = kStateSolid,
210 G4double pressure = CLHEP::STP_Pressure);
211
212 // Construct a G4Material from scratch by fraction mass
213 // temperature and pressure should be consistent with the density
214 //
216 const G4String& name,
217 const std::vector<G4String>& elm,
218 const std::vector<G4double>& weight,
219 G4double dens,
220 G4bool isotopes=true,
221 G4State state = kStateSolid,
223 G4double pressure = CLHEP::STP_Pressure);
224
225 // Construct a gas G4Material from scratch by atome count
226 //
228 const G4String& nameNist,
229 G4double temp,
230 G4double pres,
231 G4bool isotopes=true);
232
233 // Construct an ideal gas G4Material from scratch by atom count
234 //
236 const G4String& name,
237 const std::vector<G4String>& elm,
238 const std::vector<G4int>& nbAtoms,
239 G4bool isotopes = true,
241 G4double pressure = CLHEP::STP_Pressure);
242
243 // enable/disable density effect calculator by material name
244 //
246
247 // enable/disable density effect calculator by material pointer
248 //
250
251 // Get number of G4Materials
252 //
253 inline size_t GetNumberOfMaterials() const;
254
255 inline G4int GetVerbose() const;
256
257 void SetVerbose(G4int);
258
259 // Print G4Material by name
260 //
261 void PrintG4Material(const G4String&) const;
262
263 // Print predefined Geant4 materials:
264 // "simple" - only pure materials in basic state (Z = 1, ..., 98)
265 // "compound" - NIST compounds
266 // "hep" - HEP materials and compounds
267 // "bio" - bio-medical materials and compounds
268 // "all" - all
269 //
270 inline void ListMaterials(const G4String&) const;
271
272 // Access to the list of names of Geant4 predefined materials
273 //
274 inline const std::vector<G4String>& GetNistMaterialNames() const;
275
276 // Fast computation of Z^1/3
277 //
278 inline G4double GetZ13(G4double Z) const;
279 inline G4double GetZ13(G4int Z) const;
280
281 // Fast computation of A^0.27 for natuaral abundances
282 //
283 inline G4double GetA27(G4int Z) const;
284
285 // Fast computation of log(A)
286 //
287 inline G4double GetLOGZ(G4int Z) const;
288 inline G4double GetLOGAMU(G4int Z) const;
289
291
292private:
293
294 explicit G4NistManager();
295
297
298 std::vector<G4Element*> elements;
299 std::vector<G4Material*> materials;
300
306
309
310 size_t nElements;
311 size_t nMaterials;
313
314#ifdef G4MULTITHREADED
315 static G4Mutex nistManagerMutex;
316#endif
317};
318
319//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
320//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
321
323{
324 return nMaterials;
325}
326
327//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
328
329inline G4Element* G4NistManager::GetElement(size_t index) const
330{
331 const G4ElementTable* theElementTable = G4Element::GetElementTable();
332 return (index < theElementTable->size()) ? (*theElementTable)[index] : nullptr;
333}
334
335//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
336
337inline
339{
340 return elmBuilder->FindElement(Z);
341}
342
343//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
344
345inline
347{
348 return elmBuilder->FindOrBuildElement(Z, isotopes);
349}
350
351//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
352
353inline
355 G4bool isotopes)
356{
357 return elmBuilder->FindOrBuildElement(symb, isotopes);
358}
359
360//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
361
363{
364 return nElements;
365}
366
367//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
368
369inline G4int G4NistManager::GetZ(const G4String& symb) const
370{
371 return elmBuilder->GetZ(symb);
372}
373
374//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
375
377{
378 return elmBuilder->GetAtomicMassAmu(symb);
379}
380
381//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
382
384{
386}
387
388//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
389
390inline
392{
393 return elmBuilder->GetIsotopeMass(Z, N);
394}
395
396//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
397
398inline
400{
401 return elmBuilder->GetAtomicMass(Z, N);
402}
403
404//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
405
406inline
408{
410}
411
412//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
413
414inline
416{
417 return elmBuilder->GetIsotopeAbundance(Z, N);
418}
419
420//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
421
422inline
424{
426}
427
428//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
429
430inline
432{
434}
435
436//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
437
438inline
439const std::vector<G4String>& G4NistManager::GetNistElementNames() const
440{
441 return elmBuilder->GetElementNames();
442}
443
444//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
445
447{
449}
450
451//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
452
454{
456}
457
458//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
459
461{
463}
464
465//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
466
467inline G4Material* G4NistManager::GetMaterial(size_t index) const
468{
469 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
470 return (index < theMaterialTable->size()) ? (*theMaterialTable)[index] : nullptr;
471}
472
473//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
474
476{
477 return verbose;
478}
479
480//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
481
482inline
484{
485 return matBuilder->FindMaterial(name);
486}
487
488//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
489
490inline
492 G4bool, G4bool warning)
493{
494 return matBuilder->FindOrBuildMaterial(name, warning);
495}
496
497//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
498
499inline
501{
503}
504
505//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
506
507inline
509{
510 return matBuilder->FindOrBuildSimpleMaterial(Z, warning);
511}
512
513//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
514
516 const G4String& name,
517 const std::vector<G4String>& elm,
518 const std::vector<G4int>& nbAtoms,
519 G4double dens,
520 G4bool,
521 G4State state,
522 G4double T,
523 G4double P)
524
525{
526 return
527 matBuilder->ConstructNewMaterial(name,elm,nbAtoms,dens,state,T,P);
528}
529
530//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
531
533 const G4String& name,
534 const std::vector<G4String>& elm,
535 const std::vector<G4double>& w,
536 G4double dens,
537 G4bool,
538 G4State state,
539 G4double T,
540 G4double P)
541{
542 return matBuilder->ConstructNewMaterial(name,elm,w,dens,state,T,P);
543}
544
545//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
546
548 const G4String& name,
549 const G4String& nameNist,
550 G4double temp, G4double pres,
551 G4bool)
552{
553 return matBuilder->ConstructNewGasMaterial(name,nameNist,temp,pres);
554}
555
556//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
557
559 const G4String& name,
560 const std::vector<G4String>& elm,
561 const std::vector<G4int>& nbAtoms,
562 G4bool,
563 G4double T,
564 G4double P)
565{
566 return
568}
569
570//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
571
572inline void G4NistManager::ListMaterials(const G4String& list) const
573{
575}
576
577//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
578
579inline
580const std::vector<G4String>& G4NistManager::GetNistMaterialNames() const
581{
583}
584
585//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
586
588{
589 return g4pow->A13(A);
590}
591
592//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
593
595{
596 return g4pow->Z13(Z);
597}
598
599//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
600
602{
603 return (0 <= Z && Z < 101) ? POWERA27[Z] : g4pow->powZ(Z, 0.27);
604}
605
606//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
607
609{
610 return g4pow->logZ(Z);
611}
612
613//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
614
616{
617 return (0 <= Z && Z < 101) ? LOGAZ[Z] : 0.0;
618}
619
620//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
621
622#endif
623
std::vector< G4Element * > G4ElementTable
std::vector< G4Material * > G4MaterialTable
G4State
Definition: G4Material.hh:111
@ kStateSolid
Definition: G4Material.hh:111
static const G4double NTP_Temperature
Definition: G4Material.hh:113
std::mutex G4Mutex
Definition: G4Threading.hh:81
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]
static G4ElementTable * GetElementTable()
Definition: G4Element.cc:397
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:672
G4double GetAtomicMass(G4int Z, G4int N) const
G4double GetAtomicMassAmu(const G4String &symb) const
G4double GetIsotopeMass(G4int Z, G4int N) const
G4Element * FindOrBuildElement(G4int Z, G4bool buildIsotopes=true)
G4int GetNumberOfNistIsotopes(G4int Z) const
G4int GetZ(const G4String &symb) const
G4Element * FindElement(G4int Z) const
G4double GetIsotopeAbundance(G4int Z, G4int N) const
G4int GetNistFirstIsotopeN(G4int Z) const
const std::vector< G4String > & GetElementNames() const
void PrintElement(G4int Z) const
G4double GetTotalElectronBindingEnergy(G4int Z) const
G4Material * ConstructNewGasMaterial(const G4String &name, const G4String &nameNist, G4double temp, G4double pres, G4bool isotopes=true)
G4int GetNumberOfNistIsotopes(G4int Z) const
G4ICRU90StoppingData * GetICRU90StoppingData()
G4double GetA27(G4int Z) const
G4Element * FindElement(G4int Z) const
G4NistMessenger * messenger
G4double GetTotalElectronBindingEnergy(G4int Z) const
std::vector< G4Element * > elements
G4ICRU90StoppingData * fICRU90
G4double GetZ13(G4double Z) const
G4Material * FindSimpleMaterial(G4int Z) const
void PrintElement(G4int Z) const
G4double POWERA27[101]
void SetDensityEffectCalculatorFlag(const G4String &, G4bool)
G4int GetVerbose() const
G4Material * ConstructNewIdealGasMaterial(const G4String &name, const std::vector< G4String > &elm, const std::vector< G4int > &nbAtoms, G4bool isotopes=true, G4double temp=NTP_Temperature, G4double pressure=CLHEP::STP_Pressure)
G4double GetIsotopeMass(G4int Z, G4int N) const
G4Element * GetElement(size_t index) const
static G4NistManager * instance
G4double LOGAZ[101]
const std::vector< G4String > & GetNistMaterialNames() const
G4NistMaterialBuilder * matBuilder
G4double GetAtomicMass(G4int Z, G4int N) const
G4Material * FindOrBuildSimpleMaterial(G4int Z, G4bool warning=false)
void ListMaterials(const G4String &) const
G4NistElementBuilder * elmBuilder
G4Material * BuildMaterialWithNewDensity(const G4String &name, const G4String &basename, G4double density=0.0, G4double temp=NTP_Temperature, G4double pres=CLHEP::STP_Pressure)
G4double GetMeanIonisationEnergy(G4int Z) const
const std::vector< G4String > & GetNistElementNames() const
void PrintG4Material(const G4String &) const
void PrintG4Element(const G4String &) const
G4Material * ConstructNewMaterial(const G4String &name, const std::vector< G4String > &elm, const std::vector< G4int > &nbAtoms, G4double dens, G4bool isotopes=true, G4State state=kStateSolid, G4double temp=NTP_Temperature, G4double pressure=CLHEP::STP_Pressure)
G4double GetLOGZ(G4int Z) const
std::vector< G4Material * > materials
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
G4Material * FindMaterial(const G4String &name) const
G4int GetZ(const G4String &symb) const
G4int GetNistFirstIsotopeN(G4int Z) const
size_t GetNumberOfElements() const
static G4NistManager * Instance()
void SetVerbose(G4int)
size_t GetNumberOfMaterials() const
G4double GetIsotopeAbundance(G4int Z, G4int N) const
G4Element * FindOrBuildElement(G4int Z, G4bool isotopes=true)
G4Material * GetMaterial(size_t index) const
G4double GetLOGAMU(G4int Z) const
G4double GetAtomicMassAmu(const G4String &symb) const
G4double GetNominalDensity(G4int Z) const
G4double GetMeanIonisationEnergy(G4int index) const
G4Material * ConstructNewMaterial(const G4String &name, const std::vector< G4String > &elm, const std::vector< G4int > &nbAtoms, G4double dens, G4State state=kStateSolid, G4double temp=NTP_Temperature, G4double pressure=CLHEP::STP_Pressure)
void ListMaterials(const G4String &) const
G4Material * FindOrBuildMaterial(const G4String &name, G4bool warning=true)
G4Material * ConstructNewIdealGasMaterial(const G4String &name, const std::vector< G4String > &elm, const std::vector< G4int > &nbAtoms, G4double temp=NTP_Temperature, G4double pressure=CLHEP::STP_Pressure)
const std::vector< G4String > & GetMaterialNames() const
G4double GetNominalDensity(G4int index) const
G4Material * FindSimpleMaterial(G4int Z) const
G4Material * FindOrBuildSimpleMaterial(G4int Z, G4bool warning)
G4Material * FindMaterial(const G4String &name) const
G4Material * ConstructNewGasMaterial(const G4String &name, const G4String &nameDB, G4double temp, G4double pres)
Definition: G4Pow.hh:49
G4double logZ(G4int Z) const
Definition: G4Pow.hh:137
G4double A13(G4double A) const
Definition: G4Pow.cc:120
G4double powZ(G4int Z, G4double y) const
Definition: G4Pow.hh:225
G4double Z13(G4int Z) const
Definition: G4Pow.hh:123
static constexpr double STP_Pressure
const char * name(G4int ptype)
static double P[]