10 #include "GeoModelKernel/GeoMaterial.h"
14 #include "G4Material.hh"
17 #include <unordered_map>
20 typedef std::unordered_map<const GeoMaterial* , G4Material*> matList;
21 typedef std::unordered_map<std::string, const GeoMaterial*> matNames;
38 std::scoped_lock lock(matLock);
43 const auto itr = geoMaterialToG4Material.find(geoMaterial);
44 if(itr != geoMaterialToG4Material.end()) {
48 const std::string& geoMaterialName = geoMaterial->getName();
49 const int nelements = geoMaterial->getNumElements();
55 G4Material* g4Material{};
58 G4State state = kStateUndefined;
63 state = kStateUndefined;
81 g4Material=
new G4Material(geoMaterialName,
93 G4MaterialPropertiesTable* g4PropTable = tFactory.
Build(geoPropTable);
95 g4Material->SetMaterialPropertiesTable(g4PropTable);
100 g4Material=
new G4Material(geoMaterialName,
101 geoMaterial->getDensity(),
106 for (
int ii = 0; ii< nelements; ii++) {
107 G4Element* g4Element = eFactory.Build(geoMaterial->getElement(ii));
108 g4Material->AddElement(g4Element, geoMaterial->getFraction(ii));
111 const G4MaterialTable & theMaterialTable = *(g4Material->GetMaterialTable());
112 const G4String& g4MaterialName = g4Material->GetName();
113 std::vector<size_t> copyIndex{};
114 for(
size_t i=0;
i< theMaterialTable.size(); ++
i) {
115 if(theMaterialTable[
i]->GetName() == g4MaterialName) {
116 copyIndex.push_back(
i);
119 if ( copyIndex.size() > 1 ) {
120 ATH_MSG_WARNING (
"Details of all G4Materials named " << g4MaterialName <<
" in the G4MaterialTable.");
121 for (
size_t index : copyIndex) {
127 geoMaterialToG4Material[geoMaterial]=g4Material;
132 const auto [
it, inserted] = geoMaterialNameToObject.try_emplace(geoMaterialName, geoMaterial);
134 ATH_MSG_WARNING (
"!!! On GeoModel side two different materials share the name: " << geoMaterialName );