Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-16 08:19:19

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Tolerance.hpp"
0013 #include "Acts/Surfaces/DiscBounds.hpp"
0014 #include "Acts/Surfaces/SurfaceBounds.hpp"
0015 
0016 #include <array>
0017 #include <cmath>
0018 #include <iosfwd>
0019 #include <numbers>
0020 #include <vector>
0021 
0022 namespace Acts {
0023 
0024 /// @class RadialBounds
0025 ///
0026 /// Class to describe the bounds for a planar DiscSurface.
0027 /// By providing an argument for hphisec, the bounds can
0028 /// be restricted to a phi-range around the center position.
0029 ///
0030 class RadialBounds : public DiscBounds {
0031  public:
0032   /// @enum BoundValues
0033   /// Enumeration for the bound values
0034   enum BoundValues {
0035     eMinR = 0,
0036     eMaxR = 1,
0037     eHalfPhiSector = 2,
0038     eAveragePhi = 3,
0039     eSize = 4
0040   };
0041 
0042   /// Constructor for full disc of symmetric disc around phi=0
0043   ///
0044   /// @param minR The inner radius (0 for full disc)
0045   /// @param maxR The outer radius
0046   /// @param halfPhi The half opening angle (Pi for full angular coverage)
0047   /// @param avgPhi The average phi for the disc/ring sector
0048   explicit RadialBounds(double minR, double maxR,
0049                         double halfPhi = std::numbers::pi,
0050                         double avgPhi = 0.) noexcept(false)
0051       : m_values({minR, maxR, halfPhi, avgPhi}) {
0052     checkConsistency();
0053   }
0054 
0055   /// Constructor from array values
0056   ///
0057   /// @param values The bound values
0058   explicit RadialBounds(const std::array<double, eSize>& values) noexcept(false)
0059       : m_values(values) {
0060     checkConsistency();
0061   }
0062 
0063   /// @copydoc SurfaceBounds::type
0064   BoundsType type() const final { return eDisc; }
0065 
0066   /// @copydoc SurfaceBounds::isCartesian
0067   bool isCartesian() const final { return false; }
0068 
0069   /// @copydoc SurfaceBounds::boundToCartesianJacobian
0070   SquareMatrix2 boundToCartesianJacobian(const Vector2& lposition) const final;
0071 
0072   /// @copydoc SurfaceBounds::boundToCartesianMetric
0073   SquareMatrix2 boundToCartesianMetric(const Vector2& lposition) const final;
0074 
0075   /// Return the bound values as dynamically sized vector
0076   /// @return this returns a copy of the internal values
0077   std::vector<double> values() const final;
0078 
0079   /// @copydoc SurfaceBounds::inside
0080   bool inside(const Vector2& lposition) const final;
0081 
0082   /// @copydoc SurfaceBounds::closestPoint
0083   Vector2 closestPoint(const Vector2& lposition,
0084                        const SquareMatrix2& metric) const final;
0085 
0086   using SurfaceBounds::inside;
0087 
0088   /// @copydoc SurfaceBounds::center
0089   /// @note For RadialBounds: returns ((rMin + rMax)/2, averagePhi) in polar coordinates
0090   Vector2 center() const final;
0091 
0092   /// Outstream operator
0093   ///
0094   /// @param sl is the ostream to be dumped into
0095   /// @return Reference to the output stream for chaining
0096   std::ostream& toStream(std::ostream& sl) const final;
0097 
0098   /// Return method for inner Radius
0099   /// @return Minimum radius value of the bounds
0100   double rMin() const final { return get(eMinR); }
0101 
0102   /// Return method for outer Radius
0103   /// @return Maximum radius value of the bounds
0104   double rMax() const final { return get(eMaxR); }
0105 
0106   /// Access to the bound values
0107   /// @param bValue the class nested enum for the array access
0108   /// @return The boundary value corresponding to the requested parameter
0109   double get(BoundValues bValue) const { return m_values[bValue]; }
0110 
0111   /// Returns true for full phi coverage
0112   /// @return True if bounds cover full azimuthal range (2π), false otherwise
0113   bool coversFullAzimuth() const final {
0114     return std::abs(get(eHalfPhiSector) - std::numbers::pi) <
0115            s_fullAzimuthTolerance;
0116   }
0117 
0118   /// Checks if this is inside the radial coverage
0119   /// given the a tolerance
0120   /// @param R Radius value to check
0121   /// @param tolerance Tolerance for the boundary check
0122   /// @return True if radius is within radial bounds considering tolerance
0123   bool insideRadialBounds(double R, double tolerance = 0.) const final {
0124     return (R + tolerance > get(eMinR) && R - tolerance < get(eMaxR));
0125   }
0126 
0127   /// Return a reference radius for binning
0128   /// @return Average radius value used as binning reference
0129   double binningValueR() const final { return 0.5 * (get(eMinR) + get(eMaxR)); }
0130 
0131   /// Return a reference phi value for binning
0132   /// @return Average phi value used as binning reference
0133   double binningValuePhi() const final { return get(eAveragePhi); }
0134 
0135  private:
0136   std::array<double, eSize> m_values;
0137 
0138   /// Check the input values for consistency, will throw a logic_exception
0139   /// if consistency is not given
0140   void checkConsistency() noexcept(false);
0141 
0142   /// Private helper method to shift a local position
0143   /// within the bounds
0144   ///
0145   /// @param lposition The local position in polar coordinates
0146   Vector2 shifted(const Vector2& lposition) const;
0147 
0148   /// This method returns the xy coordinates of vertices along
0149   /// the radial bounds
0150   ///
0151   /// @param lseg the number of segments used to approximate
0152   /// and eventually curved line
0153   ///
0154   /// @note that the extrema are given, which may slightly alter the
0155   /// number of segments returned
0156   ///
0157   /// @return vector for vertices in 2D
0158   std::vector<Vector2> vertices(unsigned int lseg) const final;
0159 };
0160 
0161 }  // namespace Acts