Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:59:01

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 
0026 // -------------------------------------------------------------------
0027 //
0028 // GEANT4 Class header file
0029 //
0030 // File name:     G4NistManager
0031 //
0032 // Author:        Vladimir Ivanchenko
0033 //
0034 // Creation date: 23.12.2004
0035 //
0036 // Modifications:
0037 // 27.02.06 V.Ivanchneko add GetAtomicMassAmu and ConstructNewGasMaterial
0038 // 11.05.06 V.Ivanchneko add warning flag to FindMaterial method
0039 // 17.10.06 V.Ivanchneko add methods: GetAtomicMass, GetNistElementNames,
0040 //                       GetNistMaterialNames
0041 // 02.05.07 V.Ivanchneko add GetNistFirstIsotopeN and GetNumberOfNistIsotopes
0042 // 28.07.07 V.Ivanchneko make simple methods inline
0043 // 28.10.07 V.Ivanchneko add state, T, P to maetrial build
0044 // 29.04.10 V.Ivanchneko add GetMeanIonisationEnergy method
0045 // 01.11.10 V.Ivanchneko add G4Pow for fast computations
0046 // 09.02.12 P.Gumplinger add ConstructNewIdealGasMaterial
0047 //
0048 // Class Description:
0049 //
0050 // A utility static class
0051 //
0052 // Element data from the NIST DB on Atomic Weights and Isotope Compositions
0053 // http://physics.nist.gov/PhysRefData/Compositions/index.html
0054 //
0055 // -------------------------------------------------------------------
0056 
0057 #ifndef G4NistManager_h
0058 #define G4NistManager_h 1
0059 
0060 #include "G4ICRU90StoppingData.hh"
0061 #include "G4Material.hh"
0062 #include "G4Element.hh"
0063 #include "G4Isotope.hh"
0064 #include "G4NistElementBuilder.hh"
0065 #include "G4NistMaterialBuilder.hh"
0066 #include "G4Pow.hh"
0067 #include "globals.hh"
0068 
0069 #include <CLHEP/Units/PhysicalConstants.h>
0070 
0071 #include <vector>
0072 
0073 class G4NistMessenger;
0074 
0075 class G4NistManager
0076 {
0077  public:
0078   static G4NistManager* Instance();
0079   ~G4NistManager();
0080 
0081   // Get G4Element by index
0082   //
0083   inline G4Element* GetElement(std::size_t index) const;
0084 
0085   // Find or build G4Element by atomic number
0086   //
0087   inline G4Element* FindElement(G4int Z) const;
0088   inline G4Element* FindOrBuildElement(G4int Z, G4bool isotopes = true);
0089 
0090   // Find or build G4Element by symbol
0091   //
0092   inline G4Element* FindOrBuildElement(const G4String& symb, G4bool isotopes = true);
0093 
0094   // Get number of elements
0095   //
0096   inline std::size_t GetNumberOfElements() const;
0097 
0098   // Get atomic number by element symbol
0099   //
0100   inline G4int GetZ(const G4String& symb) const;
0101 
0102   // Get atomic weight by element symbol - mean mass in units of amu of
0103   // an atom with electron shell for the natural isotope composition
0104   //
0105   inline G4double GetAtomicMassAmu(const G4String& symb) const;
0106 
0107   // Get atomic weight in atomic units - mean mass in units of amu of an atom
0108   // with electron shell for the natural isotope composition
0109   //
0110   inline G4double GetAtomicMassAmu(G4int Z) const;
0111 
0112   // Get mass of isotope without electron shell in Geant4 energy units
0113   //
0114   inline G4double GetIsotopeMass(G4int Z, G4int N) const;
0115 
0116   // Get mass in Geant4 energy units of an atom of a particular isotope
0117   // with the electron shell
0118   //
0119   inline G4double GetAtomicMass(G4int Z, G4int N) const;
0120 
0121   // Get total ionisation energy of an atom
0122   //
0123   inline G4double GetTotalElectronBindingEnergy(G4int Z) const;
0124 
0125   // Get N for the first natural isotope
0126   //
0127   inline G4int GetNistFirstIsotopeN(G4int Z) const;
0128 
0129   // Get number of natural isotopes
0130   //
0131   inline G4int GetNumberOfNistIsotopes(G4int Z) const;
0132 
0133   // Get natural isotope abundance
0134   //
0135   inline G4double GetIsotopeAbundance(G4int Z, G4int N) const;
0136 
0137   // Print element by Z
0138   //
0139   inline void PrintElement(G4int Z) const;
0140 
0141   // Print element from internal DB by symbol, if "all" - print all elements
0142   //
0143   void PrintElement(const G4String&) const;
0144 
0145   // Print G4Element by name, if "all" - print all G4Elements
0146   //
0147   void PrintG4Element(const G4String&) const;
0148 
0149   // Access to the vector of Geant4 predefined element names
0150   //
0151   inline const std::vector<G4String>& GetNistElementNames() const;
0152 
0153   // Access mean ionisation energy for atoms (Z <= 98) by its index
0154   //
0155   inline G4double GetMeanIonisationEnergy(G4int Z) const;
0156 
0157   // Access nominal density by atomic number for simple materials and
0158   // by the index for other NIST materials
0159   //
0160   inline G4double GetNominalDensity(G4int Z) const;
0161 
0162   // Get G4Material by index
0163   //
0164   inline G4Material* GetMaterial(std::size_t index) const;
0165 
0166   // Find or build a G4Material by name, from the Geant4 dataBase
0167   //
0168   inline G4Material* FindMaterial(const G4String& name) const;
0169   inline G4Material* FindOrBuildMaterial(
0170     const G4String& name, G4bool isotopes = true, G4bool warning = false);
0171 
0172   // Find or build a simple material via atomic number
0173   //
0174   inline G4Material* FindSimpleMaterial(G4int Z) const;
0175   inline G4Material* FindOrBuildSimpleMaterial(G4int Z, G4bool warning = false);
0176 
0177   // Build G4Material with user defined name and density on base
0178   // of a material from Geant4 dataBase
0179   //
0180   G4Material* BuildMaterialWithNewDensity(const G4String& name, const G4String& basename,
0181     G4double density = 0.0, G4double temp = NTP_Temperature, G4double pres = CLHEP::STP_Pressure);
0182 
0183   // Construct a G4Material from scratch by atome count
0184   // temperature and pressure should be consistent with the density
0185   //
0186   inline G4Material* ConstructNewMaterial(const G4String& name, const std::vector<G4String>& elm,
0187     const std::vector<G4int>& nbAtoms, G4double dens, G4bool isotopes = true,
0188     G4State state = kStateSolid, G4double temp = NTP_Temperature,
0189     G4double pressure = CLHEP::STP_Pressure);
0190 
0191   // Construct a G4Material from scratch by fraction mass
0192   // temperature and pressure should be consistent with the density
0193   //
0194   inline G4Material* ConstructNewMaterial(const G4String& name, const std::vector<G4String>& elm,
0195     const std::vector<G4double>& weight, G4double dens, G4bool isotopes = true,
0196     G4State state = kStateSolid, G4double temp = NTP_Temperature,
0197     G4double pressure = CLHEP::STP_Pressure);
0198 
0199   // Construct a gas G4Material from scratch by atome count
0200   //
0201   inline G4Material* ConstructNewGasMaterial(const G4String& name, const G4String& nameNist,
0202     G4double temp, G4double pres, G4bool isotopes = true);
0203 
0204   // Construct an ideal gas G4Material from scratch by atom count
0205   //
0206   inline G4Material* ConstructNewIdealGasMaterial(const G4String& name,
0207     const std::vector<G4String>& elm, const std::vector<G4int>& nbAtoms, G4bool isotopes = true,
0208     G4double temp = NTP_Temperature, G4double pressure = CLHEP::STP_Pressure);
0209 
0210   // enable/disable density effect calculator by material name
0211   //
0212   void SetDensityEffectCalculatorFlag(const G4String&, G4bool);
0213 
0214   // enable/disable density effect calculator by material pointer
0215   //
0216   void SetDensityEffectCalculatorFlag(G4Material*, G4bool);
0217 
0218   // Get number of G4Materials
0219   //
0220   inline std::size_t GetNumberOfMaterials() const;
0221 
0222   inline G4int GetVerbose() const;
0223 
0224   void SetVerbose(G4int);
0225 
0226   // Print G4Material by name
0227   //
0228   void PrintG4Material(const G4String&) const;
0229 
0230   // Print predefined Geant4 materials:
0231   // "simple" - only pure materials in basic state (Z = 1, ..., 98)
0232   // "compound" - NIST compounds
0233   // "hep" - HEP materials and compounds
0234   // "bio" - bio-medical materials and compounds
0235   // "all" - all
0236   //
0237   inline void ListMaterials(const G4String&) const;
0238 
0239   // Access to the list of names of Geant4 predefined materials
0240   //
0241   inline const std::vector<G4String>& GetNistMaterialNames() const;
0242 
0243   // Fast computation of Z^1/3
0244   //
0245   inline G4double GetZ13(G4double Z) const;
0246   inline G4double GetZ13(G4int Z) const;
0247 
0248   // Fast computation of A^0.27 for natuaral abundances
0249   //
0250   inline G4double GetA27(G4int Z) const;
0251 
0252   // Fast computation of log(A)
0253   //
0254   inline G4double GetLOGZ(G4int Z) const;
0255   inline G4double GetLOGAMU(G4int Z) const;
0256 
0257   G4ICRU90StoppingData* GetICRU90StoppingData();
0258 
0259  private:
0260   G4NistManager();
0261 
0262   std::vector<G4Element*> elements;
0263   std::vector<G4Material*> materials;
0264 
0265   G4ICRU90StoppingData* fICRU90;
0266   G4NistElementBuilder* elmBuilder;
0267   G4NistMaterialBuilder* matBuilder;
0268   G4NistMessenger* messenger;
0269   G4Pow* g4pow;
0270   const G4MaterialTable* theMaterialTable;
0271   const G4ElementTable* theElementTable;
0272   const G4IsotopeTable* theIsotopeTable;
0273 
0274   G4double POWERA27[101];
0275   G4double LOGAZ[101];
0276 
0277   std::size_t nElements;
0278   std::size_t nMaterials;
0279   G4int verbose;
0280 };
0281 
0282 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0283 
0284 inline std::size_t G4NistManager::GetNumberOfMaterials() const { return nMaterials; }
0285 
0286 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0287 
0288 inline G4Element* G4NistManager::GetElement(std::size_t index) const
0289 {
0290   return (index < theElementTable->size()) ? (*theElementTable)[index] : nullptr;
0291 }
0292 
0293 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0294 
0295 inline G4Element* G4NistManager::FindElement(G4int Z) const { return elmBuilder->FindElement(Z); }
0296 
0297 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0298 
0299 inline G4Element* G4NistManager::FindOrBuildElement(G4int Z, G4bool isotopes)
0300 {
0301   return elmBuilder->FindOrBuildElement(Z, isotopes);
0302 }
0303 
0304 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0305 
0306 inline G4Element* G4NistManager::FindOrBuildElement(const G4String& symb, G4bool isotopes)
0307 {
0308   return elmBuilder->FindOrBuildElement(symb, isotopes);
0309 }
0310 
0311 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0312 
0313 inline std::size_t G4NistManager::GetNumberOfElements() const { return nElements; }
0314 
0315 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0316 
0317 inline G4int G4NistManager::GetZ(const G4String& symb) const { return elmBuilder->GetZ(symb); }
0318 
0319 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0320 
0321 inline G4double G4NistManager::GetAtomicMassAmu(const G4String& symb) const
0322 {
0323   return elmBuilder->GetAtomicMassAmu(symb);
0324 }
0325 
0326 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0327 
0328 inline G4double G4NistManager::GetAtomicMassAmu(G4int Z) const
0329 {
0330   return elmBuilder->GetAtomicMassAmu(Z);
0331 }
0332 
0333 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0334 
0335 inline G4double G4NistManager::GetIsotopeMass(G4int Z, G4int N) const
0336 {
0337   return elmBuilder->GetIsotopeMass(Z, N);
0338 }
0339 
0340 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0341 
0342 inline G4double G4NistManager::GetAtomicMass(G4int Z, G4int N) const
0343 {
0344   return elmBuilder->GetAtomicMass(Z, N);
0345 }
0346 
0347 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0348 
0349 inline G4double G4NistManager::GetTotalElectronBindingEnergy(G4int Z) const
0350 {
0351   return elmBuilder->GetTotalElectronBindingEnergy(Z);
0352 }
0353 
0354 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0355 
0356 inline G4double G4NistManager::GetIsotopeAbundance(G4int Z, G4int N) const
0357 {
0358   return elmBuilder->GetIsotopeAbundance(Z, N);
0359 }
0360 
0361 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0362 
0363 inline G4int G4NistManager::GetNistFirstIsotopeN(G4int Z) const
0364 {
0365   return elmBuilder->GetNistFirstIsotopeN(Z);
0366 }
0367 
0368 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0369 
0370 inline G4int G4NistManager::GetNumberOfNistIsotopes(G4int Z) const
0371 {
0372   return elmBuilder->GetNumberOfNistIsotopes(Z);
0373 }
0374 
0375 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0376 
0377 inline const std::vector<G4String>& G4NistManager::GetNistElementNames() const
0378 {
0379   return elmBuilder->GetElementNames();
0380 }
0381 
0382 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0383 
0384 inline G4double G4NistManager::GetMeanIonisationEnergy(G4int Z) const
0385 {
0386   return matBuilder->GetMeanIonisationEnergy(Z);
0387 }
0388 
0389 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0390 
0391 inline G4double G4NistManager::GetNominalDensity(G4int Z) const
0392 {
0393   return matBuilder->GetNominalDensity(Z);
0394 }
0395 
0396 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0397 
0398 inline void G4NistManager::PrintElement(G4int Z) const { elmBuilder->PrintElement(Z); }
0399 
0400 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0401 
0402 inline G4Material* G4NistManager::GetMaterial(std::size_t index) const
0403 {
0404   return (index < theMaterialTable->size()) ? (*theMaterialTable)[index] : nullptr;
0405 }
0406 
0407 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0408 
0409 inline G4int G4NistManager::GetVerbose() const { return verbose; }
0410 
0411 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0412 
0413 inline G4Material* G4NistManager::FindMaterial(const G4String& name) const
0414 {
0415   return matBuilder->FindMaterial(name);
0416 }
0417 
0418 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0419 
0420 inline G4Material* G4NistManager::FindOrBuildMaterial(const G4String& name, G4bool, G4bool warning)
0421 {
0422   return matBuilder->FindOrBuildMaterial(name, warning);
0423 }
0424 
0425 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0426 
0427 inline G4Material* G4NistManager::FindSimpleMaterial(G4int Z) const
0428 {
0429   return matBuilder->FindSimpleMaterial(Z);
0430 }
0431 
0432 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0433 
0434 inline G4Material* G4NistManager::FindOrBuildSimpleMaterial(G4int Z, G4bool warning)
0435 {
0436   return matBuilder->FindOrBuildSimpleMaterial(Z, warning);
0437 }
0438 
0439 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0440 
0441 inline G4Material* G4NistManager::ConstructNewMaterial(const G4String& name,
0442   const std::vector<G4String>& elm, const std::vector<G4int>& nbAtoms, G4double dens, G4bool,
0443   G4State state, G4double T, G4double P)
0444 
0445 {
0446   return matBuilder->ConstructNewMaterial(name, elm, nbAtoms, dens, state, T, P);
0447 }
0448 
0449 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0450 
0451 inline G4Material* G4NistManager::ConstructNewMaterial(const G4String& name,
0452   const std::vector<G4String>& elm, const std::vector<G4double>& w, G4double dens, G4bool,
0453   G4State state, G4double T, G4double P)
0454 {
0455   return matBuilder->ConstructNewMaterial(name, elm, w, dens, state, T, P);
0456 }
0457 
0458 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0459 
0460 inline G4Material* G4NistManager::ConstructNewGasMaterial(
0461   const G4String& name, const G4String& nameNist, G4double temp, G4double pres, G4bool)
0462 {
0463   return matBuilder->ConstructNewGasMaterial(name, nameNist, temp, pres);
0464 }
0465 
0466 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0467 
0468 inline G4Material* G4NistManager::ConstructNewIdealGasMaterial(const G4String& name,
0469   const std::vector<G4String>& elm, const std::vector<G4int>& nbAtoms, G4bool, G4double T,
0470   G4double P)
0471 {
0472   return matBuilder->ConstructNewIdealGasMaterial(name, elm, nbAtoms, T, P);
0473 }
0474 
0475 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0476 
0477 inline void G4NistManager::ListMaterials(const G4String& list) const
0478 {
0479   matBuilder->ListMaterials(list);
0480 }
0481 
0482 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0483 
0484 inline const std::vector<G4String>& G4NistManager::GetNistMaterialNames() const
0485 {
0486   return matBuilder->GetMaterialNames();
0487 }
0488 
0489 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0490 
0491 inline G4double G4NistManager::GetZ13(G4double A) const { return g4pow->A13(A); }
0492 
0493 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0494 
0495 inline G4double G4NistManager::GetZ13(G4int Z) const { return g4pow->Z13(Z); }
0496 
0497 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0498 
0499 inline G4double G4NistManager::GetA27(G4int Z) const
0500 {
0501   return (0 <= Z && Z < 101) ? POWERA27[Z] : g4pow->powZ(Z, 0.27);
0502 }
0503 
0504 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0505 
0506 inline G4double G4NistManager::GetLOGZ(G4int Z) const { return g4pow->logZ(Z); }
0507 
0508 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0509 
0510 inline G4double G4NistManager::GetLOGAMU(G4int Z) const
0511 {
0512   return (0 <= Z && Z < 101) ? LOGAZ[Z] : 0.0;
0513 }
0514 
0515 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0516 
0517 #endif