diff --git a/DDCore/include/XML/Utilities.h b/DDCore/include/XML/Utilities.h index ecc8cf94119c5c470a03a93fdbaada4253e49764..56b977836023ce3d85224ae3a2fe388a84548175 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 6c68bcea4deebf6fd29d6ea92bc23e92f2c9d25e..7981e8c3eaf05c9c6c31c02166387ee5606cf1e4 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);