Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-01 08:08:01

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2024 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 <cstddef>
0020 #include <iostream>
0021 #include <stdexcept>
0022 #include <vector>
0023 
0024 namespace Acts {
0025 
0026 /// @class CylinderBounds
0027 /// @image html CylinderBounds.gif
0028 ///
0029 /// Bounds for a cylindrical Surface.
0030 ///
0031 /// These bounds may be used for a CylinderSurface
0032 /// In case of bounds for a StraightLineSurface the radius determines the radius
0033 /// within a localPosition
0034 /// is regarded as inside bounds.
0035 ///
0036 /// CylinderBounds also enhance the possibility of a cylinder segment with an
0037 /// opening angle @f$ 2\cdot\phi_{half}@f$
0038 /// around an average @f$ \phi @f$ angle @f$ \phi_{ave} @f$.
0039 ///
0040 /// CylinderBounds also supports beveled sides defined by an angle.
0041 /// Different angles can be defined on both sides of the cylinder.
0042 /// A positive angle is defined as "extruding" from the defined Zlength,
0043 /// while a negative angle is "intruding" on the Zlength.
0044 /// +    -            -   +
0045 /// ________________________
0046 /// \  |  /          \  |  /
0047 ///  \ | /            \ | /
0048 ///   \|/______________\|/
0049 ///     2 * ZhalfLength
0050 class CylinderBounds : public SurfaceBounds {
0051  public:
0052   enum BoundValues : int {
0053     eR = 0,
0054     eHalfLengthZ = 1,
0055     eHalfPhiSector = 2,
0056     eAveragePhi = 3,
0057     eBevelMinZ = 4,
0058     eBevelMaxZ = 5,
0059     eSize = 6
0060   };
0061 
0062   CylinderBounds() = delete;
0063 
0064   /// Constructor - full cylinder
0065   ///
0066   /// @param r The radius of the cylinder
0067   /// @param halfZ The half length in z
0068   /// @param halfPhi The half opening angle
0069   /// @param avgPhi (optional) The phi value from which the opening angle spans
0070   /// @param bevelMinZ (optional) The bevel on the negative z side
0071   /// @param bevelMaxZ (optional) The bevel on the positive z sid The bevel on the positive z side
0072   CylinderBounds(double r, double halfZ, double halfPhi = M_PI,
0073                  double avgPhi = 0., double bevelMinZ = 0.,
0074                  double bevelMaxZ = 0.) noexcept(false)
0075       : m_values({r, halfZ, halfPhi, avgPhi, bevelMinZ, bevelMaxZ}),
0076         m_closed(std::abs(halfPhi - M_PI) < s_epsilon) {
0077     checkConsistency();
0078   }
0079 
0080   /// Constructor - from fixed size array
0081   ///
0082   /// @param values The parameter values
0083   CylinderBounds(const std::array<double, eSize>& values) noexcept(false)
0084       : m_values(values),
0085         m_closed(std::abs(values[eHalfPhiSector] - M_PI) < s_epsilon) {
0086     checkConsistency();
0087   }
0088 
0089   ~CylinderBounds() override = default;
0090 
0091   BoundsType type() const final;
0092 
0093   /// Return the bound values as dynamically sized vector
0094   ///
0095   /// @return this returns a copy of the internal values
0096   std::vector<double> values() const final;
0097 
0098   /// Inside check for the bounds object driven by the boundary check directive
0099   /// Each Bounds has a method inside, which checks if a LocalPosition is inside
0100   /// the bounds  Inside can be called without/with tolerances.
0101   ///
0102   /// @param lposition Local position (assumed to be in right surface frame)
0103   /// @param boundaryTolerance boundary check tolerance directive
0104   /// @return boolean indicator for the success of this operation
0105   bool inside(const Vector2& lposition,
0106               const BoundaryTolerance& boundaryTolerance) const final;
0107 
0108   /// Access to the bound values
0109   /// @param bValue the class nested enum for the array access
0110   double get(BoundValues bValue) const { return m_values[bValue]; }
0111 
0112   /// Returns true for full phi coverage
0113   bool coversFullAzimuth() const;
0114 
0115   /// Create the bows/circles on either side of the cylinder
0116   ///
0117   /// @param trans is the global transform
0118   /// @param lseg  are the numbero if phi segments
0119   std::vector<Vector3> createCircles(const Transform3 trans,
0120                                      std::size_t lseg) const;
0121 
0122   /// Output Method for std::ostream
0123   std::ostream& toStream(std::ostream& sl) const final;
0124 
0125  private:
0126   /// The bound radius, half Z, half phi and average phi
0127   std::array<double, eSize> m_values;
0128   /// Indicator if the bounds are closed
0129   bool m_closed{false};
0130 
0131   /// Check the input values for consistency, will throw a logic_exception
0132   /// if consistency is not given
0133   void checkConsistency() noexcept(false);
0134 
0135   /// Helper method to shift into the phi-frame
0136   /// @param lposition the polar coordinates in the global frame
0137   Vector2 shifted(const Vector2& lposition) const;
0138 
0139   /// Return the jacobian into the polar coordinate
0140   ActsMatrix<2, 2> jacobian() const;
0141 };
0142 
0143 inline std::vector<double> CylinderBounds::values() const {
0144   std::vector<double> valvector;
0145   valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
0146   return valvector;
0147 }
0148 
0149 inline bool CylinderBounds::coversFullAzimuth() const {
0150   return m_closed;
0151 }
0152 
0153 }  // namespace Acts