ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4NistMaterialBuilder.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4NistMaterialBuilder.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 #ifndef G4NistMaterialBuilder_h
28 #define G4NistMaterialBuilder_h 1
29 
30 //---------------------------------------------------------------------------
31 //
32 // ClassName: G4NistMaterialBuilder
33 //
34 // Description: Utility class to hold and manipulate G4Materials
35 //
36 // Author: V.Ivanchenko 21.11.2004
37 //
38 // Modifications:
39 // 31.10.05 Add chemical effect and gas properties (V.Ivanchenko)
40 // 27.02.06 V.Ivanchneko add ConstructNewGasMaterial
41 // 11.05.06 V.Ivanchneko add warning flag to FindOrBuildMaterial method
42 // 27.07.06 V.Ivanchneko set defaul warning=true for FindOrBuildMaterial
43 // 27.07.07 V.Ivanchneko add matIndex vector to control built materials
44 // 28.07.07 V.Ivanchneko add BuildMaterial method using Nist index
45 // 29.04.10 V.Ivanchneko add GetMeanIonisationEnergy method using Nist index
46 // 09.02.12 P.Gumplinger add ConstructNewIdealGasMaterial
47 //
48 //----------------------------------------------------------------------------
49 //
50 // Class Description:
51 //
52 // Element data from the NIST DB on Atomic Weights and Isotope Compositions
53 // http://physics.nist.gov/PhysRefData/Compositions/index.html
54 //
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
58 #include <vector>
60 
61 #include "globals.hh"
62 #include "G4Material.hh"
63 #include "G4Threading.hh"
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
68 
70 {
71 public:
72 
74 
76 
77  // Find or build a G4Material by name, from dataBase
78  //
79  inline G4Material* FindMaterial (const G4String& name) const;
81  G4bool isotopes=true,
82  G4bool warning =true);
83 
84 
85  // Find or build a simple material via atomic number
86  //
87  inline G4Material* FindSimpleMaterial(G4int Z) const;
89 
90  // construct a G4Material from scratch by atome count
91  //
93  const std::vector<G4String>& elm,
94  const std::vector<G4int>& nbAtoms,
95  G4double dens,
96  G4bool isotopes = true,
97  G4State state = kStateSolid,
98  G4double temp = NTP_Temperature,
99  G4double pressure = CLHEP::STP_Pressure);
100 
101  // construct a G4Material from scratch by fraction mass
102  //
104  const std::vector<G4String>& elm,
105  const std::vector<G4double>& weight,
106  G4double dens,
107  G4bool isotopes = true,
108  G4State state = kStateSolid,
109  G4double temp = NTP_Temperature,
110  G4double pressure = CLHEP::STP_Pressure);
111 
112 
113  // construct a gas G4Material from scratch by atome count
114  //
116  const G4String& nameDB,
117  G4double temp, G4double pres,
118  G4bool isotopes = true);
119 
120  // Construct an ideal gas G4Material from scratch by atom count
121  //
123  const std::vector<G4String>& elm,
124  const std::vector<G4int>& nbAtoms,
125  G4bool isotopes = true,
126  G4double temp = NTP_Temperature,
127  G4double pressure = CLHEP::STP_Pressure);
128 
129  // verbosity level defined by G4NistManager
130  //
131  void SetVerbose(G4int val);
132 
133  // cout predefined materials:
134  // "simple" - only pure materials in basic state (Z = 1, ..., 98)
135  // "compound" - NIST compounds
136  // "hep" - HEP materials and compounds
137  // "biochemical" - bio-chemical materials
138  // "all" - all
139  //
140  void ListMaterials(const G4String&) const;
141 
142  // cout lists of predefined materials
143  //
144  void ListNistSimpleMaterials() const;
145  void ListNistCompoundMaterials() const;
146  void ListHepMaterials() const;
147  void ListSpaceMaterials() const;
148  void ListBioChemicalMaterials() const;
149 
150  // access to the list of names of Geant4 predefined materials
151  //
152  const std::vector<G4String>& GetMaterialNames() const;
153 
154  // access to the NIST mean ionisation potentials and nominal densities
155  //
156  inline G4double GetMeanIonisationEnergy(G4int index) const;
157  inline G4double GetNominalDensity(G4int index) const;
158 
159 private:
160 
161  void Initialise();
162  void NistSimpleMaterials();
163  void NistCompoundMaterials();
164  void NistCompoundMaterials2();
165  void HepAndNuclearMaterials();
166  void SpaceMaterials();
167  void BioChemicalMaterials();
168 
169  // add parameters of material from NIST DB to internal vectors
170  // density in g/cm3, mean ionisation potential in eV
171  //
172  void AddMaterial(const G4String& nameMat, G4double dens, G4int Z=0,
173  G4double pot=0.0, G4int ncomp=1,
174  G4State=kStateSolid, G4bool stp = true);
175 
176  void AddGas(const G4String& nameMat, G4double T, G4double P);
177 
180 
181  void AddElementByWeightFraction(const G4String& name, G4double);
182  void AddElementByAtomCount (const G4String& name, G4int);
183 
184  // build a G4Material from dataBase
185  G4Material* BuildNistMaterial(const G4String& matname, G4bool warning);
187 
188  void DumpElm(G4int) const;
189  void DumpMix(G4int) const;
190 
191 private:
192 
194 
203 
204  std::vector<G4String> names;
205  std::vector<G4String> chFormulas;
206 
207  std::vector<G4double> densities;
208  std::vector<G4double> ionPotentials;
209  std::vector<G4State> states;
210  std::vector<G4double> fractions;
211  std::vector<G4bool> atomCount;
212  std::vector<G4int> components;
213  std::vector<G4int> indexes;
214  std::vector<G4int> elements;
215  std::vector<G4int> matIndex;
216  std::vector<G4bool> STP;
217 
218  std::vector<G4int> idxGas;
219  std::vector<G4double> gasTemperature;
220  std::vector<G4double> gasPressure;
221 
222 #ifdef G4MULTITHREADED
223  static G4Mutex nistMaterialMutex;
224 #endif
225 
226 };
227 
228 inline const std::vector<G4String>&
230 {
231  return names;
232 }
233 
234 inline G4double
236 {
237  return (index >= 0 && index < nMaterials) ? ionPotentials[index] : 10.0*index;
238 }
239 
240 inline G4double
242 {
243  return (index >= 0 && index < nMaterials) ? densities[index] : 0.0;
244 }
245 
246 inline G4Material*
248 {
249  const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
250  size_t nmat = theMaterialTable->size();
251  G4Material* ptr = nullptr;
252  for(size_t i=0; i<nmat; ++i) {
253  if(name == ((*theMaterialTable)[i])->GetName()) {
254  ptr = (*theMaterialTable)[i];
255  break;
256  }
257  }
258  return ptr;
259 }
260 
261 inline G4Material*
263 {
264  return (Z>0 && Z<nElementary) ? FindMaterial(names[Z]) : nullptr;
265 }
266 
267 #endif