From bb1b6117ffc28b705999e05df7ccc6c4cdcb514a Mon Sep 17 00:00:00 2001 From: Frank Gaede <frank.gaede@desy.de> Date: Tue, 6 May 2014 10:52:43 +0000 Subject: [PATCH] - added ICylinder and CylinderSurface to provide access to cylinider radius for the tracking --- DDRec/include/DDRec/Surface.h | 21 ++++++++++++++++++--- DDRec/src/DetectorSurfaces.cpp | 9 ++++----- DDRec/src/Surface.cpp | 6 ++++++ DDSurfaces/include/DDSurfaces/ISurface.h | 23 +++++++++++++++++++++-- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/DDRec/include/DDRec/Surface.h b/DDRec/include/DDRec/Surface.h index e4d366b00..6e74fd55f 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 cc41ba346..dc6c9551d 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 4466e75d4..d4574aebc 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 dc26061d1..549f5ba44 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 ; } -- GitLab