Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:23:34

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/BoundaryCheck.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 bcheck is the boundary check directive
0081   bool inside(const Vector2& lposition,
0082               const BoundaryCheck& bcheck = BoundaryCheck(true)) const final;
0083 
0084   /// Output Method for std::ostream
0085   std::ostream& toStream(std::ostream& sl) const final;
0086 
0087   /// Access to the bound values
0088   /// @param bValue the class nested enum for the array access
0089   double get(BoundValues bValue) const { return m_values[bValue]; }
0090 
0091   /// This method returns inner radius
0092   double rMin() const final;
0093 
0094   /// This method returns outer radius
0095   double rMax() const final;
0096 
0097   /// This method returns the center radius
0098   double rCenter() const;
0099 
0100   /// This method returns the stereo angle
0101   double stereo() const;
0102 
0103   /// This method returns the halfPhiSector which is covered by the disc
0104   double halfPhiSector() const;
0105 
0106   /// This method returns the half length in Y (this is Rmax -Rmin)
0107   double halfLengthY() const;
0108 
0109   /// Returns true for full phi coverage - obviously false here
0110   bool coversFullAzimuth() const final;
0111 
0112   /// Checks if this is inside the radial coverage
0113   /// given the a tolerance
0114   bool insideRadialBounds(double R, double tolerance = 0.) const final;
0115 
0116   /// Return a reference radius for binning
0117   double binningValueR() const final;
0118 
0119   /// Return a reference phi for binning
0120   double binningValuePhi() const final;
0121 
0122   /// This method returns the xy coordinates of the four corners of the
0123   /// bounds in module coorindates (in xy)
0124   ///
0125   /// @param lseg the number of segments used to approximate
0126   /// and eventually curved line
0127   ///
0128   /// @note that the number of segments are ignored for this surface
0129   ///
0130   /// @return vector for vertices in 2D
0131   std::vector<Vector2> vertices(unsigned int lseg) const final;
0132 
0133  private:
0134   std::array<double, eSize> m_values;
0135 
0136   /// Dreived maximum y value
0137   double m_ymax = 0;
0138 
0139   /// Check the input values for consistency, will throw a logic_exception
0140   /// if consistency is not given
0141   void checkConsistency() noexcept(false);
0142 
0143   /// Private helper method to convert a local position
0144   /// into its Cartesian representation
0145   ///
0146   /// @param lposition The local position in polar coordinates
0147   Vector2 toLocalCartesian(const Vector2& lposition) const;
0148 
0149   /// Jacobian
0150   /// into its Cartesian representation
0151   ///
0152   /// @param lposition The local position in polar coordinates
0153   ActsMatrix<2, 2> jacobianToLocalCartesian(const Vector2& lposition) const;
0154 };
0155 
0156 inline double DiscTrapezoidBounds::rMin() const {
0157   return get(eMinR);
0158 }
0159 
0160 inline double DiscTrapezoidBounds::rMax() const {
0161   return get(eMaxR);
0162 }
0163 
0164 inline double DiscTrapezoidBounds::stereo() const {
0165   return get(eStereo);
0166 }
0167 
0168 inline double DiscTrapezoidBounds::halfPhiSector() const {
0169   auto minHalfPhi = std::asin(get(eHalfLengthXminR) / get(eMinR));
0170   auto maxHalfPhi = std::asin(get(eHalfLengthXmaxR) / get(eMaxR));
0171   return std::max(minHalfPhi, maxHalfPhi);
0172 }
0173 
0174 inline double DiscTrapezoidBounds::rCenter() const {
0175   double rmin = get(eMinR);
0176   double rmax = get(eMaxR);
0177   double hxmin = get(eHalfLengthXminR);
0178   double hxmax = get(eHalfLengthXmaxR);
0179   auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin);
0180   auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax);
0181   return 0.5 * (hmin + hmax);
0182 }
0183 
0184 inline double DiscTrapezoidBounds::halfLengthY() const {
0185   double rmin = get(eMinR);
0186   double rmax = get(eMaxR);
0187   double hxmin = get(eHalfLengthXminR);
0188   double hxmax = get(eHalfLengthXmaxR);
0189   auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin);
0190   auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax);
0191   return 0.5 * (hmax - hmin);
0192 }
0193 
0194 inline bool DiscTrapezoidBounds::coversFullAzimuth() const {
0195   return false;
0196 }
0197 
0198 inline bool DiscTrapezoidBounds::insideRadialBounds(double R,
0199                                                     double tolerance) const {
0200   return (R + tolerance > get(eMinR) && R - tolerance < get(eMaxR));
0201 }
0202 
0203 inline double DiscTrapezoidBounds::binningValueR() const {
0204   return 0.5 * (get(eMinR) + get(eMaxR));
0205 }
0206 
0207 inline double DiscTrapezoidBounds::binningValuePhi() const {
0208   return get(eAveragePhi);
0209 }
0210 
0211 inline std::vector<double> DiscTrapezoidBounds::values() const {
0212   std::vector<double> valvector;
0213   valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
0214   return valvector;
0215 }
0216 
0217 inline void DiscTrapezoidBounds::checkConsistency() noexcept(false) {
0218   if (get(eMinR) < 0. || get(eMaxR) <= 0. || get(eMinR) > get(eMaxR)) {
0219     throw std::invalid_argument("DiscTrapezoidBounds: invalid radial setup.");
0220   }
0221   if (get(eHalfLengthXminR) < 0. || get(eHalfLengthXmaxR) <= 0.) {
0222     throw std::invalid_argument("DiscTrapezoidBounds: negative length given.");
0223   }
0224   if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
0225     throw std::invalid_argument(
0226         "DiscTrapezoidBounds: invalid phi positioning.");
0227   }
0228 }
0229 
0230 }  // namespace Acts