Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:03

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