Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:45

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 "G4NistElementBuilder.hh"
0063 #include "G4NistMaterialBuilder.hh"
0064 #include "G4Pow.hh"
0065 #include "globals.hh"
0066 
0067 #include <CLHEP/Units/PhysicalConstants.h>
0068 
0069 #include <vector>
0070 
0071 class G4NistMessenger;
0072 
0073 class G4NistManager
0074 {
0075  public:
0076   static G4NistManager* Instance();
0077   ~G4NistManager();
0078 
0079   // Get G4Element by index
0080   //
0081   inline G4Element* GetElement(size_t index) const;
0082 
0083   // Find or build G4Element by atomic number
0084   //
0085   inline G4Element* FindElement(G4int Z) const;
0086   inline G4Element* FindOrBuildElement(G4int Z, G4bool isotopes = true);
0087 
0088   // Find or build G4Element by symbol
0089   //
0090   inline G4Element* FindOrBuildElement(const G4String& symb, G4bool isotopes = true);
0091 
0092   // Get number of elements
0093   //
0094   inline size_t GetNumberOfElements() const;
0095 
0096   // Get atomic number by element symbol
0097   //
0098   inline G4int GetZ(const G4String& symb) const;
0099 
0100   // Get atomic weight by element symbol - mean mass in units of amu of
0101   // an atom with electron shell for the natural isotope composition
0102   //
0103   inline G4double GetAtomicMassAmu(const G4String& symb) const;
0104 
0105   // Get atomic weight in atomic units - mean mass in units of amu of an atom
0106   // with electron shell for the natural isotope composition
0107   //
0108   inline G4double GetAtomicMassAmu(G4int Z) const;
0109 
0110   // Get mass of isotope without electron shell in Geant4 energy units
0111   //
0112   inline G4double GetIsotopeMass(G4int Z, G4int N) const;
0113 
0114   // Get mass in Geant4 energy units of an atom of a particular isotope
0115   // with the electron shell
0116   //
0117   inline G4double GetAtomicMass(G4int Z, G4int N) const;
0118 
0119   // Get total ionisation energy of an atom
0120   //
0121   inline G4double GetTotalElectronBindingEnergy(G4int Z) const;
0122 
0123   // Get N for the first natural isotope
0124   //
0125   inline G4int GetNistFirstIsotopeN(G4int Z) const;
0126 
0127   // Get number of natural isotopes
0128   //
0129   inline G4int GetNumberOfNistIsotopes(G4int Z) const;
0130 
0131   // Get natural isotope abundance
0132   //
0133   inline G4double GetIsotopeAbundance(G4int Z, G4int N) const;
0134 
0135   // Print element by Z
0136   //
0137   inline void PrintElement(G4int Z) const;
0138 
0139   // Print element from internal DB by symbol, if "all" - print all elements
0140   //
0141   void PrintElement(const G4String&) const;
0142 
0143   // Print G4Element by name, if "all" - print all G4Elements
0144   //
0145   void PrintG4Element(const G4String&) const;
0146 
0147   // Access to the vector of Geant4 predefined element names
0148   //
0149   inline const std::vector<G4String>& GetNistElementNames() const;
0150 
0151   // Access mean ionisation energy for atoms (Z <= 98) by its index
0152   //
0153   inline G4double GetMeanIonisationEnergy(G4int Z) const;
0154 
0155   // Access nominal density by atomic number for simple materials and
0156   // by the index for other NIST materials
0157   //
0158   inline G4double GetNominalDensity(G4int Z) const;
0159 
0160   // Get G4Material by index
0161   //
0162   inline G4Material* GetMaterial(size_t index) const;
0163 
0164   // Find or build a G4Material by name, from the Geant4 dataBase
0165   //
0166   inline G4Material* FindMaterial(const G4String& name) const;
0167   inline G4Material* FindOrBuildMaterial(
0168     const G4String& name, G4bool isotopes = true, G4bool warning = false);
0169 
0170   // Find or build a simple material via atomic number
0171   //
0172   inline G4Material* FindSimpleMaterial(G4int Z) const;
0173   inline G4Material* FindOrBuildSimpleMaterial(G4int Z, G4bool warning = false);
0174 
0175   // Build G4Material with user defined name and density on base
0176   // of a material from Geant4 dataBase
0177   //
0178   G4Material* BuildMaterialWithNewDensity(const G4String& name, const G4String& basename,
0179     G4double density = 0.0, G4double temp = NTP_Temperature, G4double pres = CLHEP::STP_Pressure);
0180 
0181   // Construct a G4Material from scratch by atome count
0182   // temperature and pressure should be consistent with the density
0183   //
0184   inline G4Material* ConstructNewMaterial(const G4String& name, const std::vector<G4String>& elm,
0185     const std::vector<G4int>& nbAtoms, G4double dens, G4bool isotopes = true,
0186     G4State state = kStateSolid, G4double temp = NTP_Temperature,
0187     G4double pressure = CLHEP::STP_Pressure);
0188 
0189   // Construct a G4Material from scratch by fraction mass
0190   // temperature and pressure should be consistent with the density
0191   //
0192   inline G4Material* ConstructNewMaterial(const G4String& name, const std::vector<G4String>& elm,
0193     const std::vector<G4double>& weight, G4double dens, G4bool isotopes = true,
0194     G4State state = kStateSolid, G4double temp = NTP_Temperature,
0195     G4double pressure = CLHEP::STP_Pressure);
0196 
0197   // Construct a gas G4Material from scratch by atome count
0198   //
0199   inline G4Material* ConstructNewGasMaterial(const G4String& name, const G4String& nameNist,
0200     G4double temp, G4double pres, G4bool isotopes = true);
0201 
0202   // Construct an ideal gas G4Material from scratch by atom count
0203   //
0204   inline G4Material* ConstructNewIdealGasMaterial(const G4String& name,
0205     const std::vector<G4String>& elm, const std::vector<G4int>& nbAtoms, G4bool isotopes = true,
0206     G4double temp = NTP_Temperature, G4double pressure = CLHEP::STP_Pressure);
0207 
0208   // enable/disable density effect calculator by material name
0209   //
0210   void SetDensityEffectCalculatorFlag(const G4String&, G4bool);
0211 
0212   // enable/disable density effect calculator by material pointer
0213   //
0214   void SetDensityEffectCalculatorFlag(G4Material*, G4bool);
0215 
0216   // Get number of G4Materials
0217   //
0218   inline size_t GetNumberOfMaterials() const;
0219 
0220   inline G4int GetVerbose() const;
0221 
0222   void SetVerbose(G4int);
0223 
0224   // Print G4Material by name
0225   //
0226   void PrintG4Material(const G4String&) const;
0227 
0228   // Print predefined Geant4 materials:
0229   // "simple" - only pure materials in basic state (Z = 1, ..., 98)
0230   // "compound" - NIST compounds
0231   // "hep" - HEP materials and compounds
0232   // "bio" - bio-medical materials and compounds
0233   // "all" - all
0234   //
0235   inline void ListMaterials(const G4String&) const;
0236 
0237   // Access to the list of names of Geant4 predefined materials
0238   //
0239   inline const std::vector<G4String>& GetNistMaterialNames() const;
0240 
0241   // Fast computation of Z^1/3
0242   //
0243   inline G4double GetZ13(G4double Z) const;
0244   inline G4double GetZ13(G4int Z) const;
0245 
0246   // Fast computation of A^0.27 for natuaral abundances
0247   //
0248   inline G4double GetA27(G4int Z) const;
0249 
0250   // Fast computation of log(A)
0251   //
0252   inline G4double GetLOGZ(G4int Z) const;
0253   inline G4double GetLOGAMU(G4int Z) const;
0254 
0255   G4ICRU90StoppingData* GetICRU90StoppingData();
0256 
0257  private:
0258   G4NistManager();
0259 
0260   static G4NistManager* instance;
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 
0271   G4double POWERA27[101];
0272   G4double LOGAZ[101];
0273 
0274   size_t nElements;
0275   size_t nMaterials;
0276   G4int verbose;
0277 };
0278 
0279 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0280 
0281 inline size_t G4NistManager::GetNumberOfMaterials() const { return nMaterials; }
0282 
0283 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0284 
0285 inline G4Element* G4NistManager::GetElement(size_t index) const
0286 {
0287   const G4ElementTable* theElementTable = G4Element::GetElementTable();
0288   return (index < theElementTable->size()) ? (*theElementTable)[index] : nullptr;
0289 }
0290 
0291 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0292 
0293 inline G4Element* G4NistManager::FindElement(G4int Z) const { return elmBuilder->FindElement(Z); }
0294 
0295 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0296 
0297 inline G4Element* G4NistManager::FindOrBuildElement(G4int Z, G4bool isotopes)
0298 {
0299   return elmBuilder->FindOrBuildElement(Z, isotopes);
0300 }
0301 
0302 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0303 
0304 inline G4Element* G4NistManager::FindOrBuildElement(const G4String& symb, G4bool isotopes)
0305 {
0306   return elmBuilder->FindOrBuildElement(symb, isotopes);
0307 }
0308 
0309 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0310 
0311 inline size_t G4NistManager::GetNumberOfElements() const { return nElements; }
0312 
0313 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0314 
0315 inline G4int G4NistManager::GetZ(const G4String& symb) const { return elmBuilder->GetZ(symb); }
0316 
0317 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0318 
0319 inline G4double G4NistManager::GetAtomicMassAmu(const G4String& symb) const
0320 {
0321   return elmBuilder->GetAtomicMassAmu(symb);
0322 }
0323 
0324 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0325 
0326 inline G4double G4NistManager::GetAtomicMassAmu(G4int Z) const
0327 {
0328   return elmBuilder->GetAtomicMassAmu(Z);
0329 }
0330 
0331 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0332 
0333 inline G4double G4NistManager::GetIsotopeMass(G4int Z, G4int N) const
0334 {
0335   return elmBuilder->GetIsotopeMass(Z, N);
0336 }
0337 
0338 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0339 
0340 inline G4double G4NistManager::GetAtomicMass(G4int Z, G4int N) const
0341 {
0342   return elmBuilder->GetAtomicMass(Z, N);
0343 }
0344 
0345 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0346 
0347 inline G4double G4NistManager::GetTotalElectronBindingEnergy(G4int Z) const
0348 {
0349   return elmBuilder->GetTotalElectronBindingEnergy(Z);
0350 }
0351 
0352 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0353 
0354 inline G4double G4NistManager::GetIsotopeAbundance(G4int Z, G4int N) const
0355 {
0356   return elmBuilder->GetIsotopeAbundance(Z, N);
0357 }
0358 
0359 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0360 
0361 inline G4int G4NistManager::GetNistFirstIsotopeN(G4int Z) const
0362 {
0363   return elmBuilder->GetNistFirstIsotopeN(Z);
0364 }
0365 
0366 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0367 
0368 inline G4int G4NistManager::GetNumberOfNistIsotopes(G4int Z) const
0369 {
0370   return elmBuilder->GetNumberOfNistIsotopes(Z);
0371 }
0372 
0373 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0374 
0375 inline const std::vector<G4String>& G4NistManager::GetNistElementNames() const
0376 {
0377   return elmBuilder->GetElementNames();
0378 }
0379 
0380 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0381 
0382 inline G4double G4NistManager::GetMeanIonisationEnergy(G4int Z) const
0383 {
0384   return matBuilder->GetMeanIonisationEnergy(Z);
0385 }
0386 
0387 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0388 
0389 inline G4double G4NistManager::GetNominalDensity(G4int Z) const
0390 {
0391   return matBuilder->GetNominalDensity(Z);
0392 }
0393 
0394 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0395 
0396 inline void G4NistManager::PrintElement(G4int Z) const { elmBuilder->PrintElement(Z); }
0397 
0398 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0399 
0400 inline G4Material* G4NistManager::GetMaterial(size_t index) const
0401 {
0402   const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
0403   return (index < theMaterialTable->size()) ? (*theMaterialTable)[index] : nullptr;
0404 }
0405 
0406 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0407 
0408 inline G4int G4NistManager::GetVerbose() const { return verbose; }
0409 
0410 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0411 
0412 inline G4Material* G4NistManager::FindMaterial(const G4String& name) const
0413 {
0414   return matBuilder->FindMaterial(name);
0415 }
0416 
0417 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0418 
0419 inline G4Material* G4NistManager::FindOrBuildMaterial(const G4String& name, G4bool, G4bool warning)
0420 {
0421   return matBuilder->FindOrBuildMaterial(name, warning);
0422 }
0423 
0424 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0425 
0426 inline G4Material* G4NistManager::FindSimpleMaterial(G4int Z) const
0427 {
0428   return matBuilder->FindSimpleMaterial(Z);
0429 }
0430 
0431 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0432 
0433 inline G4Material* G4NistManager::FindOrBuildSimpleMaterial(G4int Z, G4bool warning)
0434 {
0435   return matBuilder->FindOrBuildSimpleMaterial(Z, warning);
0436 }
0437 
0438 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0439 
0440 inline G4Material* G4NistManager::ConstructNewMaterial(const G4String& name,
0441   const std::vector<G4String>& elm, const std::vector<G4int>& nbAtoms, G4double dens, G4bool,
0442   G4State state, G4double T, G4double P)
0443 
0444 {
0445   return matBuilder->ConstructNewMaterial(name, elm, nbAtoms, dens, state, T, P);
0446 }
0447 
0448 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0449 
0450 inline G4Material* G4NistManager::ConstructNewMaterial(const G4String& name,
0451   const std::vector<G4String>& elm, const std::vector<G4double>& w, G4double dens, G4bool,
0452   G4State state, G4double T, G4double P)
0453 {
0454   return matBuilder->ConstructNewMaterial(name, elm, w, dens, state, T, P);
0455 }
0456 
0457 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0458 
0459 inline G4Material* G4NistManager::ConstructNewGasMaterial(
0460   const G4String& name, const G4String& nameNist, G4double temp, G4double pres, G4bool)
0461 {
0462   return matBuilder->ConstructNewGasMaterial(name, nameNist, temp, pres);
0463 }
0464 
0465 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0466 
0467 inline G4Material* G4NistManager::ConstructNewIdealGasMaterial(const G4String& name,
0468   const std::vector<G4String>& elm, const std::vector<G4int>& nbAtoms, G4bool, G4double T,
0469   G4double P)
0470 {
0471   return matBuilder->ConstructNewIdealGasMaterial(name, elm, nbAtoms, T, P);
0472 }
0473 
0474 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0475 
0476 inline void G4NistManager::ListMaterials(const G4String& list) const
0477 {
0478   matBuilder->ListMaterials(list);
0479 }
0480 
0481 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0482 
0483 inline const std::vector<G4String>& G4NistManager::GetNistMaterialNames() const
0484 {
0485   return matBuilder->GetMaterialNames();
0486 }
0487 
0488 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0489 
0490 inline G4double G4NistManager::GetZ13(G4double A) const { return g4pow->A13(A); }
0491 
0492 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0493 
0494 inline G4double G4NistManager::GetZ13(G4int Z) const { return g4pow->Z13(Z); }
0495 
0496 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0497 
0498 inline G4double G4NistManager::GetA27(G4int Z) const
0499 {
0500   return (0 <= Z && Z < 101) ? POWERA27[Z] : g4pow->powZ(Z, 0.27);
0501 }
0502 
0503 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0504 
0505 inline G4double G4NistManager::GetLOGZ(G4int Z) const { return g4pow->logZ(Z); }
0506 
0507 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0508 
0509 inline G4double G4NistManager::GetLOGAMU(G4int Z) const
0510 {
0511   return (0 <= Z && Z < 101) ? LOGAZ[Z] : 0.0;
0512 }
0513 
0514 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0515 
0516 #endif