BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
BDSMaterials Class Reference

A class for all material definitions known to BDSIM. Additional materials can be added in the parser as well. More...

#include <BDSMaterials.hh>

Collaboration diagram for BDSMaterials:
Collaboration graph

Public Member Functions

void PrepareRequiredMaterials (G4bool verbose=false)
 converts parser material list More...
 
void ListMaterials () const
 output available materials More...
 
G4Material * GetMaterial (G4String material) const
 Get material by name. More...
 
G4Element * GetElement (const G4String &symbol) const
 Get element by name. More...
 
void CacheMaterialsFromGDML (const std::map< G4String, G4Material * > &materialsGDML, const G4String &prepend, G4bool prependWasUsed)
 

Static Public Member Functions

static BDSMaterialsInstance ()
 Singleton pattern access. More...
 

Protected Member Functions

void AddMaterial (G4Material *material, G4String name)
 Add G4Material. More...
 
void AddExistingMaterialAlias (const G4String &existingMaterialName, G4String alias)
 Add alias to a material. More...
 
void AddMaterial (G4String name, G4double Z, G4double A, G4double density, G4State state, G4double temperature, G4double pressure)
 
template<typename Type >
void AddMaterial (G4String name, G4double density, G4State state, G4double temperature, G4double pressure, const std::list< G4String > &components, const std::list< Type > &componentFractions)
 
G4Element * CheckElement (const G4String &symbol) const
 Return element if defined (nullptr if not) More...
 

Private Member Functions

void DensityCheck (G4double density, const G4String &materialName) const
 Print warning if density suspiciously high. Should be in g/cm3 in G4 units already. More...
 
void PrintBasicMaterialMassFraction (G4Material *material) const
 Print mass fractions of consituents of a given material. More...
 
G4MaterialPropertiesTable * CreatePropertiesTable ()
 Create new properties table and store in vector. More...
 
void DefineMetals ()
 Methods called by constructor. More...
 
void DefineSuperconductors ()
 Methods called by constructor. More...
 
void DefineNonMetalSolids ()
 Methods called by constructor. More...
 
void DefineScintillators ()
 Methods called by constructor. More...
 
void DefineLHCComponents ()
 Methods called by constructor. More...
 
void DefineLiquids ()
 Methods called by constructor. More...
 
void DefineGases ()
 Methods called by constructor. More...
 
void DefinePlasmas ()
 Methods called by constructor. More...
 
void DefineVacuums ()
 Methods called by constructor. More...
 
void AddElement (G4Element *element, const G4String &symbol)
 Add a G4Element. More...
 
void AddElement (const G4String &name, const G4String &symbol, G4double itsZ, G4double itsA)
 Add a G4Element. More...
 

Private Attributes

std::map< G4String, G4Material * > materials
 <ap of materials, convention name lowercase. More...
 
std::map< G4String, G4Material * > aliases
 Maps of other names to existing materials. To avoid double deletion. Also in lower case. More...
 
std::map< G4String, G4int > possibleDuplicates
 
std::map< G4String, G4Element * > elements
 Map of elements, no lowercase convention. More...
 
std::vector< G4MaterialPropertiesTable * > propertiesTables
 Material tables for storing pointers. More...
 

Static Private Attributes

static BDSMaterialsinstance = nullptr
 Singleton instance. More...
 

Detailed Description

A class for all material definitions known to BDSIM. Additional materials can be added in the parser as well.

Definition at line 37 of file BDSMaterials.hh.

Constructor & Destructor Documentation

◆ ~BDSMaterials()

BDSMaterials::~BDSMaterials ( )

Definition at line 1212 of file BDSMaterials.cc.

◆ BDSMaterials()

BDSMaterials::BDSMaterials ( )
protected

Definition at line 45 of file BDSMaterials.cc.

Member Function Documentation

◆ AddElement() [1/2]

void BDSMaterials::AddElement ( const G4String &  name,
const G4String &  symbol,
G4double  itsZ,
G4double  itsA 
)
private

Add a G4Element.

Definition at line 1123 of file BDSMaterials.cc.

References AddElement().

Here is the call graph for this function:

◆ AddElement() [2/2]

void BDSMaterials::AddElement ( G4Element *  element,
const G4String &  symbol 
)
private

Add a G4Element.

Definition at line 1112 of file BDSMaterials.cc.

References CheckElement(), and elements.

Referenced by AddElement(), and PrepareRequiredMaterials().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddExistingMaterialAlias()

void BDSMaterials::AddExistingMaterialAlias ( const G4String &  existingMaterialName,
G4String  alias 
)
protected

Add alias to a material.

Definition at line 963 of file BDSMaterials.cc.

References aliases, GetMaterial(), and BDS::LowerCase().

Referenced by DefineGases(), DefineLHCComponents(), DefineLiquids(), DefineMetals(), and DefineSuperconductors().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddMaterial() [1/3]

void BDSMaterials::AddMaterial ( G4Material *  material,
G4String  name 
)
protected

Add G4Material.

Definition at line 950 of file BDSMaterials.cc.

References BDS::LowerCase(), and materials.

Referenced by AddMaterial(), DefineGases(), DefineLHCComponents(), DefineLiquids(), DefineMetals(), DefineNonMetalSolids(), DefinePlasmas(), DefineScintillators(), DefineSuperconductors(), DefineVacuums(), and PrepareRequiredMaterials().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddMaterial() [2/3]

template<typename Type >
void BDSMaterials::AddMaterial ( G4String  name,
G4double  density,
G4State  state,
G4double  temperature,
G4double  pressure,
const std::list< G4String > &  components,
const std::list< Type > &  componentFractions 
)
protected

Add materials

Parameters
[in]densityin g/cm3
[in]statesolid/gas
[in]tempin kelvin
[in]pressurein atm
[in]componentslist of elements
[in]componentsFractionslist of fractions or integers of the elements

Definition at line 994 of file BDSMaterials.cc.

References AddMaterial(), CheckElement(), DensityCheck(), GetMaterial(), and BDS::LowerCase().

Here is the call graph for this function:

◆ AddMaterial() [3/3]

void BDSMaterials::AddMaterial ( G4String  name,
G4double  Z,
G4double  A,
G4double  density,
G4State  state,
G4double  temperature,
G4double  pressure 
)
protected

Add materials

Parameters
[in]Zatomic number
[in]Amole mass in g/mole
[in]densityin g/cm3
[in]statesolid/gas
[in]tempin kelvin
[in]pressurein atm

Definition at line 971 of file BDSMaterials.cc.

References AddMaterial(), DensityCheck(), and BDS::LowerCase().

Here is the call graph for this function:

◆ CacheMaterialsFromGDML()

void BDSMaterials::CacheMaterialsFromGDML ( const std::map< G4String, G4Material * > &  materialsGDML,
const G4String &  prepend,
G4bool  prependWasUsed 
)

Introduce materials loaded from GDML into this instance. If a prepend was used to load the material then it's cached both with and without it and the once without the prepend is flagged as a possible dupliate. If it's defined more than one without the prepend, then an exception will be thrown as the search is ambiguous.

Definition at line 1087 of file BDSMaterials.cc.

References aliases, BDS::LowerCase(), materials, possibleDuplicates, and BDS::StartsWith().

Referenced by BDSGeometryFactoryGDML::Build().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckElement()

G4Element * BDSMaterials::CheckElement ( const G4String &  symbol) const
protected

Return element if defined (nullptr if not)

Definition at line 1143 of file BDSMaterials.cc.

References elements.

Referenced by AddElement(), AddMaterial(), and GetElement().

Here is the caller graph for this function:

◆ CreatePropertiesTable()

G4MaterialPropertiesTable * BDSMaterials::CreatePropertiesTable ( )
private

Create new properties table and store in vector.

Definition at line 1318 of file BDSMaterials.cc.

References propertiesTables.

Referenced by DefineGases(), DefineLiquids(), DefineNonMetalSolids(), DefineScintillators(), and DefineVacuums().

Here is the caller graph for this function:

◆ DefineGases()

void BDSMaterials::DefineGases ( )
private

Methods called by constructor.

Definition at line 845 of file BDSMaterials.cc.

References AddExistingMaterialAlias(), AddMaterial(), CreatePropertiesTable(), GetElement(), and GetMaterial().

Here is the call graph for this function:

◆ DefineLHCComponents()

void BDSMaterials::DefineLHCComponents ( )
private

Methods called by constructor.

Definition at line 721 of file BDSMaterials.cc.

References AddExistingMaterialAlias(), and AddMaterial().

Here is the call graph for this function:

◆ DefineLiquids()

void BDSMaterials::DefineLiquids ( )
private

Methods called by constructor.

Definition at line 821 of file BDSMaterials.cc.

References AddExistingMaterialAlias(), AddMaterial(), CreatePropertiesTable(), and GetMaterial().

Here is the call graph for this function:

◆ DefineMetals()

void BDSMaterials::DefineMetals ( )
private

Methods called by constructor.

Definition at line 66 of file BDSMaterials.cc.

References AddExistingMaterialAlias(), and AddMaterial().

Here is the call graph for this function:

◆ DefineNonMetalSolids()

void BDSMaterials::DefineNonMetalSolids ( )
private

Methods called by constructor.

Definition at line 245 of file BDSMaterials.cc.

References AddMaterial(), CreatePropertiesTable(), and GetElement().

Here is the call graph for this function:

◆ DefinePlasmas()

void BDSMaterials::DefinePlasmas ( )
private

Methods called by constructor.

Definition at line 898 of file BDSMaterials.cc.

References AddMaterial().

Here is the call graph for this function:

◆ DefineScintillators()

void BDSMaterials::DefineScintillators ( )
private

Methods called by constructor.

Definition at line 403 of file BDSMaterials.cc.

References AddMaterial(), CreatePropertiesTable(), GetElement(), and GetMaterial().

Here is the call graph for this function:

◆ DefineSuperconductors()

void BDSMaterials::DefineSuperconductors ( )
private

Methods called by constructor.

Definition at line 236 of file BDSMaterials.cc.

References AddExistingMaterialAlias(), and AddMaterial().

Here is the call graph for this function:

◆ DefineVacuums()

void BDSMaterials::DefineVacuums ( )
private

Methods called by constructor.

Definition at line 908 of file BDSMaterials.cc.

References AddMaterial(), CreatePropertiesTable(), GetElement(), GetMaterial(), BDSParser::GetOptions(), BDSParser::Instance(), and BDSParser::IsInitialised().

Here is the call graph for this function:

◆ DensityCheck()

void BDSMaterials::DensityCheck ( G4double  density,
const G4String &  materialName 
) const
private

Print warning if density suspiciously high. Should be in g/cm3 in G4 units already.

Definition at line 1132 of file BDSMaterials.cc.

Referenced by AddMaterial().

Here is the caller graph for this function:

◆ GetElement()

G4Element * BDSMaterials::GetElement ( const G4String &  symbol) const

Get element by name.

Definition at line 1156 of file BDSMaterials.cc.

References CheckElement().

Referenced by DefineGases(), DefineNonMetalSolids(), DefineScintillators(), and DefineVacuums().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMaterial()

G4Material * BDSMaterials::GetMaterial ( G4String  material) const

Get material by name.

Definition at line 1029 of file BDSMaterials.cc.

References aliases, ListMaterials(), BDS::LowerCase(), materials, and possibleDuplicates.

Referenced by AddExistingMaterialAlias(), AddMaterial(), BDSAcceleratorComponent::BDSAcceleratorComponent(), BDSBeamPipeInfo::BDSBeamPipeInfo(), BDSTunnelInfo::BDSTunnelInfo(), BDSUndulator::Build(), BDSGeometryFactorySQL::Build(), BDSBeamPipeFactoryBase::BuildLogicalVolumes(), BDSBeamPipeFactoryLHCDetailed::BuildLogicalVolumes(), BDSTunnelFactoryBase::BuildLogicalVolumes(), BDSMultilayerScreen::BuildMotherVolume(), BDS::BuildPlacementGeometry(), BDSDetectorConstruction::BuildWorld(), BDSBLMFactory::CommonConstruction(), BDSMagnetOuterFactoryPolesBase::CommonConstructor(), BDSMagnetOuterFactoryCylindrical::CommonFinalConstructor(), BDSBeamPipeFactoryLHCDetailed::CreateBeamPipe(), BDSMagnetOuterFactory::CreateContainerForExternal(), BDSMagnetOuterFactoryPolesBase::CreateEndPiece(), BDSMagnetOuterFactoryLHC::CreateLHCDipole(), BDSMagnetOuterFactoryBase::CreateLogicalVolumes(), BDSMagnetOuterFactoryPolesSquare::CreateLogicalVolumes(), BDSMagnetOuterFactoryPolesBase::CreateLogicalVolumesCoil(), BDSMagnetOuterFactoryLHC::CreateQuadrupole(), DefineGases(), DefineLiquids(), DefineScintillators(), DefineVacuums(), BDSMagnetOuterFactoryPolesBase::DipoleCommonPreConstruction(), BDSLaserCompton::GetMeanFreePath(), ListMaterials(), BDSComponentFactory::PrepareCavityModelInfo(), BDSComponentFactory::PrepareCavityModels(), BDSComponentFactory::PrepareCrystals(), BDSComponentFactory::PrepareMagnetOuterInfo(), BDSComponentFactory::PrepareMaterial(), and BDSComponentFactory::PrepareVacuumMaterial().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Instance()

BDSMaterials * BDSMaterials::Instance ( )
static

Singleton pattern access.

Definition at line 38 of file BDSMaterials.cc.

References instance.

Referenced by BDSAcceleratorComponent::BDSAcceleratorComponent(), BDSBeamPipeInfo::BDSBeamPipeInfo(), BDSScorerInfo::BDSScorerInfo(), BDSTunnelInfo::BDSTunnelInfo(), BDSUndulator::Build(), BDSGeometryFactoryGDML::Build(), BDSGeometryFactorySQL::Build(), BDSLaserWire::BuildContainerLogicalVolume(), BDSBeamPipeFactoryBase::BuildLogicalVolumes(), BDSBeamPipeFactoryLHCDetailed::BuildLogicalVolumes(), BDSTunnelFactoryBase::BuildLogicalVolumes(), BDSMultilayerScreen::BuildMotherVolume(), BDS::BuildPlacementGeometry(), BDSDetectorConstruction::BuildWorld(), BDSSampler::CommonConstruction(), BDSBLMFactory::CommonConstruction(), BDSMagnetOuterFactoryPolesBase::CommonConstructor(), BDSMagnetOuterFactoryCylindrical::CommonFinalConstructor(), BDSBeamPipeFactoryLHCDetailed::CreateBeamPipe(), BDSMagnetOuterFactory::CreateContainerForExternal(), BDSMagnetOuterFactoryPolesBase::CreateEndPiece(), BDSMagnetOuterFactoryLHC::CreateLHCDipole(), BDSMagnetOuterFactoryBase::CreateLogicalVolumes(), BDSMagnetOuterFactoryPolesSquare::CreateLogicalVolumes(), BDSMagnetOuterFactoryPolesBase::CreateLogicalVolumesCoil(), BDSMagnetOuterFactoryLHC::CreateQuadrupole(), BDSMagnetOuterFactoryPolesBase::DipoleCommonPreConstruction(), BDSLaserCompton::GetMeanFreePath(), BDSIM::Initialise(), BDSIMLink::Initialise(), BDSExecOptions::Parse(), BDSComponentFactory::PrepareCavityModelInfo(), BDSComponentFactory::PrepareCavityModelInfoForElement(), BDSComponentFactory::PrepareCavityModels(), BDSComponentFactory::PrepareCrystals(), BDSComponentFactory::PrepareMagnetOuterInfo(), BDSComponentFactory::PrepareMaterial(), BDSComponentFactory::PrepareVacuumMaterial(), BDSIM::~BDSIM(), and BDSIMLink::~BDSIMLink().

Here is the caller graph for this function:

◆ ListMaterials()

void BDSMaterials::ListMaterials ( ) const

output available materials

Definition at line 1174 of file BDSMaterials.cc.

References elements, GetMaterial(), materials, and PrintBasicMaterialMassFraction().

Referenced by GetMaterial(), and BDSExecOptions::Parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PrepareRequiredMaterials()

void BDSMaterials::PrepareRequiredMaterials ( G4bool  verbose = false)

converts parser material list

Definition at line 1228 of file BDSMaterials.cc.

References AddElement(), AddMaterial(), BDSParser::GetAtoms(), BDSParser::GetMaterials(), and BDSParser::Instance().

Referenced by BDSIM::Initialise(), and BDSIMLink::Initialise().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PrintBasicMaterialMassFraction()

void BDSMaterials::PrintBasicMaterialMassFraction ( G4Material *  material) const
private

Print mass fractions of consituents of a given material.

Definition at line 1164 of file BDSMaterials.cc.

Referenced by ListMaterials().

Here is the caller graph for this function:

Field Documentation

◆ aliases

std::map<G4String, G4Material*> BDSMaterials::aliases
private

Maps of other names to existing materials. To avoid double deletion. Also in lower case.

Definition at line 139 of file BDSMaterials.hh.

Referenced by AddExistingMaterialAlias(), CacheMaterialsFromGDML(), and GetMaterial().

◆ elements

std::map<G4String,G4Element*> BDSMaterials::elements
private

Map of elements, no lowercase convention.

Definition at line 144 of file BDSMaterials.hh.

Referenced by AddElement(), CheckElement(), and ListMaterials().

◆ instance

BDSMaterials * BDSMaterials::instance = nullptr
staticprivate

Singleton instance.

Definition at line 110 of file BDSMaterials.hh.

Referenced by Instance().

◆ materials

std::map<G4String, G4Material*> BDSMaterials::materials
private

<ap of materials, convention name lowercase.

Definition at line 137 of file BDSMaterials.hh.

Referenced by AddMaterial(), CacheMaterialsFromGDML(), GetMaterial(), and ListMaterials().

◆ possibleDuplicates

std::map<G4String, G4int> BDSMaterials::possibleDuplicates
private

Map of names of loaded materials externally to the number of times loaded for possible duplicates.

Definition at line 142 of file BDSMaterials.hh.

Referenced by CacheMaterialsFromGDML(), and GetMaterial().

◆ propertiesTables

std::vector<G4MaterialPropertiesTable*> BDSMaterials::propertiesTables
private

Material tables for storing pointers.

Definition at line 146 of file BDSMaterials.hh.

Referenced by CreatePropertiesTable().


The documentation for this class was generated from the following files: