Geant4  10.01.p02
G4Material.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 // $Id: G4Material.hh 88957 2015-03-16 16:46:05Z gcosmo $
28 //
29 
30 //---------------------------------------------------------------------------
31 //
32 // ClassName: G4Material
33 //
34 // Description: Contains material properties
35 //
36 // Class description:
37 //
38 // Is used to define the material composition of Geant4 volumes.
39 // A G4Material is always made of G4Elements. It should has the name,
40 // the list of G4Elements, material density, material state, temperature,
41 // pressure. Other parameters are optional and may be set by the user code
42 // or computed at initialisation.
43 //
44 // There is several ways to construct G4Material:
45 // - from single element;
46 // - from a list of components (elements or other materials);
47 // - from internal Geant4 database of materials
48 //
49 // A collection of constituent Elements/Materials should be defined
50 // with specified weights by fractional mass or atom counts (only for Elements).
51 //
52 // Quantities, with physical meaning or not, which are constant in a given
53 // material are computed and stored here as Derived data members.
54 //
55 // The class contains as a private static member the Table of defined
56 // materials (an ordered vector of materials).
57 //
58 // It is strongly not recommended to delete materials in user code.
59 // All materials will be deleted automatically at the end of Geant4 session.
60 //
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
64 // 10-07-96, new data members added by L.Urban
65 // 12-12-96, new data members added by L.Urban
66 // 20-01-97, aesthetic rearrangement. RadLength calculation modified
67 // Data members Zeff and Aeff REMOVED (i.e. passed to the Elements).
68 // (local definition of Zeff in DensityEffect and FluctModel...)
69 // Vacuum defined as a G4State. Mixture flag removed, M.Maire
70 // 29-01-97, State=Vacuum automatically set density=0 in the contructors.
71 // Subsequent protections have been put in the calculation of
72 // MeanExcEnergy, ShellCorrectionVector, DensityEffect, M.Maire
73 // 20-03-97, corrected initialization of pointers, M.Maire
74 // 10-06-97, new data member added by V.Grichine (fSandiaPhotoAbsCof)
75 // 27-06-97, new function GetElement(int), M.Maire
76 // 24-02-98, fFractionVector become fMassFractionVector
77 // 28-05-98, kState=kVacuum removed:
78 // The vacuum is an ordinary gas vith very low density, M.Maire
79 // 12-06-98, new method AddMaterial() allowing mixture of materials, M.Maire
80 // 09-07-98, Ionisation parameters removed from the class, M.Maire
81 // 04-08-98, new method GetMaterial(materialName), M.Maire
82 // 05-10-98, change name: NumDensity -> NbOfAtomsPerVolume
83 // 18-11-98, SandiaTable interface modified.
84 // 19-07-99, new data member (chemicalFormula) added by V.Ivanchenko
85 // 12-03-01, G4bool fImplicitElement (mma)
86 // 30-03-01, suppression of the warning message in GetMaterial
87 // 17-07-01, migration to STL. M. Verderi.
88 // 14-09-01, Suppression of the data member fIndexInTable
89 // 31-10-01, new function SetChemicalFormula() (mma)
90 // 26-02-02, fIndexInTable renewed
91 // 06-08-02, remove constructors with ChemicalFormula (mma)
92 // 15-11-05, GetMaterial(materialName, G4bool warning=true)
93 // 13-04-12, std::map<G4Material*,G4double> fMatComponents (mma)
94 // 21-04-12, fMassOfMolecule (mma)
95 
96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
97 
98 #ifndef G4MATERIAL_HH
99 #define G4MATERIAL_HH 1
100 
101 #include <vector>
102 #include <map>
103 #include <CLHEP/Units/PhysicalConstants.h>
104 
105 #include "globals.hh"
106 #include "G4ios.hh"
107 #include "G4Element.hh"
109 #include "G4IonisParamMat.hh"
110 #include "G4SandiaTable.hh"
111 #include "G4ElementVector.hh"
112 #include "G4MaterialTable.hh"
113 
115 
116 static const G4double NTP_Temperature = 293.15;
117 
118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
119 
121 {
122 public: // with description
123  //
124  // Constructor to create a material from single element
125  //
126  G4Material(const G4String& name, //its name
127  G4double z, //atomic number
128  G4double a, //mass of mole
129  G4double density, //density
130  G4State state = kStateUndefined, //solid,gas
131  G4double temp = NTP_Temperature, //temperature
132  G4double pressure = CLHEP::STP_Pressure); //pressure
133 
134  //
135  // Constructor to create a material from a combination of elements
136  // and/or materials subsequently added via AddElement and/or AddMaterial
137  //
138  G4Material(const G4String& name, //its name
139  G4double density, //density
140  G4int nComponents, //nbOfComponents
141  G4State state = kStateUndefined, //solid,gas
142  G4double temp = NTP_Temperature, //temperature
143  G4double pressure = CLHEP::STP_Pressure); //pressure
144 
145  //
146  // Constructor to create a material from the base material
147  //
148  G4Material(const G4String& name, //its name
149  G4double density, //density
150  const G4Material* baseMaterial, //base material
151  G4State state = kStateUndefined, //solid,gas
152  G4double temp = NTP_Temperature, //temperature
153  G4double pressure = CLHEP::STP_Pressure); //pressure
154 
155  //
156  // Add an element, giving number of atoms
157  //
158  void AddElement(G4Element* element, //the element
159  G4int nAtoms); //nb of atoms in
160  // a molecule
161  //
162  // Add an element or material, giving fraction of mass
163  //
164  void AddElement (G4Element* element , //the element
165  G4double fraction); //fractionOfMass
166 
167  void AddMaterial(G4Material* material, //the material
168  G4double fraction); //fractionOfMass
169 
170 
171  virtual ~G4Material();
172 
173  inline void SetChemicalFormula (const G4String& chF) {fChemicalFormula=chF;}
174 
175  //
176  // retrieval methods
177  //
178  inline const G4String& GetName() const {return fName;}
179  inline const G4String& GetChemicalFormula() const {return fChemicalFormula;}
180  inline G4double GetDensity() const {return fDensity;}
181  inline G4State GetState() const {return fState;}
182  inline G4double GetTemperature() const {return fTemp;}
183  inline G4double GetPressure() const {return fPressure;}
184 
185  //number of elements constituing this material:
186  inline size_t GetNumberOfElements() const {return fNumberOfElements;}
187 
188  //vector of pointers to elements constituing this material:
189  inline const
191 
192  //vector of fractional mass of each element:
193  inline const
195 
196  //vector of atom count of each element:
197  inline const
198  G4int* GetAtomsVector() const {return fAtomsVector;}
199 
200  //return a pointer to an element, given its index in the material:
201  inline const
202  G4Element* GetElement(G4int iel) const {return (*theElementVector)[iel];}
203 
204  //vector of nb of atoms per volume of each element in this material:
205  inline const
207  //total number of atoms per volume:
208  inline
210  //total number of electrons per volume:
211  inline
213 
214  //obsolete names (5-10-98) see the 2 functions above
215  inline const
218 
219  // Radiation length:
220  inline G4double GetRadlen() const {return fRadlen;}
221 
222  // Nuclear interaction length
224 
225  // ionisation parameters:
226  inline G4IonisParamMat* GetIonisation() const {return fIonisation;}
227 
228  // Sandia table:
229  inline G4SandiaTable* GetSandiaTable() const {return fSandiaTable;}
230 
231  // Base material:
232  inline
233  const G4Material* GetBaseMaterial() const {return fBaseMaterial;}
234 
235  // material components:
236  inline
237  std::map<G4Material*,G4double> GetMatComponents() const
238  {return fMatComponents;}
239 
240  //for chemical compound
241  inline
243 
244  //meaningful only for single material:
245  G4double GetZ() const;
246  G4double GetA() const;
247 
248  //the MaterialPropertiesTable (if any) attached to this material:
250  {fMaterialPropertiesTable = anMPT;}
251 
253  {return fMaterialPropertiesTable;}
254 
255  //the (static) Table of Materials:
256  //
258 
259  static size_t GetNumberOfMaterials();
260 
261  //the index of this material in the Table:
262  inline size_t GetIndex() const {return fIndexInTable;}
263 
264  //return pointer to a material, given its name:
265  static G4Material* GetMaterial(const G4String& name, G4bool warning=true);
266 
267  //
268  //printing methods
269  //
270  friend std::ostream& operator<<(std::ostream&, const G4Material*);
271  friend std::ostream& operator<<(std::ostream&, const G4Material&);
272  friend std::ostream& operator<<(std::ostream&, G4MaterialTable);
273 
274  // operators
275  G4int operator==(const G4Material&) const;
276  G4int operator!=(const G4Material&) const;
277  G4Material(__void__&);
278  // Fake default constructor for usage restricted to direct object
279  // persistency for clients requiring preallocation of memory for
280  // persistifiable objects.
281 
282  inline void SetName (const G4String& name) {fName=name;}
283 
284 private:
285 
286  G4Material(const G4Material&);
287  const G4Material& operator=(const G4Material&);
288 
289  void InitializePointers();
290 
291  // Header routine for all derived quantities
293 
294  // Compute Radiation length
295  void ComputeRadiationLength();
296 
297  // Compute Nuclear interaction length
299 
300  // Copy pointers of base material
302 
303 private:
304 
305  //
306  // Basic data members ( To define a material)
307  //
308  G4String fName; // Material name
309  G4String fChemicalFormula; // Material chemical formula
310  G4double fDensity; // Material density
311 
312  G4State fState; // Material state (determined
313  // internally based on density)
314  G4double fTemp; // Temperature (defaults: STP)
315  G4double fPressure; // Pressure (defaults: STP)
316 
317  G4int maxNbComponents; // totalNbOfComponentsInTheMaterial
318  G4int fArrayLength; // the length of fAtomsVector
319  G4int fNumberOfComponents; // Nb of components declared so far
320 
321  G4int fNumberOfElements; // Nb of Elements in the material
322  G4ElementVector* theElementVector; // vector of constituent Elements
323  G4bool fImplicitElement; // implicit Element created by this?
324  G4double* fMassFractionVector; // composition by fractional mass
325  G4int* fAtomsVector; // composition by atom count
326 
328 
329  static
330  G4MaterialTable theMaterialTable; // the material table
331  size_t fIndexInTable; // the position in the table
332 
333  //
334  // Derived data members (computed from the basic data members)
335  //
336  // some general atomic properties
337 
338  G4double* VecNbOfAtomsPerVolume; // vector of nb of atoms per volume
339  G4double TotNbOfAtomsPerVolume; // total nb of atoms per volume
340  G4double TotNbOfElectPerVolume; // total nb of electrons per volume
341  G4double fRadlen; // Radiation length
342  G4double fNuclInterLen; // Nuclear interaction length
343 
344  G4IonisParamMat* fIonisation; // ionisation parameters
345  G4SandiaTable* fSandiaTable; // Sandia table
346 
347  // utilities
348  //
349  const G4Material* fBaseMaterial; // Pointer to the base material
350  G4double fMassOfMolecule; // for materials built by atoms count
351  std::map<G4Material*,G4double> fMatComponents; // for composites built via
352  // AddMaterial()
353 };
354 
355 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
356 
357 #endif
G4double GetPressure() const
Definition: G4Material.hh:183
static G4MaterialTable theMaterialTable
Definition: G4Material.hh:330
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:226
void InitializePointers()
Definition: G4Material.cc:259
G4double GetZ() const
Definition: G4Material.cc:632
G4int operator==(const G4Material &) const
Definition: G4Material.cc:709
void SetChemicalFormula(const G4String &chF)
Definition: G4Material.hh:173
void SetName(const G4String &name)
Definition: G4Material.hh:282
G4double GetTotNbOfElectPerVolume() const
Definition: G4Material.hh:212
std::vector< G4Element * > G4ElementVector
void CopyPointersOfBaseMaterial()
Definition: G4Material.cc:332
G4int fNumberOfElements
Definition: G4Material.hh:321
const G4Material * fBaseMaterial
Definition: G4Material.hh:349
void AddMaterial(G4Material *material, G4double fraction)
Definition: G4Material.cc:469
G4State
Definition: G4Material.hh:114
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:603
G4double z
Definition: TRTMaterials.hh:39
size_t GetIndex() const
Definition: G4Material.hh:262
const G4String & GetChemicalFormula() const
Definition: G4Material.hh:179
G4double fMassOfMolecule
Definition: G4Material.hh:350
G4String name
Definition: TRTMaterials.hh:40
void SetMaterialPropertiesTable(G4MaterialPropertiesTable *anMPT)
Definition: G4Material.hh:249
const G4String & GetName() const
Definition: G4Material.hh:178
G4ElementVector * theElementVector
Definition: G4Material.hh:322
size_t fIndexInTable
Definition: G4Material.hh:331
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:588
std::vector< G4Material * > G4MaterialTable
G4double GetDensity() const
Definition: G4Material.hh:180
G4int fNumberOfComponents
Definition: G4Material.hh:319
const G4Material & operator=(const G4Material &)
G4double a
Definition: TRTMaterials.hh:39
G4double fDensity
Definition: G4Material.hh:310
G4IonisParamMat * fIonisation
Definition: G4Material.hh:344
G4int nComponents
Definition: TRTMaterials.hh:41
void ComputeDerivedQuantities()
Definition: G4Material.cc:302
G4double * fMassFractionVector
Definition: G4Material.hh:324
const G4Element * GetElement(G4int iel) const
Definition: G4Material.hh:202
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
int G4int
Definition: G4Types.hh:78
G4int maxNbComponents
Definition: G4Material.hh:317
G4bool fImplicitElement
Definition: G4Material.hh:323
G4SandiaTable * GetSandiaTable() const
Definition: G4Material.hh:229
G4SandiaTable * fSandiaTable
Definition: G4Material.hh:345
G4double density
Definition: TRTMaterials.hh:39
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:206
friend std::ostream & operator<<(std::ostream &, const G4Material *)
Definition: G4Material.cc:723
G4double TotNbOfAtomsPerVolume
Definition: G4Material.hh:339
G4double GetElectronDensity() const
Definition: G4Material.hh:217
bool G4bool
Definition: G4Types.hh:79
G4MaterialPropertiesTable * fMaterialPropertiesTable
Definition: G4Material.hh:327
G4int * fAtomsVector
Definition: G4Material.hh:325
G4double fRadlen
Definition: G4Material.hh:341
G4double fNuclInterLen
Definition: G4Material.hh:342
static size_t GetNumberOfMaterials()
Definition: G4Material.cc:595
G4double GetRadlen() const
Definition: G4Material.hh:220
const G4double * GetAtomicNumDensityVector() const
Definition: G4Material.hh:216
G4Material(const G4String &name, G4double z, G4double a, G4double density, G4State state=kStateUndefined, G4double temp=NTP_Temperature, G4double pressure=CLHEP::STP_Pressure)
Definition: G4Material.cc:88
G4int fArrayLength
Definition: G4Material.hh:318
G4double GetA() const
Definition: G4Material.cc:645
G4String fChemicalFormula
Definition: G4Material.hh:309
G4double GetTotNbOfAtomsPerVolume() const
Definition: G4Material.hh:209
G4int operator!=(const G4Material &) const
Definition: G4Material.cc:716
void ComputeNuclearInterLength()
Definition: G4Material.cc:569
G4MaterialPropertiesTable * GetMaterialPropertiesTable() const
Definition: G4Material.hh:252
G4double GetMassOfMolecule() const
Definition: G4Material.hh:242
G4double TotNbOfElectPerVolume
Definition: G4Material.hh:340
G4State fState
Definition: G4Material.hh:312
const G4Material * GetBaseMaterial() const
Definition: G4Material.hh:233
const G4int * GetAtomsVector() const
Definition: G4Material.hh:198
std::map< G4Material *, G4double > GetMatComponents() const
Definition: G4Material.hh:237
static const G4double NTP_Temperature
Definition: G4Material.hh:116
G4double GetTemperature() const
Definition: G4Material.hh:182
G4double fTemp
Definition: G4Material.hh:314
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:364
size_t GetNumberOfElements() const
Definition: G4Material.hh:186
void ComputeRadiationLength()
Definition: G4Material.cc:558
G4State GetState() const
Definition: G4Material.hh:181
double G4double
Definition: G4Types.hh:76
G4double fPressure
Definition: G4Material.hh:315
std::map< G4Material *, G4double > fMatComponents
Definition: G4Material.hh:351
const G4double * GetFractionVector() const
Definition: G4Material.hh:194
virtual ~G4Material()
Definition: G4Material.cc:240
G4double * VecNbOfAtomsPerVolume
Definition: G4Material.hh:338
G4double GetNuclearInterLength() const
Definition: G4Material.hh:223
G4String fName
Definition: G4Material.hh:308