Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-14 08:12:05

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/SurfaceBounds.hpp"
0013 
0014 #include <array>
0015 #include <cmath>
0016 #include <cstdlib>
0017 #include <iosfwd>
0018 #include <numbers>
0019 #include <vector>
0020 
0021 namespace Acts {
0022 
0023 ///  @class ConeBounds
0024 ///
0025 ///  Bounds for a conical surface,
0026 ///  the opening angle is stored in \f$ \tan(\alpha) \f$ and always positively
0027 /// defined.
0028 ///  The cone can open to both sides, steered by \f$ z_min \f$ and \f$ z_max
0029 ///  \f$.
0030 ///
0031 ///  @image html ConeBounds.gif
0032 ///
0033 class ConeBounds : public SurfaceBounds {
0034  public:
0035   enum BoundValues : int {
0036     eAlpha = 0,
0037     eMinZ = 1,
0038     eMaxZ = 2,
0039     eHalfPhiSector = 3,
0040     eAveragePhi = 4,
0041     eSize = 5
0042   };
0043 
0044   /// Constructor - open cone with alpha, by default a full cone
0045   /// but optionally can make a conical section
0046   ///
0047   /// @param alpha is the opening angle of the cone
0048   /// @param symm is the boolean indicating if the cone is symmetric in +/- z
0049   /// @param halfphi is the half opening angle (default is pi)
0050   /// @param avphi is the phi value around which the bounds are opened
0051   /// (default=0)
0052   ConeBounds(double alpha, bool symm, double halfphi = std::numbers::pi,
0053              double avphi = 0.) noexcept(false);
0054 
0055   /// Constructor - open cone with alpha, minz and maxz, by
0056   /// default a full cone but can optionally make it a conical section
0057   ///
0058   /// @param alpha is the opening angle of the cone
0059   /// @param minz cone expanding from minimal z
0060   /// @param maxz cone expanding to maximal z
0061   /// @param halfphi is the half opening angle (default is pi)
0062   /// @param avphi is the phi value around which the bounds are opened
0063   /// (default=0)
0064   ConeBounds(double alpha, double minz, double maxz,
0065              double halfphi = std::numbers::pi,
0066              double avphi = 0.) noexcept(false);
0067 
0068   /// Constructor - from parameters array
0069   ///
0070   /// @param values The parameter array
0071   explicit ConeBounds(const std::array<double, eSize>& values) noexcept(false);
0072 
0073   /// @copydoc SurfaceBounds::type
0074   BoundsType type() const final { return eCone; }
0075 
0076   /// @copydoc SurfaceBounds::isCartesian
0077   bool isCartesian() const final { return true; }
0078 
0079   /// @copydoc SurfaceBounds::boundToCartesianJacobian
0080   SquareMatrix2 boundToCartesianJacobian(const Vector2& lposition) const final {
0081     (void)lposition;
0082     return SquareMatrix2::Identity();
0083   }
0084 
0085   /// @copydoc SurfaceBounds::boundToCartesianMetric
0086   SquareMatrix2 boundToCartesianMetric(const Vector2& lposition) const final {
0087     (void)lposition;
0088     return SquareMatrix2::Identity();
0089   }
0090 
0091   /// @copydoc SurfaceBounds::values
0092   std::vector<double> values() const final;
0093 
0094   /// @copydoc SurfaceBounds::inside
0095   bool inside(const Vector2& lposition) const final;
0096 
0097   /// @copydoc SurfaceBounds::closestPoint
0098   Vector2 closestPoint(const Vector2& lposition,
0099                        const SquareMatrix2& metric) const final;
0100 
0101   using SurfaceBounds::inside;
0102 
0103   /// @copydoc SurfaceBounds::center
0104   /// @note For ConeBounds: returns (averagePhi, (minZ + maxZ)/2) in cone coordinates
0105   Vector2 center() const final;
0106 
0107   /// Output Method for std::ostream
0108   /// @param sl is the ostrea into which the dump is done
0109   /// @return is the input object
0110   std::ostream& toStream(std::ostream& sl) const final;
0111 
0112   /// Return the radius at a specific z values
0113   ///
0114   /// @param z is the z value for which r is requested
0115   /// @return is the r value associated with z
0116   double r(double z) const { return std::abs(z * m_tanAlpha); }
0117 
0118   /// Return tangent of alpha (pre-computed)
0119   double tanAlpha() const { return m_tanAlpha; }
0120 
0121   /// Access to the bound values
0122   /// @param bValue the class nested enum for the array access
0123   double get(BoundValues bValue) const { return m_values[bValue]; }
0124 
0125  private:
0126   std::array<double, eSize> m_values;
0127   double m_tanAlpha;
0128 
0129   /// Check the input values for consistency, will throw a logic_exception
0130   /// if consistency is not given
0131   void checkConsistency() noexcept(false);
0132 
0133   /// Private helper function to shift a local 2D position
0134   ///
0135   /// Shift r-phi coordinate to be centered around the average phi.
0136   ///
0137   /// @param lposition The original local position
0138   Vector2 shifted(const Vector2& lposition) const;
0139 };
0140 
0141 }  // namespace Acts