Back to home page

EIC code displayed by LXR

 
 

    


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

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/SurfaceBounds.hpp"
0015 
0016 #include <array>
0017 #include <iosfwd>
0018 #include <vector>
0019 
0020 namespace Acts {
0021 
0022 /// @class RectangleBounds
0023 ///
0024 /// @image html RectangleBounds.gif
0025 ///
0026 /// Bounds for a rectangular, planar surface - it can be used to for
0027 /// rectangles that are symmetrically centered around (0./0.) and for
0028 /// generic shifted rectangles
0029 class RectangleBounds : public PlanarBounds {
0030  public:
0031   enum BoundValues : int {
0032     eMinX = 0,
0033     eMinY = 1,
0034     eMaxX = 2,
0035     eMaxY = 3,
0036     eSize = 4
0037   };
0038 
0039   /// Constructor with halflength in x and y - symmetric
0040   ///
0041   /// @param halfX halflength in X
0042   /// @param halfY halflength in Y
0043   RectangleBounds(double halfX, double halfY) noexcept(false)
0044       : m_min({-halfX, -halfY}), m_max({halfX, halfY}) {
0045     checkConsistency();
0046   }
0047 
0048   /// Constructor - from fixed size array - generic
0049   ///
0050   /// @param values The parameter values
0051   RectangleBounds(const std::array<double, eSize>& values) noexcept(false)
0052       : m_min({values[eMinX], values[eMinY]}),
0053         m_max({values[eMaxX], values[eMaxY]}) {
0054     checkConsistency();
0055   }
0056 
0057   /// Constructor - from min/max - generic
0058   ///
0059   /// @param min The left bottom corner
0060   /// @param max The right top corning
0061   RectangleBounds(const Vector2& min, const Vector2& max) noexcept(false)
0062       : m_min(min), m_max(max) {
0063     checkConsistency();
0064   }
0065 
0066   BoundsType type() const final { return SurfaceBounds::eRectangle; }
0067 
0068   std::vector<double> values() const final {
0069     return {m_min.x(), m_min.y(), m_max.x(), m_max.y()};
0070   }
0071 
0072   /// Inside check for the bounds object driven by the boundary check directive
0073   /// Each Bounds has a method inside, which checks if a LocalPosition is inside
0074   /// the bounds  Inside can be called without/with tolerances.
0075   ///
0076   /// @param lposition Local position (assumed to be in right surface frame)
0077   /// @param boundaryTolerance boundary check directive
0078   /// @return boolean indicator for the success of this operation
0079   bool inside(const Vector2& lposition,
0080               const BoundaryTolerance& boundaryTolerance) const final;
0081 
0082   /// Return the vertices
0083   ///
0084   /// @param quarterSegments is the number of segments used to describe curved
0085   /// segments in a quarter of the phi range.
0086   /// @note the number of segments is ignored in this representation
0087   ///
0088   /// @return vector for vertices in 2D
0089   std::vector<Vector2> vertices(unsigned int quarterSegments = 0u) const final;
0090 
0091   // Bounding box representation
0092   const RectangleBounds& boundingBox() const final;
0093 
0094   /// Output Method for std::ostream
0095   ///
0096   /// @param sl is the ostream for the dump
0097   std::ostream& toStream(std::ostream& sl) const final;
0098 
0099   /// Access to the bound values
0100   /// @param bValue the class nested enum for the array access
0101   double get(BoundValues bValue) const;
0102 
0103   /// Access to the half length in X
0104   double halfLengthX() const { return 0.5 * (m_max.x() - m_min.x()); }
0105 
0106   /// Access to the half length in Y
0107   double halfLengthY() const { return 0.5 * (m_max.y() - m_min.y()); }
0108 
0109   /// Get the min vertex defining the bounds
0110   /// @return The min vertex
0111   const Vector2& min() const { return m_min; }
0112 
0113   /// Get the max vertex defining the bounds
0114   /// @return The max vertex
0115   const Vector2& max() const { return m_max; }
0116 
0117  private:
0118   Vector2 m_min;
0119   Vector2 m_max;
0120 
0121   /// Check the input values for consistency, will throw a logic_exception
0122   /// if consistency is not given
0123   void checkConsistency() noexcept(false);
0124 };
0125 
0126 }  // namespace Acts