Belle II Software development
|
Thin wrapper around the Geant4 Material system. More...
#include <Materials.h>
Public Types | |
enum | { CacheSize = 100 } |
Public Member Functions | |
~Materials () | |
Destructor for objects that I have created. | |
G4Material * | getMaterial (const std::string &name, bool showErrors=true) |
Get a pointer to the G4Material with the given name. | |
G4Element * | getElement (const std::string &name) |
Find given chemical element. | |
G4Material * | createMaterial (const gearbox::Interface ¶meters) |
Create a material from the parameters specified by parameters. | |
G4Material * | createMaterial (const GeoMaterial ¶meters) |
Create Geant4 Material from Material definition in DB. | |
G4OpticalSurface * | createOpticalSurface (const gearbox::Interface ¶meters) |
Create an optical surface from parameters, will abort on error. | |
G4OpticalSurface * | createOpticalSurface (const GeoOpticalSurface &surface) |
Create an optical surface from Surface definition in DB. | |
GeoMaterial | createMaterialConfig (const gearbox::Interface ¶meters) |
Create Material from XML description. | |
GeoOpticalSurface | createOpticalSurfaceConfig (const gearbox::Interface ¶meters) |
Create Optical Surface Configuration from XML description. | |
void | clear () |
Clear all existing materials. | |
void | setDensityScale (double scale) |
Set the density scale to the given value. | |
void | resetDensityScale () |
Disable density scaling. | |
std::set< std::string > | getDensityScaleIgnoredMaterials () const |
get the set of material names which will not be scaled in any way | |
void | setDensityScaleIgnoredMaterials (const std::set< std::string > &ignored) |
set the set of material names which will not be scaled in any way | |
Static Public Member Functions | |
static Materials & | getInstance () |
Get a reference to the singleton instance. | |
static G4Material * | get (const std::string &name) |
Find given material. | |
Protected Member Functions | |
Materials () | |
Singleton: hide constructor. | |
Materials (const Materials &)=delete | |
Singleton: hide copy constructor. | |
void | operator= (const Materials &)=delete |
Singleton: hide assignment operator. | |
G4Material * | findMaterial (const std::string &name) |
find an existing material by name | |
G4MaterialPropertiesTable * | createProperties (const std::vector< GeoMaterialProperty > &props) |
Create a properties table from a vector of properties. | |
void | initBuilders () |
Initialize Nist Builder instances. | |
Protected Attributes | |
MRUCache< std::string, G4Material * > | m_materialCache |
Cache for already searched Materials. | |
std::vector< G4MaterialPropertiesTable * > | m_PropTables |
Vector of created G4MaterialProperties objects. | |
G4NistElementBuilder * | m_nistElementBuilder {nullptr} |
G4NistElementBuilder instance to create chemical elements with correct natural abundances from NIST database. | |
G4NistMaterialBuilder * | m_nistMaterialBuilder {nullptr} |
G4NistMaterialBuilder to create predefined materials from NIST database. | |
std::optional< double > | m_densityScale |
If set we scale all densities by a given factor. | |
std::set< std::string > | m_ignoreScaling {"G4_AIR", "Air", "Vacuum"} |
Names of materials we don't want to scale. | |
Thin wrapper around the Geant4 Material system.
This class serves the purpose to simplify the access to the Geant4 materials using the G4NistManager and to directly create materials from a Gearbox parameter set. Since Geant4 keeps track of all defined materials, this class is also able to find Materials created directly by the user.
Care should be taken when a Material is created with a name that already exists. In that case it may be possible that we return the wrong material since the first material with the given name will be returned.
Definition at line 48 of file Materials.h.
anonymous enum |
Definition at line 50 of file Materials.h.
~Materials | ( | ) |
Destructor for objects that I have created.
Definition at line 91 of file Materials.cc.
|
inlineprotected |
Singleton: hide constructor.
Definition at line 152 of file Materials.h.
void clear | ( | ) |
Clear all existing materials.
Definition at line 384 of file Materials.cc.
G4Material * createMaterial | ( | const gearbox::Interface & | parameters | ) |
Create a material from the parameters specified by parameters.
parameters | Material properties |
Definition at line 158 of file Materials.cc.
G4Material * createMaterial | ( | const GeoMaterial & | parameters | ) |
Create Geant4 Material from Material definition in DB.
parameters | Material properties |
Definition at line 164 of file Materials.cc.
GeoMaterial createMaterialConfig | ( | const gearbox::Interface & | parameters | ) |
Create Material from XML description.
parameters | GearDir pointing to the Material description |
Definition at line 233 of file Materials.cc.
G4OpticalSurface * createOpticalSurface | ( | const gearbox::Interface & | parameters | ) |
Create an optical surface from parameters, will abort on error.
parameters | Optical surface definition |
Definition at line 295 of file Materials.cc.
G4OpticalSurface * createOpticalSurface | ( | const GeoOpticalSurface & | surface | ) |
Create an optical surface from Surface definition in DB.
surface | Optical surface definition |
Definition at line 301 of file Materials.cc.
GeoOpticalSurface createOpticalSurfaceConfig | ( | const gearbox::Interface & | parameters | ) |
Create Optical Surface Configuration from XML description.
parameters | GearDir pointing to the Optical Surface description |
Definition at line 313 of file Materials.cc.
|
protected |
Create a properties table from a vector of properties.
Return 0 if the vector is empty
Definition at line 69 of file Materials.cc.
|
protected |
find an existing material by name
Definition at line 105 of file Materials.cc.
|
inlinestatic |
Find given material.
Shorthand for Materials::getInstance().getMaterial()
name | of the material to find |
Definition at line 63 of file Materials.h.
|
inline |
get the set of material names which will not be scaled in any way
Definition at line 147 of file Materials.h.
G4Element * getElement | ( | const std::string & | name | ) |
Find given chemical element.
name | Name of the Element, e.g. Si, Al, He |
Definition at line 150 of file Materials.cc.
|
static |
Get a reference to the singleton instance.
Definition at line 85 of file Materials.cc.
G4Material * getMaterial | ( | const std::string & | name, |
bool | showErrors = true |
||
) |
Get a pointer to the G4Material with the given name.
If the given name cannot be found we also try to find it in the Nist database by prepending the name with G4_ and trying in with given case and all uppercase since single element materials are defined as e.g. G4_Si, G4_Al and other materials are defined all uppercase, e.g. G4_AIR, G4_TEFLON.
Found materials are cached internaly using an MRU cache so repitive access to materials should be O(1) in most cases
name | Name of the material to be found |
showErrors | If false don't show any errors, just return nullptr if the material cannot be found |
Definition at line 127 of file Materials.cc.
|
protected |
Initialize Nist Builder instances.
Definition at line 96 of file Materials.cc.
|
inline |
Disable density scaling.
Definition at line 142 of file Materials.h.
|
inline |
Set the density scale to the given value.
Definition at line 136 of file Materials.h.
|
inline |
set the set of material names which will not be scaled in any way
Definition at line 149 of file Materials.h.
|
protected |
If set we scale all densities by a given factor.
Definition at line 179 of file Materials.h.
|
protected |
Names of materials we don't want to scale.
Definition at line 181 of file Materials.h.
|
mutableprotected |
Cache for already searched Materials.
Definition at line 161 of file Materials.h.
|
protected |
G4NistElementBuilder instance to create chemical elements with correct natural abundances from NIST database.
Definition at line 168 of file Materials.h.
|
protected |
G4NistMaterialBuilder to create predefined materials from NIST database.
Definition at line 170 of file Materials.h.
|
protected |
Vector of created G4MaterialProperties objects.
Definition at line 164 of file Materials.h.