Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-14 08:00:04

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