BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
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
 
void ListMaterials () const
 output available materials
 
G4Material * GetMaterial (G4String material) const
 Get material by name.
 
G4Element * GetElement (const G4String &symbol) const
 Get element by name.
 
void CacheMaterialsFromGDML (const std::map< G4String, G4Material * > &materialsGDML)
 Introduce materials loaded from GDML into this instance.
 
void CheckForConflictingMaterialsAfterLoad (const G4String &geometryFileName, const G4String &componentName) const
 

Static Public Member Functions

static BDSMaterialsInstance ()
 Singleton pattern access.
 

Protected Member Functions

void AddMaterial (G4Material *material, G4String name)
 Add G4Material.
 
void AddExistingMaterialAlias (const G4String &existingMaterialName, G4String alias)
 Add alias to a material.
 
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)
 

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.
 
void PrintBasicMaterialMassFraction (G4Material *material) const
 Print mass fractions of consituents of a given material.
 
G4MaterialPropertiesTable * CreatePropertiesTable ()
 Create new properties table and store in vector.
 
void DefineMetals ()
 Methods called by constructor.
 
void DefineSuperconductors ()
 Methods called by constructor.
 
void DefineNonMetalSolids ()
 Methods called by constructor.
 
void DefineScintillators ()
 Methods called by constructor.
 
void DefineLHCComponents ()
 Methods called by constructor.
 
void DefineLiquids ()
 Methods called by constructor.
 
void DefineGases ()
 Methods called by constructor.
 
void DefinePlasmas ()
 Methods called by constructor.
 
void DefineVacuums ()
 Methods called by constructor.
 
void AddElement (G4Element *element, const G4String &symbol)
 Add a G4Element.
 
void AddElement (const G4String &name, const G4String &symbol, G4double itsZ, G4double itsA)
 Add a G4Element.
 

Private Attributes

std::set< G4String > materialNames
 Map of materials, convention name lowercase.
 
std::map< G4String, G4Material * > materials
 
std::set< G4String > aliasNames
 Map of other names to existing materials. To avoid double deletion. Also in lower case.
 
std::map< G4String, G4Material * > aliases
 
std::map< G4Material *, std::vector< G4String > > materialToAliases
 Keep a vector of possible aliases for every material for print out and user feedback.
 
std::set< G4String > externalMaterialNames
 Keep hold of externally constructed materials to indicate conflicts to the user but not to delete.
 
std::map< G4String, G4Material * > externalMaterials
 
std::map< G4String, G4Element * > elements
 Map of elements, no lowercase convention.
 
std::vector< G4MaterialPropertiesTable * > propertiesTables
 Material tables for storing pointers.
 

Static Private Attributes

static BDSMaterialsinstance = nullptr
 Singleton instance.
 

Detailed Description

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

Definition at line 38 of file BDSMaterials.hh.

Constructor & Destructor Documentation

◆ ~BDSMaterials()

BDSMaterials::~BDSMaterials ( )

Definition at line 1269 of file BDSMaterials.cc.

◆ BDSMaterials()

BDSMaterials::BDSMaterials ( )
protected

Definition at line 46 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 1165 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 1154 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 aliasNames, GetMaterial(), BDS::LowerCase(), and materialToAliases.

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 951 of file BDSMaterials.cc.

References BDS::LowerCase(), and materialNames.

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 1001 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 978 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)

Introduce materials loaded from GDML into this instance.

Definition at line 1123 of file BDSMaterials.cc.

References externalMaterialNames, BDS::LowerCase(), 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 1185 of file BDSMaterials.cc.

References elements.

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

Here is the caller graph for this function:

◆ CheckForConflictingMaterialsAfterLoad()

void BDSMaterials::CheckForConflictingMaterialsAfterLoad ( const G4String &  geometryFileName,
const G4String &  componentName 
) const

This function will loop through the Geant4 global material table looking for any duplicate names. This implicitly implies that a material was loaded from the GDML file that is degenerate with a material already defined (e.g. from BDSIM's predefined ones or ones defined in the parser through input GMAD. Names do not conflict with any aliases in BDSIM.

Definition at line 1086 of file BDSMaterials.cc.

References BDS::LowerCase(), and BDS::StartsWith().

Referenced by BDSGeometryFactoryGDML::Build().

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

◆ CreatePropertiesTable()

G4MaterialPropertiesTable * BDSMaterials::CreatePropertiesTable ( )
private

Create new properties table and store in vector.

Definition at line 1380 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 846 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 722 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 822 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 67 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 246 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 899 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 404 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 237 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 909 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 1174 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 1198 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 1036 of file BDSMaterials.cc.

References aliasNames, externalMaterialNames, ListMaterials(), BDS::LowerCase(), and materialNames.

Referenced by AddExistingMaterialAlias(), AddMaterial(), BDSAcceleratorComponent::BDSAcceleratorComponent(), BDSBeamPipeInfo::BDSBeamPipeInfo(), BDSTunnelInfo::BDSTunnelInfo(), BDSUndulator::Build(), BDSGeometryFactorySQL::Build(), BDSBeamPipeFactoryBase::BuildLogicalVolumes(), BDSBeamPipeFactoryLHCDetailed::BuildLogicalVolumes(), BDSTunnelFactoryBase::BuildLogicalVolumes(), BDSMultilayerScreen::BuildMotherVolume(), 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 39 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(), BDSDetectorConstruction::BuildWorld(), 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(), BDSSampler::MakeMaterialValidForUseInMassWorld(), 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 1216 of file BDSMaterials.cc.

References elements, GetMaterial(), materialToAliases, 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 1290 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 1206 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

Definition at line 145 of file BDSMaterials.hh.

◆ aliasNames

std::set<G4String> BDSMaterials::aliasNames
private

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

Definition at line 144 of file BDSMaterials.hh.

Referenced by AddExistingMaterialAlias(), and GetMaterial().

◆ elements

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

Map of elements, no lowercase convention.

Definition at line 152 of file BDSMaterials.hh.

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

◆ externalMaterialNames

std::set<G4String> BDSMaterials::externalMaterialNames
private

Keep hold of externally constructed materials to indicate conflicts to the user but not to delete.

Definition at line 149 of file BDSMaterials.hh.

Referenced by CacheMaterialsFromGDML(), and GetMaterial().

◆ externalMaterials

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

Definition at line 150 of file BDSMaterials.hh.

◆ instance

BDSMaterials * BDSMaterials::instance = nullptr
staticprivate

Singleton instance.

Definition at line 114 of file BDSMaterials.hh.

Referenced by Instance().

◆ materialNames

std::set<G4String> BDSMaterials::materialNames
private

Map of materials, convention name lowercase.

Definition at line 141 of file BDSMaterials.hh.

Referenced by AddMaterial(), and GetMaterial().

◆ materials

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

Definition at line 142 of file BDSMaterials.hh.

◆ materialToAliases

std::map<G4Material*, std::vector<G4String> > BDSMaterials::materialToAliases
private

Keep a vector of possible aliases for every material for print out and user feedback.

Definition at line 147 of file BDSMaterials.hh.

Referenced by AddExistingMaterialAlias(), and ListMaterials().

◆ propertiesTables

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

Material tables for storing pointers.

Definition at line 154 of file BDSMaterials.hh.

Referenced by CreatePropertiesTable().


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