From 33785f621d08587855ba9b12f17d6b32200cd2c9 Mon Sep 17 00:00:00 2001 From: christos Date: Sat, 7 May 2022 21:05:02 +0200 Subject: [PATCH] Surface make m_lineDirection a simple variable --- .../TrkSurfaces/TrkSurfaces/PerigeeSurface.h | 4 ++-- .../TrkSurfaces/TrkSurfaces/PerigeeSurface.icc | 13 ++----------- .../TrkSurfaces/StraightLineSurface.h | 7 ++++--- .../TrkSurfaces/StraightLineSurface.icc | 5 +---- .../TrkSurfaces/src/PerigeeSurface.cxx | 17 +++++++++-------- .../TrkSurfaces/src/StraightLineSurface.cxx | 12 ++++++------ 6 files changed, 24 insertions(+), 34 deletions(-) diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h index 8e9ab27f744..55c81ca3c81 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.h @@ -286,8 +286,8 @@ public: protected: //!< data members - //!< cache of the line direction (speeds up) - CxxUtils::CachedValue m_lineDirection; + //!< Precalculated line direction (speeds up) + Amg::Vector3D m_lineDirection; static const NoBounds s_perigeeBounds; }; diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.icc index 7f727ed9dcd..d94e9dd1a40 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/PerigeeSurface.icc @@ -205,18 +205,9 @@ PerigeeSurface::straightLineIntersection(const Amg::Vector3D& pos, inline const Amg::Vector3D& PerigeeSurface::lineDirection() const { - if (m_lineDirection.isValid()) { - return *(m_lineDirection.ptr()); - } - - if (Surface::m_transforms) { - if (!m_lineDirection.isValid()) { - m_lineDirection.set(transform().rotation().col(2)); - return *(m_lineDirection.ptr()); - } - } - return Trk::s_zAxis; + return m_lineDirection; } + /** the pathCorrection for derived classes with thickness */ inline double PerigeeSurface::pathCorrection(const Amg::Vector3D&, const Amg::Vector3D&) const diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.h b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.h index 4fb8f6ed95f..dad802bf2a0 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.h +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.h @@ -222,9 +222,10 @@ public: double locZ) const; /** Special method for StraightLineSurface - provides the Line direction from - * cache: speedup */ + * speedup */ const Amg::Vector3D& lineDirection() const; + /** fast straight line intersection schema - standard: provides closest intersection and (signed) path length forceDir is to provide the closest forward solution @@ -306,8 +307,8 @@ protected: //!< data members friend class ::BoundSurfaceCnv_p1; template friend class ::BoundSurfaceCnv_p2; - //!< cache of the line direction (speeds up) - CxxUtils::CachedValue m_lineDirection; + //!< Precalculate the line direction (speeds up access) + Amg::Vector3D m_lineDirection; //!< bounds (shared) SharedObject m_bounds; //!< NoBounds as return object when no bounds are declared diff --git a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.icc b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.icc index cd1ae574d43..ec8c23f922d 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.icc +++ b/Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/StraightLineSurface.icc @@ -172,10 +172,7 @@ StraightLineSurface::insideBoundsCheck(const Amg::Vector2D& locpos, inline const Amg::Vector3D& StraightLineSurface::lineDirection() const { - if (!m_lineDirection.isValid()) { - m_lineDirection.set(transform().rotation().col(2)); - } - return *(m_lineDirection.ptr()); + return m_lineDirection; } /** the pathCorrection for derived classes with thickness */ diff --git a/Tracking/TrkDetDescr/TrkSurfaces/src/PerigeeSurface.cxx b/Tracking/TrkDetDescr/TrkSurfaces/src/PerigeeSurface.cxx index 0d277d35f6b..5062cd303e1 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/src/PerigeeSurface.cxx +++ b/Tracking/TrkDetDescr/TrkSurfaces/src/PerigeeSurface.cxx @@ -20,24 +20,25 @@ const Trk::NoBounds Trk::PerigeeSurface::s_perigeeBounds; Trk::PerigeeSurface::PerigeeSurface() : Surface() - , m_lineDirection{} -{} +{ + m_lineDirection = transform().rotation().col(2); +} Trk::PerigeeSurface::PerigeeSurface(const Amg::Vector3D& gp) : Surface() - , m_lineDirection{} { - Amg::Transform3D transform (Amg::Translation3D(gp.x(), gp.y(), gp.z())); - Surface::m_transforms = std::make_unique(transform, gp, s_xAxis); + Amg::Transform3D tmpTransform(Amg::Translation3D(gp.x(), gp.y(), gp.z())); + Surface::m_transforms = std::make_unique(tmpTransform, gp, s_xAxis); + m_lineDirection = transform().rotation().col(2); } Trk::PerigeeSurface::PerigeeSurface(const Amg::Transform3D& tTransform) : Surface() // default for base - , m_lineDirection{} { Surface::m_transforms = std::make_unique(tTransform, tTransform.translation(), s_xAxis); + m_lineDirection = transform().rotation().col(2); } #if defined(FLATTEN) && defined(__GNUC__) @@ -50,17 +51,16 @@ __attribute__ ((flatten)) #endif Trk::PerigeeSurface::PerigeeSurface(const PerigeeSurface& pesf) : Surface(pesf) - , m_lineDirection{} { if (pesf.m_transforms) { Surface::m_transforms = std::make_unique( pesf.m_transforms->transform, pesf.m_transforms->center, s_xAxis); } + m_lineDirection = transform().rotation().col(2); } Trk::PerigeeSurface::PerigeeSurface(const PerigeeSurface& pesf, const Amg::Transform3D& shift) : Surface() - , m_lineDirection{} { if (pesf.m_transforms) { Surface::m_transforms = @@ -68,6 +68,7 @@ Trk::PerigeeSurface::PerigeeSurface(const PerigeeSurface& pesf, const Amg::Trans shift * pesf.m_transforms->center, s_xAxis); } + m_lineDirection = transform().rotation().col(2); } diff --git a/Tracking/TrkDetDescr/TrkSurfaces/src/StraightLineSurface.cxx b/Tracking/TrkDetDescr/TrkSurfaces/src/StraightLineSurface.cxx index aefc68dd486..f6401ccaf10 100644 --- a/Tracking/TrkDetDescr/TrkSurfaces/src/StraightLineSurface.cxx +++ b/Tracking/TrkDetDescr/TrkSurfaces/src/StraightLineSurface.cxx @@ -22,14 +22,14 @@ const Trk::NoBounds Trk::StraightLineSurface::s_boundless; // default constructor Trk::StraightLineSurface::StraightLineSurface() : Surface() - , m_lineDirection{} + , m_lineDirection{transform().rotation().col(2)} , m_bounds(nullptr) {} // constructors by arguments: boundless surface Trk::StraightLineSurface::StraightLineSurface(const Amg::Transform3D& htrans) : Surface(htrans) - , m_lineDirection{} + , m_lineDirection{transform().rotation().col(2)} , m_bounds(nullptr) {} @@ -39,7 +39,7 @@ Trk::StraightLineSurface::StraightLineSurface( double radius, double halez) : Surface(htrans) - , m_lineDirection{} + , m_lineDirection{transform().rotation().col(2)} , m_bounds(std::make_shared(radius, halez)) {} @@ -48,7 +48,7 @@ Trk::StraightLineSurface::StraightLineSurface( const Trk::TrkDetElementBase& detelement, const Identifier& id) : Surface(detelement, id) - , m_lineDirection{} + , m_lineDirection{transform().rotation().col(2)} , m_bounds(nullptr) {} @@ -56,7 +56,7 @@ Trk::StraightLineSurface::StraightLineSurface( Trk::StraightLineSurface::StraightLineSurface( const Trk::StraightLineSurface& slsf) : Surface(slsf) - , m_lineDirection{} + , m_lineDirection{transform().rotation().col(2)} , m_bounds(slsf.m_bounds) {} @@ -65,7 +65,7 @@ Trk::StraightLineSurface::StraightLineSurface( const StraightLineSurface& csf, const Amg::Transform3D& transf) : Surface(csf, transf) - , m_lineDirection{} + , m_lineDirection{transform().rotation().col(2)} , m_bounds(csf.m_bounds) {} -- GitLab