Skip to content
Snippets Groups Projects
Commit 5dbf9b8e authored by Wouter Deconinck's avatar Wouter Deconinck Committed by MarkusFrankATcernch
Browse files

[gdmlFile] optionally import physvol below top level

This allows syntax like
```xml
  <detectors>
    <detector id="1" name="FT_MT" type="DD4hep_GdmlDetector" vis="InvisibleWithChildren">
      <gdmlFile ref="GdmlDetector.gdml" physvol="lvUpstreamRegion_0"/>
      <parent name="/world"/>
    </detector>
  </detectors>
```
to only load the specific `physvol` in `examples/ClientTests/compact/GdmlDetector.gdml`.
parent ee51c48c
No related branches found
No related tags found
No related merge requests found
...@@ -269,6 +269,7 @@ static Ref_t create_detector(Detector& description, xml_h e, Ref_t /* sens_det * ...@@ -269,6 +269,7 @@ static Ref_t create_detector(Detector& description, xml_h e, Ref_t /* sens_det *
string name = x_det.nameStr(); string name = x_det.nameStr();
string par_nam = x_par.nameStr(); string par_nam = x_par.nameStr();
string gdml = x_gdml.attr<string>(_U(ref)); string gdml = x_gdml.attr<string>(_U(ref));
string gdml_physvol = dd4hep::getAttrOrDefault<string>(x_gdml, _Unicode(physvol), "");
DetElement det_parent = description.detector(par_nam); DetElement det_parent = description.detector(par_nam);
TGDMLParse parser; TGDMLParse parser;
if ( !gdml.empty() && gdml[0] == '/' ) { if ( !gdml.empty() && gdml[0] == '/' ) {
...@@ -293,6 +294,18 @@ static Ref_t create_detector(Detector& description, xml_h e, Ref_t /* sens_det * ...@@ -293,6 +294,18 @@ static Ref_t create_detector(Detector& description, xml_h e, Ref_t /* sens_det *
Volume mother = det_parent.volume(); Volume mother = det_parent.volume();
PlacedVolume pv; 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 ) { if ( x_pos && x_rot ) {
Rotation3D rot(RotationZYX(x_rot.z(),x_rot.y(),x_rot.x())); 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())); Transform3D transform(rot,Position(x_pos.x(),x_pos.y(),x_pos.z()));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment