Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-15 08:12: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/Surfaces/BoundaryTolerance.hpp"
0013 #include "Acts/Surfaces/PlanarBounds.hpp"
0014 #include "Acts/Surfaces/RectangleBounds.hpp"
0015 #include "Acts/Surfaces/SurfaceBounds.hpp"
0016 
0017 #include <array>
0018 #include <iosfwd>
0019 #include <numbers>
0020 #include <vector>
0021 
0022 namespace Acts {
0023 
0024 /// @class EllipseBounds
0025 ///
0026 /// @image html EllipseBounds.png
0027 ///
0028 /// Class to describe the bounds for a planar ellispoid
0029 /// surface.
0030 ///
0031 /// By providing an argument for hphisec, the bounds can
0032 /// be restricted to a phi-range around the center position.
0033 class EllipseBounds : public PlanarBounds {
0034  public:
0035   enum BoundValues {
0036     eInnerRx = 0,
0037     eInnerRy = 1,
0038     eOuterRx = 2,
0039     eOuterRy = 3,
0040     eHalfPhiSector = 4,
0041     eAveragePhi = 5,
0042     eSize = 6
0043   };
0044 
0045   /// Constructor for full of an ellipsoid ring
0046   ///
0047   /// @param innerRx The inner ellipse radius in x
0048   /// @param innerRy The inner ellipse radius in y
0049   /// @param outerRx The outer ellipse radius in x
0050   /// @param outerRy The outer ellipse radius in y
0051   /// @param halfPhi spanning phi sector (is set to pi as default)
0052   /// @param averagePhi average phi (is set to 0. as default)
0053   explicit EllipseBounds(double innerRx, double innerRy, double outerRx,
0054                          double outerRy, double halfPhi = std::numbers::pi,
0055                          double averagePhi = 0.) noexcept(false)
0056       : m_values({innerRx, innerRy, outerRx, outerRy, halfPhi, averagePhi}),
0057         m_boundingBox(m_values[eInnerRy], m_values[eOuterRy]) {
0058     checkConsistency();
0059   }
0060 
0061   /// Constructor - from fixed size array
0062   ///
0063   /// @param values The parameter values
0064   explicit EllipseBounds(const std::array<double, eSize>& values) noexcept(
0065       false)
0066       : m_values(values), m_boundingBox(values[eInnerRy], values[eOuterRy]) {
0067     checkConsistency();
0068   }
0069 
0070   BoundsType type() const final { return SurfaceBounds::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   /// This method checks if the point given in the local coordinates is between
0078   /// two ellipsoids if only tol0 is given and additional in the phi sector is
0079   /// tol1 is given
0080   ///
0081   /// @warning This **only** works for tolerance-based checks
0082   ///
0083   /// @param lposition Local position (assumed to be in right surface frame)
0084   /// @param boundaryTolerance boundary check directive
0085   /// @return boolean indicator for the success of this operation
0086   bool inside(const Vector2& lposition,
0087               const BoundaryTolerance& boundaryTolerance) 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