Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-19 07:57:23

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