Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 07:51:54

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