From 72145fca5e4856cf4bb16297f64c3b8af15ea3e4 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Thu, 19 Dec 2024 10:26:14 +0100 Subject: [PATCH] chore: Cleanup some surface code (#3991) - clean includes - remove explicitly deleted or defaulted constructors / destructors - allows c++ to generate move constructor / assignment implicitly - clean namespace in source files ## Summary by CodeRabbit - **New Features** - Added `values()` method to multiple classes (e.g., `AnnulusBounds`, `ConeBounds`, `DiamondBounds`, `DiscTrapezoidBounds`, `EllipseBounds`, `RadialBounds`, `RectangleBounds`, `TrapezoidVolumeBounds`) to return internal state as a vector of doubles. - Introduced `checkConsistency()` method in several classes to validate parameters and throw exceptions for invalid configurations. - **Bug Fixes** - Enhanced error handling in `checkConsistency()` methods across various classes to throw `std::invalid_argument` exceptions for invalid inputs. - **Refactor** - Removed default constructors and destructors from multiple classes to enforce parameterized construction. - Streamlined method implementations by removing unnecessary namespace prefixes and inline definitions. - **Documentation** - Improved comments and documentation within the code to clarify functionality and usage. - **Tests** - Expanded unit tests for various classes to ensure comprehensive coverage of functionality and error handling. - **Chores** - Removed unused include directives from several files to clean up dependencies. --- .../Geometry/CutoutCylinderVolumeBounds.hpp | 25 --- Core/include/Acts/Surfaces/AnnulusBounds.hpp | 95 ++--------- .../Acts/Surfaces/BoundaryTolerance.hpp | 3 - Core/include/Acts/Surfaces/ConeBounds.hpp | 46 +----- Core/include/Acts/Surfaces/ConeSurface.hpp | 8 +- .../Acts/Surfaces/ConvexPolygonBounds.hpp | 17 +- .../Acts/Surfaces/ConvexPolygonBounds.ipp | 9 -- Core/include/Acts/Surfaces/CylinderBounds.hpp | 21 +-- .../include/Acts/Surfaces/CylinderSurface.hpp | 6 - Core/include/Acts/Surfaces/DiamondBounds.hpp | 25 +-- Core/include/Acts/Surfaces/DiscSurface.hpp | 6 - .../Acts/Surfaces/DiscTrapezoidBounds.hpp | 127 ++++----------- Core/include/Acts/Surfaces/EllipseBounds.hpp | 36 +---- Core/include/Acts/Surfaces/InfiniteBounds.hpp | 10 +- Core/include/Acts/Surfaces/LineBounds.hpp | 22 +-- Core/include/Acts/Surfaces/LineSurface.hpp | 5 - Core/include/Acts/Surfaces/PerigeeSurface.hpp | 8 - Core/include/Acts/Surfaces/PlaneSurface.hpp | 6 - Core/include/Acts/Surfaces/RadialBounds.hpp | 68 ++------ .../include/Acts/Surfaces/RectangleBounds.hpp | 70 +------- Core/include/Acts/Surfaces/RegularSurface.hpp | 2 +- Core/include/Acts/Surfaces/StrawSurface.hpp | 16 +- Core/include/Acts/Surfaces/Surface.hpp | 7 - Core/include/Acts/Surfaces/SurfaceArray.hpp | 1 - Core/include/Acts/Surfaces/SurfaceConcept.hpp | 1 + .../Acts/Surfaces/SurfaceMergingException.hpp | 1 + .../include/Acts/Surfaces/TrapezoidBounds.hpp | 10 +- .../Acts/Surfaces/detail/AlignmentHelper.hpp | 2 - .../Surfaces/detail/BoundaryCheckHelper.hpp | 1 + .../Acts/Surfaces/detail/MergeHelper.hpp | 5 - Core/src/Geometry/ConeVolumeBounds.cpp | 12 +- Core/src/Geometry/CuboidVolumeBounds.cpp | 10 +- .../Geometry/CutoutCylinderVolumeBounds.cpp | 45 ++++-- Core/src/Geometry/CylinderVolumeBounds.cpp | 5 +- Core/src/Geometry/TrapezoidVolumeBounds.cpp | 10 +- Core/src/Surfaces/AnnulusBounds.cpp | 130 ++++++++------- Core/src/Surfaces/BoundaryTolerance.cpp | 1 - Core/src/Surfaces/ConeBounds.cpp | 62 ++++--- Core/src/Surfaces/ConeSurface.cpp | 97 ++++++----- Core/src/Surfaces/ConvexPolygonBounds.cpp | 32 ++-- Core/src/Surfaces/CurvilinearSurface.cpp | 9 +- Core/src/Surfaces/CylinderBounds.cpp | 45 +++--- Core/src/Surfaces/CylinderSurface.cpp | 110 ++++++------- Core/src/Surfaces/DiamondBounds.cpp | 30 +++- Core/src/Surfaces/DiscSurface.cpp | 152 +++++++++--------- Core/src/Surfaces/DiscTrapezoidBounds.cpp | 68 ++++---- Core/src/Surfaces/EllipseBounds.cpp | 58 ++++--- Core/src/Surfaces/IntersectionHelper2D.cpp | 26 +-- Core/src/Surfaces/LineBounds.cpp | 25 ++- Core/src/Surfaces/LineSurface.cpp | 88 +++++----- Core/src/Surfaces/PerigeeSurface.cpp | 29 ++-- Core/src/Surfaces/PlaneSurface.cpp | 70 ++++---- Core/src/Surfaces/RadialBounds.cpp | 40 +++-- Core/src/Surfaces/RectangleBounds.cpp | 43 ++++- Core/src/Surfaces/StrawSurface.cpp | 31 ++-- Core/src/Surfaces/Surface.cpp | 121 +++++++------- Core/src/Surfaces/SurfaceArray.cpp | 20 +-- Core/src/Surfaces/TrapezoidBounds.cpp | 52 +++--- Core/src/Surfaces/detail/AlignmentHelper.cpp | 8 +- .../Surfaces/detail/AnnulusBoundsHelper.cpp | 12 +- Core/src/Surfaces/detail/MergeHelper.cpp | 5 +- Core/src/Surfaces/detail/VerticesHelper.cpp | 14 +- Plugins/Json/src/SurfaceJsonConverter.cpp | 3 +- .../Core/Surfaces/ConeSurfaceTests.cpp | 2 +- .../Surfaces/ConvexPolygonBoundsTests.cpp | 6 - .../Core/Surfaces/CylinderBoundsTests.cpp | 1 - .../Core/Surfaces/CylinderSurfaceTests.cpp | 10 +- .../Core/Surfaces/DiscSurfaceTests.cpp | 11 +- .../Core/Surfaces/LineSurfaceTests.cpp | 9 +- .../Core/Surfaces/PlaneSurfaceTests.cpp | 3 +- .../Core/Surfaces/PolyhedronSurfacesTests.cpp | 1 - .../Core/Surfaces/RadialBoundsTests.cpp | 1 - .../Core/Surfaces/StrawSurfaceTests.cpp | 4 - .../Core/Surfaces/SurfaceArrayTests.cpp | 3 - .../Surfaces/SurfaceIntersectionTests.cpp | 1 - .../SurfaceLocalToGlobalRoundtripTests.cpp | 5 - .../Core/Surfaces/TrapezoidBoundsTests.cpp | 2 - 77 files changed, 881 insertions(+), 1300 deletions(-) diff --git a/Core/include/Acts/Geometry/CutoutCylinderVolumeBounds.hpp b/Core/include/Acts/Geometry/CutoutCylinderVolumeBounds.hpp index fb9d6ca15a7..5d7278219da 100644 --- a/Core/include/Acts/Geometry/CutoutCylinderVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/CutoutCylinderVolumeBounds.hpp @@ -15,7 +15,6 @@ #include #include #include -#include #include namespace Acts { @@ -47,8 +46,6 @@ class CutoutCylinderVolumeBounds : public VolumeBounds { eSize }; - CutoutCylinderVolumeBounds() = delete; - /// Constructor from defining parameters /// /// @param rmin Minimum radius at the "choke points" @@ -73,8 +70,6 @@ class CutoutCylinderVolumeBounds : public VolumeBounds { buildSurfaceBounds(); } - ~CutoutCylinderVolumeBounds() override = default; - VolumeBounds::BoundsType type() const final { return VolumeBounds::eCutoutCylinder; } @@ -151,24 +146,4 @@ class CutoutCylinderVolumeBounds : public VolumeBounds { void checkConsistency() noexcept(false); }; -inline std::vector CutoutCylinderVolumeBounds::values() const { - std::vector valvector; - valvector.insert(valvector.begin(), m_values.begin(), m_values.end()); - return valvector; -} - -inline void CutoutCylinderVolumeBounds::checkConsistency() noexcept(false) { - if (get(eMinR) < 0. || get(eMedR) <= 0. || get(eMaxR) <= 0. || - get(eMinR) >= get(eMedR) || get(eMinR) >= get(eMaxR) || - get(eMedR) >= get(eMaxR)) { - throw std::invalid_argument( - "CutoutCylinderVolumeBounds: invalid radial input."); - } - if (get(eHalfLengthZ) <= 0 || get(eHalfLengthZcutout) <= 0. || - get(eHalfLengthZcutout) > get(eHalfLengthZ)) { - throw std::invalid_argument( - "CutoutCylinderVolumeBounds: invalid longitudinal input."); - } -} - } // namespace Acts diff --git a/Core/include/Acts/Surfaces/AnnulusBounds.hpp b/Core/include/Acts/Surfaces/AnnulusBounds.hpp index 942c20dc764..4e56b56dac7 100644 --- a/Core/include/Acts/Surfaces/AnnulusBounds.hpp +++ b/Core/include/Acts/Surfaces/AnnulusBounds.hpp @@ -10,18 +10,14 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/Tolerance.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/DiscBounds.hpp" #include "Acts/Surfaces/SurfaceBounds.hpp" -#include "Acts/Utilities/detail/periodic.hpp" #include #include -#include #include #include -#include #include namespace Acts { @@ -49,8 +45,6 @@ class AnnulusBounds : public DiscBounds { eSize = 7 }; - AnnulusBounds() = delete; - /// @brief Default constructor from parameters /// @param minR inner radius, in module system /// @param maxR outer radius, in module system @@ -74,7 +68,7 @@ class AnnulusBounds : public DiscBounds { AnnulusBounds(const AnnulusBounds& source) = default; - SurfaceBounds::BoundsType type() const final; + BoundsType type() const final { return SurfaceBounds::eAnnulus; } /// Return the bound values as dynamically sized vector /// @@ -102,24 +96,29 @@ class AnnulusBounds : public DiscBounds { /// @brief Returns the right angular edge of the module /// @return The right side angle - double phiMin() const; + double phiMin() const { return get(eMinPhiRel) + get(eAveragePhi); } /// @brief Returns the left angular edge of the module /// @return The left side angle - double phiMax() const; + double phiMax() const { return get(eMaxPhiRel) + get(eAveragePhi); } /// Returns true for full phi coverage - bool coversFullAzimuth() const final; + bool coversFullAzimuth() const final { + return (std::abs((get(eMinPhiRel) - get(eMaxPhiRel)) - std::numbers::pi) < + s_onSurfaceTolerance); + } /// Checks if this is inside the radial coverage /// given the a tolerance - bool insideRadialBounds(double R, double tolerance = 0.) const final; + bool insideRadialBounds(double R, double tolerance = 0.) const final { + return ((R + tolerance) > get(eMinR) && (R - tolerance) < get(eMaxR)); + } /// Return a reference radius for binning - double binningValueR() const final; + double binningValueR() const final { return 0.5 * (get(eMinR) + get(eMaxR)); } /// Return a reference radius for binning - double binningValuePhi() const final; + double binningValuePhi() const final { return get(eAveragePhi); } /// @brief Returns moduleOrigin, but rotated out, so @c averagePhi is already /// considered. The module origin needs to consider the rotation introduced by @@ -150,10 +149,10 @@ class AnnulusBounds : public DiscBounds { unsigned int quarterSegments = 2u) const override; /// This method returns inner radius - double rMin() const final; + double rMin() const final { return get(eMinR); } /// This method returns outer radius - double rMax() const final; + double rMax() const final { return get(eMaxR); } private: std::array m_values; @@ -202,72 +201,6 @@ class AnnulusBounds : public DiscBounds { /// @param vStripXY the position in the cartesian strip system /// @return the position in the module polar coordinate system Vector2 stripXYToModulePC(const Vector2& vStripXY) const; - - /// Private helper method - Vector2 closestOnSegment(const Vector2& a, const Vector2& b, const Vector2& p, - const SquareMatrix2& weight) const; - - /// Private helper method - double squaredNorm(const Vector2& v, const SquareMatrix2& weight) const; }; -inline SurfaceBounds::BoundsType AnnulusBounds::type() const { - return SurfaceBounds::eAnnulus; -} - -inline double AnnulusBounds::rMin() const { - return get(eMinR); -} - -inline double AnnulusBounds::rMax() const { - return get(eMaxR); -} - -inline double AnnulusBounds::phiMin() const { - return get(eMinPhiRel) + get(eAveragePhi); -} - -inline double AnnulusBounds::phiMax() const { - return get(eMaxPhiRel) + get(eAveragePhi); -} - -inline bool AnnulusBounds::coversFullAzimuth() const { - return (std::abs((get(eMinPhiRel) - get(eMaxPhiRel)) - std::numbers::pi) < - s_onSurfaceTolerance); -} - -inline bool AnnulusBounds::insideRadialBounds(double R, - double tolerance) const { - return ((R + tolerance) > get(eMinR) && (R - tolerance) < get(eMaxR)); -} - -inline double AnnulusBounds::binningValueR() const { - return 0.5 * (get(eMinR) + get(eMaxR)); -} - -inline double AnnulusBounds::binningValuePhi() const { - return get(eAveragePhi); -} - -inline std::vector AnnulusBounds::values() const { - std::vector valvector; - valvector.insert(valvector.begin(), m_values.begin(), m_values.end()); - return valvector; -} - -inline void AnnulusBounds::checkConsistency() noexcept(false) { - if (get(eMinR) < 0. || get(eMaxR) < 0. || get(eMinR) > get(eMaxR) || - std::abs(get(eMinR) - get(eMaxR)) < s_epsilon) { - throw std::invalid_argument("AnnulusBounds: invalid radial setup."); - } - if (get(eMinPhiRel) != detail::radian_sym(get(eMinPhiRel)) || - get(eMaxPhiRel) != detail::radian_sym(get(eMaxPhiRel)) || - get(eMinPhiRel) > get(eMaxPhiRel)) { - throw std::invalid_argument("AnnulusBounds: invalid phi boundary setup."); - } - if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) { - throw std::invalid_argument("AnnulusBounds: invalid phi positioning."); - } -} - } // namespace Acts diff --git a/Core/include/Acts/Surfaces/BoundaryTolerance.hpp b/Core/include/Acts/Surfaces/BoundaryTolerance.hpp index 603b8a2abe9..b4d9d041054 100644 --- a/Core/include/Acts/Surfaces/BoundaryTolerance.hpp +++ b/Core/include/Acts/Surfaces/BoundaryTolerance.hpp @@ -10,11 +10,8 @@ #include "Acts/Definitions/Algebra.hpp" -#include -#include #include #include -#include namespace Acts { diff --git a/Core/include/Acts/Surfaces/ConeBounds.hpp b/Core/include/Acts/Surfaces/ConeBounds.hpp index d0d684016a8..7d852f2df87 100644 --- a/Core/include/Acts/Surfaces/ConeBounds.hpp +++ b/Core/include/Acts/Surfaces/ConeBounds.hpp @@ -9,17 +9,14 @@ #pragma once #include "Acts/Definitions/Algebra.hpp" -#include "Acts/Definitions/Tolerance.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/SurfaceBounds.hpp" -#include "Acts/Utilities/detail/periodic.hpp" #include #include #include #include #include -#include #include namespace Acts { @@ -34,7 +31,6 @@ namespace Acts { /// /// @image html ConeBounds.gif /// - class ConeBounds : public SurfaceBounds { public: enum BoundValues : int { @@ -46,8 +42,6 @@ class ConeBounds : public SurfaceBounds { eSize = 5 }; - ConeBounds() = delete; - /// Constructor - open cone with alpha, by default a full cone /// but optionally can make a conical section /// @@ -77,9 +71,7 @@ class ConeBounds : public SurfaceBounds { /// @param values The parameter array ConeBounds(const std::array& values) noexcept(false); - ~ConeBounds() override = default; - - BoundsType type() const final; + BoundsType type() const final { return SurfaceBounds::eCone; } /// Return the bound values as dynamically sized vector /// @@ -105,10 +97,10 @@ class ConeBounds : public SurfaceBounds { /// /// @param z is the z value for which r is requested /// @return is the r value associated with z - double r(double z) const; + double r(double z) const { return std::abs(z * m_tanAlpha); } /// Return tangent of alpha (pre-computed) - double tanAlpha() const; + double tanAlpha() const { return m_tanAlpha; } /// Access to the bound values /// @param bValue the class nested enum for the array access @@ -124,38 +116,10 @@ class ConeBounds : public SurfaceBounds { /// Private helper function to shift a local 2D position /// + /// Shift r-phi coordinate to be centered around the average phi. + /// /// @param lposition The original local position Vector2 shifted(const Vector2& lposition) const; }; -inline double ConeBounds::r(double z) const { - return std::abs(z * m_tanAlpha); -} - -inline double ConeBounds::tanAlpha() const { - return m_tanAlpha; -} - -inline std::vector ConeBounds::values() const { - std::vector valvector; - valvector.insert(valvector.begin(), m_values.begin(), m_values.end()); - return valvector; -} - -inline void ConeBounds::checkConsistency() noexcept(false) { - if (get(eAlpha) < 0. || get(eAlpha) >= std::numbers::pi) { - throw std::invalid_argument("ConeBounds: invalid open angle."); - } - if (get(eMinZ) > get(eMaxZ) || - std::abs(get(eMinZ) - get(eMaxZ)) < s_epsilon) { - throw std::invalid_argument("ConeBounds: invalid z range setup."); - } - if (get(eHalfPhiSector) < 0. || abs(eHalfPhiSector) > std::numbers::pi) { - throw std::invalid_argument("ConeBounds: invalid phi sector setup."); - } - if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) { - throw std::invalid_argument("ConeBounds: invalid phi positioning."); - } -} - } // namespace Acts diff --git a/Core/include/Acts/Surfaces/ConeSurface.hpp b/Core/include/Acts/Surfaces/ConeSurface.hpp index 2f88bfe9532..34ebaf49694 100644 --- a/Core/include/Acts/Surfaces/ConeSurface.hpp +++ b/Core/include/Acts/Surfaces/ConeSurface.hpp @@ -11,7 +11,6 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/Alignment.hpp" #include "Acts/Definitions/Tolerance.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/Polyhedron.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" @@ -23,8 +22,6 @@ #include "Acts/Utilities/Result.hpp" #include "Acts/Utilities/detail/RealQuadraticEquation.hpp" -#include -#include #include #include #include @@ -41,7 +38,7 @@ namespace Acts { /// at the tip of the cone. /// Propagations to a cone surface will be returned in /// curvilinear coordinates. - +/// class ConeSurface : public RegularSurface { friend class Surface; @@ -85,9 +82,6 @@ class ConeSurface : public RegularSurface { const Transform3& shift); public: - ~ConeSurface() override = default; - ConeSurface() = delete; - /// Assignment operator /// /// @param other is the source surface for the assignment diff --git a/Core/include/Acts/Surfaces/ConvexPolygonBounds.hpp b/Core/include/Acts/Surfaces/ConvexPolygonBounds.hpp index e802056e7fd..afb5bb406f9 100644 --- a/Core/include/Acts/Surfaces/ConvexPolygonBounds.hpp +++ b/Core/include/Acts/Surfaces/ConvexPolygonBounds.hpp @@ -15,10 +15,7 @@ #include "Acts/Surfaces/SurfaceBounds.hpp" #include -#include -#include #include -#include #include #include @@ -82,8 +79,6 @@ class ConvexPolygonBounds : public ConvexPolygonBoundsBase { static_assert(N >= 3, "ConvexPolygonBounds needs at least 3 sides."); - ConvexPolygonBounds() = delete; - /// Constructor from a vector of vertices, to facilitate construction. /// This will throw if the vector size does not match `num_vertices`. /// This will throw if the vertices do not form a convex polygon. @@ -100,9 +95,7 @@ class ConvexPolygonBounds : public ConvexPolygonBoundsBase { /// @param values The values to build up the vertices ConvexPolygonBounds(const value_array& values) noexcept(false); - ~ConvexPolygonBounds() override = default; - - BoundsType type() const final; + BoundsType type() const final { return SurfaceBounds::eConvexPolygon; } /// Return whether a local 2D point lies inside of the bounds defined by this /// object. @@ -146,12 +139,6 @@ class ConvexPolygonBounds : public ConvexPolygonBoundsBase { public: constexpr static int eSize = -1; - /// Default constructor, deleted - ConvexPolygonBounds() = delete; - - /// Defaulted destructor - ~ConvexPolygonBounds() override = default; - /// Constructor from a vector of vertices, to facilitate construction. /// This will throw if the vertices do not form a convex polygon. /// @param vertices The list of vertices. @@ -159,7 +146,7 @@ class ConvexPolygonBounds : public ConvexPolygonBoundsBase { /// Return the bounds type of this bounds object. /// @return The bounds type - BoundsType type() const final; + BoundsType type() const final { return SurfaceBounds::eConvexPolygon; } /// Return whether a local 2D point lies inside of the bounds defined by this /// object. diff --git a/Core/include/Acts/Surfaces/ConvexPolygonBounds.ipp b/Core/include/Acts/Surfaces/ConvexPolygonBounds.ipp index 9f1a61955ae..8201a9dedd6 100644 --- a/Core/include/Acts/Surfaces/ConvexPolygonBounds.ipp +++ b/Core/include/Acts/Surfaces/ConvexPolygonBounds.ipp @@ -6,13 +6,9 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -#include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/detail/BoundaryCheckHelper.hpp" #include "Acts/Utilities/ThrowAssert.hpp" -#include -#include - template requires std::same_as void Acts::ConvexPolygonBoundsBase::convex_impl( @@ -96,11 +92,6 @@ Acts::ConvexPolygonBounds::ConvexPolygonBounds( checkConsistency(); } -template -Acts::SurfaceBounds::BoundsType Acts::ConvexPolygonBounds::type() const { - return SurfaceBounds::eConvexPolygon; -} - template bool Acts::ConvexPolygonBounds::inside( const Acts::Vector2& lposition, diff --git a/Core/include/Acts/Surfaces/CylinderBounds.hpp b/Core/include/Acts/Surfaces/CylinderBounds.hpp index 11e011059b9..10fab504635 100644 --- a/Core/include/Acts/Surfaces/CylinderBounds.hpp +++ b/Core/include/Acts/Surfaces/CylinderBounds.hpp @@ -12,14 +12,11 @@ #include "Acts/Definitions/Tolerance.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/SurfaceBounds.hpp" -#include "Acts/Utilities/detail/periodic.hpp" #include #include -#include #include #include -#include #include namespace Acts { @@ -60,8 +57,6 @@ class CylinderBounds : public SurfaceBounds { eSize = 6 }; - CylinderBounds() = delete; - /// Constructor - full cylinder /// /// @param r The radius of the cylinder @@ -88,9 +83,7 @@ class CylinderBounds : public SurfaceBounds { checkConsistency(); } - ~CylinderBounds() override = default; - - BoundsType type() const final; + BoundsType type() const final { return SurfaceBounds::eCylinder; } /// Return the bound values as dynamically sized vector /// @@ -112,7 +105,7 @@ class CylinderBounds : public SurfaceBounds { double get(BoundValues bValue) const { return m_values[bValue]; } /// Returns true for full phi coverage - bool coversFullAzimuth() const; + bool coversFullAzimuth() const { return m_closed; } /// Create the bow/circle vertices on either side of the cylinder /// @@ -148,14 +141,4 @@ class CylinderBounds : public SurfaceBounds { SquareMatrix2 jacobian() const; }; -inline std::vector CylinderBounds::values() const { - std::vector valvector; - valvector.insert(valvector.begin(), m_values.begin(), m_values.end()); - return valvector; -} - -inline bool CylinderBounds::coversFullAzimuth() const { - return m_closed; -} - } // namespace Acts diff --git a/Core/include/Acts/Surfaces/CylinderSurface.hpp b/Core/include/Acts/Surfaces/CylinderSurface.hpp index 971ff7039f7..2f64852dbee 100644 --- a/Core/include/Acts/Surfaces/CylinderSurface.hpp +++ b/Core/include/Acts/Surfaces/CylinderSurface.hpp @@ -11,7 +11,6 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/Alignment.hpp" #include "Acts/Definitions/Tolerance.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/Polyhedron.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" @@ -24,8 +23,6 @@ #include "Acts/Utilities/Result.hpp" #include "Acts/Utilities/detail/RealQuadraticEquation.hpp" -#include -#include #include #include #include @@ -90,9 +87,6 @@ class CylinderSurface : public RegularSurface { const Transform3& shift); public: - ~CylinderSurface() override = default; - CylinderSurface() = delete; - /// Assignment operator /// /// @param other is the source cylinder for the copy diff --git a/Core/include/Acts/Surfaces/DiamondBounds.hpp b/Core/include/Acts/Surfaces/DiamondBounds.hpp index 7497bd22309..096efc2dd27 100644 --- a/Core/include/Acts/Surfaces/DiamondBounds.hpp +++ b/Core/include/Acts/Surfaces/DiamondBounds.hpp @@ -9,7 +9,6 @@ #pragma once #include "Acts/Definitions/Algebra.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/PlanarBounds.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" @@ -17,9 +16,7 @@ #include #include -#include #include -#include #include namespace Acts { @@ -39,8 +36,6 @@ class DiamondBounds : public PlanarBounds { eSize = 5 }; - DiamondBounds() = delete; - /// Constructor for convex hexagon symmetric about the y axis /// /// @param halfXnegY is the halflength in x at minimal y @@ -71,9 +66,7 @@ class DiamondBounds : public PlanarBounds { Vector2{*std::max_element(values.begin(), values.begin() + 2), values[eHalfLengthYpos]}) {} - ~DiamondBounds() override = default; - - BoundsType type() const final; + BoundsType type() const final { return SurfaceBounds::eDiamond; } /// Return the bound values as dynamically sized vector /// @@ -119,20 +112,4 @@ class DiamondBounds : public PlanarBounds { void checkConsistency() noexcept(false); }; -inline std::vector DiamondBounds::values() const { - std::vector valvector; - valvector.insert(valvector.begin(), m_values.begin(), m_values.end()); - return valvector; -} - -inline void DiamondBounds::checkConsistency() noexcept(false) { - if (std::ranges::any_of(m_values, [](auto v) { return v <= 0.; })) { - throw std::invalid_argument("DiamondBounds: negative half length."); - } - if (get(eHalfLengthXnegY) > get(eHalfLengthXzeroY) || - get(eHalfLengthXposY) > get(eHalfLengthXzeroY)) { - throw std::invalid_argument("DiamondBounds: not a diamond shape."); - } -} - } // namespace Acts diff --git a/Core/include/Acts/Surfaces/DiscSurface.hpp b/Core/include/Acts/Surfaces/DiscSurface.hpp index 6a3144a00aa..01e6bbd297c 100644 --- a/Core/include/Acts/Surfaces/DiscSurface.hpp +++ b/Core/include/Acts/Surfaces/DiscSurface.hpp @@ -15,15 +15,12 @@ #include "Acts/Geometry/Polyhedron.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/DiscBounds.hpp" -#include "Acts/Surfaces/InfiniteBounds.hpp" #include "Acts/Surfaces/RegularSurface.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Surfaces/SurfaceConcept.hpp" #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Result.hpp" -#include -#include #include #include #include @@ -109,9 +106,6 @@ class DiscSurface : public RegularSurface { const Transform3& shift); public: - ~DiscSurface() override = default; - DiscSurface() = delete; - /// Assignment operator /// /// @param other The source sourface for the assignment diff --git a/Core/include/Acts/Surfaces/DiscTrapezoidBounds.hpp b/Core/include/Acts/Surfaces/DiscTrapezoidBounds.hpp index 1c5215b3c20..57ffd86586a 100644 --- a/Core/include/Acts/Surfaces/DiscTrapezoidBounds.hpp +++ b/Core/include/Acts/Surfaces/DiscTrapezoidBounds.hpp @@ -9,18 +9,15 @@ #pragma once #include "Acts/Definitions/Algebra.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/DiscBounds.hpp" #include "Acts/Surfaces/SurfaceBounds.hpp" -#include "Acts/Utilities/detail/periodic.hpp" #include #include #include #include #include -#include #include namespace Acts { @@ -30,7 +27,7 @@ namespace Acts { /// Class to describe the bounds for a planar DiscSurface. /// By providing an argument for hphisec, the bounds can /// be restricted to a phi-range around the center position. - +/// class DiscTrapezoidBounds : public DiscBounds { public: enum BoundValues : int { @@ -43,8 +40,6 @@ class DiscTrapezoidBounds : public DiscBounds { eSize = 6 }; - DiscTrapezoidBounds() = delete; - /// Constructor for a symmetric Trapezoid giving min X length, max X length, /// Rmin and R max /// @param halfXminR half length in X at min radius @@ -65,9 +60,7 @@ class DiscTrapezoidBounds : public DiscBounds { checkConsistency(); } - ~DiscTrapezoidBounds() override = default; - - SurfaceBounds::BoundsType type() const final; + BoundsType type() const final { return SurfaceBounds::eDiscTrapezoid; } /// Return the bound values as dynamically sized vector /// @@ -92,35 +85,57 @@ class DiscTrapezoidBounds : public DiscBounds { double get(BoundValues bValue) const { return m_values[bValue]; } /// This method returns inner radius - double rMin() const final; + double rMin() const final { return get(eMinR); } /// This method returns outer radius - double rMax() const final; + double rMax() const final { return get(eMaxR); } /// This method returns the center radius - double rCenter() const; + double rCenter() const { + double rmin = get(eMinR); + double rmax = get(eMaxR); + double hxmin = get(eHalfLengthXminR); + double hxmax = get(eHalfLengthXmaxR); + auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin); + auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax); + return 0.5 * (hmin + hmax); + } /// This method returns the stereo angle - double stereo() const; + double stereo() const { return get(eStereo); } /// This method returns the halfPhiSector which is covered by the disc - double halfPhiSector() const; + double halfPhiSector() const { + auto minHalfPhi = std::asin(get(eHalfLengthXminR) / get(eMinR)); + auto maxHalfPhi = std::asin(get(eHalfLengthXmaxR) / get(eMaxR)); + return std::max(minHalfPhi, maxHalfPhi); + } /// This method returns the half length in Y (this is Rmax -Rmin) - double halfLengthY() const; + double halfLengthY() const { + double rmin = get(eMinR); + double rmax = get(eMaxR); + double hxmin = get(eHalfLengthXminR); + double hxmax = get(eHalfLengthXmaxR); + auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin); + auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax); + return 0.5 * (hmax - hmin); + } /// Returns true for full phi coverage - obviously false here - bool coversFullAzimuth() const final; + bool coversFullAzimuth() const final { return false; } /// Checks if this is inside the radial coverage /// given the a tolerance - bool insideRadialBounds(double R, double tolerance = 0.) const final; + bool insideRadialBounds(double R, double tolerance = 0.) const final { + return (R + tolerance > get(eMinR) && R - tolerance < get(eMaxR)); + } /// Return a reference radius for binning - double binningValueR() const final; + double binningValueR() const final { return 0.5 * (get(eMinR) + get(eMaxR)); } /// Return a reference phi for binning - double binningValuePhi() const final; + double binningValuePhi() const final { return get(eAveragePhi); } /// This method returns the xy coordinates of the four corners of the /// bounds in module coorindates (in xy) @@ -154,78 +169,4 @@ class DiscTrapezoidBounds : public DiscBounds { SquareMatrix2 jacobianToLocalCartesian(const Vector2& lposition) const; }; -inline double DiscTrapezoidBounds::rMin() const { - return get(eMinR); -} - -inline double DiscTrapezoidBounds::rMax() const { - return get(eMaxR); -} - -inline double DiscTrapezoidBounds::stereo() const { - return get(eStereo); -} - -inline double DiscTrapezoidBounds::halfPhiSector() const { - auto minHalfPhi = std::asin(get(eHalfLengthXminR) / get(eMinR)); - auto maxHalfPhi = std::asin(get(eHalfLengthXmaxR) / get(eMaxR)); - return std::max(minHalfPhi, maxHalfPhi); -} - -inline double DiscTrapezoidBounds::rCenter() const { - double rmin = get(eMinR); - double rmax = get(eMaxR); - double hxmin = get(eHalfLengthXminR); - double hxmax = get(eHalfLengthXmaxR); - auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin); - auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax); - return 0.5 * (hmin + hmax); -} - -inline double DiscTrapezoidBounds::halfLengthY() const { - double rmin = get(eMinR); - double rmax = get(eMaxR); - double hxmin = get(eHalfLengthXminR); - double hxmax = get(eHalfLengthXmaxR); - auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin); - auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax); - return 0.5 * (hmax - hmin); -} - -inline bool DiscTrapezoidBounds::coversFullAzimuth() const { - return false; -} - -inline bool DiscTrapezoidBounds::insideRadialBounds(double R, - double tolerance) const { - return (R + tolerance > get(eMinR) && R - tolerance < get(eMaxR)); -} - -inline double DiscTrapezoidBounds::binningValueR() const { - return 0.5 * (get(eMinR) + get(eMaxR)); -} - -inline double DiscTrapezoidBounds::binningValuePhi() const { - return get(eAveragePhi); -} - -inline std::vector DiscTrapezoidBounds::values() const { - std::vector valvector; - valvector.insert(valvector.begin(), m_values.begin(), m_values.end()); - return valvector; -} - -inline void DiscTrapezoidBounds::checkConsistency() noexcept(false) { - if (get(eMinR) < 0. || get(eMaxR) <= 0. || get(eMinR) > get(eMaxR)) { - throw std::invalid_argument("DiscTrapezoidBounds: invalid radial setup."); - } - if (get(eHalfLengthXminR) < 0. || get(eHalfLengthXmaxR) <= 0.) { - throw std::invalid_argument("DiscTrapezoidBounds: negative length given."); - } - if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) { - throw std::invalid_argument( - "DiscTrapezoidBounds: invalid phi positioning."); - } -} - } // namespace Acts diff --git a/Core/include/Acts/Surfaces/EllipseBounds.hpp b/Core/include/Acts/Surfaces/EllipseBounds.hpp index ea90e3d2a88..007c0fd0aff 100644 --- a/Core/include/Acts/Surfaces/EllipseBounds.hpp +++ b/Core/include/Acts/Surfaces/EllipseBounds.hpp @@ -13,15 +13,10 @@ #include "Acts/Surfaces/PlanarBounds.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Surfaces/SurfaceBounds.hpp" -#include "Acts/Utilities/detail/periodic.hpp" #include -#include -#include -#include #include #include -#include #include namespace Acts { @@ -47,8 +42,6 @@ class EllipseBounds : public PlanarBounds { eSize = 6 }; - EllipseBounds() = delete; - /// Constructor for full of an ellipsoid ring /// /// @param innerRx The inner ellipse radius in x @@ -73,9 +66,7 @@ class EllipseBounds : public PlanarBounds { checkConsistency(); } - ~EllipseBounds() override = default; - - BoundsType type() const final; + BoundsType type() const final { return SurfaceBounds::eEllipse; } /// Return the bound values as dynamically sized vector /// @@ -86,6 +77,8 @@ class EllipseBounds : public PlanarBounds { /// two ellipsoids if only tol0 is given and additional in the phi sector is /// tol1 is given /// + /// @warning This **only** works for tolerance-based checks + /// /// @param lposition Local position (assumed to be in right surface frame) /// @param boundaryTolerance boundary check directive /// @return boolean indicator for the success of this operation @@ -121,27 +114,4 @@ class EllipseBounds : public PlanarBounds { void checkConsistency() noexcept(false); }; -inline std::vector EllipseBounds::values() const { - std::vector valvector; - valvector.insert(valvector.begin(), m_values.begin(), m_values.end()); - return valvector; -} - -inline void EllipseBounds::checkConsistency() noexcept(false) { - if (get(eInnerRx) >= get(eOuterRx) || get(eInnerRx) < 0. || - get(eOuterRx) <= 0.) { - throw std::invalid_argument("EllipseBounds: invalid along x axis"); - } - if (get(eInnerRy) >= get(eOuterRy) || get(eInnerRy) < 0. || - get(eOuterRy) <= 0.) { - throw std::invalid_argument("EllipseBounds: invalid along y axis."); - } - if (get(eHalfPhiSector) < 0. || get(eHalfPhiSector) > std::numbers::pi) { - throw std::invalid_argument("EllipseBounds: invalid phi sector setup."); - } - if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) { - throw std::invalid_argument("EllipseBounds: invalid phi positioning."); - } -} - } // namespace Acts diff --git a/Core/include/Acts/Surfaces/InfiniteBounds.hpp b/Core/include/Acts/Surfaces/InfiniteBounds.hpp index 261f40e4729..e08ff779cbf 100644 --- a/Core/include/Acts/Surfaces/InfiniteBounds.hpp +++ b/Core/include/Acts/Surfaces/InfiniteBounds.hpp @@ -17,16 +17,10 @@ namespace Acts { /// /// templated boundless extension to forward the interface /// Returns all inside checks to true and can templated for all bounds - +/// class InfiniteBounds : public SurfaceBounds { public: - InfiniteBounds() = default; - - ~InfiniteBounds() override = default; - - SurfaceBounds::BoundsType type() const final { - return SurfaceBounds::eBoundless; - } + BoundsType type() const final { return SurfaceBounds::eBoundless; } std::vector values() const final { return {}; } diff --git a/Core/include/Acts/Surfaces/LineBounds.hpp b/Core/include/Acts/Surfaces/LineBounds.hpp index e3169d8a845..7a8d2af2468 100644 --- a/Core/include/Acts/Surfaces/LineBounds.hpp +++ b/Core/include/Acts/Surfaces/LineBounds.hpp @@ -14,7 +14,6 @@ #include #include -#include #include namespace Acts { @@ -26,8 +25,6 @@ class LineBounds : public SurfaceBounds { public: enum BoundValues : int { eR = 0, eHalfLengthZ = 1, eSize = 2 }; - LineBounds() = delete; - /// Constructor /// /// @param r is the radius of the cylinder, default = 0. @@ -44,9 +41,7 @@ class LineBounds : public SurfaceBounds { checkConsistency(); } - ~LineBounds() override = default; - - BoundsType type() const final; + BoundsType type() const final { return SurfaceBounds::eLine; } /// Return the bound values as dynamically sized vector /// @@ -81,19 +76,4 @@ class LineBounds : public SurfaceBounds { void checkConsistency() noexcept(false); }; -inline std::vector LineBounds::values() const { - std::vector valvector; - valvector.insert(valvector.begin(), m_values.begin(), m_values.end()); - return valvector; -} - -inline void LineBounds::checkConsistency() noexcept(false) { - if (get(eR) < 0.) { - throw std::invalid_argument("LineBounds: zero radius."); - } - if (get(eHalfLengthZ) <= 0.) { - throw std::invalid_argument("LineBounds: zero/negative length."); - } -} - } // namespace Acts diff --git a/Core/include/Acts/Surfaces/LineSurface.hpp b/Core/include/Acts/Surfaces/LineSurface.hpp index be13e90b43b..79660e17dca 100644 --- a/Core/include/Acts/Surfaces/LineSurface.hpp +++ b/Core/include/Acts/Surfaces/LineSurface.hpp @@ -13,9 +13,7 @@ #include "Acts/Definitions/Tolerance.hpp" #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/Geometry/Polyhedron.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" -#include "Acts/Surfaces/InfiniteBounds.hpp" #include "Acts/Surfaces/LineBounds.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/BinningType.hpp" @@ -81,9 +79,6 @@ class LineSurface : public Surface { const Transform3& shift); public: - ~LineSurface() override = default; - LineSurface() = delete; - /// Assignment operator /// /// @param other is the source surface dor copying diff --git a/Core/include/Acts/Surfaces/PerigeeSurface.hpp b/Core/include/Acts/Surfaces/PerigeeSurface.hpp index 25fb6d08343..660e0b3ad93 100644 --- a/Core/include/Acts/Surfaces/PerigeeSurface.hpp +++ b/Core/include/Acts/Surfaces/PerigeeSurface.hpp @@ -11,12 +11,10 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/Polyhedron.hpp" -#include "Acts/Surfaces/InfiniteBounds.hpp" #include "Acts/Surfaces/LineSurface.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Surfaces/SurfaceConcept.hpp" -#include #include #include @@ -57,12 +55,6 @@ class PerigeeSurface : public LineSurface { const Transform3& shift); public: - /// Destructor - defaulted - ~PerigeeSurface() override = default; - - /// Default Constructor - deleted - PerigeeSurface() = delete; - /// Assignment operator /// /// @param other is the source surface to be assigned diff --git a/Core/include/Acts/Surfaces/PlaneSurface.hpp b/Core/include/Acts/Surfaces/PlaneSurface.hpp index e4fda361828..ddf968da2ea 100644 --- a/Core/include/Acts/Surfaces/PlaneSurface.hpp +++ b/Core/include/Acts/Surfaces/PlaneSurface.hpp @@ -13,7 +13,6 @@ #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Geometry/Polyhedron.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" -#include "Acts/Surfaces/InfiniteBounds.hpp" #include "Acts/Surfaces/PlanarBounds.hpp" #include "Acts/Surfaces/RegularSurface.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -21,8 +20,6 @@ #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Result.hpp" -#include -#include #include #include @@ -73,9 +70,6 @@ class PlaneSurface : public RegularSurface { std::shared_ptr pbounds = nullptr); public: - ~PlaneSurface() override = default; - PlaneSurface() = delete; - /// Assignment operator /// /// @param other The source PlaneSurface for assignment diff --git a/Core/include/Acts/Surfaces/RadialBounds.hpp b/Core/include/Acts/Surfaces/RadialBounds.hpp index ef3e8996572..f10884e5b75 100644 --- a/Core/include/Acts/Surfaces/RadialBounds.hpp +++ b/Core/include/Acts/Surfaces/RadialBounds.hpp @@ -9,17 +9,13 @@ #pragma once #include "Acts/Definitions/Algebra.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/DiscBounds.hpp" #include "Acts/Surfaces/SurfaceBounds.hpp" -#include "Acts/Utilities/detail/periodic.hpp" #include -#include #include #include -#include #include namespace Acts { @@ -40,8 +36,6 @@ class RadialBounds : public DiscBounds { eSize = 4 }; - RadialBounds() = delete; - /// Constructor for full disc of symmetric disc around phi=0 /// /// @param minR The inner radius (0 for full disc) @@ -62,9 +56,7 @@ class RadialBounds : public DiscBounds { checkConsistency(); } - ~RadialBounds() override = default; - - SurfaceBounds::BoundsType type() const final; + BoundsType type() const final { return SurfaceBounds::eDisc; } /// Return the bound values as dynamically sized vector /// @@ -86,27 +78,31 @@ class RadialBounds : public DiscBounds { std::ostream& toStream(std::ostream& sl) const final; /// Return method for inner Radius - double rMin() const final; + double rMin() const final { return get(eMinR); } /// Return method for outer Radius - double rMax() const final; + double rMax() const final { return get(eMaxR); } /// Access to the bound values /// @param bValue the class nested enum for the array access double get(BoundValues bValue) const { return m_values[bValue]; } /// Returns true for full phi coverage - bool coversFullAzimuth() const final; + bool coversFullAzimuth() const final { + return (get(eHalfPhiSector) == std::numbers::pi); + } /// Checks if this is inside the radial coverage /// given the a tolerance - bool insideRadialBounds(double R, double tolerance = 0.) const final; + bool insideRadialBounds(double R, double tolerance = 0.) const final { + return (R + tolerance > get(eMinR) && R - tolerance < get(eMaxR)); + } /// Return a reference radius for binning - double binningValueR() const final; + double binningValueR() const final { return 0.5 * (get(eMinR) + get(eMaxR)); } /// Return a reference radius for binning - double binningValuePhi() const final; + double binningValuePhi() const final { return get(eAveragePhi); } private: std::array m_values; @@ -134,46 +130,4 @@ class RadialBounds : public DiscBounds { std::vector vertices(unsigned int lseg) const final; }; -inline double RadialBounds::rMin() const { - return get(eMinR); -} - -inline double RadialBounds::rMax() const { - return get(eMaxR); -} - -inline bool RadialBounds::coversFullAzimuth() const { - return (get(eHalfPhiSector) == std::numbers::pi); -} - -inline bool RadialBounds::insideRadialBounds(double R, double tolerance) const { - return (R + tolerance > get(eMinR) && R - tolerance < get(eMaxR)); -} - -inline double RadialBounds::binningValueR() const { - return 0.5 * (get(eMinR) + get(eMaxR)); -} - -inline double RadialBounds::binningValuePhi() const { - return get(eAveragePhi); -} - -inline std::vector RadialBounds::values() const { - std::vector valvector; - valvector.insert(valvector.begin(), m_values.begin(), m_values.end()); - return valvector; -} - -inline void RadialBounds::checkConsistency() noexcept(false) { - if (get(eMinR) < 0. || get(eMaxR) <= 0. || get(eMinR) > get(eMaxR)) { - throw std::invalid_argument("RadialBounds: invalid radial setup"); - } - if (get(eHalfPhiSector) < 0. || get(eHalfPhiSector) > std::numbers::pi) { - throw std::invalid_argument("RadialBounds: invalid phi sector setup."); - } - if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) { - throw std::invalid_argument("RadialBounds: invalid phi positioning."); - } -} - } // namespace Acts diff --git a/Core/include/Acts/Surfaces/RectangleBounds.hpp b/Core/include/Acts/Surfaces/RectangleBounds.hpp index aba1743fa74..87620dadab8 100644 --- a/Core/include/Acts/Surfaces/RectangleBounds.hpp +++ b/Core/include/Acts/Surfaces/RectangleBounds.hpp @@ -14,10 +14,7 @@ #include "Acts/Surfaces/SurfaceBounds.hpp" #include -#include #include -#include -#include #include namespace Acts { @@ -39,8 +36,6 @@ class RectangleBounds : public PlanarBounds { eSize = 4 }; - RectangleBounds() = delete; - /// Constructor with halflength in x and y - symmetric /// /// @param halfX halflength in X @@ -68,11 +63,11 @@ class RectangleBounds : public PlanarBounds { checkConsistency(); } - ~RectangleBounds() override = default; - - BoundsType type() const final; + BoundsType type() const final { return SurfaceBounds::eRectangle; } - std::vector values() const final; + std::vector values() const final { + return {m_min.x(), m_min.y(), m_max.x(), m_max.y()}; + } /// Inside check for the bounds object driven by the boundary check directive /// Each Bounds has a method inside, which checks if a LocalPosition is inside @@ -106,18 +101,18 @@ class RectangleBounds : public PlanarBounds { double get(BoundValues bValue) const; /// Access to the half length in X - double halfLengthX() const; + double halfLengthX() const { return 0.5 * (m_max.x() - m_min.x()); } /// Access to the half length in Y - double halfLengthY() const; + double halfLengthY() const { return 0.5 * (m_max.y() - m_min.y()); } /// Get the min vertex defining the bounds /// @return The min vertex - const Vector2& min() const; + const Vector2& min() const { return m_min; } /// Get the max vertex defining the bounds /// @return The max vertex - const Vector2& max() const; + const Vector2& max() const { return m_max; } private: Vector2 m_min; @@ -128,53 +123,4 @@ class RectangleBounds : public PlanarBounds { void checkConsistency() noexcept(false); }; -inline SurfaceBounds::BoundsType RectangleBounds::type() const { - return SurfaceBounds::eRectangle; -} - -inline const Vector2& RectangleBounds::min() const { - return m_min; -} - -inline const Vector2& RectangleBounds::max() const { - return m_max; -} - -inline double RectangleBounds::halfLengthX() const { - return 0.5 * (m_max.x() - m_min.x()); -} - -inline double RectangleBounds::halfLengthY() const { - return 0.5 * (m_max.y() - m_min.y()); -} - -inline std::vector RectangleBounds::values() const { - return {m_min.x(), m_min.y(), m_max.x(), m_max.y()}; -} - -inline double RectangleBounds::get(BoundValues bValue) const { - switch (bValue) { - case eMinX: - return m_min.x(); - case eMinY: - return m_min.y(); - case eMaxX: - return m_max.x(); - case eMaxY: - return m_max.y(); - default: - assert(false && "Invalid BoundValue enum value"); - return std::numeric_limits::quiet_NaN(); - } -} - -inline void RectangleBounds::checkConsistency() noexcept(false) { - if (get(eMinX) > get(eMaxX)) { - throw std::invalid_argument("RectangleBounds: invalid local x setup"); - } - if (get(eMinY) > get(eMaxY)) { - throw std::invalid_argument("RectangleBounds: invalid local y setup"); - } -} - } // namespace Acts diff --git a/Core/include/Acts/Surfaces/RegularSurface.hpp b/Core/include/Acts/Surfaces/RegularSurface.hpp index f091c73b99a..48a35302f12 100644 --- a/Core/include/Acts/Surfaces/RegularSurface.hpp +++ b/Core/include/Acts/Surfaces/RegularSurface.hpp @@ -10,7 +10,6 @@ #include "Acts/Definitions/Tolerance.hpp" #include "Acts/Surfaces/Surface.hpp" -#include "Acts/Utilities/ThrowAssert.hpp" namespace Acts { @@ -116,4 +115,5 @@ class RegularSurface : public Surface { using Surface::isOnSurface; }; + } // namespace Acts diff --git a/Core/include/Acts/Surfaces/StrawSurface.hpp b/Core/include/Acts/Surfaces/StrawSurface.hpp index 706bb7d9823..f638723ce8f 100644 --- a/Core/include/Acts/Surfaces/StrawSurface.hpp +++ b/Core/include/Acts/Surfaces/StrawSurface.hpp @@ -15,7 +15,6 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Surfaces/SurfaceConcept.hpp" -#include #include #include @@ -75,19 +74,16 @@ class StrawSurface : public LineSurface { const Transform3& shift); public: - ~StrawSurface() override = default; - StrawSurface() = delete; - /// Assignment operator /// /// @param other is the source surface for copying StrawSurface& operator=(const StrawSurface& other); /// Return the surface type - SurfaceType type() const final; + SurfaceType type() const final { return Surface::Straw; } /// Return properly formatted class name for screen output */ - std::string name() const final; + std::string name() const final { return "Acts::StrawSurface"; } /// Return a Polyhedron for the surfaces /// @@ -101,14 +97,6 @@ class StrawSurface : public LineSurface { unsigned int quarterSegments) const final; }; -inline Surface::SurfaceType StrawSurface::type() const { - return Surface::Straw; -} - -inline std::string Acts::StrawSurface::name() const { - return "Acts::StrawSurface"; -} - static_assert(SurfaceConcept, "StrawSurface does not fulfill SurfaceConcept"); diff --git a/Core/include/Acts/Surfaces/Surface.hpp b/Core/include/Acts/Surfaces/Surface.hpp index 43d8161aa8c..6bd1c126a93 100644 --- a/Core/include/Acts/Surfaces/Surface.hpp +++ b/Core/include/Acts/Surfaces/Surface.hpp @@ -10,7 +10,6 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/Alignment.hpp" -#include "Acts/Definitions/Common.hpp" #include "Acts/Definitions/Tolerance.hpp" #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Geometry/DetectorElementBase.hpp" @@ -19,20 +18,14 @@ #include "Acts/Geometry/Polyhedron.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/SurfaceBounds.hpp" -#include "Acts/Surfaces/SurfaceError.hpp" -#include "Acts/Surfaces/detail/AlignmentHelper.hpp" -#include "Acts/Utilities/BinnedArray.hpp" -#include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Intersection.hpp" #include "Acts/Utilities/Result.hpp" #include "Acts/Visualization/ViewConfig.hpp" #include -#include #include #include #include -#include #include namespace Acts { diff --git a/Core/include/Acts/Surfaces/SurfaceArray.hpp b/Core/include/Acts/Surfaces/SurfaceArray.hpp index c81f47d286b..ee40434f102 100644 --- a/Core/include/Acts/Surfaces/SurfaceArray.hpp +++ b/Core/include/Acts/Surfaces/SurfaceArray.hpp @@ -11,7 +11,6 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Surfaces/Surface.hpp" -#include "Acts/Utilities/Axis.hpp" #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Grid.hpp" #include "Acts/Utilities/IAxis.hpp" diff --git a/Core/include/Acts/Surfaces/SurfaceConcept.hpp b/Core/include/Acts/Surfaces/SurfaceConcept.hpp index 2abcda1d5d7..54c705d9bb9 100644 --- a/Core/include/Acts/Surfaces/SurfaceConcept.hpp +++ b/Core/include/Acts/Surfaces/SurfaceConcept.hpp @@ -119,4 +119,5 @@ concept RegularSurfaceConcept = { cs.isOnSurface(gctx, Vector3{}, tolerance) } -> std::same_as; }; + } // namespace Acts diff --git a/Core/include/Acts/Surfaces/SurfaceMergingException.hpp b/Core/include/Acts/Surfaces/SurfaceMergingException.hpp index f2ae605aab7..6887d7c08fc 100644 --- a/Core/include/Acts/Surfaces/SurfaceMergingException.hpp +++ b/Core/include/Acts/Surfaces/SurfaceMergingException.hpp @@ -32,4 +32,5 @@ class SurfaceMergingException : public std::exception { std::weak_ptr m_surfaceB; std::string m_message; }; + } // namespace Acts diff --git a/Core/include/Acts/Surfaces/TrapezoidBounds.hpp b/Core/include/Acts/Surfaces/TrapezoidBounds.hpp index aab8848e17e..f8bfebe2971 100644 --- a/Core/include/Acts/Surfaces/TrapezoidBounds.hpp +++ b/Core/include/Acts/Surfaces/TrapezoidBounds.hpp @@ -9,17 +9,13 @@ #pragma once #include "Acts/Definitions/Algebra.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/PlanarBounds.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Surfaces/SurfaceBounds.hpp" -#include #include -#include #include -#include #include namespace Acts { @@ -41,8 +37,6 @@ class TrapezoidBounds : public PlanarBounds { eSize = 4 }; - TrapezoidBounds() = delete; - /// Constructor for symmetric Trapezoid /// /// @param halfXnegY minimal half length X, definition at negative Y @@ -57,9 +51,7 @@ class TrapezoidBounds : public PlanarBounds { /// @param values the values to be stream in TrapezoidBounds(const std::array& values) noexcept(false); - ~TrapezoidBounds() override; - - BoundsType type() const final; + BoundsType type() const final { return SurfaceBounds::eTrapezoid; } std::vector values() const final; diff --git a/Core/include/Acts/Surfaces/detail/AlignmentHelper.hpp b/Core/include/Acts/Surfaces/detail/AlignmentHelper.hpp index 5d4ef72b8bd..3c46793fa56 100644 --- a/Core/include/Acts/Surfaces/detail/AlignmentHelper.hpp +++ b/Core/include/Acts/Surfaces/detail/AlignmentHelper.hpp @@ -11,8 +11,6 @@ #include "Acts/Definitions/Algebra.hpp" #include -#include -#include namespace Acts::detail { diff --git a/Core/include/Acts/Surfaces/detail/BoundaryCheckHelper.hpp b/Core/include/Acts/Surfaces/detail/BoundaryCheckHelper.hpp index 898fe5541ae..20e7a9f7850 100644 --- a/Core/include/Acts/Surfaces/detail/BoundaryCheckHelper.hpp +++ b/Core/include/Acts/Surfaces/detail/BoundaryCheckHelper.hpp @@ -8,6 +8,7 @@ #pragma once +#include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/detail/VerticesHelper.hpp" #include diff --git a/Core/include/Acts/Surfaces/detail/MergeHelper.hpp b/Core/include/Acts/Surfaces/detail/MergeHelper.hpp index ed396c9e6ad..5bd44108249 100644 --- a/Core/include/Acts/Surfaces/detail/MergeHelper.hpp +++ b/Core/include/Acts/Surfaces/detail/MergeHelper.hpp @@ -8,13 +8,8 @@ #pragma once -#include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/Tolerance.hpp" -#include "Acts/Definitions/Units.hpp" #include "Acts/Utilities/Logger.hpp" -#include "Acts/Utilities/detail/periodic.hpp" - -#include namespace Acts::detail { diff --git a/Core/src/Geometry/ConeVolumeBounds.cpp b/Core/src/Geometry/ConeVolumeBounds.cpp index ebc1262c1b8..425166abcd0 100644 --- a/Core/src/Geometry/ConeVolumeBounds.cpp +++ b/Core/src/Geometry/ConeVolumeBounds.cpp @@ -26,10 +26,10 @@ #include #include #include -#include #include namespace Acts { + ConeVolumeBounds::ConeVolumeBounds(double innerAlpha, double innerOffsetZ, double outerAlpha, double outerOffsetZ, double halflengthZ, double averagePhi, @@ -92,6 +92,10 @@ ConeVolumeBounds::ConeVolumeBounds(double cylinderR, double alpha, checkConsistency(); } +std::vector ConeVolumeBounds::values() const { + return {m_values.begin(), m_values.end()}; +} + std::vector Acts::ConeVolumeBounds::orientedSurfaces( const Transform3& transform) const { std::vector oSurfaces; @@ -334,10 +338,4 @@ double ConeVolumeBounds::outerTanAlpha() const { return m_outerTanAlpha; } -std::vector ConeVolumeBounds::values() const { - std::vector valvector; - valvector.insert(valvector.begin(), m_values.begin(), m_values.end()); - return valvector; -} - } // namespace Acts diff --git a/Core/src/Geometry/CuboidVolumeBounds.cpp b/Core/src/Geometry/CuboidVolumeBounds.cpp index be2443c9691..a8b1729c74a 100644 --- a/Core/src/Geometry/CuboidVolumeBounds.cpp +++ b/Core/src/Geometry/CuboidVolumeBounds.cpp @@ -30,6 +30,10 @@ CuboidVolumeBounds::CuboidVolumeBounds(const std::array& values) buildSurfaceBounds(); } +std::vector CuboidVolumeBounds::values() const { + return {m_values.begin(), m_values.end()}; +} + std::vector Acts::CuboidVolumeBounds::orientedSurfaces( const Transform3& transform) const { std::vector oSurfaces; @@ -119,12 +123,6 @@ bool CuboidVolumeBounds::inside(const Vector3& pos, double tol) const { std::abs(pos.z()) <= get(eHalfLengthZ) + tol); } -std::vector CuboidVolumeBounds::values() const { - std::vector valvector; - valvector.insert(valvector.begin(), m_values.begin(), m_values.end()); - return valvector; -} - void CuboidVolumeBounds::checkConsistency() noexcept(false) { if (get(eHalfLengthX) <= 0 || get(eHalfLengthY) <= 0 || get(eHalfLengthZ) <= 0.) { diff --git a/Core/src/Geometry/CutoutCylinderVolumeBounds.cpp b/Core/src/Geometry/CutoutCylinderVolumeBounds.cpp index 9d70f49b4b9..62033200b58 100644 --- a/Core/src/Geometry/CutoutCylinderVolumeBounds.cpp +++ b/Core/src/Geometry/CutoutCylinderVolumeBounds.cpp @@ -23,11 +23,30 @@ #include #include -#include +#include #include -bool Acts::CutoutCylinderVolumeBounds::inside(const Acts::Vector3& gpos, - double tol) const { +namespace Acts { + +std::vector CutoutCylinderVolumeBounds::values() const { + return {m_values.begin(), m_values.end()}; +} + +void CutoutCylinderVolumeBounds::checkConsistency() noexcept(false) { + if (get(eMinR) < 0. || get(eMedR) <= 0. || get(eMaxR) <= 0. || + get(eMinR) >= get(eMedR) || get(eMinR) >= get(eMaxR) || + get(eMedR) >= get(eMaxR)) { + throw std::invalid_argument( + "CutoutCylinderVolumeBounds: invalid radial input."); + } + if (get(eHalfLengthZ) <= 0 || get(eHalfLengthZcutout) <= 0. || + get(eHalfLengthZcutout) > get(eHalfLengthZ)) { + throw std::invalid_argument( + "CutoutCylinderVolumeBounds: invalid longitudinal input."); + } +} + +bool CutoutCylinderVolumeBounds::inside(const Vector3& gpos, double tol) const { // first check whether we are in the outer envelope at all (ignore r_med) using VectorHelpers::perp; using VectorHelpers::phi; @@ -48,8 +67,7 @@ bool Acts::CutoutCylinderVolumeBounds::inside(const Acts::Vector3& gpos, return !insideRInner || !insideZInner; // we are not, inside bounds } -std::vector -Acts::CutoutCylinderVolumeBounds::orientedSurfaces( +std::vector CutoutCylinderVolumeBounds::orientedSurfaces( const Transform3& transform) const { std::vector oSurfaces; @@ -122,9 +140,9 @@ Acts::CutoutCylinderVolumeBounds::orientedSurfaces( return oSurfaces; } -Acts::Volume::BoundingBox Acts::CutoutCylinderVolumeBounds::boundingBox( - const Acts::Transform3* trf, const Acts::Vector3& envelope, - const Acts::Volume* entity) const { +Volume::BoundingBox CutoutCylinderVolumeBounds::boundingBox( + const Transform3* trf, const Vector3& envelope, + const Volume* entity) const { Vector3 vmin, vmax; // no phi sector is possible, so this is just the outer size of @@ -133,21 +151,20 @@ Acts::Volume::BoundingBox Acts::CutoutCylinderVolumeBounds::boundingBox( vmax = {get(eMaxR), get(eMaxR), get(eHalfLengthZ)}; vmin = {-get(eMaxR), -get(eMaxR), -get(eHalfLengthZ)}; - Acts::Volume::BoundingBox box(entity, vmin - envelope, vmax + envelope); + Volume::BoundingBox box(entity, vmin - envelope, vmax + envelope); // transform at the very end, if required return trf == nullptr ? box : box.transformed(*trf); } -std::ostream& Acts::CutoutCylinderVolumeBounds::toStream( - std::ostream& sl) const { - sl << "Acts::CutoutCylinderVolumeBounds(\n"; +std::ostream& CutoutCylinderVolumeBounds::toStream(std::ostream& sl) const { + sl << "CutoutCylinderVolumeBounds(\n"; sl << "rmin = " << get(eMinR) << " rmed = " << get(eMedR) << " rmax = " << get(eMaxR) << "\n"; sl << "dz1 = " << get(eHalfLengthZ) << " dz2 = " << get(eHalfLengthZcutout); return sl; } -void Acts::CutoutCylinderVolumeBounds::buildSurfaceBounds() { +void CutoutCylinderVolumeBounds::buildSurfaceBounds() { if (get(eMinR) > s_epsilon) { double hlChoke = (get(eHalfLengthZ) - get(eHalfLengthZcutout)) * 0.5; m_innerCylinderBounds = @@ -164,3 +181,5 @@ void Acts::CutoutCylinderVolumeBounds::buildSurfaceBounds() { m_outerDiscBounds = std::make_shared(get(eMinR), get(eMaxR)); } + +} // namespace Acts diff --git a/Core/src/Geometry/CylinderVolumeBounds.cpp b/Core/src/Geometry/CylinderVolumeBounds.cpp index 1e3bba1d67f..00a4c71f882 100644 --- a/Core/src/Geometry/CylinderVolumeBounds.cpp +++ b/Core/src/Geometry/CylinderVolumeBounds.cpp @@ -19,6 +19,7 @@ #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/BoundingBox.hpp" +#include "Acts/Utilities/detail/periodic.hpp" #include #include @@ -251,9 +252,7 @@ double CylinderVolumeBounds::binningBorder(BinningValue bValue) const { } std::vector CylinderVolumeBounds::values() const { - std::vector valvector; - valvector.insert(valvector.begin(), m_values.begin(), m_values.end()); - return valvector; + return {m_values.begin(), m_values.end()}; } void CylinderVolumeBounds::checkConsistency() { diff --git a/Core/src/Geometry/TrapezoidVolumeBounds.cpp b/Core/src/Geometry/TrapezoidVolumeBounds.cpp index f03af8c85c0..2034ce6f302 100644 --- a/Core/src/Geometry/TrapezoidVolumeBounds.cpp +++ b/Core/src/Geometry/TrapezoidVolumeBounds.cpp @@ -54,6 +54,10 @@ TrapezoidVolumeBounds::TrapezoidVolumeBounds(double minhalex, double haley, buildSurfaceBounds(); } +std::vector TrapezoidVolumeBounds::values() const { + return {m_values.begin(), m_values.end()}; +} + std::vector TrapezoidVolumeBounds::orientedSurfaces( const Transform3& transform) const { std::vector oSurfaces; @@ -198,12 +202,6 @@ Volume::BoundingBox TrapezoidVolumeBounds::boundingBox( return {entity, vmin - envelope, vmax + envelope}; } -std::vector TrapezoidVolumeBounds::values() const { - std::vector valvector; - valvector.insert(valvector.begin(), m_values.begin(), m_values.end()); - return valvector; -} - void TrapezoidVolumeBounds::checkConsistency() noexcept(false) { if (get(eHalfLengthXnegY) < 0. || get(eHalfLengthXposY) < 0.) { throw std::invalid_argument( diff --git a/Core/src/Surfaces/AnnulusBounds.cpp b/Core/src/Surfaces/AnnulusBounds.cpp index 0296517d6d7..2075e3cb59d 100644 --- a/Core/src/Surfaces/AnnulusBounds.cpp +++ b/Core/src/Surfaces/AnnulusBounds.cpp @@ -8,7 +8,6 @@ #include "Acts/Surfaces/AnnulusBounds.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/detail/VerticesHelper.hpp" #include "Acts/Utilities/VectorHelpers.hpp" @@ -21,8 +20,30 @@ #include #include -Acts::AnnulusBounds::AnnulusBounds( - const std::array& values) noexcept(false) +namespace Acts { + +namespace { + +Vector2 closestOnSegment(const Vector2& a, const Vector2& b, const Vector2& p, + const SquareMatrix2& weight) { + // connecting vector + auto n = b - a; + // squared norm of line + auto f = (n.transpose() * weight * n).value(); + // weighted scalar product of line to point and segment line + auto u = ((p - a).transpose() * weight * n).value() / f; + // clamp to [0, 1], convert to point + return std::clamp(u, 0., 1.) * n + a; +} + +double squaredNorm(const Vector2& v, const SquareMatrix2& weight) { + return (v.transpose() * weight * v).value(); +} + +} // namespace + +AnnulusBounds::AnnulusBounds(const std::array& values) noexcept( + false) : m_values(values), m_moduleOrigin({values[eOriginX], values[eOriginY]}) { checkConsistency(); m_rotationStripPC = Translation2(Vector2(0, -get(eAveragePhi))); @@ -68,17 +89,13 @@ Acts::AnnulusBounds::AnnulusBounds( // calculate corners in STRIP XY, keep them we need them for minDistance() m_outLeftStripXY = - circIx(m_moduleOrigin[eBoundLoc0], m_moduleOrigin[eBoundLoc1], get(eMaxR), - get(eMaxPhiRel)); + circIx(m_moduleOrigin[0], m_moduleOrigin[1], get(eMaxR), get(eMaxPhiRel)); m_inLeftStripXY = - circIx(m_moduleOrigin[eBoundLoc0], m_moduleOrigin[eBoundLoc1], get(eMinR), - get(eMaxPhiRel)); + circIx(m_moduleOrigin[0], m_moduleOrigin[1], get(eMinR), get(eMaxPhiRel)); m_outRightStripXY = - circIx(m_moduleOrigin[eBoundLoc0], m_moduleOrigin[eBoundLoc1], get(eMaxR), - get(eMinPhiRel)); + circIx(m_moduleOrigin[0], m_moduleOrigin[1], get(eMaxR), get(eMinPhiRel)); m_inRightStripXY = - circIx(m_moduleOrigin[eBoundLoc0], m_moduleOrigin[eBoundLoc1], get(eMinR), - get(eMinPhiRel)); + circIx(m_moduleOrigin[0], m_moduleOrigin[1], get(eMinR), get(eMinPhiRel)); m_outLeftStripPC = {m_outLeftStripXY.norm(), VectorHelpers::phi(m_outLeftStripXY)}; @@ -95,14 +112,33 @@ Acts::AnnulusBounds::AnnulusBounds( m_inRightModulePC = stripXYToModulePC(m_inRightStripXY); } -std::vector Acts::AnnulusBounds::corners() const { +std::vector AnnulusBounds::values() const { + return {m_values.begin(), m_values.end()}; +} + +void AnnulusBounds::checkConsistency() noexcept(false) { + if (get(eMinR) < 0. || get(eMaxR) < 0. || get(eMinR) > get(eMaxR) || + std::abs(get(eMinR) - get(eMaxR)) < s_epsilon) { + throw std::invalid_argument("AnnulusBounds: invalid radial setup."); + } + if (get(eMinPhiRel) != detail::radian_sym(get(eMinPhiRel)) || + get(eMaxPhiRel) != detail::radian_sym(get(eMaxPhiRel)) || + get(eMinPhiRel) > get(eMaxPhiRel)) { + throw std::invalid_argument("AnnulusBounds: invalid phi boundary setup."); + } + if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) { + throw std::invalid_argument("AnnulusBounds: invalid phi positioning."); + } +} + +std::vector AnnulusBounds::corners() const { auto rot = m_rotationStripPC.inverse(); return {rot * m_outRightStripPC, rot * m_outLeftStripPC, rot * m_inLeftStripPC, rot * m_inRightStripPC}; } -std::vector Acts::AnnulusBounds::vertices( +std::vector AnnulusBounds::vertices( unsigned int quarterSegments) const { if (quarterSegments > 0u) { using VectorHelpers::phi; @@ -114,7 +150,7 @@ std::vector Acts::AnnulusBounds::vertices( double phiMaxOuter = phi(m_outLeftStripXY - m_moduleOrigin); // Inner bow from phi_min -> phi_max (needs to be reversed) - std::vector rvertices = + std::vector rvertices = detail::VerticesHelper::segmentVertices( {get(eMinR), get(eMinR)}, phiMinInner, phiMaxInner, {}, quarterSegments); @@ -128,20 +164,20 @@ std::vector Acts::AnnulusBounds::vertices( rvertices.insert(rvertices.end(), overtices.begin(), overtices.end()); std::for_each(rvertices.begin(), rvertices.end(), - [&](Acts::Vector2& rv) { rv += m_moduleOrigin; }); + [&](Vector2& rv) { rv += m_moduleOrigin; }); return rvertices; } return {m_inLeftStripXY, m_inRightStripXY, m_outRightStripXY, m_outLeftStripXY}; } -bool Acts::AnnulusBounds::inside(const Vector2& lposition, double tolR, - double tolPhi) const { +bool AnnulusBounds::inside(const Vector2& lposition, double tolR, + double tolPhi) const { // locpo is PC in STRIP SYSTEM // need to perform internal rotation induced by average phi Vector2 locpo_rotated = m_rotationStripPC * lposition; - double phiLoc = locpo_rotated[eBoundLoc1]; - double rLoc = locpo_rotated[eBoundLoc0]; + double phiLoc = locpo_rotated[1]; + double rLoc = locpo_rotated[0]; if (phiLoc < (get(eMinPhiRel) - tolPhi) || phiLoc > (get(eMaxPhiRel) + tolPhi)) { @@ -151,18 +187,16 @@ bool Acts::AnnulusBounds::inside(const Vector2& lposition, double tolR, // calculate R in MODULE SYSTEM to evaluate R-bounds if (tolR == 0.) { // don't need R, can use R^2 - double r_mod2 = - m_shiftPC[eBoundLoc0] * m_shiftPC[eBoundLoc0] + rLoc * rLoc + - 2 * m_shiftPC[eBoundLoc0] * rLoc * cos(phiLoc - m_shiftPC[eBoundLoc1]); + double r_mod2 = m_shiftPC[0] * m_shiftPC[0] + rLoc * rLoc + + 2 * m_shiftPC[0] * rLoc * cos(phiLoc - m_shiftPC[1]); if (r_mod2 < get(eMinR) * get(eMinR) || r_mod2 > get(eMaxR) * get(eMaxR)) { return false; } } else { // use R - double r_mod = sqrt( - m_shiftPC[eBoundLoc0] * m_shiftPC[eBoundLoc0] + rLoc * rLoc + - 2 * m_shiftPC[eBoundLoc0] * rLoc * cos(phiLoc - m_shiftPC[eBoundLoc1])); + double r_mod = sqrt(m_shiftPC[0] * m_shiftPC[0] + rLoc * rLoc + + 2 * m_shiftPC[0] * rLoc * cos(phiLoc - m_shiftPC[1])); if (r_mod < (get(eMinR) - tolR) || r_mod > (get(eMaxR) + tolR)) { return false; @@ -171,9 +205,8 @@ bool Acts::AnnulusBounds::inside(const Vector2& lposition, double tolR, return true; } -bool Acts::AnnulusBounds::inside( - const Vector2& lposition, - const BoundaryTolerance& boundaryTolerance) const { +bool AnnulusBounds::inside(const Vector2& lposition, + const BoundaryTolerance& boundaryTolerance) const { if (boundaryTolerance.isInfinite()) { return true; } @@ -207,10 +240,10 @@ bool Acts::AnnulusBounds::inside( // to the MODULE SYSTEM in PC via jacobian. The following transforms into // STRIP XY, does the shift into MODULE XY, and then transforms into MODULE PC double dphi = get(eAveragePhi); - double phi_strip = locpo_rotated[eBoundLoc1]; - double r_strip = locpo_rotated[eBoundLoc0]; - double O_x = m_shiftXY[eBoundLoc0]; - double O_y = m_shiftXY[eBoundLoc1]; + double phi_strip = locpo_rotated[1]; + double r_strip = locpo_rotated[0]; + double O_x = m_shiftXY[0]; + double O_y = m_shiftXY[1]; // For a transformation from cartesian into polar coordinates // @@ -312,9 +345,8 @@ bool Acts::AnnulusBounds::inside( // now: MODULE system. Need to transform locpo to MODULE PC // transform is STRIP PC -> STRIP XY -> MODULE XY -> MODULE PC - Vector2 locpoStripXY( - locpo_rotated[eBoundLoc0] * std::cos(locpo_rotated[eBoundLoc1]), - locpo_rotated[eBoundLoc0] * std::sin(locpo_rotated[eBoundLoc1])); + Vector2 locpoStripXY(locpo_rotated[0] * std::cos(locpo_rotated[1]), + locpo_rotated[0] * std::sin(locpo_rotated[1])); Vector2 locpoModulePC = stripXYToModulePC(locpoStripXY); // now check edges in MODULE PC (inner and outer circle) assuming Mahalanobis @@ -339,36 +371,16 @@ bool Acts::AnnulusBounds::inside( boundaryToleranceChi2.maxChi2 * boundaryToleranceChi2.maxChi2; } -Acts::Vector2 Acts::AnnulusBounds::stripXYToModulePC( - const Vector2& vStripXY) const { +Vector2 AnnulusBounds::stripXYToModulePC(const Vector2& vStripXY) const { Vector2 vecModuleXY = vStripXY + m_shiftXY; return {vecModuleXY.norm(), VectorHelpers::phi(vecModuleXY)}; } -Acts::Vector2 Acts::AnnulusBounds::closestOnSegment( - const Vector2& a, const Vector2& b, const Vector2& p, - const SquareMatrix2& weight) const { - // connecting vector - auto n = b - a; - // squared norm of line - auto f = (n.transpose() * weight * n).value(); - // weighted scalar product of line to point and segment line - auto u = ((p - a).transpose() * weight * n).value() / f; - // clamp to [0, 1], convert to point - return std::min(std::max(u, 0.), 1.) * n + a; -} - -double Acts::AnnulusBounds::squaredNorm(const Vector2& v, - const SquareMatrix2& weight) const { - return (v.transpose() * weight * v).value(); -} - -Acts::Vector2 Acts::AnnulusBounds::moduleOrigin() const { +Vector2 AnnulusBounds::moduleOrigin() const { return Eigen::Rotation2D(get(eAveragePhi)) * m_moduleOrigin; } -// Ostream operator overload -std::ostream& Acts::AnnulusBounds::toStream(std::ostream& sl) const { +std::ostream& AnnulusBounds::toStream(std::ostream& sl) const { sl << std::setiosflags(std::ios::fixed); sl << std::setprecision(7); sl << "Acts::AnnulusBounds: (innerRadius, outerRadius, minPhi, maxPhi) = "; @@ -379,3 +391,5 @@ std::ostream& Acts::AnnulusBounds::toStream(std::ostream& sl) const { sl << std::setprecision(-1); return sl; } + +} // namespace Acts diff --git a/Core/src/Surfaces/BoundaryTolerance.cpp b/Core/src/Surfaces/BoundaryTolerance.cpp index b5077fa4ec4..3538a82f414 100644 --- a/Core/src/Surfaces/BoundaryTolerance.cpp +++ b/Core/src/Surfaces/BoundaryTolerance.cpp @@ -10,7 +10,6 @@ #include "Acts/Definitions/Algebra.hpp" -#include #include #include diff --git a/Core/src/Surfaces/ConeBounds.cpp b/Core/src/Surfaces/ConeBounds.cpp index 5dce8995326..31f9da55b59 100644 --- a/Core/src/Surfaces/ConeBounds.cpp +++ b/Core/src/Surfaces/ConeBounds.cpp @@ -8,9 +8,9 @@ #include "Acts/Surfaces/ConeBounds.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/detail/BoundaryCheckHelper.hpp" +#include "Acts/Utilities/detail/periodic.hpp" #include #include @@ -18,55 +18,69 @@ #include #include -Acts::ConeBounds::ConeBounds(double alpha, bool symm, double halfphi, - double avphi) noexcept(false) +namespace Acts { + +ConeBounds::ConeBounds(double alpha, bool symm, double halfphi, + double avphi) noexcept(false) : m_values({alpha, symm ? -std::numeric_limits::infinity() : 0, std::numeric_limits::infinity(), halfphi, avphi}), m_tanAlpha(std::tan(alpha)) { checkConsistency(); } -Acts::ConeBounds::ConeBounds(double alpha, double minz, double maxz, - double halfphi, double avphi) noexcept(false) +ConeBounds::ConeBounds(double alpha, double minz, double maxz, double halfphi, + double avphi) noexcept(false) : m_values({alpha, minz, maxz, halfphi, avphi}), m_tanAlpha(std::tan(alpha)) { checkConsistency(); } -Acts::ConeBounds::ConeBounds(const std::array& values) noexcept( - false) +ConeBounds::ConeBounds(const std::array& values) noexcept(false) : m_values(values), m_tanAlpha(std::tan(values[eAlpha])) { checkConsistency(); } -Acts::SurfaceBounds::BoundsType Acts::ConeBounds::type() const { - return SurfaceBounds::eCone; +std::vector ConeBounds::values() const { + return {m_values.begin(), m_values.end()}; +} + +void ConeBounds::checkConsistency() noexcept(false) { + if (get(eAlpha) < 0. || get(eAlpha) >= std::numbers::pi) { + throw std::invalid_argument("ConeBounds: invalid open angle."); + } + if (get(eMinZ) > get(eMaxZ) || + std::abs(get(eMinZ) - get(eMaxZ)) < s_epsilon) { + throw std::invalid_argument("ConeBounds: invalid z range setup."); + } + if (get(eHalfPhiSector) < 0. || std::abs(eHalfPhiSector) > std::numbers::pi) { + throw std::invalid_argument("ConeBounds: invalid phi sector setup."); + } + if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) { + throw std::invalid_argument("ConeBounds: invalid phi positioning."); + } } -/// Shift r-phi coordinate to be centered around the average phi. -Acts::Vector2 Acts::ConeBounds::shifted(const Acts::Vector2& lposition) const { - using Acts::detail::radian_sym; +Vector2 ConeBounds::shifted(const Vector2& lposition) const { + using detail::radian_sym; - auto x = r(lposition[eBoundLoc1]); // cone radius at the local position + auto x = r(lposition[1]); // cone radius at the local position Vector2 shifted; - shifted[eBoundLoc1] = lposition[eBoundLoc1]; - shifted[eBoundLoc0] = - std::isnormal(x) - ? (x * radian_sym((lposition[eBoundLoc0] / x) - get(eAveragePhi))) - : lposition[eBoundLoc0]; + shifted[1] = lposition[1]; + shifted[0] = std::isnormal(x) + ? (x * radian_sym((lposition[0] / x) - get(eAveragePhi))) + : lposition[0]; return shifted; } -bool Acts::ConeBounds::inside( - const Acts::Vector2& lposition, - const Acts::BoundaryTolerance& boundaryTolerance) const { - auto rphiHalf = r(lposition[eBoundLoc1]) * get(eHalfPhiSector); +bool ConeBounds::inside(const Vector2& lposition, + const BoundaryTolerance& boundaryTolerance) const { + auto rphiHalf = r(lposition[1]) * get(eHalfPhiSector); return detail::insideAlignedBox( Vector2(-rphiHalf, get(eMinZ)), Vector2(rphiHalf, get(eMaxZ)), boundaryTolerance, shifted(lposition), std::nullopt); } -std::ostream& Acts::ConeBounds::toStream(std::ostream& sl) const { +std::ostream& ConeBounds::toStream(std::ostream& sl) const { sl << std::setiosflags(std::ios::fixed); sl << std::setprecision(7); sl << "Acts::ConeBounds: (tanAlpha, minZ, maxZ, halfPhiSector, averagePhi) " @@ -76,3 +90,5 @@ std::ostream& Acts::ConeBounds::toStream(std::ostream& sl) const { sl << std::setprecision(-1); return sl; } + +} // namespace Acts diff --git a/Core/src/Surfaces/ConeSurface.cpp b/Core/src/Surfaces/ConeSurface.cpp index 5dddd1527bf..bb8f8ed4cf4 100644 --- a/Core/src/Surfaces/ConeSurface.cpp +++ b/Core/src/Surfaces/ConeSurface.cpp @@ -14,7 +14,6 @@ #include "Acts/Surfaces/detail/AlignmentHelper.hpp" #include "Acts/Surfaces/detail/FacesHelper.hpp" #include "Acts/Surfaces/detail/VerticesHelper.hpp" -#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/Intersection.hpp" #include "Acts/Utilities/ThrowAssert.hpp" #include "Acts/Utilities/detail/RealQuadraticEquation.hpp" @@ -27,47 +26,47 @@ #include #include -using Acts::VectorHelpers::perp; -using Acts::VectorHelpers::phi; +namespace Acts { -Acts::ConeSurface::ConeSurface(const ConeSurface& other) +using VectorHelpers::perp; +using VectorHelpers::phi; + +ConeSurface::ConeSurface(const ConeSurface& other) : GeometryObject(), RegularSurface(other), m_bounds(other.m_bounds) {} -Acts::ConeSurface::ConeSurface(const GeometryContext& gctx, - const ConeSurface& other, - const Transform3& shift) +ConeSurface::ConeSurface(const GeometryContext& gctx, const ConeSurface& other, + const Transform3& shift) : GeometryObject(), RegularSurface(gctx, other, shift), m_bounds(other.m_bounds) {} -Acts::ConeSurface::ConeSurface(const Transform3& transform, double alpha, - bool symmetric) +ConeSurface::ConeSurface(const Transform3& transform, double alpha, + bool symmetric) : GeometryObject(), RegularSurface(transform), m_bounds(std::make_shared(alpha, symmetric)) {} -Acts::ConeSurface::ConeSurface(const Transform3& transform, double alpha, - double zmin, double zmax, double halfPhi) +ConeSurface::ConeSurface(const Transform3& transform, double alpha, double zmin, + double zmax, double halfPhi) : GeometryObject(), RegularSurface(transform), m_bounds(std::make_shared(alpha, zmin, zmax, halfPhi)) { } -Acts::ConeSurface::ConeSurface(const Transform3& transform, - std::shared_ptr cbounds) +ConeSurface::ConeSurface(const Transform3& transform, + std::shared_ptr cbounds) : GeometryObject(), RegularSurface(transform), m_bounds(std::move(cbounds)) { throw_assert(m_bounds, "ConeBounds must not be nullptr"); } -Acts::Vector3 Acts::ConeSurface::binningPosition( - const GeometryContext& gctx, Acts::BinningValue bValue) const { +Vector3 ConeSurface::binningPosition(const GeometryContext& gctx, + BinningValue bValue) const { const Vector3& sfCenter = center(gctx); // special binning type for R-type methods - if (bValue == Acts::BinningValue::binR || - bValue == Acts::BinningValue::binRPhi) { + if (bValue == BinningValue::binR || bValue == BinningValue::binRPhi) { return Vector3(sfCenter.x() + bounds().r(sfCenter.z()), sfCenter.y(), sfCenter.z()); } @@ -78,11 +77,11 @@ Acts::Vector3 Acts::ConeSurface::binningPosition( return sfCenter; } -Acts::Surface::SurfaceType Acts::ConeSurface::type() const { +Surface::SurfaceType ConeSurface::type() const { return Surface::Cone; } -Acts::ConeSurface& Acts::ConeSurface::operator=(const ConeSurface& other) { +ConeSurface& ConeSurface::operator=(const ConeSurface& other) { if (this != &other) { Surface::operator=(other); m_bounds = other.m_bounds; @@ -90,12 +89,11 @@ Acts::ConeSurface& Acts::ConeSurface::operator=(const ConeSurface& other) { return *this; } -Acts::Vector3 Acts::ConeSurface::rotSymmetryAxis( - const GeometryContext& gctx) const { +Vector3 ConeSurface::rotSymmetryAxis(const GeometryContext& gctx) const { return transform(gctx).matrix().block<3, 1>(0, 2); } -Acts::RotationMatrix3 Acts::ConeSurface::referenceFrame( +RotationMatrix3 ConeSurface::referenceFrame( const GeometryContext& gctx, const Vector3& position, const Vector3& /*direction*/) const { RotationMatrix3 mFrame; @@ -105,7 +103,7 @@ Acts::RotationMatrix3 Acts::ConeSurface::referenceFrame( // measured z is the position transverse normalized Vector3 measDepth = Vector3(position.x(), position.y(), 0.).normalized(); // measured X is what comoes out of it - Acts::Vector3 measX(measY.cross(measDepth).normalized()); + Vector3 measX(measY.cross(measDepth).normalized()); // the columnes mFrame.col(0) = measX; mFrame.col(1) = measY; @@ -116,30 +114,30 @@ Acts::RotationMatrix3 Acts::ConeSurface::referenceFrame( return mFrame; } -Acts::Vector3 Acts::ConeSurface::localToGlobal(const GeometryContext& gctx, - const Vector2& lposition) const { +Vector3 ConeSurface::localToGlobal(const GeometryContext& gctx, + const Vector2& lposition) const { // create the position in the local 3d frame - double r = lposition[Acts::eBoundLoc1] * bounds().tanAlpha(); - double phi = lposition[Acts::eBoundLoc0] / r; - Vector3 loc3Dframe(r * cos(phi), r * sin(phi), lposition[Acts::eBoundLoc1]); + double r = lposition[1] * bounds().tanAlpha(); + double phi = lposition[0] / r; + Vector3 loc3Dframe(r * cos(phi), r * sin(phi), lposition[1]); return transform(gctx) * loc3Dframe; } -Acts::Result Acts::ConeSurface::globalToLocal( - const GeometryContext& gctx, const Vector3& position, - double tolerance) const { +Result ConeSurface::globalToLocal(const GeometryContext& gctx, + const Vector3& position, + double tolerance) const { Vector3 loc3Dframe = transform(gctx).inverse() * position; double r = loc3Dframe.z() * bounds().tanAlpha(); if (std::abs(perp(loc3Dframe) - r) > tolerance) { return Result::failure(SurfaceError::GlobalPositionNotOnSurface); } - return Result::success( + return Result::success( Vector2(r * atan2(loc3Dframe.y(), loc3Dframe.x()), loc3Dframe.z())); } -double Acts::ConeSurface::pathCorrection(const GeometryContext& gctx, - const Vector3& position, - const Vector3& direction) const { +double ConeSurface::pathCorrection(const GeometryContext& gctx, + const Vector3& position, + const Vector3& direction) const { // (cos phi cos alpha, sin phi cos alpha, sgn z sin alpha) Vector3 posLocal = transform(gctx).inverse() * position; double phi = VectorHelpers::phi(posLocal); @@ -153,24 +151,23 @@ double Acts::ConeSurface::pathCorrection(const GeometryContext& gctx, return std::abs(1. / cAlpha); } -std::string Acts::ConeSurface::name() const { +std::string ConeSurface::name() const { return "Acts::ConeSurface"; } -Acts::Vector3 Acts::ConeSurface::normal(const GeometryContext& gctx, - const Acts::Vector2& lposition) const { +Vector3 ConeSurface::normal(const GeometryContext& gctx, + const Vector2& lposition) const { // (cos phi cos alpha, sin phi cos alpha, sgn z sin alpha) - double phi = lposition[Acts::eBoundLoc0] / - (bounds().r(lposition[Acts::eBoundLoc1])), - sgn = lposition[Acts::eBoundLoc1] > 0 ? -1. : +1.; + double phi = lposition[0] / (bounds().r(lposition[1])), + sgn = lposition[1] > 0 ? -1. : +1.; double cosAlpha = std::cos(bounds().get(ConeBounds::eAlpha)); double sinAlpha = std::sin(bounds().get(ConeBounds::eAlpha)); Vector3 localNormal(cos(phi) * cosAlpha, sin(phi) * cosAlpha, sgn * sinAlpha); return Vector3(transform(gctx).linear() * localNormal); } -Acts::Vector3 Acts::ConeSurface::normal(const GeometryContext& gctx, - const Acts::Vector3& position) const { +Vector3 ConeSurface::normal(const GeometryContext& gctx, + const Vector3& position) const { // get it into the cylinder frame if needed // @todo respect opening angle Vector3 pos3D = transform(gctx).inverse() * position; @@ -178,12 +175,12 @@ Acts::Vector3 Acts::ConeSurface::normal(const GeometryContext& gctx, return pos3D.normalized(); } -const Acts::ConeBounds& Acts::ConeSurface::bounds() const { +const ConeBounds& ConeSurface::bounds() const { // is safe because no constructor w/o bounds exists return (*m_bounds.get()); } -Acts::Polyhedron Acts::ConeSurface::polyhedronRepresentation( +Polyhedron ConeSurface::polyhedronRepresentation( const GeometryContext& gctx, unsigned int quarterSegments) const { // Prepare vertices and faces std::vector vertices; @@ -258,7 +255,7 @@ Acts::Polyhedron Acts::ConeSurface::polyhedronRepresentation( return Polyhedron(vertices, faces, triangularMesh, false); } -Acts::detail::RealQuadraticEquation Acts::ConeSurface::intersectionSolver( +detail::RealQuadraticEquation ConeSurface::intersectionSolver( const GeometryContext& gctx, const Vector3& position, const Vector3& direction) const { // Transform into the local frame @@ -281,7 +278,7 @@ Acts::detail::RealQuadraticEquation Acts::ConeSurface::intersectionSolver( return detail::RealQuadraticEquation(A, B, C); } -Acts::SurfaceMultiIntersection Acts::ConeSurface::intersect( +SurfaceMultiIntersection ConeSurface::intersect( const GeometryContext& gctx, const Vector3& position, const Vector3& direction, const BoundaryTolerance& boundaryTolerance, double tolerance) const { @@ -325,7 +322,7 @@ Acts::SurfaceMultiIntersection Acts::ConeSurface::intersect( return {{second, first}, this}; } -Acts::AlignmentToPathMatrix Acts::ConeSurface::alignmentToPathDerivative( +AlignmentToPathMatrix ConeSurface::alignmentToPathDerivative( const GeometryContext& gctx, const Vector3& position, const Vector3& direction) const { assert(isOnSurface(gctx, position, direction, BoundaryTolerance::Infinite())); @@ -377,7 +374,7 @@ Acts::AlignmentToPathMatrix Acts::ConeSurface::alignmentToPathDerivative( return alignToPath; } -Acts::ActsMatrix<2, 3> Acts::ConeSurface::localCartesianToBoundLocalDerivative( +ActsMatrix<2, 3> ConeSurface::localCartesianToBoundLocalDerivative( const GeometryContext& gctx, const Vector3& position) const { using VectorHelpers::perp; using VectorHelpers::phi; @@ -397,3 +394,5 @@ Acts::ActsMatrix<2, 3> Acts::ConeSurface::localCartesianToBoundLocalDerivative( return loc3DToLocBound; } + +} // namespace Acts diff --git a/Core/src/Surfaces/ConvexPolygonBounds.cpp b/Core/src/Surfaces/ConvexPolygonBounds.cpp index f6b08624308..d48dfaf7030 100644 --- a/Core/src/Surfaces/ConvexPolygonBounds.cpp +++ b/Core/src/Surfaces/ConvexPolygonBounds.cpp @@ -12,11 +12,12 @@ #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/detail/BoundaryCheckHelper.hpp" -#include #include #include -std::ostream& Acts::ConvexPolygonBoundsBase::toStream(std::ostream& sl) const { +namespace Acts { + +std::ostream& ConvexPolygonBoundsBase::toStream(std::ostream& sl) const { std::vector vtxs = vertices(); sl << "Acts::ConvexPolygonBounds<" << vtxs.size() << ">: vertices: [x, y]\n"; for (std::size_t i = 0; i < vtxs.size(); i++) { @@ -30,7 +31,7 @@ std::ostream& Acts::ConvexPolygonBoundsBase::toStream(std::ostream& sl) const { return sl; } -std::vector Acts::ConvexPolygonBoundsBase::values() const { +std::vector ConvexPolygonBoundsBase::values() const { std::vector values; for (const auto& vtx : vertices()) { values.push_back(vtx.x()); @@ -39,35 +40,32 @@ std::vector Acts::ConvexPolygonBoundsBase::values() const { return values; } -Acts::ConvexPolygonBounds::ConvexPolygonBounds( +ConvexPolygonBounds::ConvexPolygonBounds( const std::vector& vertices) : m_vertices(vertices.begin(), vertices.end()), m_boundingBox(makeBoundingBox(vertices)) {} -Acts::SurfaceBounds::BoundsType -Acts::ConvexPolygonBounds::type() const { - return SurfaceBounds::eConvexPolygon; -} - -bool Acts::ConvexPolygonBounds::inside( - const Acts::Vector2& lposition, - const Acts::BoundaryTolerance& boundaryTolerance) const { +bool ConvexPolygonBounds::inside( + const Vector2& lposition, + const BoundaryTolerance& boundaryTolerance) const { return detail::insidePolygon( std::span(m_vertices.data(), m_vertices.size()), boundaryTolerance, lposition, std::nullopt); } -std::vector Acts::ConvexPolygonBounds< - Acts::PolygonDynamic>::vertices(unsigned int /*lseg*/) const { +std::vector ConvexPolygonBounds::vertices( + unsigned int /*lseg*/) const { return {m_vertices.begin(), m_vertices.end()}; } -const Acts::RectangleBounds& -Acts::ConvexPolygonBounds::boundingBox() const { +const RectangleBounds& ConvexPolygonBounds::boundingBox() + const { return m_boundingBox; } -void Acts::ConvexPolygonBounds::checkConsistency() const +void ConvexPolygonBounds::checkConsistency() const noexcept(false) { convex_impl(m_vertices); } + +} // namespace Acts diff --git a/Core/src/Surfaces/CurvilinearSurface.cpp b/Core/src/Surfaces/CurvilinearSurface.cpp index c320177de57..899eee5f6f4 100644 --- a/Core/src/Surfaces/CurvilinearSurface.cpp +++ b/Core/src/Surfaces/CurvilinearSurface.cpp @@ -11,7 +11,6 @@ #include "Acts/Definitions/Tolerance.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Utilities/JacobianHelpers.hpp" -#include "Acts/Utilities/VectorHelpers.hpp" #include #include @@ -25,10 +24,10 @@ bool CurvilinearSurface::isStandardRepresentation() const { } RotationMatrix3 CurvilinearSurface::referenceFrame() const { - /// the right-handed coordinate system is defined as - /// T = normal - /// U = Z x T if T not parallel to Z otherwise U = X x T - /// V = T x U + // the right-handed coordinate system is defined as + // T = normal + // U = Z x T if T not parallel to Z otherwise U = X x T + // V = T x U Vector3 T = m_direction.normalized(); Vector3 U = (isStandardRepresentation() ? Vector3::UnitZ() : Vector3::UnitX()) .cross(T) diff --git a/Core/src/Surfaces/CylinderBounds.cpp b/Core/src/Surfaces/CylinderBounds.cpp index 443998b3b4e..ab5fce5e296 100644 --- a/Core/src/Surfaces/CylinderBounds.cpp +++ b/Core/src/Surfaces/CylinderBounds.cpp @@ -8,11 +8,11 @@ #include "Acts/Surfaces/CylinderBounds.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/detail/BoundaryCheckHelper.hpp" #include "Acts/Surfaces/detail/VerticesHelper.hpp" #include "Acts/Utilities/VectorHelpers.hpp" +#include "Acts/Utilities/detail/periodic.hpp" #include #include @@ -21,32 +21,31 @@ #include #include -using Acts::VectorHelpers::perp; -using Acts::VectorHelpers::phi; +namespace Acts { -Acts::SurfaceBounds::BoundsType Acts::CylinderBounds::type() const { - return SurfaceBounds::eCylinder; +using VectorHelpers::perp; +using VectorHelpers::phi; + +std::vector CylinderBounds::values() const { + return {m_values.begin(), m_values.end()}; } -Acts::Vector2 Acts::CylinderBounds::shifted( - const Acts::Vector2& lposition) const { - return {Acts::detail::radian_sym((lposition[Acts::eBoundLoc0] / get(eR)) - - get(eAveragePhi)), - lposition[Acts::eBoundLoc1]}; +Vector2 CylinderBounds::shifted(const Vector2& lposition) const { + return {detail::radian_sym((lposition[0] / get(eR)) - get(eAveragePhi)), + lposition[1]}; } -Acts::SquareMatrix2 Acts::CylinderBounds::jacobian() const { +SquareMatrix2 CylinderBounds::jacobian() const { SquareMatrix2 j; - j(0, eBoundLoc0) = 1 / get(eR); - j(0, eBoundLoc1) = 0; - j(1, eBoundLoc0) = 0; - j(1, eBoundLoc1) = 1; + j(0, 0) = 1 / get(eR); + j(0, 1) = 0; + j(1, 0) = 0; + j(1, 1) = 1; return j; } -bool Acts::CylinderBounds::inside( - const Vector2& lposition, - const BoundaryTolerance& boundaryTolerance) const { +bool CylinderBounds::inside(const Vector2& lposition, + const BoundaryTolerance& boundaryTolerance) const { double bevelMinZ = get(eBevelMinZ); double bevelMaxZ = get(eBevelMaxZ); @@ -93,7 +92,7 @@ bool Acts::CylinderBounds::inside( jacobian()); } -std::ostream& Acts::CylinderBounds::toStream(std::ostream& sl) const { +std::ostream& CylinderBounds::toStream(std::ostream& sl) const { sl << std::setiosflags(std::ios::fixed); sl << std::setprecision(7); sl << "Acts::CylinderBounds: (radius, halfLengthZ, halfPhiSector, " @@ -105,7 +104,7 @@ std::ostream& Acts::CylinderBounds::toStream(std::ostream& sl) const { return sl; } -std::vector Acts::CylinderBounds::circleVertices( +std::vector CylinderBounds::circleVertices( const Transform3 transform, unsigned int quarterSegments) const { std::vector vertices; @@ -120,7 +119,7 @@ std::vector Acts::CylinderBounds::circleVertices( // Write the two bows/circles on either side std::vector sides = {-1, 1}; for (auto& side : sides) { - /// Helper method to create the segment + // Helper method to create the segment auto svertices = detail::VerticesHelper::segmentVertices( {get(eR), get(eR)}, avgPhi - halfPhi, avgPhi + halfPhi, phiRef, quarterSegments, Vector3(0., 0., side * get(eHalfLengthZ)), transform); @@ -152,7 +151,7 @@ std::vector Acts::CylinderBounds::circleVertices( return vertices; } -void Acts::CylinderBounds::checkConsistency() noexcept(false) { +void CylinderBounds::checkConsistency() noexcept(false) { if (get(eR) <= 0.) { throw std::invalid_argument( "CylinderBounds: invalid radial setup: radius is negative"); @@ -175,3 +174,5 @@ void Acts::CylinderBounds::checkConsistency() noexcept(false) { throw std::invalid_argument("CylinderBounds: invalid bevel at max Z."); } } + +} // namespace Acts diff --git a/Core/src/Surfaces/CylinderSurface.cpp b/Core/src/Surfaces/CylinderSurface.cpp index 23bb74e49f8..7990b4fd8d2 100644 --- a/Core/src/Surfaces/CylinderSurface.cpp +++ b/Core/src/Surfaces/CylinderSurface.cpp @@ -19,7 +19,6 @@ #include "Acts/Surfaces/detail/FacesHelper.hpp" #include "Acts/Surfaces/detail/MergeHelper.hpp" #include "Acts/Utilities/BinningType.hpp" -#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/Intersection.hpp" #include "Acts/Utilities/ThrowAssert.hpp" #include "Acts/Utilities/detail/periodic.hpp" @@ -34,46 +33,41 @@ #include namespace Acts { -class DetectorElementBase; -} // namespace Acts -using Acts::VectorHelpers::perp; -using Acts::VectorHelpers::phi; +using VectorHelpers::perp; +using VectorHelpers::phi; -Acts::CylinderSurface::CylinderSurface(const CylinderSurface& other) +CylinderSurface::CylinderSurface(const CylinderSurface& other) : GeometryObject(), RegularSurface(other), m_bounds(other.m_bounds) {} -Acts::CylinderSurface::CylinderSurface(const GeometryContext& gctx, - const CylinderSurface& other, - const Transform3& shift) +CylinderSurface::CylinderSurface(const GeometryContext& gctx, + const CylinderSurface& other, + const Transform3& shift) : GeometryObject(), RegularSurface(gctx, other, shift), m_bounds(other.m_bounds) {} -Acts::CylinderSurface::CylinderSurface(const Transform3& transform, - double radius, double halfz, - double halfphi, double avphi, - double bevelMinZ, double bevelMaxZ) +CylinderSurface::CylinderSurface(const Transform3& transform, double radius, + double halfz, double halfphi, double avphi, + double bevelMinZ, double bevelMaxZ) : RegularSurface(transform), m_bounds(std::make_shared( radius, halfz, halfphi, avphi, bevelMinZ, bevelMaxZ)) {} -Acts::CylinderSurface::CylinderSurface( - std::shared_ptr cbounds, - const DetectorElementBase& detelement) +CylinderSurface::CylinderSurface(std::shared_ptr cbounds, + const DetectorElementBase& detelement) : RegularSurface(detelement), m_bounds(std::move(cbounds)) { - /// surfaces representing a detector element must have bounds + // surfaces representing a detector element must have bounds throw_assert(m_bounds, "CylinderBounds must not be nullptr"); } -Acts::CylinderSurface::CylinderSurface( - const Transform3& transform, std::shared_ptr cbounds) +CylinderSurface::CylinderSurface(const Transform3& transform, + std::shared_ptr cbounds) : RegularSurface(transform), m_bounds(std::move(cbounds)) { throw_assert(m_bounds, "CylinderBounds must not be nullptr"); } -Acts::CylinderSurface& Acts::CylinderSurface::operator=( - const CylinderSurface& other) { +CylinderSurface& CylinderSurface::operator=(const CylinderSurface& other) { if (this != &other) { Surface::operator=(other); m_bounds = other.m_bounds; @@ -82,11 +76,10 @@ Acts::CylinderSurface& Acts::CylinderSurface::operator=( } // return the binning position for ordering in the BinnedArray -Acts::Vector3 Acts::CylinderSurface::binningPosition( - const GeometryContext& gctx, BinningValue bValue) const { +Vector3 CylinderSurface::binningPosition(const GeometryContext& gctx, + BinningValue bValue) const { // special binning type for R-type methods - if (bValue == Acts::BinningValue::binR || - bValue == Acts::BinningValue::binRPhi) { + if (bValue == BinningValue::binR || bValue == BinningValue::binRPhi) { double R = bounds().get(CylinderBounds::eR); double phi = bounds().get(CylinderBounds::eAveragePhi); return localToGlobal(gctx, Vector2{phi * R, 0}, Vector3{}); @@ -99,7 +92,7 @@ Acts::Vector3 Acts::CylinderSurface::binningPosition( } // return the measurement frame: it's the tangential plane -Acts::RotationMatrix3 Acts::CylinderSurface::referenceFrame( +RotationMatrix3 CylinderSurface::referenceFrame( const GeometryContext& gctx, const Vector3& position, const Vector3& /*direction*/) const { RotationMatrix3 mFrame; @@ -118,22 +111,22 @@ Acts::RotationMatrix3 Acts::CylinderSurface::referenceFrame( return mFrame; } -Acts::Surface::SurfaceType Acts::CylinderSurface::type() const { +Surface::SurfaceType CylinderSurface::type() const { return Surface::Cylinder; } -Acts::Vector3 Acts::CylinderSurface::localToGlobal( - const GeometryContext& gctx, const Vector2& lposition) const { +Vector3 CylinderSurface::localToGlobal(const GeometryContext& gctx, + const Vector2& lposition) const { // create the position in the local 3d frame double r = bounds().get(CylinderBounds::eR); - double phi = lposition[Acts::eBoundLoc0] / r; - Vector3 position(r * cos(phi), r * sin(phi), lposition[Acts::eBoundLoc1]); + double phi = lposition[0] / r; + Vector3 position(r * cos(phi), r * sin(phi), lposition[1]); return transform(gctx) * position; } -Acts::Result Acts::CylinderSurface::globalToLocal( - const GeometryContext& gctx, const Vector3& position, - double tolerance) const { +Result CylinderSurface::globalToLocal(const GeometryContext& gctx, + const Vector3& position, + double tolerance) const { double inttol = tolerance; if (tolerance == s_onSurfaceTolerance) { // transform default value! @@ -153,19 +146,19 @@ Acts::Result Acts::CylinderSurface::globalToLocal( {bounds().get(CylinderBounds::eR) * phi(loc3Dframe), loc3Dframe.z()}); } -std::string Acts::CylinderSurface::name() const { +std::string CylinderSurface::name() const { return "Acts::CylinderSurface"; } -Acts::Vector3 Acts::CylinderSurface::normal( - const GeometryContext& gctx, const Acts::Vector2& lposition) const { - double phi = lposition[Acts::eBoundLoc0] / m_bounds->get(CylinderBounds::eR); +Vector3 CylinderSurface::normal(const GeometryContext& gctx, + const Vector2& lposition) const { + double phi = lposition[0] / m_bounds->get(CylinderBounds::eR); Vector3 localNormal(cos(phi), sin(phi), 0.); return transform(gctx).linear() * localNormal; } -Acts::Vector3 Acts::CylinderSurface::normal( - const GeometryContext& gctx, const Acts::Vector3& position) const { +Vector3 CylinderSurface::normal(const GeometryContext& gctx, + const Vector3& position) const { const Transform3& sfTransform = transform(gctx); // get it into the cylinder frame Vector3 pos3D = sfTransform.inverse() * position; @@ -175,19 +168,19 @@ Acts::Vector3 Acts::CylinderSurface::normal( return sfTransform.linear() * pos3D.normalized(); } -double Acts::CylinderSurface::pathCorrection( - const GeometryContext& gctx, const Acts::Vector3& position, - const Acts::Vector3& direction) const { +double CylinderSurface::pathCorrection(const GeometryContext& gctx, + const Vector3& position, + const Vector3& direction) const { Vector3 normalT = normal(gctx, position); double cosAlpha = normalT.dot(direction); return std::abs(1. / cosAlpha); } -const Acts::CylinderBounds& Acts::CylinderSurface::bounds() const { +const CylinderBounds& CylinderSurface::bounds() const { return (*m_bounds.get()); } -Acts::Polyhedron Acts::CylinderSurface::polyhedronRepresentation( +Polyhedron CylinderSurface::polyhedronRepresentation( const GeometryContext& gctx, unsigned int quarterSegments) const { auto ctrans = transform(gctx); @@ -199,13 +192,12 @@ Acts::Polyhedron Acts::CylinderSurface::polyhedronRepresentation( return Polyhedron(vertices, faces, triangularMesh, false); } -Acts::Vector3 Acts::CylinderSurface::rotSymmetryAxis( - const GeometryContext& gctx) const { +Vector3 CylinderSurface::rotSymmetryAxis(const GeometryContext& gctx) const { // fast access via transform matrix (and not rotation()) return transform(gctx).matrix().block<3, 1>(0, 2); } -Acts::detail::RealQuadraticEquation Acts::CylinderSurface::intersectionSolver( +detail::RealQuadraticEquation CylinderSurface::intersectionSolver( const Transform3& transform, const Vector3& position, const Vector3& direction) const { // Solve for radius R @@ -227,7 +219,7 @@ Acts::detail::RealQuadraticEquation Acts::CylinderSurface::intersectionSolver( return detail::RealQuadraticEquation(a, b, c); } -Acts::SurfaceMultiIntersection Acts::CylinderSurface::intersect( +SurfaceMultiIntersection CylinderSurface::intersect( const GeometryContext& gctx, const Vector3& position, const Vector3& direction, const BoundaryTolerance& boundaryTolerance, double tolerance) const { @@ -294,7 +286,7 @@ Acts::SurfaceMultiIntersection Acts::CylinderSurface::intersect( return {{second, first}, this}; } -Acts::AlignmentToPathMatrix Acts::CylinderSurface::alignmentToPathDerivative( +AlignmentToPathMatrix CylinderSurface::alignmentToPathDerivative( const GeometryContext& gctx, const Vector3& position, const Vector3& direction) const { assert(isOnSurface(gctx, position, direction, BoundaryTolerance::Infinite())); @@ -342,8 +334,7 @@ Acts::AlignmentToPathMatrix Acts::CylinderSurface::alignmentToPathDerivative( return alignToPath; } -Acts::ActsMatrix<2, 3> -Acts::CylinderSurface::localCartesianToBoundLocalDerivative( +ActsMatrix<2, 3> CylinderSurface::localCartesianToBoundLocalDerivative( const GeometryContext& gctx, const Vector3& position) const { using VectorHelpers::perp; using VectorHelpers::phi; @@ -363,11 +354,10 @@ Acts::CylinderSurface::localCartesianToBoundLocalDerivative( return loc3DToLocBound; } -std::pair, bool> -Acts::CylinderSurface::mergedWith(const CylinderSurface& other, - BinningValue direction, bool externalRotation, - const Logger& logger) const { - using namespace Acts::UnitLiterals; +std::pair, bool> CylinderSurface::mergedWith( + const CylinderSurface& other, BinningValue direction, bool externalRotation, + const Logger& logger) const { + using namespace UnitLiterals; ACTS_VERBOSE("Merging cylinder surfaces in " << binningValueName(direction) << " direction"); @@ -458,7 +448,7 @@ Acts::CylinderSurface::mergedWith(const CylinderSurface& other, double otherHlPhi = other.bounds().get(CylinderBounds::eHalfPhiSector); double otherAvgPhi = other.bounds().get(CylinderBounds::eAveragePhi); - if (direction == Acts::BinningValue::binZ) { + if (direction == BinningValue::binZ) { // z shift must match the bounds if (std::abs(otherLocal.linear().col(eY)[eX]) >= tolerance && @@ -505,7 +495,7 @@ Acts::CylinderSurface::mergedWith(const CylinderSurface& other, return {Surface::makeShared(newTransform, newBounds), zShift < 0}; - } else if (direction == Acts::BinningValue::binRPhi) { + } else if (direction == BinningValue::binRPhi) { // no z shift is allowed if (std::abs(translation[2]) > tolerance) { ACTS_ERROR( @@ -568,3 +558,5 @@ Acts::CylinderSurface::mergedWith(const CylinderSurface& other, binningValueName(direction)); } } + +} // namespace Acts diff --git a/Core/src/Surfaces/DiamondBounds.cpp b/Core/src/Surfaces/DiamondBounds.cpp index aa913404c0f..78ff02c8c4a 100644 --- a/Core/src/Surfaces/DiamondBounds.cpp +++ b/Core/src/Surfaces/DiamondBounds.cpp @@ -15,14 +15,26 @@ #include #include #include +#include -Acts::SurfaceBounds::BoundsType Acts::DiamondBounds::type() const { - return SurfaceBounds::eDiamond; +namespace Acts { + +std::vector DiamondBounds::values() const { + return {m_values.begin(), m_values.end()}; +} + +void DiamondBounds::checkConsistency() noexcept(false) { + if (std::ranges::any_of(m_values, [](auto v) { return v <= 0.; })) { + throw std::invalid_argument("DiamondBounds: negative half length."); + } + if (get(eHalfLengthXnegY) > get(eHalfLengthXzeroY) || + get(eHalfLengthXposY) > get(eHalfLengthXzeroY)) { + throw std::invalid_argument("DiamondBounds: not a diamond shape."); + } } -bool Acts::DiamondBounds::inside( - const Acts::Vector2& lposition, - const Acts::BoundaryTolerance& boundaryTolerance) const { +bool DiamondBounds::inside(const Vector2& lposition, + const BoundaryTolerance& boundaryTolerance) const { // Vertices starting at lower left (min rel. phi) // counter-clockwise double x1 = get(DiamondBounds::eHalfLengthXnegY); @@ -37,7 +49,7 @@ bool Acts::DiamondBounds::inside( std::nullopt); } -std::vector Acts::DiamondBounds::vertices( +std::vector DiamondBounds::vertices( unsigned int /*ignoredSegments*/) const { // Vertices starting at lower left (min rel. phi) // counter-clockwise @@ -50,11 +62,11 @@ std::vector Acts::DiamondBounds::vertices( return {{-x1, -y1}, {x1, -y1}, {x2, y2}, {x3, y3}, {-x3, y3}, {-x2, y2}}; } -const Acts::RectangleBounds& Acts::DiamondBounds::boundingBox() const { +const RectangleBounds& DiamondBounds::boundingBox() const { return m_boundingBox; } -std::ostream& Acts::DiamondBounds::toStream(std::ostream& sl) const { +std::ostream& DiamondBounds::toStream(std::ostream& sl) const { sl << std::setiosflags(std::ios::fixed); sl << std::setprecision(7); sl << "Acts::DiamondBounds: (halfXatYneg, halfXatYzero, halfXatYpos, " @@ -67,3 +79,5 @@ std::ostream& Acts::DiamondBounds::toStream(std::ostream& sl) const { sl << std::setprecision(-1); return sl; } + +} // namespace Acts diff --git a/Core/src/Surfaces/DiscSurface.cpp b/Core/src/Surfaces/DiscSurface.cpp index ac3c188fd7d..8981bb24c5e 100644 --- a/Core/src/Surfaces/DiscSurface.cpp +++ b/Core/src/Surfaces/DiscSurface.cpp @@ -26,90 +26,90 @@ #include "Acts/Utilities/Intersection.hpp" #include "Acts/Utilities/JacobianHelpers.hpp" #include "Acts/Utilities/ThrowAssert.hpp" +#include "Acts/Utilities/detail/periodic.hpp" #include #include #include #include -using Acts::VectorHelpers::perp; -using Acts::VectorHelpers::phi; +namespace Acts { -Acts::DiscSurface::DiscSurface(const DiscSurface& other) +using VectorHelpers::perp; +using VectorHelpers::phi; + +DiscSurface::DiscSurface(const DiscSurface& other) : GeometryObject(), RegularSurface(other), m_bounds(other.m_bounds) {} -Acts::DiscSurface::DiscSurface(const GeometryContext& gctx, - const DiscSurface& other, - const Transform3& shift) +DiscSurface::DiscSurface(const GeometryContext& gctx, const DiscSurface& other, + const Transform3& shift) : GeometryObject(), RegularSurface(gctx, other, shift), m_bounds(other.m_bounds) {} -Acts::DiscSurface::DiscSurface(const Transform3& transform, double rmin, - double rmax, double hphisec) +DiscSurface::DiscSurface(const Transform3& transform, double rmin, double rmax, + double hphisec) : GeometryObject(), RegularSurface(transform), m_bounds(std::make_shared(rmin, rmax, hphisec)) {} -Acts::DiscSurface::DiscSurface(const Transform3& transform, double minhalfx, - double maxhalfx, double minR, double maxR, - double avephi, double stereo) +DiscSurface::DiscSurface(const Transform3& transform, double minhalfx, + double maxhalfx, double minR, double maxR, + double avephi, double stereo) : GeometryObject(), RegularSurface(transform), m_bounds(std::make_shared( minhalfx, maxhalfx, minR, maxR, avephi, stereo)) {} -Acts::DiscSurface::DiscSurface(const Transform3& transform, - std::shared_ptr dbounds) +DiscSurface::DiscSurface(const Transform3& transform, + std::shared_ptr dbounds) : GeometryObject(), RegularSurface(transform), m_bounds(std::move(dbounds)) {} -Acts::DiscSurface::DiscSurface(std::shared_ptr dbounds, - const DetectorElementBase& detelement) +DiscSurface::DiscSurface(std::shared_ptr dbounds, + const DetectorElementBase& detelement) : GeometryObject(), RegularSurface(detelement), m_bounds(std::move(dbounds)) { throw_assert(m_bounds, "nullptr as DiscBounds"); } -Acts::DiscSurface& Acts::DiscSurface::operator=(const DiscSurface& other) { +DiscSurface& DiscSurface::operator=(const DiscSurface& other) { if (this != &other) { - Acts::Surface::operator=(other); + Surface::operator=(other); m_bounds = other.m_bounds; } return *this; } -Acts::Surface::SurfaceType Acts::DiscSurface::type() const { +Surface::SurfaceType DiscSurface::type() const { return Surface::Disc; } -Acts::Vector3 Acts::DiscSurface::localToGlobal(const GeometryContext& gctx, - const Vector2& lposition) const { +Vector3 DiscSurface::localToGlobal(const GeometryContext& gctx, + const Vector2& lposition) const { // create the position in the local 3d frame - Vector3 loc3Dframe( - lposition[Acts::eBoundLoc0] * cos(lposition[Acts::eBoundLoc1]), - lposition[Acts::eBoundLoc0] * sin(lposition[Acts::eBoundLoc1]), 0.); + Vector3 loc3Dframe(lposition[0] * cos(lposition[1]), + lposition[0] * sin(lposition[1]), 0.); // transform to globalframe return transform(gctx) * loc3Dframe; } -Acts::Result Acts::DiscSurface::globalToLocal( - const GeometryContext& gctx, const Vector3& position, - double tolerance) const { +Result DiscSurface::globalToLocal(const GeometryContext& gctx, + const Vector3& position, + double tolerance) const { // transport it to the globalframe Vector3 loc3Dframe = (transform(gctx).inverse()) * position; if (std::abs(loc3Dframe.z()) > std::abs(tolerance)) { return Result::failure(SurfaceError::GlobalPositionNotOnSurface); } - return Result::success({perp(loc3Dframe), phi(loc3Dframe)}); + return Result::success({perp(loc3Dframe), phi(loc3Dframe)}); } -Acts::Vector2 Acts::DiscSurface::localPolarToLocalCartesian( - const Vector2& locpol) const { +Vector2 DiscSurface::localPolarToLocalCartesian(const Vector2& locpol) const { const DiscTrapezoidBounds* dtbo = - dynamic_cast(&(bounds())); + dynamic_cast(&(bounds())); if (dtbo != nullptr) { double rMedium = dtbo->rCenter(); double phi = dtbo->get(DiscTrapezoidBounds::eAveragePhi); @@ -117,43 +117,40 @@ Acts::Vector2 Acts::DiscSurface::localPolarToLocalCartesian( Vector2 polarCenter(rMedium, phi); Vector2 cartCenter = localPolarToCartesian(polarCenter); Vector2 cartPos = localPolarToCartesian(locpol); - Vector2 Pos = cartPos - cartCenter; + Vector2 pos = cartPos - cartCenter; - Acts::Vector2 locPos( - Pos[Acts::eBoundLoc0] * sin(phi) - Pos[Acts::eBoundLoc1] * cos(phi), - Pos[Acts::eBoundLoc1] * sin(phi) + Pos[Acts::eBoundLoc0] * cos(phi)); - return Vector2(locPos[Acts::eBoundLoc0], locPos[Acts::eBoundLoc1]); + Vector2 locPos(pos[0] * sin(phi) - pos[1] * cos(phi), + pos[1] * sin(phi) + pos[0] * cos(phi)); + return Vector2(locPos[0], locPos[1]); } - return Vector2(locpol[Acts::eBoundLoc0] * cos(locpol[Acts::eBoundLoc1]), - locpol[Acts::eBoundLoc0] * sin(locpol[Acts::eBoundLoc1])); + return Vector2(locpol[0] * cos(locpol[1]), locpol[0] * sin(locpol[1])); } -Acts::Vector3 Acts::DiscSurface::localCartesianToGlobal( - const GeometryContext& gctx, const Vector2& lposition) const { - Vector3 loc3Dframe(lposition[Acts::eBoundLoc0], lposition[Acts::eBoundLoc1], - 0.); +Vector3 DiscSurface::localCartesianToGlobal(const GeometryContext& gctx, + const Vector2& lposition) const { + Vector3 loc3Dframe(lposition[0], lposition[1], 0.); return transform(gctx) * loc3Dframe; } -Acts::Vector2 Acts::DiscSurface::globalToLocalCartesian( - const GeometryContext& gctx, const Vector3& position, - double /*direction*/) const { +Vector2 DiscSurface::globalToLocalCartesian(const GeometryContext& gctx, + const Vector3& position, + double /*direction*/) const { Vector3 loc3Dframe = (transform(gctx).inverse()) * position; return Vector2(loc3Dframe.x(), loc3Dframe.y()); } -std::string Acts::DiscSurface::name() const { +std::string DiscSurface::name() const { return "Acts::DiscSurface"; } -const Acts::SurfaceBounds& Acts::DiscSurface::bounds() const { +const SurfaceBounds& DiscSurface::bounds() const { if (m_bounds) { return (*(m_bounds.get())); } return s_noBounds; } -Acts::Polyhedron Acts::DiscSurface::polyhedronRepresentation( +Polyhedron DiscSurface::polyhedronRepresentation( const GeometryContext& gctx, unsigned int quarterSegments) const { // Prepare vertices and faces std::vector vertices; @@ -194,19 +191,15 @@ Acts::Polyhedron Acts::DiscSurface::polyhedronRepresentation( throw std::domain_error("Polyhedron repr of boundless surface not possible."); } -Acts::Vector2 Acts::DiscSurface::localPolarToCartesian( - const Vector2& lpolar) const { - return Vector2(lpolar[eBoundLoc0] * cos(lpolar[eBoundLoc1]), - lpolar[eBoundLoc0] * sin(lpolar[eBoundLoc1])); +Vector2 DiscSurface::localPolarToCartesian(const Vector2& lpolar) const { + return Vector2(lpolar[0] * cos(lpolar[1]), lpolar[0] * sin(lpolar[1])); } -Acts::Vector2 Acts::DiscSurface::localCartesianToPolar( - const Vector2& lcart) const { - return Vector2(lcart.norm(), - std::atan2(lcart[eBoundLoc1], lcart[eBoundLoc0])); +Vector2 DiscSurface::localCartesianToPolar(const Vector2& lcart) const { + return Vector2(lcart.norm(), std::atan2(lcart[1], lcart[0])); } -Acts::BoundToFreeMatrix Acts::DiscSurface::boundToFreeJacobian( +BoundToFreeMatrix DiscSurface::boundToFreeJacobian( const GeometryContext& gctx, const Vector3& position, const Vector3& direction) const { assert(isOnSurface(gctx, position, direction, BoundaryTolerance::Infinite())); @@ -239,7 +232,7 @@ Acts::BoundToFreeMatrix Acts::DiscSurface::boundToFreeJacobian( return jacToGlobal; } -Acts::FreeToBoundMatrix Acts::DiscSurface::freeToBoundJacobian( +FreeToBoundMatrix DiscSurface::freeToBoundJacobian( const GeometryContext& gctx, const Vector3& position, const Vector3& direction) const { using VectorHelpers::perp; @@ -275,7 +268,7 @@ Acts::FreeToBoundMatrix Acts::DiscSurface::freeToBoundJacobian( return jacToLocal; } -Acts::SurfaceMultiIntersection Acts::DiscSurface::intersect( +SurfaceMultiIntersection DiscSurface::intersect( const GeometryContext& gctx, const Vector3& position, const Vector3& direction, const BoundaryTolerance& boundaryTolerance, double tolerance) const { @@ -310,7 +303,7 @@ Acts::SurfaceMultiIntersection Acts::DiscSurface::intersect( this}; } -Acts::ActsMatrix<2, 3> Acts::DiscSurface::localCartesianToBoundLocalDerivative( +ActsMatrix<2, 3> DiscSurface::localCartesianToBoundLocalDerivative( const GeometryContext& gctx, const Vector3& position) const { using VectorHelpers::perp; using VectorHelpers::phi; @@ -328,24 +321,24 @@ Acts::ActsMatrix<2, 3> Acts::DiscSurface::localCartesianToBoundLocalDerivative( return loc3DToLocBound; } -Acts::Vector3 Acts::DiscSurface::normal(const GeometryContext& gctx, - const Vector2& /*lposition*/) const { +Vector3 DiscSurface::normal(const GeometryContext& gctx, + const Vector2& /*lposition*/) const { return normal(gctx); } -Acts::Vector3 Acts::DiscSurface::normal(const GeometryContext& gctx, - const Vector3& /*position*/) const { +Vector3 DiscSurface::normal(const GeometryContext& gctx, + const Vector3& /*position*/) const { return normal(gctx); } -Acts::Vector3 Acts::DiscSurface::normal(const GeometryContext& gctx) const { +Vector3 DiscSurface::normal(const GeometryContext& gctx) const { // fast access via transform matrix (and not rotation()) const auto& tMatrix = transform(gctx).matrix(); return Vector3(tMatrix(0, 2), tMatrix(1, 2), tMatrix(2, 2)); } -Acts::Vector3 Acts::DiscSurface::binningPosition(const GeometryContext& gctx, - BinningValue bValue) const { +Vector3 DiscSurface::binningPosition(const GeometryContext& gctx, + BinningValue bValue) const { if (bValue == BinningValue::binR || bValue == BinningValue::binPhi) { double r = m_bounds->binningValueR(); double phi = m_bounds->binningValuePhi(); @@ -354,8 +347,8 @@ Acts::Vector3 Acts::DiscSurface::binningPosition(const GeometryContext& gctx, return center(gctx); } -double Acts::DiscSurface::binningPositionValue(const GeometryContext& gctx, - BinningValue bValue) const { +double DiscSurface::binningPositionValue(const GeometryContext& gctx, + BinningValue bValue) const { if (bValue == BinningValue::binR) { return VectorHelpers::perp(binningPosition(gctx, bValue)); } @@ -366,18 +359,17 @@ double Acts::DiscSurface::binningPositionValue(const GeometryContext& gctx, return GeometryObject::binningPositionValue(gctx, bValue); } -double Acts::DiscSurface::pathCorrection(const GeometryContext& gctx, - const Vector3& /*position*/, - const Vector3& direction) const { - /// we can ignore the global position here +double DiscSurface::pathCorrection(const GeometryContext& gctx, + const Vector3& /*position*/, + const Vector3& direction) const { + // we can ignore the global position here return 1. / std::abs(normal(gctx).dot(direction)); } -std::pair, bool> -Acts::DiscSurface::mergedWith(const DiscSurface& other, BinningValue direction, - bool externalRotation, - const Logger& logger) const { - using namespace Acts::UnitLiterals; +std::pair, bool> DiscSurface::mergedWith( + const DiscSurface& other, BinningValue direction, bool externalRotation, + const Logger& logger) const { + using namespace UnitLiterals; ACTS_VERBOSE("Merging disc surfaces in " << direction << " direction"); @@ -451,7 +443,7 @@ Acts::DiscSurface::mergedWith(const DiscSurface& other, BinningValue direction, << otherAvgPhi / 1_degree << " +- " << otherHlPhi / 1_degree); - if (direction == Acts::BinningValue::binR) { + if (direction == BinningValue::binR) { if (std::abs(otherLocal.linear().col(eY)[eX]) >= tolerance && (!bounds->coversFullAzimuth() || !otherBounds->coversFullAzimuth())) { throw SurfaceMergingException(getSharedPtr(), other.getSharedPtr(), @@ -491,7 +483,7 @@ Acts::DiscSurface::mergedWith(const DiscSurface& other, BinningValue direction, return {Surface::makeShared(*m_transform, newBounds), minR > otherMinR}; - } else if (direction == Acts::BinningValue::binPhi) { + } else if (direction == BinningValue::binPhi) { if (std::abs(maxR - otherMaxR) > tolerance || std::abs(minR - otherMinR) > tolerance) { ACTS_ERROR("DiscSurface::merge: surfaces don't have same r bounds"); @@ -548,3 +540,5 @@ Acts::DiscSurface::mergedWith(const DiscSurface& other, BinningValue direction, "DiscSurface::merge: invalid direction " + binningValueName(direction)); } } + +} // namespace Acts diff --git a/Core/src/Surfaces/DiscTrapezoidBounds.cpp b/Core/src/Surfaces/DiscTrapezoidBounds.cpp index 3a234edbd9c..d96b2ea645e 100644 --- a/Core/src/Surfaces/DiscTrapezoidBounds.cpp +++ b/Core/src/Surfaces/DiscTrapezoidBounds.cpp @@ -8,52 +8,63 @@ #include "Acts/Surfaces/DiscTrapezoidBounds.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" +#include "Acts/Definitions/Algebra.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/detail/BoundaryCheckHelper.hpp" +#include "Acts/Utilities/detail/periodic.hpp" #include #include #include -#include +#include -Acts::DiscTrapezoidBounds::DiscTrapezoidBounds(double halfXminR, - double halfXmaxR, double minR, - double maxR, double avgPhi, - double stereo) noexcept(false) +namespace Acts { + +DiscTrapezoidBounds::DiscTrapezoidBounds(double halfXminR, double halfXmaxR, + double minR, double maxR, + double avgPhi, + double stereo) noexcept(false) : m_values({halfXminR, halfXmaxR, minR, maxR, avgPhi, stereo}) { checkConsistency(); m_ymax = std::sqrt(get(eMaxR) * get(eMaxR) - get(eHalfLengthXmaxR) * get(eHalfLengthXmaxR)); } -Acts::SurfaceBounds::BoundsType Acts::DiscTrapezoidBounds::type() const { - return SurfaceBounds::eDiscTrapezoid; +std::vector DiscTrapezoidBounds::values() const { + return {m_values.begin(), m_values.end()}; +} + +void DiscTrapezoidBounds::checkConsistency() noexcept(false) { + if (get(eMinR) < 0. || get(eMaxR) <= 0. || get(eMinR) > get(eMaxR)) { + throw std::invalid_argument("DiscTrapezoidBounds: invalid radial setup."); + } + if (get(eHalfLengthXminR) < 0. || get(eHalfLengthXmaxR) <= 0.) { + throw std::invalid_argument("DiscTrapezoidBounds: negative length given."); + } + if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) { + throw std::invalid_argument( + "DiscTrapezoidBounds: invalid phi positioning."); + } } -Acts::Vector2 Acts::DiscTrapezoidBounds::toLocalCartesian( - const Acts::Vector2& lposition) const { - return {lposition[eBoundLoc0] * - std::sin(lposition[eBoundLoc1] - get(eAveragePhi)), - lposition[eBoundLoc0] * - std::cos(lposition[eBoundLoc1] - get(eAveragePhi))}; +Vector2 DiscTrapezoidBounds::toLocalCartesian(const Vector2& lposition) const { + return {lposition[0] * std::sin(lposition[1] - get(eAveragePhi)), + lposition[0] * std::cos(lposition[1] - get(eAveragePhi))}; } -Acts::SquareMatrix2 Acts::DiscTrapezoidBounds::jacobianToLocalCartesian( - const Acts::Vector2& lposition) const { +SquareMatrix2 DiscTrapezoidBounds::jacobianToLocalCartesian( + const Vector2& lposition) const { SquareMatrix2 jacobian; - jacobian(0, eBoundLoc0) = std::sin(lposition[eBoundLoc1] - get(eAveragePhi)); - jacobian(1, eBoundLoc0) = std::cos(lposition[eBoundLoc1] - get(eAveragePhi)); - jacobian(0, eBoundLoc1) = - lposition[eBoundLoc0] * std::cos(lposition[eBoundLoc1]); - jacobian(1, eBoundLoc1) = - lposition[eBoundLoc0] * -std::sin(lposition[eBoundLoc1]); + jacobian(0, 0) = std::sin(lposition[1] - get(eAveragePhi)); + jacobian(1, 0) = std::cos(lposition[1] - get(eAveragePhi)); + jacobian(0, 1) = lposition[0] * std::cos(lposition[1]); + jacobian(1, 1) = lposition[0] * -std::sin(lposition[1]); return jacobian; } -bool Acts::DiscTrapezoidBounds::inside( - const Acts::Vector2& lposition, - const Acts::BoundaryTolerance& boundaryTolerance) const { +bool DiscTrapezoidBounds::inside( + const Vector2& lposition, + const BoundaryTolerance& boundaryTolerance) const { Vector2 vertices[] = {{get(eHalfLengthXminR), get(eMinR)}, {get(eHalfLengthXmaxR), m_ymax}, {-get(eHalfLengthXmaxR), m_ymax}, @@ -63,7 +74,7 @@ bool Acts::DiscTrapezoidBounds::inside( toLocalCartesian(lposition), jacobian); } -std::vector Acts::DiscTrapezoidBounds::vertices( +std::vector DiscTrapezoidBounds::vertices( unsigned int /*ignoredSegments*/) const { Vector2 cAxis(std::cos(get(eAveragePhi)), std::sin(get(eAveragePhi))); Vector2 nAxis(cAxis.y(), -cAxis.x()); @@ -76,8 +87,7 @@ std::vector Acts::DiscTrapezoidBounds::vertices( halfY * cAxis - get(eHalfLengthXmaxR) * nAxis}; } -// ostream operator overload -std::ostream& Acts::DiscTrapezoidBounds::toStream(std::ostream& sl) const { +std::ostream& DiscTrapezoidBounds::toStream(std::ostream& sl) const { sl << std::setiosflags(std::ios::fixed); sl << std::setprecision(7); sl << "Acts::DiscTrapezoidBounds: (innerRadius, outerRadius, " @@ -91,3 +101,5 @@ std::ostream& Acts::DiscTrapezoidBounds::toStream(std::ostream& sl) const { sl << std::setprecision(-1); return sl; } + +} // namespace Acts diff --git a/Core/src/Surfaces/EllipseBounds.cpp b/Core/src/Surfaces/EllipseBounds.cpp index 485f36736d8..531e1ce7d28 100644 --- a/Core/src/Surfaces/EllipseBounds.cpp +++ b/Core/src/Surfaces/EllipseBounds.cpp @@ -8,31 +8,44 @@ #include "Acts/Surfaces/EllipseBounds.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/detail/VerticesHelper.hpp" +#include "Acts/Utilities/MathHelpers.hpp" #include "Acts/Utilities/VectorHelpers.hpp" +#include "Acts/Utilities/detail/periodic.hpp" #include #include #include -#include -using Acts::VectorHelpers::perp; -using Acts::VectorHelpers::phi; +namespace Acts { -Acts::SurfaceBounds::BoundsType Acts::EllipseBounds::type() const { - return SurfaceBounds::eEllipse; +using VectorHelpers::perp; +using VectorHelpers::phi; + +std::vector EllipseBounds::values() const { + return {m_values.begin(), m_values.end()}; } -static inline double square(double x) { - return x * x; +void EllipseBounds::checkConsistency() noexcept(false) { + if (get(eInnerRx) >= get(eOuterRx) || get(eInnerRx) < 0. || + get(eOuterRx) <= 0.) { + throw std::invalid_argument("EllipseBounds: invalid along x axis"); + } + if (get(eInnerRy) >= get(eOuterRy) || get(eInnerRy) < 0. || + get(eOuterRy) <= 0.) { + throw std::invalid_argument("EllipseBounds: invalid along y axis."); + } + if (get(eHalfPhiSector) < 0. || get(eHalfPhiSector) > std::numbers::pi) { + throw std::invalid_argument("EllipseBounds: invalid phi sector setup."); + } + if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) { + throw std::invalid_argument("EllipseBounds: invalid phi positioning."); + } } -/// @warning This **only** works for tolerance-based checks -bool Acts::EllipseBounds::inside( - const Vector2& lposition, - const BoundaryTolerance& boundaryTolerance) const { +bool EllipseBounds::inside(const Vector2& lposition, + const BoundaryTolerance& boundaryTolerance) const { if (boundaryTolerance.isInfinite()) { return true; } @@ -47,32 +60,29 @@ bool Acts::EllipseBounds::inside( double phiHalf = get(eHalfPhiSector) + tol1; bool insidePhi = (-phiHalf <= phi) && (phi < phiHalf); - bool insideInner = - (get(eInnerRx) <= tol0) || (get(eOuterRx) <= tol0) || - (1 < (square(lposition[Acts::eBoundLoc0] / (get(eInnerRx) - tol0)) + - square(lposition[Acts::eBoundLoc1] / (get(eOuterRx) - tol0)))); - bool insideOuter = - (square(lposition[Acts::eBoundLoc0] / (get(eInnerRy) + tol0)) + - square(lposition[Acts::eBoundLoc1] / (get(eOuterRy) + tol0))) < 1; + bool insideInner = (get(eInnerRx) <= tol0) || (get(eOuterRx) <= tol0) || + (1 < (square(lposition[0] / (get(eInnerRx) - tol0)) + + square(lposition[1] / (get(eOuterRx) - tol0)))); + bool insideOuter = (square(lposition[0] / (get(eInnerRy) + tol0)) + + square(lposition[1] / (get(eOuterRy) + tol0))) < 1; return insidePhi && insideInner && insideOuter; } throw std::logic_error("Unsupported boundary check type"); } -std::vector Acts::EllipseBounds::vertices( +std::vector EllipseBounds::vertices( unsigned int quarterSegments) const { return detail::VerticesHelper::ellipsoidVertices( get(eInnerRx), get(eInnerRy), get(eOuterRx), get(eOuterRy), get(eAveragePhi), get(eHalfPhiSector), quarterSegments); } -const Acts::RectangleBounds& Acts::EllipseBounds::boundingBox() const { +const RectangleBounds& EllipseBounds::boundingBox() const { return m_boundingBox; } -// ostream operator overload -std::ostream& Acts::EllipseBounds::toStream(std::ostream& sl) const { +std::ostream& EllipseBounds::toStream(std::ostream& sl) const { sl << std::setiosflags(std::ios::fixed); sl << std::setprecision(7); sl << "Acts::EllipseBounds: (innerRadius0, outerRadius0, innerRadius1, " @@ -83,3 +93,5 @@ std::ostream& Acts::EllipseBounds::toStream(std::ostream& sl) const { sl << std::setprecision(-1); return sl; } + +} // namespace Acts diff --git a/Core/src/Surfaces/IntersectionHelper2D.cpp b/Core/src/Surfaces/IntersectionHelper2D.cpp index 458a54a2262..c3cd0cdf8b2 100644 --- a/Core/src/Surfaces/IntersectionHelper2D.cpp +++ b/Core/src/Surfaces/IntersectionHelper2D.cpp @@ -14,9 +14,13 @@ #include -Acts::Intersection2D Acts::detail::IntersectionHelper2D::intersectSegment( - const Vector2& s0, const Vector2& s1, const Vector2& origin, - const Vector2& dir, bool boundCheck) { +namespace Acts::detail { + +Intersection2D IntersectionHelper2D::intersectSegment(const Vector2& s0, + const Vector2& s1, + const Vector2& origin, + const Vector2& dir, + bool boundCheck) { using Line = Eigen::ParametrizedLine; using Plane = Eigen::Hyperplane; @@ -40,13 +44,11 @@ Acts::Intersection2D Acts::detail::IntersectionHelper2D::intersectSegment( return Intersection2D(intersection, d, status); } -std::array -Acts::detail::IntersectionHelper2D::intersectEllipse(double Rx, double Ry, - const Vector2& origin, - const Vector2& dir) { +std::array IntersectionHelper2D::intersectEllipse( + double Rx, double Ry, const Vector2& origin, const Vector2& dir) { auto createSolution = [&](const Vector2& sol, - const Vector2& alt) -> std::array { + const Vector2& alt) -> std::array { Vector2 toSolD(sol - origin); Vector2 toAltD(alt - origin); @@ -98,7 +100,7 @@ Acts::detail::IntersectionHelper2D::intersectEllipse(double Rx, double Ry, double alpha = 1. / (Rx * Rx) + k * k / Ry2; double beta = 2. * k * d / Ry2; double gamma = d * d / Ry2 - 1; - Acts::detail::RealQuadraticEquation solver(alpha, beta, gamma); + RealQuadraticEquation solver(alpha, beta, gamma); if (solver.solutions == 1) { double x = solver.first; Vector2 sol(x, k * x + d); @@ -116,13 +118,13 @@ Acts::detail::IntersectionHelper2D::intersectEllipse(double Rx, double Ry, return {Intersection2D::invalid(), Intersection2D::invalid()}; } -Acts::Intersection2D Acts::detail::IntersectionHelper2D::intersectCircleSegment( +Intersection2D IntersectionHelper2D::intersectCircleSegment( double R, double phiMin, double phiMax, const Vector2& origin, const Vector2& dir) { auto intersections = intersectCircle(R, origin, dir); for (const auto& candidate : intersections) { if (candidate.pathLength() > 0.) { - double phi = Acts::VectorHelpers::phi(candidate.position()); + double phi = VectorHelpers::phi(candidate.position()); if (phi > phiMin && phi < phiMax) { return candidate; } @@ -130,3 +132,5 @@ Acts::Intersection2D Acts::detail::IntersectionHelper2D::intersectCircleSegment( } return Intersection2D::invalid(); } + +} // namespace Acts::detail diff --git a/Core/src/Surfaces/LineBounds.cpp b/Core/src/Surfaces/LineBounds.cpp index bdb0673a010..9511722d002 100644 --- a/Core/src/Surfaces/LineBounds.cpp +++ b/Core/src/Surfaces/LineBounds.cpp @@ -14,13 +14,23 @@ #include #include -Acts::SurfaceBounds::BoundsType Acts::LineBounds::type() const { - return SurfaceBounds::eLine; +namespace Acts { + +std::vector LineBounds::values() const { + return {m_values.begin(), m_values.end()}; +} + +void LineBounds::checkConsistency() noexcept(false) { + if (get(eR) < 0.) { + throw std::invalid_argument("LineBounds: zero radius."); + } + if (get(eHalfLengthZ) <= 0.) { + throw std::invalid_argument("LineBounds: zero/negative length."); + } } -bool Acts::LineBounds::inside( - const Acts::Vector2& lposition, - const Acts::BoundaryTolerance& boundaryTolerance) const { +bool LineBounds::inside(const Vector2& lposition, + const BoundaryTolerance& boundaryTolerance) const { double r = get(LineBounds::eR); double halfLengthZ = get(LineBounds::eHalfLengthZ); return detail::insideAlignedBox(Vector2(-r, -halfLengthZ), @@ -28,8 +38,7 @@ bool Acts::LineBounds::inside( lposition, std::nullopt); } -// ostream operator overload -std::ostream& Acts::LineBounds::toStream(std::ostream& sl) const { +std::ostream& LineBounds::toStream(std::ostream& sl) const { sl << std::setiosflags(std::ios::fixed); sl << std::setprecision(7); sl << "Acts::LineBounds: (radius, halflengthInZ) = "; @@ -38,3 +47,5 @@ std::ostream& Acts::LineBounds::toStream(std::ostream& sl) const { sl << std::setprecision(-1); return sl; } + +} // namespace Acts diff --git a/Core/src/Surfaces/LineSurface.cpp b/Core/src/Surfaces/LineSurface.cpp index 166a36bf630..68957d5824b 100644 --- a/Core/src/Surfaces/LineSurface.cpp +++ b/Core/src/Surfaces/LineSurface.cpp @@ -15,46 +15,39 @@ #include "Acts/Surfaces/SurfaceBounds.hpp" #include "Acts/Surfaces/SurfaceError.hpp" #include "Acts/Surfaces/detail/AlignmentHelper.hpp" -#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/Intersection.hpp" -#include "Acts/Utilities/JacobianHelpers.hpp" #include "Acts/Utilities/ThrowAssert.hpp" -#include #include #include -#include #include namespace Acts { -class DetectorElementBase; -} // namespace Acts -Acts::LineSurface::LineSurface(const Transform3& transform, double radius, - double halez) +LineSurface::LineSurface(const Transform3& transform, double radius, + double halez) : GeometryObject(), Surface(transform), m_bounds(std::make_shared(radius, halez)) {} -Acts::LineSurface::LineSurface(const Transform3& transform, - std::shared_ptr lbounds) +LineSurface::LineSurface(const Transform3& transform, + std::shared_ptr lbounds) : GeometryObject(), Surface(transform), m_bounds(std::move(lbounds)) {} -Acts::LineSurface::LineSurface(std::shared_ptr lbounds, - const DetectorElementBase& detelement) +LineSurface::LineSurface(std::shared_ptr lbounds, + const DetectorElementBase& detelement) : GeometryObject(), Surface(detelement), m_bounds(std::move(lbounds)) { throw_assert(m_bounds, "LineBounds must not be nullptr"); } -Acts::LineSurface::LineSurface(const LineSurface& other) +LineSurface::LineSurface(const LineSurface& other) : GeometryObject(), Surface(other), m_bounds(other.m_bounds) {} -Acts::LineSurface::LineSurface(const GeometryContext& gctx, - const LineSurface& other, - const Transform3& shift) +LineSurface::LineSurface(const GeometryContext& gctx, const LineSurface& other, + const Transform3& shift) : GeometryObject(), Surface(gctx, other, shift), m_bounds(other.m_bounds) {} -Acts::LineSurface& Acts::LineSurface::operator=(const LineSurface& other) { +LineSurface& LineSurface::operator=(const LineSurface& other) { if (this != &other) { Surface::operator=(other); m_bounds = other.m_bounds; @@ -62,23 +55,22 @@ Acts::LineSurface& Acts::LineSurface::operator=(const LineSurface& other) { return *this; } -Acts::Vector3 Acts::LineSurface::localToGlobal(const GeometryContext& gctx, - const Vector2& lposition, - const Vector3& direction) const { +Vector3 LineSurface::localToGlobal(const GeometryContext& gctx, + const Vector2& lposition, + const Vector3& direction) const { Vector3 unitZ0 = lineDirection(gctx); // get the vector perpendicular to the momentum direction and the straw axis Vector3 radiusAxisGlobal = unitZ0.cross(direction); - Vector3 locZinGlobal = - transform(gctx) * Vector3(0., 0., lposition[eBoundLoc1]); - // add eBoundLoc0 * radiusAxis - return Vector3(locZinGlobal + - lposition[eBoundLoc0] * radiusAxisGlobal.normalized()); + Vector3 locZinGlobal = transform(gctx) * Vector3(0., 0., lposition[1]); + // add loc0 * radiusAxis + return Vector3(locZinGlobal + lposition[0] * radiusAxisGlobal.normalized()); } -Acts::Result Acts::LineSurface::globalToLocal( - const GeometryContext& gctx, const Vector3& position, - const Vector3& direction, double tolerance) const { +Result LineSurface::globalToLocal(const GeometryContext& gctx, + const Vector3& position, + const Vector3& direction, + double tolerance) const { using VectorHelpers::perp; // Bring the global position into the local frame. First remove the @@ -102,13 +94,13 @@ Acts::Result Acts::LineSurface::globalToLocal( return Result::success(localXY); } -std::string Acts::LineSurface::name() const { +std::string LineSurface::name() const { return "Acts::LineSurface"; } -Acts::RotationMatrix3 Acts::LineSurface::referenceFrame( - const GeometryContext& gctx, const Vector3& /*position*/, - const Vector3& direction) const { +RotationMatrix3 LineSurface::referenceFrame(const GeometryContext& gctx, + const Vector3& /*position*/, + const Vector3& direction) const { Vector3 unitZ0 = lineDirection(gctx); Vector3 unitD0 = unitZ0.cross(direction).normalized(); Vector3 unitDistance = unitD0.cross(unitZ0); @@ -121,32 +113,31 @@ Acts::RotationMatrix3 Acts::LineSurface::referenceFrame( return mFrame; } -double Acts::LineSurface::pathCorrection(const GeometryContext& /*gctx*/, - const Vector3& /*pos*/, - const Vector3& /*mom*/) const { +double LineSurface::pathCorrection(const GeometryContext& /*gctx*/, + const Vector3& /*pos*/, + const Vector3& /*mom*/) const { return 1.; } -Acts::Vector3 Acts::LineSurface::binningPosition( - const GeometryContext& gctx, BinningValue /*bValue*/) const { +Vector3 LineSurface::binningPosition(const GeometryContext& gctx, + BinningValue /*bValue*/) const { return center(gctx); } -Acts::Vector3 Acts::LineSurface::normal(const GeometryContext& gctx, - const Vector3& pos, - const Vector3& direction) const { +Vector3 LineSurface::normal(const GeometryContext& gctx, const Vector3& pos, + const Vector3& direction) const { auto ref = referenceFrame(gctx, pos, direction); return ref.col(2); } -const Acts::SurfaceBounds& Acts::LineSurface::bounds() const { +const SurfaceBounds& LineSurface::bounds() const { if (m_bounds) { return (*m_bounds.get()); } return s_noBounds; } -Acts::SurfaceMultiIntersection Acts::LineSurface::intersect( +SurfaceMultiIntersection LineSurface::intersect( const GeometryContext& gctx, const Vector3& position, const Vector3& direction, const BoundaryTolerance& boundaryTolerance, double tolerance) const { @@ -192,7 +183,7 @@ Acts::SurfaceMultiIntersection Acts::LineSurface::intersect( return {{Intersection3D(result, u, status), Intersection3D::invalid()}, this}; } -Acts::BoundToFreeMatrix Acts::LineSurface::boundToFreeJacobian( +BoundToFreeMatrix LineSurface::boundToFreeJacobian( const GeometryContext& gctx, const Vector3& position, const Vector3& direction) const { assert(isOnSurface(gctx, position, direction, BoundaryTolerance::Infinite())); @@ -229,7 +220,7 @@ Acts::BoundToFreeMatrix Acts::LineSurface::boundToFreeJacobian( return jacToGlobal; } -Acts::FreeToPathMatrix Acts::LineSurface::freeToPathDerivative( +FreeToPathMatrix LineSurface::freeToPathDerivative( const GeometryContext& gctx, const Vector3& position, const Vector3& direction) const { assert(isOnSurface(gctx, position, direction, BoundaryTolerance::Infinite())); @@ -258,7 +249,7 @@ Acts::FreeToPathMatrix Acts::LineSurface::freeToPathDerivative( return freeToPath; } -Acts::AlignmentToPathMatrix Acts::LineSurface::alignmentToPathDerivative( +AlignmentToPathMatrix LineSurface::alignmentToPathDerivative( const GeometryContext& gctx, const Vector3& position, const Vector3& direction) const { assert(isOnSurface(gctx, position, direction, BoundaryTolerance::Infinite())); @@ -288,7 +279,7 @@ Acts::AlignmentToPathMatrix Acts::LineSurface::alignmentToPathDerivative( return alignToPath; } -Acts::ActsMatrix<2, 3> Acts::LineSurface::localCartesianToBoundLocalDerivative( +ActsMatrix<2, 3> LineSurface::localCartesianToBoundLocalDerivative( const GeometryContext& gctx, const Vector3& position) const { // calculate the transformation to local coordinates Vector3 localPosition = transform(gctx).inverse() * position; @@ -300,7 +291,8 @@ Acts::ActsMatrix<2, 3> Acts::LineSurface::localCartesianToBoundLocalDerivative( return loc3DToLocBound; } -Acts::Vector3 Acts::LineSurface::lineDirection( - const GeometryContext& gctx) const { +Vector3 LineSurface::lineDirection(const GeometryContext& gctx) const { return transform(gctx).linear().col(2); } + +} // namespace Acts diff --git a/Core/src/Surfaces/PerigeeSurface.cpp b/Core/src/Surfaces/PerigeeSurface.cpp index 777d061b2b1..1d6a357db29 100644 --- a/Core/src/Surfaces/PerigeeSurface.cpp +++ b/Core/src/Surfaces/PerigeeSurface.cpp @@ -15,38 +15,39 @@ #include #include -Acts::PerigeeSurface::PerigeeSurface(const Vector3& gp) +namespace Acts { + +PerigeeSurface::PerigeeSurface(const Vector3& gp) : LineSurface(Transform3(Translation3(gp.x(), gp.y(), gp.z())), nullptr) {} -Acts::PerigeeSurface::PerigeeSurface(const Transform3& transform) +PerigeeSurface::PerigeeSurface(const Transform3& transform) : GeometryObject(), LineSurface(transform) {} -Acts::PerigeeSurface::PerigeeSurface(const PerigeeSurface& other) +PerigeeSurface::PerigeeSurface(const PerigeeSurface& other) : GeometryObject(), LineSurface(other) {} -Acts::PerigeeSurface::PerigeeSurface(const GeometryContext& gctx, - const PerigeeSurface& other, - const Transform3& shift) +PerigeeSurface::PerigeeSurface(const GeometryContext& gctx, + const PerigeeSurface& other, + const Transform3& shift) : GeometryObject(), LineSurface(gctx, other, shift) {} -Acts::PerigeeSurface& Acts::PerigeeSurface::operator=( - const PerigeeSurface& other) { +PerigeeSurface& PerigeeSurface::operator=(const PerigeeSurface& other) { if (this != &other) { LineSurface::operator=(other); } return *this; } -Acts::Surface::SurfaceType Acts::PerigeeSurface::type() const { +Surface::SurfaceType PerigeeSurface::type() const { return Surface::Perigee; } -std::string Acts::PerigeeSurface::name() const { +std::string PerigeeSurface::name() const { return "Acts::PerigeeSurface"; } -std::ostream& Acts::PerigeeSurface::toStreamImpl(const GeometryContext& gctx, - std::ostream& sl) const { +std::ostream& PerigeeSurface::toStreamImpl(const GeometryContext& gctx, + std::ostream& sl) const { sl << std::setiosflags(std::ios::fixed); sl << std::setprecision(7); sl << "Acts::PerigeeSurface:" << std::endl; @@ -57,7 +58,7 @@ std::ostream& Acts::PerigeeSurface::toStreamImpl(const GeometryContext& gctx, return sl; } -Acts::Polyhedron Acts::PerigeeSurface::polyhedronRepresentation( +Polyhedron PerigeeSurface::polyhedronRepresentation( const GeometryContext& gctx, unsigned int /*quarterSegments*/) const { // Prepare vertices and faces std::vector vertices; @@ -77,3 +78,5 @@ Acts::Polyhedron Acts::PerigeeSurface::polyhedronRepresentation( return Polyhedron(vertices, faces, triangularMesh); } + +} // namespace Acts diff --git a/Core/src/Surfaces/PlaneSurface.cpp b/Core/src/Surfaces/PlaneSurface.cpp index b4ebb77956c..aebc75315ef 100644 --- a/Core/src/Surfaces/PlaneSurface.cpp +++ b/Core/src/Surfaces/PlaneSurface.cpp @@ -8,7 +8,6 @@ #include "Acts/Surfaces/PlaneSurface.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Geometry/GeometryObject.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/CurvilinearSurface.hpp" @@ -28,28 +27,30 @@ #include #include -Acts::PlaneSurface::PlaneSurface(const PlaneSurface& other) +namespace Acts { + +PlaneSurface::PlaneSurface(const PlaneSurface& other) : GeometryObject(), RegularSurface(other), m_bounds(other.m_bounds) {} -Acts::PlaneSurface::PlaneSurface(const GeometryContext& gctx, - const PlaneSurface& other, - const Transform3& transform) +PlaneSurface::PlaneSurface(const GeometryContext& gctx, + const PlaneSurface& other, + const Transform3& transform) : GeometryObject(), RegularSurface(gctx, other, transform), m_bounds(other.m_bounds) {} -Acts::PlaneSurface::PlaneSurface(std::shared_ptr pbounds, - const Acts::DetectorElementBase& detelement) +PlaneSurface::PlaneSurface(std::shared_ptr pbounds, + const DetectorElementBase& detelement) : RegularSurface(detelement), m_bounds(std::move(pbounds)) { - /// surfaces representing a detector element must have bounds + // surfaces representing a detector element must have bounds throw_assert(m_bounds, "PlaneBounds must not be nullptr"); } -Acts::PlaneSurface::PlaneSurface(const Transform3& transform, - std::shared_ptr pbounds) +PlaneSurface::PlaneSurface(const Transform3& transform, + std::shared_ptr pbounds) : RegularSurface(transform), m_bounds(std::move(pbounds)) {} -Acts::PlaneSurface& Acts::PlaneSurface::operator=(const PlaneSurface& other) { +PlaneSurface& PlaneSurface::operator=(const PlaneSurface& other) { if (this != &other) { Surface::operator=(other); m_bounds = other.m_bounds; @@ -57,19 +58,18 @@ Acts::PlaneSurface& Acts::PlaneSurface::operator=(const PlaneSurface& other) { return *this; } -Acts::Surface::SurfaceType Acts::PlaneSurface::type() const { +Surface::SurfaceType PlaneSurface::type() const { return Surface::Plane; } -Acts::Vector3 Acts::PlaneSurface::localToGlobal( - const GeometryContext& gctx, const Vector2& lposition) const { - return transform(gctx) * - Vector3(lposition[Acts::eBoundLoc0], lposition[Acts::eBoundLoc1], 0.); +Vector3 PlaneSurface::localToGlobal(const GeometryContext& gctx, + const Vector2& lposition) const { + return transform(gctx) * Vector3(lposition[0], lposition[1], 0.); } -Acts::Result Acts::PlaneSurface::globalToLocal( - const GeometryContext& gctx, const Vector3& position, - double tolerance) const { +Result PlaneSurface::globalToLocal(const GeometryContext& gctx, + const Vector3& position, + double tolerance) const { Vector3 loc3Dframe = transform(gctx).inverse() * position; if (std::abs(loc3Dframe.z()) > std::abs(tolerance)) { return Result::failure(SurfaceError::GlobalPositionNotOnSurface); @@ -77,18 +77,18 @@ Acts::Result Acts::PlaneSurface::globalToLocal( return Result::success({loc3Dframe.x(), loc3Dframe.y()}); } -std::string Acts::PlaneSurface::name() const { +std::string PlaneSurface::name() const { return "Acts::PlaneSurface"; } -const Acts::SurfaceBounds& Acts::PlaneSurface::bounds() const { +const SurfaceBounds& PlaneSurface::bounds() const { if (m_bounds) { return (*m_bounds.get()); } return s_noBounds; } -Acts::Polyhedron Acts::PlaneSurface::polyhedronRepresentation( +Polyhedron PlaneSurface::polyhedronRepresentation( const GeometryContext& gctx, unsigned int quarterSegments) const { // Prepare vertices and faces std::vector vertices; @@ -131,33 +131,33 @@ Acts::Polyhedron Acts::PlaneSurface::polyhedronRepresentation( "Polyhedron representation of boundless surface not possible."); } -Acts::Vector3 Acts::PlaneSurface::normal(const GeometryContext& gctx, - const Vector2& /*lpos*/) const { +Vector3 PlaneSurface::normal(const GeometryContext& gctx, + const Vector2& /*lpos*/) const { return normal(gctx); } -Acts::Vector3 Acts::PlaneSurface::normal(const GeometryContext& gctx, - const Vector3& /*pos*/) const { +Vector3 PlaneSurface::normal(const GeometryContext& gctx, + const Vector3& /*pos*/) const { return normal(gctx); } -Acts::Vector3 Acts::PlaneSurface::normal(const GeometryContext& gctx) const { +Vector3 PlaneSurface::normal(const GeometryContext& gctx) const { return transform(gctx).linear().col(2); } -Acts::Vector3 Acts::PlaneSurface::binningPosition( - const GeometryContext& gctx, BinningValue /*bValue*/) const { +Vector3 PlaneSurface::binningPosition(const GeometryContext& gctx, + BinningValue /*bValue*/) const { return center(gctx); } -double Acts::PlaneSurface::pathCorrection(const GeometryContext& gctx, - const Vector3& /*position*/, - const Vector3& direction) const { +double PlaneSurface::pathCorrection(const GeometryContext& gctx, + const Vector3& /*position*/, + const Vector3& direction) const { // We can ignore the global position here return 1. / std::abs(normal(gctx).dot(direction)); } -Acts::SurfaceMultiIntersection Acts::PlaneSurface::intersect( +SurfaceMultiIntersection PlaneSurface::intersect( const GeometryContext& gctx, const Vector3& position, const Vector3& direction, const BoundaryTolerance& boundaryTolerance, double tolerance) const { @@ -184,8 +184,10 @@ Acts::SurfaceMultiIntersection Acts::PlaneSurface::intersect( this}; } -Acts::ActsMatrix<2, 3> Acts::PlaneSurface::localCartesianToBoundLocalDerivative( +ActsMatrix<2, 3> PlaneSurface::localCartesianToBoundLocalDerivative( const GeometryContext& /*gctx*/, const Vector3& /*position*/) const { const ActsMatrix<2, 3> loc3DToLocBound = ActsMatrix<2, 3>::Identity(); return loc3DToLocBound; } + +} // namespace Acts diff --git a/Core/src/Surfaces/RadialBounds.cpp b/Core/src/Surfaces/RadialBounds.cpp index 03a32ef2a34..41bd184be9a 100644 --- a/Core/src/Surfaces/RadialBounds.cpp +++ b/Core/src/Surfaces/RadialBounds.cpp @@ -8,7 +8,6 @@ #include "Acts/Surfaces/RadialBounds.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/detail/BoundaryCheckHelper.hpp" #include "Acts/Surfaces/detail/VerticesHelper.hpp" @@ -16,36 +15,47 @@ #include #include +#include -Acts::SurfaceBounds::BoundsType Acts::RadialBounds::type() const { - return SurfaceBounds::eDisc; +namespace Acts { + +std::vector RadialBounds::values() const { + return {m_values.begin(), m_values.end()}; +} + +void RadialBounds::checkConsistency() noexcept(false) { + if (get(eMinR) < 0. || get(eMaxR) <= 0. || get(eMinR) > get(eMaxR)) { + throw std::invalid_argument("RadialBounds: invalid radial setup"); + } + if (get(eHalfPhiSector) < 0. || get(eHalfPhiSector) > std::numbers::pi) { + throw std::invalid_argument("RadialBounds: invalid phi sector setup."); + } + if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) { + throw std::invalid_argument("RadialBounds: invalid phi positioning."); + } } -Acts::Vector2 Acts::RadialBounds::shifted( - const Acts::Vector2& lposition) const { +Vector2 RadialBounds::shifted(const Vector2& lposition) const { Vector2 tmp; - tmp[eBoundLoc0] = lposition[eBoundLoc0]; - tmp[eBoundLoc1] = - detail::radian_sym(lposition[eBoundLoc1] - get(eAveragePhi)); + tmp[0] = lposition[0]; + tmp[1] = detail::radian_sym(lposition[1] - get(eAveragePhi)); return tmp; } -bool Acts::RadialBounds::inside( - const Acts::Vector2& lposition, - const Acts::BoundaryTolerance& boundaryTolerance) const { +bool RadialBounds::inside(const Vector2& lposition, + const BoundaryTolerance& boundaryTolerance) const { return detail::insideAlignedBox(Vector2(get(eMinR), -get(eHalfPhiSector)), Vector2(get(eMaxR), get(eHalfPhiSector)), boundaryTolerance, shifted(lposition), std::nullopt); } -std::vector Acts::RadialBounds::vertices( - unsigned int lseg) const { +std::vector RadialBounds::vertices(unsigned int lseg) const { return detail::VerticesHelper::circularVertices( get(eMinR), get(eMaxR), get(eAveragePhi), get(eHalfPhiSector), lseg); } -std::ostream& Acts::RadialBounds::toStream(std::ostream& sl) const { +std::ostream& RadialBounds::toStream(std::ostream& sl) const { sl << std::setiosflags(std::ios::fixed); sl << std::setprecision(7); sl << "Acts::RadialBounds: (innerRadius, outerRadius, hPhiSector, " @@ -55,3 +65,5 @@ std::ostream& Acts::RadialBounds::toStream(std::ostream& sl) const { sl << std::setprecision(-1); return sl; } + +} // namespace Acts diff --git a/Core/src/Surfaces/RectangleBounds.cpp b/Core/src/Surfaces/RectangleBounds.cpp index 21c8daec4e9..98bdedd930d 100644 --- a/Core/src/Surfaces/RectangleBounds.cpp +++ b/Core/src/Surfaces/RectangleBounds.cpp @@ -12,26 +12,51 @@ #include #include +#include -bool Acts::RectangleBounds::inside( - const Acts::Vector2& lposition, - const Acts::BoundaryTolerance& boundaryTolerance) const { +namespace Acts { + +double RectangleBounds::get(BoundValues bValue) const { + switch (bValue) { + case eMinX: + return m_min.x(); + case eMinY: + return m_min.y(); + case eMaxX: + return m_max.x(); + case eMaxY: + return m_max.y(); + default: + assert(false && "Invalid BoundValue enum value"); + return std::numeric_limits::quiet_NaN(); + } +} + +void RectangleBounds::checkConsistency() noexcept(false) { + if (get(eMinX) > get(eMaxX)) { + throw std::invalid_argument("RectangleBounds: invalid local x setup"); + } + if (get(eMinY) > get(eMaxY)) { + throw std::invalid_argument("RectangleBounds: invalid local y setup"); + } +} + +bool RectangleBounds::inside(const Vector2& lposition, + const BoundaryTolerance& boundaryTolerance) const { return detail::insideAlignedBox(m_min, m_max, boundaryTolerance, lposition, std::nullopt); } -std::vector Acts::RectangleBounds::vertices( - unsigned int /*lseg*/) const { +std::vector RectangleBounds::vertices(unsigned int /*lseg*/) const { // counter-clockwise starting from bottom-left corner return {m_min, {m_max.x(), m_min.y()}, m_max, {m_min.x(), m_max.y()}}; } -const Acts::RectangleBounds& Acts::RectangleBounds::boundingBox() const { +const RectangleBounds& RectangleBounds::boundingBox() const { return (*this); } -// ostream operator overload -std::ostream& Acts::RectangleBounds::toStream(std::ostream& sl) const { +std::ostream& RectangleBounds::toStream(std::ostream& sl) const { sl << std::setiosflags(std::ios::fixed); sl << std::setprecision(7); sl << "Acts::RectangleBounds: (hlX, hlY) = " @@ -42,3 +67,5 @@ std::ostream& Acts::RectangleBounds::toStream(std::ostream& sl) const { sl << std::setprecision(-1); return sl; } + +} // namespace Acts diff --git a/Core/src/Surfaces/StrawSurface.cpp b/Core/src/Surfaces/StrawSurface.cpp index b6e241af858..8a004b31354 100644 --- a/Core/src/Surfaces/StrawSurface.cpp +++ b/Core/src/Surfaces/StrawSurface.cpp @@ -14,33 +14,32 @@ #include "Acts/Surfaces/detail/FacesHelper.hpp" #include "Acts/Surfaces/detail/VerticesHelper.hpp" -#include #include #include #include -Acts::StrawSurface::StrawSurface(const Transform3& transform, double radius, - double halez) +namespace Acts { + +StrawSurface::StrawSurface(const Transform3& transform, double radius, + double halez) : GeometryObject(), LineSurface(transform, radius, halez) {} -Acts::StrawSurface::StrawSurface(const Transform3& transform, - std::shared_ptr lbounds) +StrawSurface::StrawSurface(const Transform3& transform, + std::shared_ptr lbounds) : GeometryObject(), LineSurface(transform, std::move(lbounds)) {} -Acts::StrawSurface::StrawSurface( - const std::shared_ptr& lbounds, - const DetectorElementBase& detelement) +StrawSurface::StrawSurface(const std::shared_ptr& lbounds, + const DetectorElementBase& detelement) : GeometryObject(), LineSurface(lbounds, detelement) {} -Acts::StrawSurface::StrawSurface(const Acts::StrawSurface& other) +StrawSurface::StrawSurface(const StrawSurface& other) : GeometryObject(), LineSurface(other) {} -Acts::StrawSurface::StrawSurface(const GeometryContext& gctx, - const StrawSurface& other, - const Transform3& shift) +StrawSurface::StrawSurface(const GeometryContext& gctx, + const StrawSurface& other, const Transform3& shift) : GeometryObject(), LineSurface(gctx, other, shift) {} -Acts::StrawSurface& Acts::StrawSurface::operator=(const StrawSurface& other) { +StrawSurface& StrawSurface::operator=(const StrawSurface& other) { if (this != &other) { LineSurface::operator=(other); m_bounds = other.m_bounds; @@ -48,7 +47,7 @@ Acts::StrawSurface& Acts::StrawSurface::operator=(const StrawSurface& other) { return *this; } -Acts::Polyhedron Acts::StrawSurface::polyhedronRepresentation( +Polyhedron StrawSurface::polyhedronRepresentation( const GeometryContext& gctx, unsigned int quarterSegments) const { // Prepare vertices and faces std::vector vertices; @@ -62,7 +61,7 @@ Acts::Polyhedron Acts::StrawSurface::polyhedronRepresentation( // Write the two bows/circles on either side std::vector sides = {-1, 1}; for (auto& side : sides) { - /// Helper method to create the segment + // Helper method to create the segment auto svertices = detail::VerticesHelper::segmentVertices( {r, r}, -std::numbers::pi, std::numbers::pi, {}, quarterSegments, Vector3(0., 0., side * m_bounds->get(LineBounds::eHalfLengthZ)), @@ -86,3 +85,5 @@ Acts::Polyhedron Acts::StrawSurface::polyhedronRepresentation( return Polyhedron(vertices, faces, triangularMesh, false); } + +} // namespace Acts diff --git a/Core/src/Surfaces/Surface.cpp b/Core/src/Surfaces/Surface.cpp index 0fbfe6bc982..5394587eeae 100644 --- a/Core/src/Surfaces/Surface.cpp +++ b/Core/src/Surfaces/Surface.cpp @@ -12,23 +12,24 @@ #include "Acts/Surfaces/SurfaceBounds.hpp" #include "Acts/Surfaces/detail/AlignmentHelper.hpp" #include "Acts/Utilities/JacobianHelpers.hpp" -#include "Acts/Utilities/VectorHelpers.hpp" #include "Acts/Visualization/ViewConfig.hpp" #include #include -std::array - Acts::Surface::s_surfaceTypeNames = { - "Cone", "Cylinder", "Disc", "Perigee", "Plane", "Straw", "Curvilinear"}; +namespace Acts { -Acts::Surface::Surface(const Transform3& transform) +std::array + Surface::s_surfaceTypeNames = {"Cone", "Cylinder", "Disc", "Perigee", + "Plane", "Straw", "Curvilinear"}; + +Surface::Surface(const Transform3& transform) : GeometryObject(), m_transform(std::make_unique(transform)) {} -Acts::Surface::Surface(const DetectorElementBase& detelement) +Surface::Surface(const DetectorElementBase& detelement) : GeometryObject(), m_associatedDetElement(&detelement) {} -Acts::Surface::Surface(const Surface& other) +Surface::Surface(const Surface& other) : GeometryObject(other), std::enable_shared_from_this(), m_associatedDetElement(other.m_associatedDetElement), @@ -38,19 +39,18 @@ Acts::Surface::Surface(const Surface& other) } } -Acts::Surface::Surface(const GeometryContext& gctx, const Surface& other, - const Transform3& shift) +Surface::Surface(const GeometryContext& gctx, const Surface& other, + const Transform3& shift) : GeometryObject(), m_transform(std::make_unique(shift * other.transform(gctx))), m_surfaceMaterial(other.m_surfaceMaterial) {} -Acts::Surface::~Surface() = default; +Surface::~Surface() = default; -bool Acts::Surface::isOnSurface(const GeometryContext& gctx, - const Vector3& position, - const Vector3& direction, - const BoundaryTolerance& boundaryTolerance, - double tolerance) const { +bool Surface::isOnSurface(const GeometryContext& gctx, const Vector3& position, + const Vector3& direction, + const BoundaryTolerance& boundaryTolerance, + double tolerance) const { // global to local transformation auto lpResult = globalToLocal(gctx, position, direction, tolerance); if (!lpResult.ok()) { @@ -59,7 +59,7 @@ bool Acts::Surface::isOnSurface(const GeometryContext& gctx, return bounds().inside(lpResult.value(), boundaryTolerance); } -Acts::AlignmentToBoundMatrix Acts::Surface::alignmentToBoundDerivative( +AlignmentToBoundMatrix Surface::alignmentToBoundDerivative( const GeometryContext& gctx, const Vector3& position, const Vector3& direction, const FreeVector& pathDerivative) const { assert(isOnSurface(gctx, position, direction, BoundaryTolerance::Infinite())); @@ -81,8 +81,7 @@ Acts::AlignmentToBoundMatrix Acts::Surface::alignmentToBoundDerivative( return alignToBound; } -Acts::AlignmentToBoundMatrix -Acts::Surface::alignmentToBoundDerivativeWithoutCorrection( +AlignmentToBoundMatrix Surface::alignmentToBoundDerivativeWithoutCorrection( const GeometryContext& gctx, const Vector3& position, const Vector3& direction) const { (void)direction; @@ -123,7 +122,7 @@ Acts::Surface::alignmentToBoundDerivativeWithoutCorrection( return alignToBound; } -Acts::AlignmentToPathMatrix Acts::Surface::alignmentToPathDerivative( +AlignmentToPathMatrix Surface::alignmentToPathDerivative( const GeometryContext& gctx, const Vector3& position, const Vector3& direction) const { assert(isOnSurface(gctx, position, direction, BoundaryTolerance::Infinite())); @@ -149,15 +148,15 @@ Acts::AlignmentToPathMatrix Acts::Surface::alignmentToPathDerivative( return alignToPath; } -std::shared_ptr Acts::Surface::getSharedPtr() { +std::shared_ptr Surface::getSharedPtr() { return shared_from_this(); } -std::shared_ptr Acts::Surface::getSharedPtr() const { +std::shared_ptr Surface::getSharedPtr() const { return shared_from_this(); } -Acts::Surface& Acts::Surface::operator=(const Surface& other) { +Surface& Surface::operator=(const Surface& other) { if (&other != this) { GeometryObject::operator=(other); // detector element, identifier & layer association are unique @@ -173,7 +172,7 @@ Acts::Surface& Acts::Surface::operator=(const Surface& other) { return *this; } -bool Acts::Surface::operator==(const Surface& other) const { +bool Surface::operator==(const Surface& other) const { // (a) fast exit for pointer comparison if (&other == this) { return true; @@ -204,19 +203,18 @@ bool Acts::Surface::operator==(const Surface& other) const { return true; } -// overload dump for stream operator -std::ostream& Acts::Surface::toStreamImpl(const GeometryContext& gctx, - std::ostream& sl) const { +std::ostream& Surface::toStreamImpl(const GeometryContext& gctx, + std::ostream& sl) const { sl << std::setiosflags(std::ios::fixed); sl << std::setprecision(4); sl << name() << std::endl; const Vector3& sfcenter = center(gctx); sl << " Center position (x, y, z) = (" << sfcenter.x() << ", " << sfcenter.y() << ", " << sfcenter.z() << ")" << std::endl; - Acts::RotationMatrix3 rot(transform(gctx).matrix().block<3, 3>(0, 0)); - Acts::Vector3 rotX(rot.col(0)); - Acts::Vector3 rotY(rot.col(1)); - Acts::Vector3 rotZ(rot.col(2)); + RotationMatrix3 rot(transform(gctx).matrix().block<3, 3>(0, 0)); + Vector3 rotX(rot.col(0)); + Vector3 rotY(rot.col(1)); + Vector3 rotZ(rot.col(2)); sl << std::setprecision(6); sl << " Rotation: colX = (" << rotX(0) << ", " << rotX(1) << ", " << rotX(2) << ")" << std::endl; @@ -229,41 +227,39 @@ std::ostream& Acts::Surface::toStreamImpl(const GeometryContext& gctx, return sl; } -std::string Acts::Surface::toString(const GeometryContext& gctx) const { +std::string Surface::toString(const GeometryContext& gctx) const { std::stringstream ss; ss << toStream(gctx); return ss.str(); } -Acts::Vector3 Acts::Surface::center(const GeometryContext& gctx) const { +Vector3 Surface::center(const GeometryContext& gctx) const { // fast access via transform matrix (and not translation()) auto tMatrix = transform(gctx).matrix(); return Vector3(tMatrix(0, 3), tMatrix(1, 3), tMatrix(2, 3)); } -const Acts::Transform3& Acts::Surface::transform( - const GeometryContext& gctx) const { +const Transform3& Surface::transform(const GeometryContext& gctx) const { if (m_associatedDetElement != nullptr) { return m_associatedDetElement->transform(gctx); } return *m_transform; } -bool Acts::Surface::insideBounds( - const Vector2& lposition, - const BoundaryTolerance& boundaryTolerance) const { +bool Surface::insideBounds(const Vector2& lposition, + const BoundaryTolerance& boundaryTolerance) const { return bounds().inside(lposition, boundaryTolerance); } -Acts::RotationMatrix3 Acts::Surface::referenceFrame( - const GeometryContext& gctx, const Vector3& /*position*/, - const Vector3& /*direction*/) const { +RotationMatrix3 Surface::referenceFrame(const GeometryContext& gctx, + const Vector3& /*position*/, + const Vector3& /*direction*/) const { return transform(gctx).matrix().block<3, 3>(0, 0); } -Acts::BoundToFreeMatrix Acts::Surface::boundToFreeJacobian( - const GeometryContext& gctx, const Vector3& position, - const Vector3& direction) const { +BoundToFreeMatrix Surface::boundToFreeJacobian(const GeometryContext& gctx, + const Vector3& position, + const Vector3& direction) const { assert(isOnSurface(gctx, position, direction, BoundaryTolerance::Infinite())); // retrieve the reference frame @@ -282,9 +278,9 @@ Acts::BoundToFreeMatrix Acts::Surface::boundToFreeJacobian( return jacToGlobal; } -Acts::FreeToBoundMatrix Acts::Surface::freeToBoundJacobian( - const GeometryContext& gctx, const Vector3& position, - const Vector3& direction) const { +FreeToBoundMatrix Surface::freeToBoundJacobian(const GeometryContext& gctx, + const Vector3& position, + const Vector3& direction) const { assert(isOnSurface(gctx, position, direction, BoundaryTolerance::Infinite())); // The measurement frame of the surface @@ -304,9 +300,9 @@ Acts::FreeToBoundMatrix Acts::Surface::freeToBoundJacobian( return jacToLocal; } -Acts::FreeToPathMatrix Acts::Surface::freeToPathDerivative( - const GeometryContext& gctx, const Vector3& position, - const Vector3& direction) const { +FreeToPathMatrix Surface::freeToPathDerivative(const GeometryContext& gctx, + const Vector3& position, + const Vector3& direction) const { assert(isOnSurface(gctx, position, direction, BoundaryTolerance::Infinite())); // The measurement frame of the surface @@ -321,45 +317,44 @@ Acts::FreeToPathMatrix Acts::Surface::freeToPathDerivative( return freeToPath; } -const Acts::DetectorElementBase* Acts::Surface::associatedDetectorElement() - const { +const DetectorElementBase* Surface::associatedDetectorElement() const { return m_associatedDetElement; } -const Acts::Layer* Acts::Surface::associatedLayer() const { +const Layer* Surface::associatedLayer() const { return m_associatedLayer; } -const Acts::ISurfaceMaterial* Acts::Surface::surfaceMaterial() const { +const ISurfaceMaterial* Surface::surfaceMaterial() const { return m_surfaceMaterial.get(); } -const std::shared_ptr& -Acts::Surface::surfaceMaterialSharedPtr() const { +const std::shared_ptr& +Surface::surfaceMaterialSharedPtr() const { return m_surfaceMaterial; } -void Acts::Surface::assignDetectorElement( - const DetectorElementBase& detelement) { +void Surface::assignDetectorElement(const DetectorElementBase& detelement) { m_associatedDetElement = &detelement; // resetting the transform as it will be handled through the detector element // now m_transform.reset(); } -void Acts::Surface::assignSurfaceMaterial( - std::shared_ptr material) { +void Surface::assignSurfaceMaterial( + std::shared_ptr material) { m_surfaceMaterial = std::move(material); } -void Acts::Surface::associateLayer(const Acts::Layer& lay) { +void Surface::associateLayer(const Layer& lay) { m_associatedLayer = (&lay); } -void Acts::Surface::visualize(IVisualization3D& helper, - const GeometryContext& gctx, - const ViewConfig& viewConfig) const { +void Surface::visualize(IVisualization3D& helper, const GeometryContext& gctx, + const ViewConfig& viewConfig) const { Polyhedron polyhedron = polyhedronRepresentation(gctx, viewConfig.quarterSegments); polyhedron.visualize(helper, viewConfig); } + +} // namespace Acts diff --git a/Core/src/Surfaces/SurfaceArray.cpp b/Core/src/Surfaces/SurfaceArray.cpp index 2606c13a702..619b432d7a9 100644 --- a/Core/src/Surfaces/SurfaceArray.cpp +++ b/Core/src/Surfaces/SurfaceArray.cpp @@ -11,31 +11,31 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Geometry/SurfaceArrayCreator.hpp" #include "Acts/Utilities/Helpers.hpp" -#include "Acts/Utilities/ThrowAssert.hpp" #include +namespace Acts { + // implementation for pure virtual destructor of ISurfaceGridLookup -Acts::SurfaceArray::ISurfaceGridLookup::~ISurfaceGridLookup() = default; +SurfaceArray::ISurfaceGridLookup::~ISurfaceGridLookup() = default; -Acts::SurfaceArray::SurfaceArray( - std::unique_ptr gridLookup, - std::vector> surfaces, - const Transform3& transform) +SurfaceArray::SurfaceArray(std::unique_ptr gridLookup, + std::vector> surfaces, + const Transform3& transform) : p_gridLookup(std::move(gridLookup)), m_surfaces(std::move(surfaces)), m_surfacesRawPointers(unpack_shared_vector(m_surfaces)), m_transform(transform) {} -Acts::SurfaceArray::SurfaceArray(std::shared_ptr srf) +SurfaceArray::SurfaceArray(std::shared_ptr srf) : p_gridLookup( static_cast(new SingleElementLookup(srf.get()))), m_surfaces({std::move(srf)}) { m_surfacesRawPointers.push_back(m_surfaces.at(0).get()); } -std::ostream& Acts::SurfaceArray::toStream(const GeometryContext& /*gctx*/, - std::ostream& sl) const { +std::ostream& SurfaceArray::toStream(const GeometryContext& /*gctx*/, + std::ostream& sl) const { sl << std::fixed << std::setprecision(4); sl << "SurfaceArray:" << std::endl; sl << " - no surfaces: " << m_surfaces.size() << std::endl; @@ -75,3 +75,5 @@ std::ostream& Acts::SurfaceArray::toStream(const GeometryContext& /*gctx*/, } return sl; } + +} // namespace Acts diff --git a/Core/src/Surfaces/TrapezoidBounds.cpp b/Core/src/Surfaces/TrapezoidBounds.cpp index 3450e8cea97..73b082cefec 100644 --- a/Core/src/Surfaces/TrapezoidBounds.cpp +++ b/Core/src/Surfaces/TrapezoidBounds.cpp @@ -8,7 +8,6 @@ #include "Acts/Surfaces/TrapezoidBounds.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/ConvexPolygonBounds.hpp" #include "Acts/Surfaces/detail/BoundaryCheckHelper.hpp" @@ -16,25 +15,17 @@ #include #include -/// Constructor for symmetric Trapezoid -/// -/// @param halfXnegY minimal half length X, definition at negative Y -/// @param halfXposY maximal half length X, definition at positive Y -/// @param halfY half length Y - defined at x=0 -/// @param rotAngle: rotation angle of the bounds w.r.t coordinate axes -Acts::TrapezoidBounds::TrapezoidBounds(double halfXnegY, double halfXposY, - double halfY, - double rotAngle) noexcept(false) +namespace Acts { + +TrapezoidBounds::TrapezoidBounds(double halfXnegY, double halfXposY, + double halfY, double rotAngle) noexcept(false) : m_values({halfXnegY, halfXposY, halfY, rotAngle}), m_boundingBox(std::max(halfXnegY, halfXposY), halfY) { rotateBoundingBox(); checkConsistency(); } -/// Constructor for symmetric Trapezoid - from fixed size array -/// -/// @param values the values to be stream in -Acts::TrapezoidBounds::TrapezoidBounds( +TrapezoidBounds::TrapezoidBounds( const std::array& values) noexcept(false) : m_values(values), m_boundingBox( @@ -44,15 +35,12 @@ Acts::TrapezoidBounds::TrapezoidBounds( checkConsistency(); } -Acts::TrapezoidBounds::~TrapezoidBounds() = default; - -Acts::SurfaceBounds::BoundsType Acts::TrapezoidBounds::type() const { - return SurfaceBounds::eTrapezoid; +std::vector TrapezoidBounds::values() const { + return {m_values.begin(), m_values.end()}; } -bool Acts::TrapezoidBounds::inside( - const Acts::Vector2& lposition, - const Acts::BoundaryTolerance& boundaryTolerance) const { +bool TrapezoidBounds::inside(const Vector2& lposition, + const BoundaryTolerance& boundaryTolerance) const { if (boundaryTolerance.isInfinite()) { return true; } @@ -62,7 +50,7 @@ bool Acts::TrapezoidBounds::inside( const double hlY = get(TrapezoidBounds::eHalfLengthY); const double rotAngle = get(TrapezoidBounds::eRotationAngle); - const Acts::Vector2 extPosition = Eigen::Rotation2Dd(rotAngle) * lposition; + const Vector2 extPosition = Eigen::Rotation2Dd(rotAngle) * lposition; const double x = extPosition[0]; const double y = extPosition[1]; @@ -95,14 +83,14 @@ bool Acts::TrapezoidBounds::inside( std::nullopt); } -std::vector Acts::TrapezoidBounds::vertices( +std::vector TrapezoidBounds::vertices( unsigned int /*ignoredSegments*/) const { const double hlXnY = get(TrapezoidBounds::eHalfLengthXnegY); const double hlXpY = get(TrapezoidBounds::eHalfLengthXposY); const double hlY = get(TrapezoidBounds::eHalfLengthY); const double rotAngle = get(TrapezoidBounds::eRotationAngle); - std::vector vertices = { + std::vector vertices = { {-hlXnY, -hlY}, {hlXnY, -hlY}, {hlXpY, hlY}, {-hlXpY, hlY}}; for (auto& v : vertices) { v = Eigen::Rotation2Dd(-rotAngle) * v; @@ -110,11 +98,11 @@ std::vector Acts::TrapezoidBounds::vertices( return vertices; } -const Acts::RectangleBounds& Acts::TrapezoidBounds::boundingBox() const { +const RectangleBounds& TrapezoidBounds::boundingBox() const { return m_boundingBox; } -std::ostream& Acts::TrapezoidBounds::toStream(std::ostream& sl) const { +std::ostream& TrapezoidBounds::toStream(std::ostream& sl) const { sl << std::setiosflags(std::ios::fixed); sl << std::setprecision(7); sl << "Acts::TrapezoidBounds: (halfXnegY, halfXposY, halfY, rotAngle) = " @@ -124,13 +112,7 @@ std::ostream& Acts::TrapezoidBounds::toStream(std::ostream& sl) const { return sl; } -std::vector Acts::TrapezoidBounds::values() const { - std::vector valvector; - valvector.insert(valvector.begin(), m_values.begin(), m_values.end()); - return valvector; -} - -void Acts::TrapezoidBounds::rotateBoundingBox() noexcept(false) { +void TrapezoidBounds::rotateBoundingBox() noexcept(false) { const double rotAngle = get(eRotationAngle); if (rotAngle != 0.) { @@ -138,7 +120,7 @@ void Acts::TrapezoidBounds::rotateBoundingBox() noexcept(false) { } } -void Acts::TrapezoidBounds::checkConsistency() noexcept(false) { +void TrapezoidBounds::checkConsistency() noexcept(false) { if (get(eHalfLengthXnegY) <= 0. || get(eHalfLengthXposY) <= 0.) { throw std::invalid_argument("TrapezoidBounds: invalid local x setup"); } @@ -146,3 +128,5 @@ void Acts::TrapezoidBounds::checkConsistency() noexcept(false) { throw std::invalid_argument("TrapezoidBounds: invalid local y setup"); } } + +} // namespace Acts diff --git a/Core/src/Surfaces/detail/AlignmentHelper.cpp b/Core/src/Surfaces/detail/AlignmentHelper.cpp index b5308d60c84..4f9c53a56ce 100644 --- a/Core/src/Surfaces/detail/AlignmentHelper.cpp +++ b/Core/src/Surfaces/detail/AlignmentHelper.cpp @@ -8,11 +8,11 @@ #include "Acts/Surfaces/detail/AlignmentHelper.hpp" -#include -#include #include -Acts::detail::RotationToAxes Acts::detail::rotationToLocalAxesDerivative( +namespace Acts { + +detail::RotationToAxes detail::rotationToLocalAxesDerivative( const RotationMatrix3& compositeRotation, const RotationMatrix3& relRotation) { // Suppose the local axes of the composite have small rotation first around @@ -90,3 +90,5 @@ Acts::detail::RotationToAxes Acts::detail::rotationToLocalAxesDerivative( return {std::move(rotToLocalXAxis), std::move(rotToLocalYAxis), std::move(rotToLocalZAxis)}; } + +} // namespace Acts diff --git a/Core/src/Surfaces/detail/AnnulusBoundsHelper.cpp b/Core/src/Surfaces/detail/AnnulusBoundsHelper.cpp index 4ceab6d594b..757fbaf5d0d 100644 --- a/Core/src/Surfaces/detail/AnnulusBoundsHelper.cpp +++ b/Core/src/Surfaces/detail/AnnulusBoundsHelper.cpp @@ -11,13 +11,13 @@ #include "Acts/Surfaces/AnnulusBounds.hpp" #include "Acts/Utilities/VectorHelpers.hpp" -#include #include -std::tuple, Acts::Transform3> -Acts::detail::AnnulusBoundsHelper::create(const Transform3& transform, - double rMin, double rMax, - std::vector vertices) { +namespace Acts::detail { + +std::tuple, Transform3> +AnnulusBoundsHelper::create(const Transform3& transform, double rMin, + double rMax, std::vector vertices) { using Line2D = Eigen::Hyperplane; // Construct the bound lines @@ -65,3 +65,5 @@ Acts::detail::AnnulusBoundsHelper::create(const Transform3& transform, return {annulusBounds, boundsTransform}; } + +} // namespace Acts::detail diff --git a/Core/src/Surfaces/detail/MergeHelper.cpp b/Core/src/Surfaces/detail/MergeHelper.cpp index ca394efd4e8..49fcd8a7fac 100644 --- a/Core/src/Surfaces/detail/MergeHelper.cpp +++ b/Core/src/Surfaces/detail/MergeHelper.cpp @@ -8,6 +8,9 @@ #include "Acts/Surfaces/detail/MergeHelper.hpp" +#include "Acts/Definitions/Units.hpp" +#include "Acts/Utilities/detail/periodic.hpp" + #include namespace Acts::detail { @@ -16,7 +19,7 @@ std::tuple mergedPhiSector(double hlPhi1, double avgPhi1, double hlPhi2, double avgPhi2, const Logger& logger, double tolerance) { - using namespace Acts::UnitLiterals; + using namespace UnitLiterals; if (std::abs(hlPhi1 - std::numbers::pi / 2.) < tolerance && std::abs(hlPhi2 - std::numbers::pi / 2.) < tolerance) { diff --git a/Core/src/Surfaces/detail/VerticesHelper.cpp b/Core/src/Surfaces/detail/VerticesHelper.cpp index 98a00deb142..14b7cdad222 100644 --- a/Core/src/Surfaces/detail/VerticesHelper.cpp +++ b/Core/src/Surfaces/detail/VerticesHelper.cpp @@ -13,7 +13,9 @@ #include #include -std::vector Acts::detail::VerticesHelper::phiSegments( +namespace Acts { + +std::vector detail::VerticesHelper::phiSegments( double phiMin, double phiMax, const std::vector& phiRefs, unsigned int quarterSegments) { // Check that the phi range is valid @@ -67,7 +69,7 @@ std::vector Acts::detail::VerticesHelper::phiSegments( return phiSegments; } -std::vector Acts::detail::VerticesHelper::ellipsoidVertices( +std::vector detail::VerticesHelper::ellipsoidVertices( double innerRx, double innerRy, double outerRx, double outerRy, double avgPhi, double halfPhi, unsigned int quarterSegments) { // List of vertices counter-clockwise starting at smallest phi w.r.t center, @@ -111,15 +113,15 @@ std::vector Acts::detail::VerticesHelper::ellipsoidVertices( return rvertices; } -std::vector Acts::detail::VerticesHelper::circularVertices( +std::vector detail::VerticesHelper::circularVertices( double innerR, double outerR, double avgPhi, double halfPhi, unsigned int quarterSegments) { return ellipsoidVertices(innerR, innerR, outerR, outerR, avgPhi, halfPhi, quarterSegments); } -bool Acts::detail::VerticesHelper::onHyperPlane( - const std::vector& vertices, double tolerance) { +bool detail::VerticesHelper::onHyperPlane(const std::vector& vertices, + double tolerance) { // Obvious always on one surface if (vertices.size() < 4) { return true; @@ -134,3 +136,5 @@ bool Acts::detail::VerticesHelper::onHyperPlane( } return true; } + +} // namespace Acts diff --git a/Plugins/Json/src/SurfaceJsonConverter.cpp b/Plugins/Json/src/SurfaceJsonConverter.cpp index 0df6dc8b08b..fb6b0e7b08d 100644 --- a/Plugins/Json/src/SurfaceJsonConverter.cpp +++ b/Plugins/Json/src/SurfaceJsonConverter.cpp @@ -28,8 +28,7 @@ #include "Acts/Surfaces/StrawSurface.hpp" #include "Acts/Surfaces/SurfaceBounds.hpp" #include "Acts/Surfaces/TrapezoidBounds.hpp" - -#include +#include "Acts/Utilities/ThrowAssert.hpp" void Acts::to_json(nlohmann::json& j, const Acts::SurfaceAndMaterialWithContext& surface) { diff --git a/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp index 5d0102653b2..4e037a105ba 100644 --- a/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp @@ -22,8 +22,8 @@ #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Result.hpp" +#include "Acts/Utilities/ThrowAssert.hpp" -#include #include #include #include diff --git a/Tests/UnitTests/Core/Surfaces/ConvexPolygonBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/ConvexPolygonBoundsTests.cpp index 6b6712c230b..7b516b6bfec 100644 --- a/Tests/UnitTests/Core/Surfaces/ConvexPolygonBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/ConvexPolygonBoundsTests.cpp @@ -15,15 +15,9 @@ #include #include -#include #include -#include #include -namespace Acts { -class AssertionFailureException; -} // namespace Acts - using vec2 = Acts::Vector2; template using poly = Acts::ConvexPolygonBounds; diff --git a/Tests/UnitTests/Core/Surfaces/CylinderBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/CylinderBoundsTests.cpp index 14cafdd045b..6cc6bc8da82 100644 --- a/Tests/UnitTests/Core/Surfaces/CylinderBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/CylinderBoundsTests.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include #include diff --git a/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp index 9ef504bd0df..e37b339d00c 100644 --- a/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp @@ -24,27 +24,19 @@ #include "Acts/Tests/CommonHelpers/DetectorElementStub.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/BinningType.hpp" -#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/Intersection.hpp" #include "Acts/Utilities/Logger.hpp" #include "Acts/Utilities/Result.hpp" +#include "Acts/Utilities/ThrowAssert.hpp" #include "Acts/Utilities/detail/periodic.hpp" -#include #include -#include #include #include -#include #include -#include using namespace Acts::UnitLiterals; -namespace Acts { -class AssertionFailureException; -} // namespace Acts - namespace Acts::Test { auto logger = Acts::getDefaultLogger("UnitTests", Acts::Logging::VERBOSE); diff --git a/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp index 2e1fd4473f9..15140f73c7a 100644 --- a/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp @@ -13,7 +13,6 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/Alignment.hpp" #include "Acts/Definitions/Tolerance.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Definitions/Units.hpp" #include "Acts/Geometry/Extent.hpp" #include "Acts/Geometry/GeometryContext.hpp" @@ -27,25 +26,19 @@ #include "Acts/Tests/CommonHelpers/DetectorElementStub.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Utilities/BinningType.hpp" -#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/Intersection.hpp" #include "Acts/Utilities/Result.hpp" +#include "Acts/Utilities/ThrowAssert.hpp" +#include "Acts/Utilities/detail/periodic.hpp" -#include #include -#include #include #include #include #include -#include using namespace Acts::UnitLiterals; -namespace Acts { -class AssertionFailureException; -} // namespace Acts - namespace Acts::Test { // Create a test context GeometryContext tgContext = GeometryContext(); diff --git a/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp index 15d930929af..0721039acef 100644 --- a/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp @@ -22,7 +22,6 @@ #include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/LineBounds.hpp" #include "Acts/Surfaces/Surface.hpp" -#include "Acts/Surfaces/SurfaceBounds.hpp" #include "Acts/Tests/CommonHelpers/DetectorElementStub.hpp" #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp" #include "Acts/Tests/CommonHelpers/LineSurfaceStub.hpp" @@ -30,24 +29,18 @@ #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Intersection.hpp" #include "Acts/Utilities/Result.hpp" +#include "Acts/Utilities/ThrowAssert.hpp" #include "Acts/Utilities/UnitVectors.hpp" #include "Acts/Utilities/VectorHelpers.hpp" -#include #include #include #include #include #include -#include -#include #include #include -namespace Acts { -class AssertionFailureException; -} // namespace Acts - namespace Acts::Test { // Create a test context diff --git a/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp index de2a87483e0..b62517f3e2c 100644 --- a/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp @@ -27,13 +27,12 @@ #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Intersection.hpp" #include "Acts/Utilities/Result.hpp" +#include "Acts/Utilities/ThrowAssert.hpp" -#include #include #include #include #include -#include using namespace Acts::UnitLiterals; diff --git a/Tests/UnitTests/Core/Surfaces/PolyhedronSurfacesTests.cpp b/Tests/UnitTests/Core/Surfaces/PolyhedronSurfacesTests.cpp index 184d69e341f..8029a53426b 100644 --- a/Tests/UnitTests/Core/Surfaces/PolyhedronSurfacesTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/PolyhedronSurfacesTests.cpp @@ -29,7 +29,6 @@ #include "Acts/Utilities/Logger.hpp" #include -#include #include using namespace Acts::UnitLiterals; diff --git a/Tests/UnitTests/Core/Surfaces/RadialBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/RadialBoundsTests.cpp index a25eeb4d352..a5083efaf92 100644 --- a/Tests/UnitTests/Core/Surfaces/RadialBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/RadialBoundsTests.cpp @@ -16,7 +16,6 @@ #include #include -#include #include #include #include diff --git a/Tests/UnitTests/Core/Surfaces/StrawSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/StrawSurfaceTests.cpp index 2998ad0e799..99e8671c7cf 100644 --- a/Tests/UnitTests/Core/Surfaces/StrawSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/StrawSurfaceTests.cpp @@ -20,10 +20,6 @@ #include #include -namespace Acts { -class PlanarBounds; -} // namespace Acts - namespace Acts::Test { // Create a test context diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp index 2d62f29f4e4..732e7d9ff6a 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp @@ -15,13 +15,10 @@ #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Surfaces/SurfaceArray.hpp" -#include "Acts/Surfaces/SurfaceBounds.hpp" #include "Acts/Utilities/Axis.hpp" #include "Acts/Utilities/AxisFwd.hpp" #include "Acts/Utilities/BinningType.hpp" -#include "Acts/Utilities/Grid.hpp" #include "Acts/Utilities/Helpers.hpp" -#include "Acts/Utilities/detail/grid_helper.hpp" #include #include diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp index 14b432d2945..655303f9602 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp @@ -24,7 +24,6 @@ #include #include #include -#include using namespace Acts::UnitLiterals; diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp index 11c66abf303..822c28c69df 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp @@ -30,12 +30,7 @@ #include #include -#include #include -#include -#include -#include -#include namespace { diff --git a/Tests/UnitTests/Core/Surfaces/TrapezoidBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/TrapezoidBoundsTests.cpp index 0e9f1bba029..52155fec5fe 100644 --- a/Tests/UnitTests/Core/Surfaces/TrapezoidBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/TrapezoidBoundsTests.cpp @@ -20,10 +20,8 @@ #include #include #include -#include #include #include -#include #include namespace bdata = boost::unit_test::data;