From 3b37765d6336389377b4534906a8c46f9a2e62fb Mon Sep 17 00:00:00 2001 From: Frank Gaede <frank.gaede@desy.de> Date: Tue, 31 Mar 2015 14:31:22 +0000 Subject: [PATCH] - allow to use Assemblies in createPlacedEnvelope() -> drivers can call this method also w/o defining a shape for the envelope --- DDCore/include/XML/Utilities.h | 4 +++- DDCore/src/XML/Utilities.cpp | 31 ++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/DDCore/include/XML/Utilities.h b/DDCore/include/XML/Utilities.h index ecc8cf941..56b977836 100644 --- a/DDCore/include/XML/Utilities.h +++ b/DDCore/include/XML/Utilities.h @@ -24,7 +24,8 @@ namespace DD4hep { /** Create an envelope volume that is placed into the world volume ( the parent volume of sdet) from an xml - * element <envelope/> with child nodes <shape/> and optionally <position/> and <rotation/>. + * element <envelope/> with child nodes <shape/> and optionally <position/> and <rotation/>. For special cases + * no volume but an assembly can be created with <shape type="Assembly"/>. * Example: <br> * <p> * <envelope vis="ILD_ECALVis"> @@ -32,6 +33,7 @@ namespace DD4hep { * dz="2.*TPC_Ecal_Hcal_barrel_halfZ" material = "Air" /> * <rotation x="0*deg" y="0*deg" z="90*deg-180*deg/8"/> * </envelope> + * </p> * * @author S.Lu DESY, F. Gaede CERN/DESY * @version $Id:$ diff --git a/DDCore/src/XML/Utilities.cpp b/DDCore/src/XML/Utilities.cpp index 6c68bcea4..7981e8c3e 100644 --- a/DDCore/src/XML/Utilities.cpp +++ b/DDCore/src/XML/Utilities.cpp @@ -44,9 +44,7 @@ Geometry::Volume DD4hep::XML::createPlacedEnvelope( DD4hep::Geometry::LCDD& lcdd xml_comp_t x_env = x_det.child( DD4hep::XML::Strng_t("envelope") ) ; xml_comp_t x_shape = x_env.child( _U(shape) ); - Material env_mat = lcdd.material( x_shape.materialStr() ); - bool useRot = false ; bool usePos = false ; Position pos ; @@ -63,20 +61,31 @@ Geometry::Volume DD4hep::XML::createPlacedEnvelope( DD4hep::Geometry::LCDD& lcdd rot = RotationZYX( env_rot.z(),env_rot.y(),env_rot.x() ) ; } + Volume envelope ; - // ---- create a shape from the specified xml element -------- - Box env_solid = xml_comp_t( x_shape ).createShape(); - - if( !env_solid.isValid() ){ + if( x_shape.typeStr() == "Assembly" ){ + + envelope = Assembly( det_name+"_assembly" ) ; + + } else { + // ---- create a shape from the specified xml element -------- + Box env_solid = xml_comp_t( x_shape ).createShape(); - throw std::runtime_error( std::string(" Cannot create envelope volume : ") + x_shape.typeStr() + - std::string(" for detector " ) + det_name ) ; - } - - Volume envelope ( det_name+"_envelope", env_solid, env_mat ); + if( !env_solid.isValid() ){ + + throw std::runtime_error( std::string(" Cannot create envelope volume : ") + x_shape.typeStr() + + std::string(" for detector " ) + det_name ) ; + } + + Material env_mat = lcdd.material( x_shape.materialStr() ); + envelope = Volume( det_name+"_envelope", env_solid, env_mat ); + } + + PlacedVolume env_pv ; + Volume mother = lcdd.pickMotherVolume(sdet); -- GitLab