Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 08:07:08

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2020 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 #include "Acts/Definitions/Algebra.hpp"
0011 #include "Acts/Definitions/TrackParametrization.hpp"
0012 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0013 #include "Acts/Surfaces/DiscBounds.hpp"
0014 #include "Acts/Surfaces/SurfaceBounds.hpp"
0015 #include "Acts/Utilities/detail/periodic.hpp"
0016 
0017 #include <algorithm>
0018 #include <array>
0019 #include <cmath>
0020 #include <iosfwd>
0021 #include <stdexcept>
0022 #include <vector>
0023 
0024 namespace Acts {
0025 
0026 /// @class DiscTrapezoidBounds
0027 ///
0028 /// Class to describe the bounds for a planar DiscSurface.
0029 /// By providing an argument for hphisec, the bounds can
0030 /// be restricted to a phi-range around the center position.
0031 
0032 class DiscTrapezoidBounds : public DiscBounds {
0033  public:
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   DiscTrapezoidBounds() = delete;
0045 
0046   /// Constructor for a symmetric Trapezoid giving min X length, max X length,
0047   /// Rmin and R max
0048   /// @param halfXminR half length in X at min radius
0049   /// @param halfXmaxR half length in X at maximum radius
0050   /// @param minR inner radius
0051   /// @param maxR outer radius
0052   /// @param avgPhi average phi value
0053   /// @param stereo optional stero angle applied
0054   DiscTrapezoidBounds(double halfXminR, double halfXmaxR, double minR,
0055                       double maxR, double avgPhi = M_PI_2,
0056                       double stereo = 0.) noexcept(false);
0057 
0058   /// Constructor - from fixed size array
0059   ///
0060   /// @param values The parameter values
0061   DiscTrapezoidBounds(const std::array<double, eSize>& values) noexcept(false)
0062       : m_values(values) {
0063     checkConsistency();
0064   }
0065 
0066   ~DiscTrapezoidBounds() override = default;
0067 
0068   SurfaceBounds::BoundsType type() const final;
0069 
0070   /// Return the bound values as dynamically sized vector
0071   ///
0072   /// @return this returns a copy of the internal values
0073   std::vector<double> values() const final;
0074 
0075   ///  This method checks if the radius given in the LocalPosition is inside
0076   ///  [rMin,rMax]
0077   /// if only tol0 is given and additional in the phi sector is tol1 is given
0078   /// @param lposition is the local position to be checked (in polar
0079   /// coordinates)
0080   /// @param boundaryTolerance is the boundary check directive
0081   bool inside(const Vector2& lposition,
0082               const BoundaryTolerance& boundaryTolerance =
0083                   BoundaryTolerance::None()) const final;
0084 
0085   /// Output Method for std::ostream
0086   std::ostream& toStream(std::ostream& sl) const final;
0087 
0088   /// Access to the bound values
0089   /// @param bValue the class nested enum for the array access
0090   double get(BoundValues bValue) const { return m_values[bValue]; }
0091 
0092   /// This method returns inner radius
0093   double rMin() const final;
0094 
0095   /// This method returns outer radius
0096   double rMax() const final;
0097 
0098   /// This method returns the center radius
0099   double rCenter() const;
0100 
0101   /// This method returns the stereo angle
0102   double stereo() const;
0103 
0104   /// This method returns the halfPhiSector which is covered by the disc
0105   double halfPhiSector() const;
0106 
0107   /// This method returns the half length in Y (this is Rmax -Rmin)
0108   double halfLengthY() const;
0109 
0110   /// Returns true for full phi coverage - obviously false here
0111   bool coversFullAzimuth() const final;
0112 
0113   /// Checks if this is inside the radial coverage
0114   /// given the a tolerance
0115   bool insideRadialBounds(double R, double tolerance = 0.) const final;
0116 
0117   /// Return a reference radius for binning
0118   double binningValueR() const final;
0119 
0120   /// Return a reference phi for binning
0121   double binningValuePhi() const final;
0122 
0123   /// This method returns the xy coordinates of the four corners of the
0124   /// bounds in module coorindates (in xy)
0125   ///
0126   /// @param lseg the number of segments used to approximate
0127   /// and eventually curved line
0128   ///
0129   /// @note that the number of segments are ignored for this surface
0130   ///
0131   /// @return vector for vertices in 2D
0132   std::vector<Vector2> vertices(unsigned int lseg) const final;
0133 
0134  private:
0135   std::array<double, eSize> m_values;
0136 
0137   /// Dreived maximum y value
0138   double m_ymax = 0;
0139 
0140   /// Check the input values for consistency, will throw a logic_exception
0141   /// if consistency is not given
0142   void checkConsistency() noexcept(false);
0143 
0144   /// Private helper method to convert a local position
0145   /// into its Cartesian representation
0146   ///
0147   /// @param lposition The local position in polar coordinates
0148   Vector2 toLocalCartesian(const Vector2& lposition) const;
0149 
0150   /// Jacobian
0151   /// into its Cartesian representation
0152   ///
0153   /// @param lposition The local position in polar coordinates
0154   ActsMatrix<2, 2> jacobianToLocalCartesian(const Vector2& lposition) const;
0155 };
0156 
0157 inline double DiscTrapezoidBounds::rMin() const {
0158   return get(eMinR);
0159 }
0160 
0161 inline double DiscTrapezoidBounds::rMax() const {
0162   return get(eMaxR);
0163 }
0164 
0165 inline double DiscTrapezoidBounds::stereo() const {
0166   return get(eStereo);
0167 }
0168 
0169 inline double DiscTrapezoidBounds::halfPhiSector() const {
0170   auto minHalfPhi = std::asin(get(eHalfLengthXminR) / get(eMinR));
0171   auto maxHalfPhi = std::asin(get(eHalfLengthXmaxR) / get(eMaxR));
0172   return std::max(minHalfPhi, maxHalfPhi);
0173 }
0174 
0175 inline double DiscTrapezoidBounds::rCenter() const {
0176   double rmin = get(eMinR);
0177   double rmax = get(eMaxR);
0178   double hxmin = get(eHalfLengthXminR);
0179   double hxmax = get(eHalfLengthXmaxR);
0180   auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin);
0181   auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax);
0182   return 0.5 * (hmin + hmax);
0183 }
0184 
0185 inline double DiscTrapezoidBounds::halfLengthY() const {
0186   double rmin = get(eMinR);
0187   double rmax = get(eMaxR);
0188   double hxmin = get(eHalfLengthXminR);
0189   double hxmax = get(eHalfLengthXmaxR);
0190   auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin);
0191   auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax);
0192   return 0.5 * (hmax - hmin);
0193 }
0194 
0195 inline bool DiscTrapezoidBounds::coversFullAzimuth() const {
0196   return false;
0197 }
0198 
0199 inline bool DiscTrapezoidBounds::insideRadialBounds(double R,
0200                                                     double tolerance) const {
0201   return (R + tolerance > get(eMinR) && R - tolerance < get(eMaxR));
0202 }
0203 
0204 inline double DiscTrapezoidBounds::binningValueR() const {
0205   return 0.5 * (get(eMinR) + get(eMaxR));
0206 }
0207 
0208 inline double DiscTrapezoidBounds::binningValuePhi() const {
0209   return get(eAveragePhi);
0210 }
0211 
0212 inline std::vector<double> DiscTrapezoidBounds::values() const {
0213   std::vector<double> valvector;
0214   valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
0215   return valvector;
0216 }
0217 
0218 inline void DiscTrapezoidBounds::checkConsistency() noexcept(false) {
0219   if (get(eMinR) < 0. || get(eMaxR) <= 0. || get(eMinR) > get(eMaxR)) {
0220     throw std::invalid_argument("DiscTrapezoidBounds: invalid radial setup.");
0221   }
0222   if (get(eHalfLengthXminR) < 0. || get(eHalfLengthXmaxR) <= 0.) {
0223     throw std::invalid_argument("DiscTrapezoidBounds: negative length given.");
0224   }
0225   if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
0226     throw std::invalid_argument(
0227         "DiscTrapezoidBounds: invalid phi positioning.");
0228   }
0229 }
0230 
0231 }  // namespace Acts