From 017b37b8272eed257d19f0ca67f0e78b4242a841 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Wed, 4 Aug 2021 13:32:34 -0500 Subject: [PATCH] [gdmlFile] optionally import physvol below top level This allows syntax like ```xml ``` to only load the specific `physvol` in `examples/ClientTests/compact/GdmlDetector.gdml`. --- DDCore/src/gdml/GdmlPlugins.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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()));