59 xml_comp_t x_step = x_det.child(_Unicode(step_file));
60 xml_comp_t x_pos = x_det.child(_Unicode(position));
61 xml_comp_t x_map = x_det.child(_Unicode(material_map));
63 std::string name = x_det.nameStr();
64 std::string path = x_step.attr<std::string>(_Unicode(path));
67 std::map<std::string, G4Material*> materials;
68 for (xml_coll_t it(x_map, _Unicode(entry)); it; ++it) {
69 xml_comp_t x_entry = it;
70 std::string stepName = x_entry.attr<std::string>(_Unicode(step_name));
71 std::string dd4hepMatName = x_entry.attr<std::string>(_Unicode(dd4hep_material));
75 G4Material* g4mat = G4NistManager::Instance()->FindOrBuildMaterial(dd4hepMatName);
79 g4mat = G4Material::GetMaterial(dd4hepMatName,
false);
82 throw std::runtime_error(
"G4OCCT_STEPAssembly: Geant4 material '" + dd4hepMatName +
83 "' not found for STEP name '" + stepName +
"'");
85 materials[stepName] = g4mat;
86 printout(DEBUG,
"G4OCCT_STEPAssembly",
"Mapped STEP material '%s' → G4Material '%s'",
87 stepName.c_str(), dd4hepMatName.c_str());
91 std::vector<std::string> sensitiveNames;
92 if (x_det.hasChild(_Unicode(sensitive_volumes))) {
93 xml_comp_t x_svols = x_det.child(_Unicode(sensitive_volumes));
94 for (xml_coll_t it(x_svols, _Unicode(volume)); it; ++it) {
95 xml_comp_t x_vol = it;
96 sensitiveNames.push_back(x_vol.attr<std::string>(_Unicode(name)));
111 Assembly dd4hepAssembly(name +
"_assembly");
113 printout(INFO,
"G4OCCT_STEPAssembly",
114 "Imported STEP assembly '%s' from '%s'; %d constituent solid(s) on "
115 "OCCT side; created empty dd4hep::Assembly '%s' as top-level container",
116 name.c_str(), path.c_str(), nConstituents, (name +
"_assembly").c_str());
119 DetElement det(name, x_det.id());
120 Position pos(x_pos.x(), x_pos.y(), x_pos.z());
122 PlacedVolume pv = description.pickMotherVolume(det).placeVolume(dd4hepAssembly, pos);
123 pv.addPhysVolID(
"system", x_det.id());
124 det.setPlacement(pv);