ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4NistManager.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4NistManager.hh
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"
72 #include "G4NistElementBuilder.hh"
73 #include "G4NistMaterialBuilder.hh"
74 #include "G4ICRU90StoppingData.hh"
75 #include "G4Pow.hh"
76 #include "G4Threading.hh"
77 
78 class G4NistMessenger;
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
82 
84 {
85 
86 public:
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  //
166  inline G4double GetMeanIonisationEnergy(G4int Z) const;
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;
180  inline G4Material* FindOrBuildMaterial(const G4String& name,
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,
196  G4double temp = NTP_Temperature,
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,
209  G4double temp = NTP_Temperature,
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,
222  G4double temp = NTP_Temperature,
223  G4double pressure = CLHEP::STP_Pressure);
224 
225  // Construct a gas G4Material from scratch by atome count
226  //
227  inline G4Material* ConstructNewGasMaterial(const G4String& name,
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,
240  G4double temp = NTP_Temperature,
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 
292 private:
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 
329 inline 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 
337 inline
339 {
340  return elmBuilder->FindElement(Z);
341 }
342 
343 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
344 
345 inline
347 {
348  return elmBuilder->FindOrBuildElement(Z, isotopes);
349 }
350 
351 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
352 
353 inline
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 
369 inline 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 {
385  return elmBuilder->GetAtomicMassAmu(Z);
386 }
387 
388 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
389 
390 inline
392 {
393  return elmBuilder->GetIsotopeMass(Z, N);
394 }
395 
396 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
397 
398 inline
400 {
401  return elmBuilder->GetAtomicMass(Z, N);
402 }
403 
404 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
405 
406 inline
408 {
410 }
411 
412 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
413 
414 inline
416 {
417  return elmBuilder->GetIsotopeAbundance(Z, N);
418 }
419 
420 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
421 
422 inline
424 {
425  return elmBuilder->GetNistFirstIsotopeN(Z);
426 }
427 
428 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
429 
430 inline
432 {
434 }
435 
436 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
437 
438 inline
439 const 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 {
455  return matBuilder->GetNominalDensity(Z);
456 }
457 
458 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
459 
461 {
463 }
464 
465 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
466 
467 inline 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 
482 inline
484 {
485  return matBuilder->FindMaterial(name);
486 }
487 
488 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
489 
490 inline
492  G4bool isotopes,
493  G4bool warning)
494 {
495  return matBuilder->FindOrBuildMaterial(name, isotopes, warning);
496 }
497 
498 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
499 
500 inline
502 {
503  return matBuilder->FindSimpleMaterial(Z);
504 }
505 
506 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
507 
508 inline
510 {
511  return matBuilder->FindOrBuildSimpleMaterial(Z, warning);
512 }
513 
514 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
515 
517  const G4String& name,
518  const std::vector<G4String>& elm,
519  const std::vector<G4int>& nbAtoms,
520  G4double dens,
521  G4bool isotopes,
522  G4State state,
523  G4double T,
524  G4double P)
525 
526 {
527  return
528  matBuilder->ConstructNewMaterial(name,elm,nbAtoms,dens,isotopes,state,T,P);
529 }
530 
531 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
532 
534  const G4String& name,
535  const std::vector<G4String>& elm,
536  const std::vector<G4double>& w,
537  G4double dens,
538  G4bool isotopes,
539  G4State state,
540  G4double T,
541  G4double P)
542 {
543  return matBuilder->ConstructNewMaterial(name,elm,w,dens,isotopes,state,T,P);
544 }
545 
546 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
547 
549  const G4String& name,
550  const G4String& nameNist,
551  G4double temp, G4double pres,
552  G4bool isotopes)
553 {
554  return matBuilder->ConstructNewGasMaterial(name,nameNist,
555  temp,pres,isotopes);
556 }
557 
558 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
559 
561  const G4String& name,
562  const std::vector<G4String>& elm,
563  const std::vector<G4int>& nbAtoms,
564  G4bool isotopes,
565  G4double T,
566  G4double P)
567 {
568  return
569  matBuilder->ConstructNewIdealGasMaterial(name,elm,nbAtoms,isotopes,T,P);
570 }
571 
572 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
573 
574 inline void G4NistManager::ListMaterials(const G4String& list) const
575 {
576  matBuilder->ListMaterials(list);
577 }
578 
579 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
580 
581 inline
582 const std::vector<G4String>& G4NistManager::GetNistMaterialNames() const
583 {
584  return matBuilder->GetMaterialNames();
585 }
586 
587 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
588 
590 {
591  return g4pow->A13(A);
592 }
593 
594 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
595 
597 {
598  return g4pow->Z13(Z);
599 }
600 
601 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
602 
604 {
605  return (0 <= Z && Z < 101) ? POWERA27[Z] : 0.0;
606 }
607 
608 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
609 
611 {
612  return g4pow->logZ(Z);
613 }
614 
615 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
616 
618 {
619  return (0 <= Z && Z < 101) ? LOGAZ[Z] : 0.0;
620 }
621 
622 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
623 
624 #endif
625