Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:01:52

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/PlanarBounds.hpp"
0013 #include "Acts/Surfaces/RectangleBounds.hpp"
0014 #include "Acts/Surfaces/SurfaceBounds.hpp"
0015 
0016 #include <array>
0017 #include <iosfwd>
0018 #include <numbers>
0019 #include <vector>
0020 
0021 namespace Acts {
0022 
0023 /// @class EllipseBounds
0024 ///
0025 /// @image html EllipseBounds.png
0026 ///
0027 /// Class to describe the bounds for a planar ellispoid
0028 /// surface.
0029 ///
0030 /// By providing an argument for hphisec, the bounds can
0031 /// be restricted to a phi-range around the center position.
0032 class EllipseBounds : public PlanarBounds {
0033  public:
0034   enum BoundValues {
0035     eInnerRx = 0,
0036     eInnerRy = 1,
0037     eOuterRx = 2,
0038     eOuterRy = 3,
0039     eHalfPhiSector = 4,
0040     eAveragePhi = 5,
0041     eSize = 6
0042   };
0043 
0044   /// Constructor for full of an ellipsoid ring
0045   ///
0046   /// @param innerRx The inner ellipse radius in x
0047   /// @param innerRy The inner ellipse radius in y
0048   /// @param outerRx The outer ellipse radius in x
0049   /// @param outerRy The outer ellipse radius in y
0050   /// @param halfPhi spanning phi sector (is set to pi as default)
0051   /// @param averagePhi average phi (is set to 0. as default)
0052   explicit EllipseBounds(double innerRx, double innerRy, double outerRx,
0053                          double outerRy, double halfPhi = std::numbers::pi,
0054                          double averagePhi = 0.) noexcept(false)
0055       : m_values({innerRx, innerRy, outerRx, outerRy, halfPhi, averagePhi}),
0056         m_boundingBox(m_values[eInnerRy], m_values[eOuterRy]) {
0057     checkConsistency();
0058   }
0059 
0060   /// Constructor - from fixed size array
0061   ///
0062   /// @param values The parameter values
0063   explicit EllipseBounds(const std::array<double, eSize>& values) noexcept(
0064       false)
0065       : m_values(values), m_boundingBox(values[eInnerRy], values[eOuterRy]) {
0066     checkConsistency();
0067   }
0068 
0069   /// @copydoc SurfaceBounds::type
0070   BoundsType type() const final { return eEllipse; }
0071 
0072   /// Return the bound values as dynamically sized vector
0073   ///
0074   /// @return this returns a copy of the internal values
0075   std::vector<double> values() const final;
0076 
0077   /// @copydoc SurfaceBounds::inside
0078   bool inside(const Vector2& lposition) const final;
0079 
0080   /// @copydoc SurfaceBounds::closestPoint
0081   Vector2 closestPoint(const Vector2& lposition,
0082                        const SquareMatrix2& metric) const final;
0083 
0084   using SurfaceBounds::inside;
0085 
0086   /// @copydoc SurfaceBounds::center
0087   Vector2 center() const final;
0088 
0089   /// Return the vertices
0090   ///
0091   /// @param quarterSegments is the number of segments to approximate a quarter
0092   /// of a circle. In order to symmetrize fully closed and sectoral cylinders,
0093   /// also in the first case the two end points are given (albeit they overlap)
0094   /// in -pi / pi
0095   ///
0096   /// @return vector for vertices in 2D
0097   std::vector<Vector2> vertices(unsigned int quarterSegments) const final;
0098 
0099   // Bounding box representation
0100   const RectangleBounds& boundingBox() const final;
0101 
0102   /// Output Method for std::ostream
0103   std::ostream& toStream(std::ostream& sl) const final;
0104 
0105   /// Access to the bound values
0106   /// @param bValue the class nested enum for the array access
0107   double get(BoundValues bValue) const { return m_values[bValue]; }
0108 
0109  private:
0110   std::array<double, eSize> m_values;
0111   RectangleBounds m_boundingBox;
0112 
0113   /// Check the input values for consistency, will throw a logic_exception
0114   /// if consistency is not given
0115   void checkConsistency() noexcept(false);
0116 };
0117 
0118 }  // namespace Acts