BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
BDSMaterials.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2022.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef BDSMATERIALS_H
20#define BDSMATERIALS_H
21
22#include <list>
23#include <map>
24#include <vector>
25
26#include "globals.hh"
27#include "G4Material.hh" // for G4State
28
29class G4Element;
30class G4MaterialPropertiesTable;
31
38{
39public:
40
42 static BDSMaterials* Instance();
44
46 void PrepareRequiredMaterials(G4bool verbose = false);
47
49 void ListMaterials()const;
50
52 G4Material* GetMaterial(G4String material) const;
54 G4Element* GetElement(const G4String& symbol) const;
55
60 void CacheMaterialsFromGDML(const std::map<G4String, G4Material*>& materialsGDML,
61 const G4String& prepend,
62 G4bool prependWasUsed);
63
64protected:
67 void AddMaterial(G4Material* material, G4String name);
69 void AddExistingMaterialAlias(const G4String &existingMaterialName,
70 G4String alias);
71
80 void AddMaterial(G4String name,
81 G4double Z,
82 G4double A,
83 G4double density,
84 G4State state,
85 G4double temperature,
86 G4double pressure);
87
96 template <typename Type>
97 void AddMaterial(G4String name,
98 G4double density,
99 G4State state,
100 G4double temperature,
101 G4double pressure,
102 const std::list<G4String>& components,
103 const std::list<Type>& componentFractions);
104
106 G4Element* CheckElement(const G4String& symbol) const;
107
108private:
111
113 void DefineMetals();
116 void DefineScintillators();
117 void DefineLHCComponents();
118 void DefineLiquids();
119 void DefineGases();
120 void DefinePlasmas();
121 void DefineVacuums();
123
125 void AddElement(G4Element* element, const G4String& symbol);
126 void AddElement(const G4String& name, const G4String& symbol, G4double itsZ, G4double itsA);
128
130 void DensityCheck(G4double density,
131 const G4String& materialName) const;
132
134 void PrintBasicMaterialMassFraction(G4Material* material) const;
135
137 std::map<G4String, G4Material*> materials;
139 std::map<G4String, G4Material*> aliases;
142 std::map<G4String, G4int> possibleDuplicates;
144 std::map<G4String,G4Element*> elements;
146 std::vector<G4MaterialPropertiesTable*> propertiesTables;
148 G4MaterialPropertiesTable* CreatePropertiesTable();
149};
150
151#endif
A class for all material definitions known to BDSIM. Additional materials can be added in the parser ...
Definition: BDSMaterials.hh:38
void DefineMetals()
Methods called by constructor.
Definition: BDSMaterials.cc:66
void DefineLHCComponents()
Methods called by constructor.
void DefineGases()
Methods called by constructor.
void DefineNonMetalSolids()
Methods called by constructor.
void DensityCheck(G4double density, const G4String &materialName) const
Print warning if density suspiciously high. Should be in g/cm3 in G4 units already.
void DefineScintillators()
Methods called by constructor.
void DefineVacuums()
Methods called by constructor.
static BDSMaterials * Instance()
Singleton pattern access.
Definition: BDSMaterials.cc:38
G4MaterialPropertiesTable * CreatePropertiesTable()
Create new properties table and store in vector.
std::map< G4String, G4Material * > aliases
Maps of other names to existing materials. To avoid double deletion. Also in lower case.
static BDSMaterials * instance
Singleton instance.
std::map< G4String, G4Material * > materials
<ap of materials, convention name lowercase.
std::map< G4String, G4Element * > elements
Map of elements, no lowercase convention.
void DefineLiquids()
Methods called by constructor.
void CacheMaterialsFromGDML(const std::map< G4String, G4Material * > &materialsGDML, const G4String &prepend, G4bool prependWasUsed)
G4Material * GetMaterial(G4String material) const
Get material by name.
void PrepareRequiredMaterials(G4bool verbose=false)
converts parser material list
void ListMaterials() const
output available materials
void DefinePlasmas()
Methods called by constructor.
void AddElement(G4Element *element, const G4String &symbol)
Add a G4Element.
void AddMaterial(G4Material *material, G4String name)
Add G4Material.
void DefineSuperconductors()
Methods called by constructor.
G4Element * CheckElement(const G4String &symbol) const
Return element if defined (nullptr if not)
void AddExistingMaterialAlias(const G4String &existingMaterialName, G4String alias)
Add alias to a material.
std::map< G4String, G4int > possibleDuplicates
G4Element * GetElement(const G4String &symbol) const
Get element by name.
void PrintBasicMaterialMassFraction(G4Material *material) const
Print mass fractions of consituents of a given material.
std::vector< G4MaterialPropertiesTable * > propertiesTables
Material tables for storing pointers.