Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-31 07:47:28

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 #include "Acts/Utilities/MathHelpers.hpp"
0015 
0016 #include <algorithm>
0017 #include <array>
0018 #include <cmath>
0019 #include <iosfwd>
0020 #include <numbers>
0021 #include <vector>
0022 
0023 namespace Acts {
0024 
0025 /// @class DiscTrapezoidBounds
0026 ///
0027 /// Class to describe the bounds for a planar DiscSurface.
0028 /// By providing an argument for hphisec, the bounds can
0029 /// be restricted to a phi-range around the center position.
0030 ///
0031 class DiscTrapezoidBounds : public DiscBounds {
0032  public:
0033   /// @enum BoundValues
0034   /// Enumeration for the bound values
0035   enum BoundValues : int {
0036     eHalfLengthXminR = 0,
0037     eHalfLengthXmaxR = 1,
0038     eMinR = 2,
0039     eMaxR = 3,
0040     eAveragePhi = 4,
0041     eStereo = 5,
0042     eSize = 6
0043   };
0044 
0045   /// Constructor for a symmetric Trapezoid giving min X length, max X length,
0046   /// Rmin and R max
0047   /// @param halfXminR half length in X at min radius
0048   /// @param halfXmaxR half length in X at maximum radius
0049   /// @param minR inner radius
0050   /// @param maxR outer radius
0051   /// @param avgPhi average phi value
0052   /// @param stereo optional stereo angle applied
0053   explicit DiscTrapezoidBounds(double halfXminR, double halfXmaxR, double minR,
0054                                double maxR,
0055                                double avgPhi = std::numbers::pi / 2.,
0056                                double stereo = 0.) noexcept(false);
0057 
0058   /// Constructor - from fixed size array
0059   ///
0060   /// @param values The parameter values
0061   explicit DiscTrapezoidBounds(
0062       const std::array<double, eSize>& values) noexcept(false)
0063       : m_values(values) {
0064     checkConsistency();
0065   }
0066 
0067   /// @copydoc SurfaceBounds::type
0068   BoundsType type() const final { return eDiscTrapezoid; }
0069 
0070   /// @copydoc SurfaceBounds::isCartesian
0071   bool isCartesian() const final { return false; }
0072 
0073   /// @copydoc SurfaceBounds::boundToCartesianJacobian
0074   SquareMatrix2 boundToCartesianJacobian(const Vector2& lposition) const final;
0075 
0076   /// @copydoc SurfaceBounds::boundToCartesianMetric
0077   SquareMatrix2 boundToCartesianMetric(const Vector2& lposition) const final;
0078 
0079   /// Return the bound values as dynamically sized vector
0080   /// @return this returns a copy of the internal values
0081   std::vector<double> values() const final;
0082 
0083   /// @copydoc SurfaceBounds::inside
0084   bool inside(const Vector2& lposition) const final;
0085 
0086   /// @copydoc SurfaceBounds::closestPoint
0087   Vector2 closestPoint(const Vector2& lposition,
0088                        const SquareMatrix2& metric) const final;
0089 
0090   using SurfaceBounds::inside;
0091 
0092   /// @copydoc SurfaceBounds::center
0093   Vector2 center() const final;
0094 
0095   /// Output Method for std::ostream
0096   /// @param sl The output stream to write to
0097   /// @return Reference to the output stream after writing
0098   std::ostream& toStream(std::ostream& sl) const final;
0099 
0100   /// Access to the bound values
0101   /// @param bValue the class nested enum for the array access
0102   /// @return The value of the specified bound parameter
0103   double get(BoundValues bValue) const { return m_values[bValue]; }
0104 
0105   /// This method returns inner radius
0106   /// @return Minimum radius of the disc trapezoid
0107   double rMin() const final { return get(eMinR); }
0108 
0109   /// This method returns outer radius
0110   /// @return Maximum radius of the disc trapezoid
0111   double rMax() const final { return get(eMaxR); }
0112 
0113   /// This method returns the center radius
0114   /// @return Center radius calculated from inner and outer bounds
0115   double rCenter() const {
0116     const double rmin = get(eMinR);
0117     const double rmax = get(eMaxR);
0118     const double hxmin = get(eHalfLengthXminR);
0119     const double hxmax = get(eHalfLengthXmaxR);
0120     const double hmin = fastCathetus(rmin, hxmin);
0121     const double hmax = fastCathetus(rmax, hxmax);
0122     return 0.5 * (hmin + hmax);
0123   }
0124 
0125   /// This method returns the stereo angle
0126   /// @return Stereo angle of the disc trapezoid
0127   double stereo() const { return get(eStereo); }
0128 
0129   /// This method returns the halfPhiSector which is covered by the disc
0130   /// @return Half phi sector angle covered by the disc trapezoid
0131   double halfPhiSector() const {
0132     const double minHalfPhi = std::asin(get(eHalfLengthXminR) / get(eMinR));
0133     const double maxHalfPhi = std::asin(get(eHalfLengthXmaxR) / get(eMaxR));
0134     return std::max(minHalfPhi, maxHalfPhi);
0135   }
0136 
0137   /// This method returns the half length in Y (this is Rmax -Rmin)
0138   /// @return Half length in Y direction calculated from radial bounds
0139   double halfLengthY() const {
0140     const double rmin = get(eMinR);
0141     const double rmax = get(eMaxR);
0142     const double hxmin = get(eHalfLengthXminR);
0143     const double hxmax = get(eHalfLengthXmaxR);
0144     const double hmin = fastCathetus(rmin, hxmin);
0145     const double hmax = fastCathetus(rmax, hxmax);
0146     return 0.5 * (hmax - hmin);
0147   }
0148 
0149   /// Returns true for full phi coverage - obviously false here
0150   /// @return Always false since disc trapezoids have limited phi coverage
0151   bool coversFullAzimuth() const final { return false; }
0152 
0153   /// Checks if this is inside the radial coverage
0154   /// given the a tolerance
0155   /// @param R The radius value to check
0156   /// @param tolerance The tolerance for the check
0157   /// @return True if radius is within bounds (plus tolerance), false otherwise
0158   bool insideRadialBounds(double R, double tolerance = 0.) const final {
0159     return (R + tolerance > get(eMinR) && R - tolerance < get(eMaxR));
0160   }
0161 
0162   /// Return a reference radius for binning
0163   /// @return Average radius for binning purposes
0164   double binningValueR() const final { return 0.5 * (get(eMinR) + get(eMaxR)); }
0165 
0166   /// Return a reference phi for binning
0167   /// @return Average phi angle for binning purposes
0168   double binningValuePhi() const final { return get(eAveragePhi); }
0169 
0170   /// This method returns the xy coordinates of the four corners of the
0171   /// bounds in module coorindates (in xy)
0172   ///
0173   /// @param ignoredSegments is an ignored parameter only used for
0174   /// curved bound segments
0175   ///
0176   /// @return vector for vertices in 2D
0177   std::vector<Vector2> vertices(unsigned int ignoredSegments = 0u) const final;
0178 
0179  private:
0180   std::array<double, eSize> m_values;
0181 
0182   /// Dreived maximum y value
0183   double m_ymax = 0;
0184 
0185   /// Check the input values for consistency, will throw a logic_exception
0186   /// if consistency is not given
0187   void checkConsistency() noexcept(false);
0188 
0189   /// Private helper method to convert a local position
0190   /// into its Cartesian representation
0191   ///
0192   /// @param lposition The local position in polar coordinates
0193   Vector2 toLocalCartesian(const Vector2& lposition) const;
0194 };
0195 
0196 }  // namespace Acts