Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:03

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