Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-05 08:53:53

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