Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-10 09:40:25

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 <algorithm>
0017 #include <array>
0018 #include <iosfwd>
0019 #include <vector>
0020 
0021 namespace Acts {
0022 
0023 /// @class DiamondBounds
0024 ///
0025 /// @image html DiamondBounds.svg
0026 /// Bounds for a double trapezoidal ("diamond"), planar Surface.
0027 class DiamondBounds : public PlanarBounds {
0028  public:
0029   /// @enum BoundValues
0030   /// Enumeration for the bound values
0031   enum BoundValues {
0032     eHalfLengthXnegY = 0,
0033     eHalfLengthXzeroY = 1,
0034     eHalfLengthXposY = 2,
0035     eHalfLengthYneg = 3,
0036     eHalfLengthYpos = 4,
0037     eSize = 5
0038   };
0039 
0040   /// Constructor for convex hexagon symmetric about the y axis
0041   ///
0042   /// @param halfXnegY is the halflength in x at minimal y
0043   /// @param halfXzeroY is the halflength in x at y = 0
0044   /// @param halfXposY is the halflength in x at maximal y
0045   /// @param halfYneg is the halflength into y < 0
0046   /// @param halfYpos is the halflength into y > 0
0047   DiamondBounds(double halfXnegY, double halfXzeroY, double halfXposY,
0048                 double halfYneg, double halfYpos) noexcept(false)
0049       : m_values({halfXnegY, halfXzeroY, halfXposY, halfYneg, halfYpos}),
0050         m_boundingBox(
0051             Vector2{
0052                 -(*std::max_element(m_values.begin(), m_values.begin() + 2)),
0053                 -halfYneg},
0054             Vector2{*std::max_element(m_values.begin(), m_values.begin() + 2),
0055                     halfYpos}) {
0056     checkConsistency();
0057   }
0058 
0059   /// Constructor - from fixed size array
0060   ///
0061   /// @param values The parameter values
0062   explicit DiamondBounds(const std::array<double, eSize>& values) noexcept(
0063       false)
0064       : m_values(values),
0065         m_boundingBox(
0066             Vector2{-(*std::max_element(values.begin(), values.begin() + 2)),
0067                     -values[eHalfLengthYneg]},
0068             Vector2{*std::max_element(values.begin(), values.begin() + 2),
0069                     values[eHalfLengthYpos]}) {}
0070 
0071   /// @copydoc SurfaceBounds::type
0072   BoundsType type() const final { return eDiamond; }
0073 
0074   /// Return the bound values as dynamically sized vector
0075   ///
0076   /// @return this returns a copy of the internal values
0077   std::vector<double> values() const final;
0078 
0079   /// @copydoc SurfaceBounds::inside
0080   bool inside(const Vector2& lposition) const final;
0081 
0082   /// @copydoc SurfaceBounds::closestPoint
0083   Vector2 closestPoint(const Vector2& lposition,
0084                        const SquareMatrix2& metric) const final;
0085 
0086   using SurfaceBounds::inside;
0087 
0088   /// @copydoc SurfaceBounds::center
0089   /// @note For DiamondBounds: returns center of symmetry (0,0)
0090   Vector2 center() const final;
0091 
0092   /// Return the vertices that describe this shape
0093   ///
0094   /// @param ignoredSegments is an ignored parameter only used for
0095   /// curved bound segments
0096   ///
0097   /// @return vector for vertices in 2D
0098   std::vector<Vector2> vertices(unsigned int ignoredSegments = 0u) const final;
0099 
0100   // Bounding box representation
0101   const RectangleBounds& boundingBox() const final;
0102 
0103   /// Output Method for std::ostream
0104   ///
0105   /// @param sl is the ostream in which it is dumped
0106   /// @return Reference to the output stream after writing
0107   std::ostream& toStream(std::ostream& sl) const final;
0108 
0109   /// Access to the bound values
0110   /// @param bValue the class nested enum for the array access
0111   /// @return Value of the specified bound parameter
0112   double get(BoundValues bValue) const { return m_values[bValue]; }
0113 
0114  private:
0115   std::array<double, eSize> m_values;
0116   RectangleBounds m_boundingBox;  ///< internal bounding box cache
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 
0123 }  // namespace Acts