Skip to content
Snippets Groups Projects
Commit 3b37765d authored by Frank Gaede's avatar Frank Gaede
Browse files

- allow to use Assemblies in createPlacedEnvelope()

   -> drivers can call this method also w/o defining a shape
      for the envelope
parent e9ba3adc
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,8 @@ namespace DD4hep { ...@@ -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 /** 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> * Example: <br>
* <p> * <p>
* <envelope vis="ILD_ECALVis"> * <envelope vis="ILD_ECALVis">
...@@ -32,6 +33,7 @@ namespace DD4hep { ...@@ -32,6 +33,7 @@ namespace DD4hep {
* dz="2.*TPC_Ecal_Hcal_barrel_halfZ" material = "Air" /> * dz="2.*TPC_Ecal_Hcal_barrel_halfZ" material = "Air" />
* <rotation x="0*deg" y="0*deg" z="90*deg-180*deg/8"/> * <rotation x="0*deg" y="0*deg" z="90*deg-180*deg/8"/>
* </envelope> * </envelope>
* </p>
* *
* @author S.Lu DESY, F. Gaede CERN/DESY * @author S.Lu DESY, F. Gaede CERN/DESY
* @version $Id:$ * @version $Id:$
......
...@@ -44,9 +44,7 @@ Geometry::Volume DD4hep::XML::createPlacedEnvelope( DD4hep::Geometry::LCDD& lcdd ...@@ -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_env = x_det.child( DD4hep::XML::Strng_t("envelope") ) ;
xml_comp_t x_shape = x_env.child( _U(shape) ); xml_comp_t x_shape = x_env.child( _U(shape) );
Material env_mat = lcdd.material( x_shape.materialStr() );
bool useRot = false ; bool useRot = false ;
bool usePos = false ; bool usePos = false ;
Position pos ; Position pos ;
...@@ -63,20 +61,31 @@ Geometry::Volume DD4hep::XML::createPlacedEnvelope( DD4hep::Geometry::LCDD& lcdd ...@@ -63,20 +61,31 @@ Geometry::Volume DD4hep::XML::createPlacedEnvelope( DD4hep::Geometry::LCDD& lcdd
rot = RotationZYX( env_rot.z(),env_rot.y(),env_rot.x() ) ; rot = RotationZYX( env_rot.z(),env_rot.y(),env_rot.x() ) ;
} }
Volume envelope ;
// ---- create a shape from the specified xml element -------- if( x_shape.typeStr() == "Assembly" ){
Box env_solid = xml_comp_t( x_shape ).createShape();
envelope = Assembly( det_name+"_assembly" ) ;
if( !env_solid.isValid() ){
} 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() + if( !env_solid.isValid() ){
std::string(" for detector " ) + det_name ) ;
} 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 ); }
Material env_mat = lcdd.material( x_shape.materialStr() );
envelope = Volume( det_name+"_envelope", env_solid, env_mat );
}
PlacedVolume env_pv ; PlacedVolume env_pv ;
Volume mother = lcdd.pickMotherVolume(sdet); Volume mother = lcdd.pickMotherVolume(sdet);
......
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