diff --git a/DDRec/include/DDRec/Surface.h b/DDRec/include/DDRec/Surface.h index 57f46f5f1e47741e8e175415b464294465b65d67..55d96a39cbb38fcf445efbd5cd1ca88dfc6adf7a 100644 --- a/DDRec/include/DDRec/Surface.h +++ b/DDRec/include/DDRec/Surface.h @@ -199,6 +199,12 @@ namespace DD4hep { //====================================================================================================== + struct VolSurfaceList ; + /** Helper function for accessing the list assigned to a DetElement - attaches + * empty list if needed. + */ + VolSurfaceList* volSurfaceList( Geometry::DetElement& det ) ; + /** std::list of VolSurfaces that takes ownership. * @author F.Gaede, DESY * @date Apr, 6 2014 @@ -210,36 +216,37 @@ namespace DD4hep { // required c'tor for extension mechanism VolSurfaceList(Geometry::DetElement& det){ - // det.addExtension<VolSurfaceList>( this ) ; + + VolSurfaceList* sL = volSurfaceList( det ) ; + + std::copy( this->end() , sL->begin() , sL->end() ) ; } // required c'tor for extension mechanism VolSurfaceList(const VolSurfaceList& vsl, Geometry::DetElement& det ){ - //fixme: this causes a seg fault ... + // std::cout << " VolSurfaceList(const VolSurfaceList& vsl, Geometry::DetElement& det ) - vsl.size() " << vsl.size() + // << " own size: " << this->size() << " detelem : " ; + // if( det.isValid() ) + // std::cout << det.name() << std::endl ; //<< " path : " << det.placementPath() << std::endl ; + // else + // std::cout << " INVALID " << std::endl ; - // VolSurfaceList* nL = new VolSurfaceList ; - // nL->insert( nL->end() , vsl.begin() , vsl.end() ) ; - // det.addExtension<VolSurfaceList>( nL ) ; + + this->insert( this->end() , vsl.begin() , vsl.end() ) ; } virtual ~VolSurfaceList(){ - - // delete all surfaces attached to this volume - // fixme: causes seg fault if same surfaces attached to more than one list - // -> how do we deal with this ? - // for( VolSurfaceList::iterator i=begin(), n=end() ; i !=n ; ++i ) { - // delete (*i).ptr() ; - // } - + + // delete all surfaces attached to this volume + for( VolSurfaceList::iterator i=begin(), n=end() ; i !=n ; ++i ) { + i->clear() ; + } + } } ; - /** Helper function for accessing the list assigned to a DetElement - attaches - * empty list if needed. - */ - VolSurfaceList* volSurfaceList( Geometry::DetElement& det ) ; //====================================================================================================== diff --git a/DDRec/src/DetectorSurfaces.cpp b/DDRec/src/DetectorSurfaces.cpp index dc6c9551dc4f487a8fb3832015670bd582417a6a..632021ab45a399882abc21011d93895f21c8118e 100644 --- a/DDRec/src/DetectorSurfaces.cpp +++ b/DDRec/src/DetectorSurfaces.cpp @@ -31,7 +31,7 @@ namespace DD4hep { _sL = det.addExtension<SurfaceList >( new SurfaceList( true ) ) ; } - if( ! vsL->empty() ) { + if( ! vsL->empty() && _sL->empty() ) { // only fill surfaces for this DetElement once // std::cout << " detector " << det.name() << " id: " << det.id() << " has " << vsL->size() << " surfaces " << std::endl ; diff --git a/DDRec/src/gear/createGearForILD.cpp b/DDRec/src/gear/createGearForILD.cpp index d06101563162ae0702993130891dd7770497444c..8797c169dd42b929b815978f422299fd892243d4 100644 --- a/DDRec/src/gear/createGearForILD.cpp +++ b/DDRec/src/gear/createGearForILD.cpp @@ -5,8 +5,9 @@ #include "DDRec/DetectorData.h" #include "DDRec/DDGear.h" #include "DDRec/MaterialManager.h" -#include "DDSurfaces/Vector3D.h" +#include "DDRec/API/Calorimeter.h" +#include "DDSurfaces/Vector3D.h" #include "gearimpl/TPCParametersImpl.h" #include "gearimpl/FixedPadSizeDiskLayout.h" @@ -260,11 +261,15 @@ namespace DD4hep{ tubeDE.addExtension< GearHandle >( new GearHandle( gearTUBE, "BeamPipe" ) ) ; //========= CALO ============================================================================== + + //********************************************************** + //* test gear interface w/ LayeredCalorimeterData extension + //********************************************************** + DetElement caloDE = lcdd.detector("HcalBarrel") ; LayeredCalorimeterData* calo = caloDE.extension<LayeredCalorimeterData>() ; - gear::CalorimeterParametersImpl* gearCalo = ( calo->layoutType == LayeredCalorimeterData::BarrelLayout ? new gear::CalorimeterParametersImpl( calo->extent[0]/dd4hep::mm, calo->extent[3]/dd4hep::mm, calo->symmetry, calo->phi0 ) : @@ -285,9 +290,38 @@ namespace DD4hep{ } - caloDE.addExtension< GearHandle >( new GearHandle( gearCalo, "HcalBarrelParameters" ) ) ; + //********************************************************** + //* test gear interface w/ LayeredExtensionImpl extension + //********************************************************** + + DetElement calo2DE = lcdd.detector("EcalBarrel") ; + + Calorimeter calo2( calo2DE ) ; + + gear::CalorimeterParametersImpl* gearCalo2 = + ( calo2.isBarrel() ? + new gear::CalorimeterParametersImpl( calo2.getRMin()/dd4hep::mm, calo2.getZMax()/dd4hep::mm, calo2.getNSides(), 0. ) : // fixme: phi 0 is not defined ?? + new gear::CalorimeterParametersImpl( calo2.getRMin()/dd4hep::mm, calo2.getRMax()/dd4hep::mm, calo2.getZMin()/dd4hep::mm, calo2.getNSides(), 0. ) + ) ; + + for( unsigned i=0, nL = calo2.numberOfLayers() ; i <nL ; ++i ){ + + if( i == 0 ) { + gearCalo2->layerLayout().positionLayer( calo2.getRMin()/dd4hep::mm, calo2.thickness(i)/dd4hep::mm , 0. /dd4hep::mm, 0. /dd4hep::mm, calo2.absorberThickness(i)/dd4hep::mm ) ; + + }else{ // fixme: cell sizes not in API !? + + gearCalo2->layerLayout().addLayer( calo2.thickness(i)/dd4hep::mm , 0. /dd4hep::mm, 0. /dd4hep::mm, calo2.absorberThickness(i)/dd4hep::mm ) ; + } + + + } + + calo2DE.addExtension< GearHandle >( new GearHandle( gearCalo2, "EcalBarrelParameters" ) ) ; + + //============================================================================================