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 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Tolerance.hpp"
0013 #include "Acts/Surfaces/BoundaryCheck.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 bcheck is the boundary check directive
0091   /// @return is a boolean indicating if the position is inside
0092   bool inside(const Vector2& lposition,
0093               const BoundaryCheck& bcheck = BoundaryCheck(true)) const final;
0094 
0095   /// Output Method for std::ostream
0096   ///
0097   /// @param sl is the ostrea into which the dump is done
0098   /// @return is the input object
0099   std::ostream& toStream(std::ostream& sl) const final;
0100 
0101   /// Return the radius at a specific z values
0102   ///
0103   /// @param z is the z value for which r is requested
0104   /// @return is the r value associated with z
0105   double r(double z) const;
0106 
0107   /// Return tangent of alpha (pre-computed)
0108   double tanAlpha() const;
0109 
0110   /// Access to the bound values
0111   /// @param bValue the class nested enum for the array access
0112   double get(BoundValues bValue) const { return m_values[bValue]; }
0113 
0114  private:
0115   std::array<double, eSize> m_values;
0116   double m_tanAlpha;
0117 
0118   /// Check the input values for consistency, will throw a logic_exception
0119   /// if consistency is not given
0120   void checkConsistency() noexcept(false);
0121 
0122   /// Private helper function to shift a local 2D position
0123   ///
0124   /// @param lposition The original local position
0125   Vector2 shifted(const Vector2& lposition) const;
0126 };
0127 
0128 inline double ConeBounds::r(double z) const {
0129   return std::abs(z * m_tanAlpha);
0130 }
0131 
0132 inline double ConeBounds::tanAlpha() const {
0133   return m_tanAlpha;
0134 }
0135 
0136 inline std::vector<double> ConeBounds::values() const {
0137   std::vector<double> valvector;
0138   valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
0139   return valvector;
0140 }
0141 
0142 inline void ConeBounds::checkConsistency() noexcept(false) {
0143   if (get(eAlpha) < 0. || get(eAlpha) >= M_PI) {
0144     throw std::invalid_argument("ConeBounds: invalid open angle.");
0145   }
0146   if (get(eMinZ) > get(eMaxZ) ||
0147       std::abs(get(eMinZ) - get(eMaxZ)) < s_epsilon) {
0148     throw std::invalid_argument("ConeBounds: invalid z range setup.");
0149   }
0150   if (get(eHalfPhiSector) < 0. || abs(eHalfPhiSector) > M_PI) {
0151     throw std::invalid_argument("ConeBounds: invalid phi sector setup.");
0152   }
0153   if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
0154     throw std::invalid_argument("ConeBounds: invalid phi positioning.");
0155   }
0156 }
0157 
0158 }  // namespace Acts