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/Surfaces/BoundaryTolerance.hpp"
0013 #include "Acts/Surfaces/PlanarBounds.hpp"
0014 #include "Acts/Surfaces/RectangleBounds.hpp"
0015 #include "Acts/Surfaces/SurfaceBounds.hpp"
0016 
0017 #include <algorithm>
0018 #include <array>
0019 #include <iosfwd>
0020 #include <vector>
0021 
0022 namespace Acts {
0023 
0024 /// @class DiamondBounds
0025 ///
0026 /// @image html DiamondBounds.svg
0027 /// Bounds for a double trapezoidal ("diamond"), planar Surface.
0028 class DiamondBounds : public PlanarBounds {
0029  public:
0030   enum BoundValues {
0031     eHalfLengthXnegY = 0,
0032     eHalfLengthXzeroY = 1,
0033     eHalfLengthXposY = 2,
0034     eHalfLengthYneg = 3,
0035     eHalfLengthYpos = 4,
0036     eSize = 5
0037   };
0038 
0039   /// Constructor for convex hexagon symmetric about the y axis
0040   ///
0041   /// @param halfXnegY is the halflength in x at minimal y
0042   /// @param halfXzeroY is the halflength in x at y = 0
0043   /// @param halfXposY is the halflength in x at maximal y
0044   /// @param halfYneg is the halflength into y < 0
0045   /// @param halfYpos is the halflength into y > 0
0046   DiamondBounds(double halfXnegY, double halfXzeroY, double halfXposY,
0047                 double halfYneg, double halfYpos) noexcept(false)
0048       : m_values({halfXnegY, halfXzeroY, halfXposY, halfYneg, halfYpos}),
0049         m_boundingBox(
0050             Vector2{
0051                 -(*std::max_element(m_values.begin(), m_values.begin() + 2)),
0052                 -halfYneg},
0053             Vector2{*std::max_element(m_values.begin(), m_values.begin() + 2),
0054                     halfYpos}) {
0055     checkConsistency();
0056   }
0057 
0058   /// Constructor - from fixed size array
0059   ///
0060   /// @param values The parameter values
0061   DiamondBounds(const std::array<double, eSize>& values) noexcept(false)
0062       : m_values(values),
0063         m_boundingBox(
0064             Vector2{-(*std::max_element(values.begin(), values.begin() + 2)),
0065                     -values[eHalfLengthYneg]},
0066             Vector2{*std::max_element(values.begin(), values.begin() + 2),
0067                     values[eHalfLengthYpos]}) {}
0068 
0069   BoundsType type() const final { return SurfaceBounds::eDiamond; }
0070 
0071   /// Return the bound values as dynamically sized vector
0072   ///
0073   /// @return this returns a copy of the internal values
0074   std::vector<double> values() const final;
0075 
0076   /// Inside check for the bounds object driven by the boundary check directive
0077   /// Each Bounds has a method inside, which checks if a LocalPosition is inside
0078   /// the bounds  Inside can be called without/with tolerances.
0079   ///
0080   /// @param lposition Local position (assumed to be in right surface frame)
0081   /// @param boundaryTolerance boundary check directive
0082   /// @return boolean indicator for the success of this operation
0083   bool inside(const Vector2& lposition,
0084               const BoundaryTolerance& boundaryTolerance) const final;
0085 
0086   /// Return the vertices that describe this shape
0087   ///
0088   /// @param ignoredSegments is an ignored parameter only used for
0089   /// curved bound segments
0090   ///
0091   /// @return vector for vertices in 2D
0092   std::vector<Vector2> vertices(unsigned int ignoredSegments = 0u) const final;
0093 
0094   // Bounding box representation
0095   const RectangleBounds& boundingBox() const final;
0096 
0097   /// Output Method for std::ostream
0098   ///
0099   /// @param sl is the ostream in which it is dumped
0100   std::ostream& toStream(std::ostream& sl) const final;
0101 
0102   /// Access to the bound values
0103   /// @param bValue the class nested enum for the array access
0104   double get(BoundValues bValue) const { return m_values[bValue]; }
0105 
0106  private:
0107   std::array<double, eSize> m_values;
0108   RectangleBounds m_boundingBox;  ///< internal bounding box cache
0109 
0110   /// Check the input values for consistency, will throw a logic_exception
0111   /// if consistency is not given
0112   void checkConsistency() noexcept(false);
0113 };
0114 
0115 }  // namespace Acts