diff --git a/DDCore/src/gdml/GdmlPlugins.cpp b/DDCore/src/gdml/GdmlPlugins.cpp index e17aaa631..67292e959 100644 --- a/DDCore/src/gdml/GdmlPlugins.cpp +++ b/DDCore/src/gdml/GdmlPlugins.cpp @@ -269,6 +269,7 @@ static Ref_t create_detector(Detector& description, xml_h e, Ref_t /* sens_det * string name = x_det.nameStr(); string par_nam = x_par.nameStr(); string gdml = x_gdml.attr(_U(ref)); + string gdml_physvol = dd4hep::getAttrOrDefault(x_gdml, _Unicode(physvol), ""); DetElement det_parent = description.detector(par_nam); TGDMLParse parser; if ( !gdml.empty() && gdml[0] == '/' ) { @@ -293,6 +294,18 @@ static Ref_t create_detector(Detector& description, xml_h e, Ref_t /* sens_det * Volume mother = det_parent.volume(); PlacedVolume pv; + if ( !gdml_physvol.empty() ) { + PlacedVolume node = volume->FindNode(gdml_physvol.c_str()); + if ( !node.isValid() ) { + printout(ERROR,"ROOTGDMLParse","+++ Invalid gdml placed volume %s", gdml_physvol.c_str()); + printout(ERROR,"ROOTGDMLParse","+++ Valid top-level nodes are:"); + volume->PrintNodes(); + except("ROOTGDMLParse","+++ Failed to parse GDML file:%s for node:%s", + gdml.c_str(), gdml_physvol.c_str()); + } + volume = node.volume(); + } + if ( x_pos && x_rot ) { Rotation3D rot(RotationZYX(x_rot.z(),x_rot.y(),x_rot.x())); Transform3D transform(rot,Position(x_pos.x(),x_pos.y(),x_pos.z()));