From b08ea4edabcea0a6378ab7235d8970aedc94f5d6 Mon Sep 17 00:00:00 2001 From: Frank Gaede <frank.gaede@desy.de> Date: Fri, 18 Sep 2015 08:45:46 +0000 Subject: [PATCH] - fixed some issues w/ new Surface classes - re-included implementations for CylinderSurface methods (u,v,nornaml,...) - use multi_map in SurfaceManager -> transparent to code expecting map lookup but provideds all surfaces when iterating - fixed Surface::distance using localPoint --- DDRec/include/DDRec/Surface.h | 27 +++++++++++++++- DDRec/include/DDRec/SurfaceManager.h | 2 +- DDRec/src/Surface.cpp | 47 +++++++++++++++++++++++++++- 3 files changed, 73 insertions(+), 3 deletions(-) diff --git a/DDRec/include/DDRec/Surface.h b/DDRec/include/DDRec/Surface.h index f1c99e34d..cfb96df1f 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 9f138d2b8..ee80e7532 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 0b9ef27b4..1fbc5b4c6 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 -- GitLab