Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gdmlFile] optionally import physvol below top level #860

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions DDCore/src/gdml/GdmlPlugins.cpp
Expand Up @@ -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<string>(_U(ref));
string gdml_physvol = dd4hep::getAttrOrDefault<string>(x_gdml, _Unicode(physvol), "");
DetElement det_parent = description.detector(par_nam);
TGDMLParse parser;
if ( !gdml.empty() && gdml[0] == '/' ) {
Expand All @@ -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()));
Expand Down