diff --git a/DDRec/include/DDRec/Surface.h b/DDRec/include/DDRec/Surface.h index e4d366b001d58f544b30fa25b13f80a2d406a8cc..6e74fd55ff245529613774554be06d76ba08e1ec 100644 --- a/DDRec/include/DDRec/Surface.h +++ b/DDRec/include/DDRec/Surface.h @@ -203,9 +203,11 @@ namespace DD4hep { virtual ~VolSurfaceList(){ // delete all surfaces attached to this volume - for( VolSurfaceList::iterator i=begin(), n=end() ; i !=n ; ++i ) { - delete (*i).ptr() ; - } + // 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() ; + // } } } ; @@ -373,6 +375,19 @@ namespace DD4hep { }; + //====================================================================================================== + + class CylinderSurface: public Surface, public ICylinder { + + public: + + CylinderSurface( Geometry::DetElement det, VolSurface volSurf ) : Surface( det, volSurf ) { } + + virtual double radius() const { + + return _volSurf.origin().rho() ; + } + } ; //====================================================================================================== /** std::list of Surfaces that optionally takes ownership. diff --git a/DDRec/src/DetectorSurfaces.cpp b/DDRec/src/DetectorSurfaces.cpp index cc41ba346c24a620632006e2a3cfa3e5f749fff9..dc6c9551dc4f487a8fb3832015670bd582417a6a 100644 --- a/DDRec/src/DetectorSurfaces.cpp +++ b/DDRec/src/DetectorSurfaces.cpp @@ -43,12 +43,11 @@ namespace DD4hep { VolSurface volSurf = *it ; - Surface* surf = new Surface( det, volSurf ) ; - - // std::cout << " ------------------------- " - // << " surface: " << *surf << std::endl - // << " ------------------------- " << std::endl ; + Surface* surf = ( volSurf.type().isCylinder() ? new CylinderSurface( det, volSurf ) : new Surface( det, volSurf ) ) ; + // std::cout << " ------------------------- " + // << " surface: " << *surf << std::endl + // << " ------------------------- " << std::endl ; _sL->push_back( surf ) ; diff --git a/DDRec/src/Surface.cpp b/DDRec/src/Surface.cpp index 4466e75d43cb532ca6b0810d2dd87f656e8e9840..d4574aebcf1fd6f57ea25e86d33df3fb8ec0b7d2 100644 --- a/DDRec/src/Surface.cpp +++ b/DDRec/src/Surface.cpp @@ -804,6 +804,12 @@ namespace DD4hep { //=================================================================================================================== + // double CylinderSurfaceSurface::radius() const { + + // return _volSurf.origin().rho() ; + // } + + // //=================================================================================================================== } // namespace } // namespace diff --git a/DDSurfaces/include/DDSurfaces/ISurface.h b/DDSurfaces/include/DDSurfaces/ISurface.h index dc26061d1a1c19e619b15d5d4e1cefd81d77e7f8..549f5ba44c2d8f4a465790b545ac04645903e4d3 100644 --- a/DDSurfaces/include/DDSurfaces/ISurface.h +++ b/DDSurfaces/include/DDSurfaces/ISurface.h @@ -65,7 +65,21 @@ namespace DDSurfaces { } ; - + //============================================================================================== + /** Minimal interface to provide acces to radius of cylinder surfaces. + * @author F. Gaede, DESY + * @version $Id: $ + * @date May 6 2014 + */ + class ICylinder { + + public: + /// Destructor + virtual ~ICylinder() {} + virtual double radius() const=0 ; + }; + + /** Helper class for describing surface properties. * Usage: SurfaceType type( SurfaceType::Plane, SurfaceType::Sensitive ) ; * @@ -206,7 +220,12 @@ namespace DDSurfaces { os << " inner material : " << s.innerMaterial() << " thickness: " << s.innerThickness() << std::endl << " outerMaterial : " << s.outerMaterial() << " thickness: " << s.outerThickness() << std::endl ; - return os ; + const ICylinder* cyl = dynamic_cast< const ICylinder* > ( &s ) ; + + if( cyl ) + os << " cylinder radius : " << cyl->radius() << std::endl ; + + return os ; }