3#include "G4NistManager.hh"
13 G4Material *mat = G4Material::GetMaterial(materialName,
false);
20 G4NistManager *nist = G4NistManager::Instance();
21 mat = nist->FindOrBuildMaterial(materialName);
24 G4Exception(
"GeoModulesContext::GetMaterial",
"MatNotFound",
25 FatalException, (
"Could not find material: " + materialName).c_str());
33 G4Element *el = G4Element::GetElement(elementName,
false);
40 G4NistManager *nist = G4NistManager::Instance();
41 el = nist->FindOrBuildElement(elementName);
44 G4Exception(
"GeoModulesContext::GetElement",
"ElementNotFound",
45 FatalException, (
"Could not find element: " + elementName).c_str());
53 const double dens_with_unit = dens * unit.
Native();
54 constexpr int n_components = 1;
55 constexpr G4double fraction_mass = 100 * CLHEP::perCent;
56 const auto dest =
new G4Material(name, dens_with_unit, n_components);
57 dest->AddMaterial(source, fraction_mass);
62 const G4double dens = source->GetDensity();
Typesafe units, for VolumeBuilders, Geant, ETC !! No accidental mixing values and units.
G4Material * CopyMaterial(G4MaterialPtrOrString source, const G4String &name, const G4double dens, const Density unit)
Copy a G4Material to one with a new name, and change its density.
G4Element * GetElement(const G4String &elementName)
G4Material * GetMaterial(const G4String &materialName)
Get material by local or NIST name.