diff --git a/DDRec/include/DDRec/Surface.h b/DDRec/include/DDRec/Surface.h index f1c99e34dae78d1901dbf031a78547bd39c0e088..cfb96df1fa870d420cd8cb00989f60654c7f49bb 100644 --- a/DDRec/include/DDRec/Surface.h +++ b/DDRec/include/DDRec/Surface.h @@ -44,7 +44,7 @@ namespace DD4hep { MaterialData _innerMat ; MaterialData _outerMat ; Geometry::Volume _vol ; - int _id ; + long64 _id ; unsigned _refCount ; /// setter for daughter classes @@ -422,6 +422,8 @@ namespace DD4hep { VolSurface( new T( typ, thickness_inner, thickness_outer, u_val, v_val, n_val, o_val, vol , 0 ) ){ } + + T* operator->() { return static_cast<T*>( _surf ) ; } } ; //--------------------------------------------------------------------------------------------- @@ -567,12 +569,35 @@ namespace DD4hep { ///Standard c'tor. CylinderSurface( Geometry::DetElement det, VolSurface volSurf ) : Surface( det, volSurf ) { } + /** First direction of measurement U - rotated to point projected onto the cylinder. + * No check is done whether the point actually is on the cylinder surface + */ + virtual Vector3D u( const Vector3D& point = Vector3D() ) const ; + + /** Second direction of measurement V - rotated to point projected onto the cylinder. + * No check is done whether the point actually is on the cylinder surface + */ + virtual Vector3D v(const Vector3D& point = Vector3D() ) const ; + + /** The normal direction at the given point - rotated to point projected onto the cylinder. + * No check is done whether the point actually is on the cylinder surface + */ + virtual Vector3D normal(const Vector3D& point = Vector3D() ) const ; + + /** Convert the global position to the local position (u,v) on the surface - u runs along the axis of the cylinder, v is r*phi */ + virtual Vector2D globalToLocal( const Vector3D& point) const ; + + /** Convert the local position (u,v) on the surface to the global position - u runs along the axis of the cylinder, v is r*phi*/ + virtual Vector3D localToGlobal( const Vector2D& point) const ; + /// the radius of the cylinder (rho of the origin vector) virtual double radius() const ; /// the center of the cylinder virtual Vector3D center() const ; + + } ; //====================================================================================================== diff --git a/DDRec/include/DDRec/SurfaceManager.h b/DDRec/include/DDRec/SurfaceManager.h index 9f138d2b82fc539c89b0b786fa161d99af2b217f..ee80e7532f8b6f2cc871f84633825164c486ffc0 100644 --- a/DDRec/include/DDRec/SurfaceManager.h +++ b/DDRec/include/DDRec/SurfaceManager.h @@ -9,7 +9,7 @@ namespace DD4hep { namespace DDRec { /// typedef for surface maps, keyed by the cellID - typedef std::map< unsigned long, DDSurfaces::ISurface*> SurfaceMap ; + typedef std::multimap< unsigned long, DDSurfaces::ISurface*> SurfaceMap ; /** Surface manager class that holds maps of surfaces for all known * sensitive detector types and individual sub detectors. diff --git a/DDRec/src/Surface.cpp b/DDRec/src/Surface.cpp index 0b9ef27b46d4db93b98d68a11141bb539fbd2e72..1fbc5b4c6fad058d53177e69a30849251ebc1289 100644 --- a/DDRec/src/Surface.cpp +++ b/DDRec/src/Surface.cpp @@ -527,7 +527,7 @@ namespace DD4hep { _wtM->MasterToLocal( point , pa ) ; Vector3D localPoint( pa ) ; - return _volSurf.distance( point ) ; + return _volSurf.distance( localPoint ) ; //FG return ( _volSurf.type().isPlane() ? VolPlane(_volSurf).distance( localPoint ) : VolCylinder(_volSurf).distance( localPoint ) ) ; } @@ -1024,10 +1024,55 @@ namespace DD4hep { //================================================================================================================ + + Vector3D CylinderSurface::u( const Vector3D& point ) const { + + Vector3D lp , u_val ; + _wtM->MasterToLocal( point , lp.array() ) ; + const DDSurfaces::Vector3D& lu = _volSurf.u( lp ) ; + _wtM->LocalToMasterVect( lu , u_val.array() ) ; + return u_val ; + } + + Vector3D CylinderSurface::v(const Vector3D& point ) const { + Vector3D lp , v_val ; + _wtM->MasterToLocal( point , lp.array() ) ; + const DDSurfaces::Vector3D& lv = _volSurf.v( lp ) ; + _wtM->LocalToMasterVect( lv , v_val.array() ) ; + return v_val ; + } + + Vector3D CylinderSurface::normal(const Vector3D& point ) const { + Vector3D lp , n ; + _wtM->MasterToLocal( point , lp.array() ) ; + const DDSurfaces::Vector3D& ln = _volSurf.normal( lp ) ; + _wtM->LocalToMasterVect( ln , n.array() ) ; + return n ; + } + + Vector2D CylinderSurface::globalToLocal( const Vector3D& point) const { + + Vector3D lp; + _wtM->MasterToLocal( point , lp.array() ) ; + + return _volSurf.globalToLocal( lp ) ; + } + + + Vector3D CylinderSurface::localToGlobal( const Vector2D& point) const { + + Vector3D lp = _volSurf.localToGlobal( point ) ; + Vector3D p ; + _wtM->LocalToMaster( lp , p.array() ) ; + + return p ; + } + double CylinderSurface::radius() const { return _volSurf.origin().rho() ; } Vector3D CylinderSurface::center() const { return volumeOrigin() ; } + //================================================================================================================ } // namespace