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 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Tolerance.hpp"
0013 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0014 #include "Acts/Surfaces/SurfaceBounds.hpp"
0015 #include "Acts/Utilities/detail/periodic.hpp"
0016 
0017 #include <array>
0018 #include <cmath>
0019 #include <cstdlib>
0020 #include <iosfwd>
0021 #include <stdexcept>
0022 #include <vector>
0023 
0024 namespace Acts {
0025 
0026 ///  @class ConeBounds
0027 ///
0028 ///  Bounds for a conical surface,
0029 ///  the opening angle is stored in \f$ \tan(\alpha) \f$ and always positively
0030 /// defined.
0031 ///  The cone can open to both sides, steered by \f$ z_min \f$ and \f$ z_max
0032 ///  \f$.
0033 ///
0034 ///  @image html ConeBounds.gif
0035 ///
0036 
0037 class ConeBounds : public SurfaceBounds {
0038  public:
0039   enum BoundValues : int {
0040     eAlpha = 0,
0041     eMinZ = 1,
0042     eMaxZ = 2,
0043     eHalfPhiSector = 3,
0044     eAveragePhi = 4,
0045     eSize = 5
0046   };
0047 
0048   ConeBounds() = delete;
0049 
0050   /// Constructor - open cone with alpha, by default a full cone
0051   /// but optionally can make a conical section
0052   ///
0053   /// @param alpha is the opening angle of the cone
0054   /// @param symm is the boolean indicating if the cone is symmetric in +/- z
0055   /// @param halfphi is the half opening angle (default is pi)
0056   /// @param avphi is the phi value around which the bounds are opened
0057   /// (default=0)
0058   ConeBounds(double alpha, bool symm, double halfphi = M_PI,
0059              double avphi = 0.) noexcept(false);
0060 
0061   /// Constructor - open cone with alpha, minz and maxz, by
0062   /// default a full cone but can optionally make it a conical section
0063   ///
0064   /// @param alpha is the opening angle of the cone
0065   /// @param minz cone expanding from minimal z
0066   /// @param maxz cone expanding to maximal z
0067   /// @param halfphi is the half opening angle (default is pi)
0068   /// @param avphi is the phi value around which the bounds are opened
0069   /// (default=0)
0070   ConeBounds(double alpha, double minz, double maxz, double halfphi = M_PI,
0071              double avphi = 0.) noexcept(false);
0072 
0073   /// Constructor - from parameters array
0074   ///
0075   /// @param values The parameter array
0076   ConeBounds(const std::array<double, eSize>& values) noexcept(false);
0077 
0078   ~ConeBounds() override = default;
0079 
0080   BoundsType type() const final;
0081 
0082   /// Return the bound values as dynamically sized vector
0083   ///
0084   /// @return this returns a copy of the internal values
0085   std::vector<double> values() const final;
0086 
0087   /// inside method for local position
0088   ///
0089   /// @param lposition is the local position to be checked
0090   /// @param boundaryTolerance is the boundary check directive
0091   /// @return is a boolean indicating if the position is inside
0092   bool inside(const Vector2& lposition,
0093               const BoundaryTolerance& boundaryTolerance =
0094                   BoundaryTolerance::None()) const final;
0095 
0096   /// Output Method for std::ostream
0097   ///
0098   /// @param sl is the ostrea into which the dump is done
0099   /// @return is the input object
0100   std::ostream& toStream(std::ostream& sl) const final;
0101 
0102   /// Return the radius at a specific z values
0103   ///
0104   /// @param z is the z value for which r is requested
0105   /// @return is the r value associated with z
0106   double r(double z) const;
0107 
0108   /// Return tangent of alpha (pre-computed)
0109   double tanAlpha() const;
0110 
0111   /// Access to the bound values
0112   /// @param bValue the class nested enum for the array access
0113   double get(BoundValues bValue) const { return m_values[bValue]; }
0114 
0115  private:
0116   std::array<double, eSize> m_values;
0117   double m_tanAlpha;
0118 
0119   /// Check the input values for consistency, will throw a logic_exception
0120   /// if consistency is not given
0121   void checkConsistency() noexcept(false);
0122 
0123   /// Private helper function to shift a local 2D position
0124   ///
0125   /// @param lposition The original local position
0126   Vector2 shifted(const Vector2& lposition) const;
0127 };
0128 
0129 inline double ConeBounds::r(double z) const {
0130   return std::abs(z * m_tanAlpha);
0131 }
0132 
0133 inline double ConeBounds::tanAlpha() const {
0134   return m_tanAlpha;
0135 }
0136 
0137 inline std::vector<double> ConeBounds::values() const {
0138   std::vector<double> valvector;
0139   valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
0140   return valvector;
0141 }
0142 
0143 inline void ConeBounds::checkConsistency() noexcept(false) {
0144   if (get(eAlpha) < 0. || get(eAlpha) >= M_PI) {
0145     throw std::invalid_argument("ConeBounds: invalid open angle.");
0146   }
0147   if (get(eMinZ) > get(eMaxZ) ||
0148       std::abs(get(eMinZ) - get(eMaxZ)) < s_epsilon) {
0149     throw std::invalid_argument("ConeBounds: invalid z range setup.");
0150   }
0151   if (get(eHalfPhiSector) < 0. || abs(eHalfPhiSector) > M_PI) {
0152     throw std::invalid_argument("ConeBounds: invalid phi sector setup.");
0153   }
0154   if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
0155     throw std::invalid_argument("ConeBounds: invalid phi positioning.");
0156   }
0157 }
0158 
0159 }  // namespace Acts