Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:23:34

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2020 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Surfaces/BoundaryCheck.hpp"
0013 #include "Acts/Surfaces/PlanarBounds.hpp"
0014 #include "Acts/Surfaces/RectangleBounds.hpp"
0015 #include "Acts/Surfaces/SurfaceBounds.hpp"
0016 #include "Acts/Utilities/detail/periodic.hpp"
0017 
0018 #include <array>
0019 #include <cmath>
0020 #include <cstdlib>
0021 #include <exception>
0022 #include <iosfwd>
0023 #include <stdexcept>
0024 #include <vector>
0025 
0026 namespace Acts {
0027 
0028 /// @class EllipseBounds
0029 ///
0030 /// @image html EllipseBounds.png
0031 ///
0032 /// Class to describe the bounds for a planar ellispoid
0033 /// surface.
0034 ///
0035 /// By providing an argument for hphisec, the bounds can
0036 /// be restricted to a phi-range around the center position.
0037 class EllipseBounds : public PlanarBounds {
0038  public:
0039   enum BoundValues {
0040     eInnerRx = 0,
0041     eInnerRy = 1,
0042     eOuterRx = 2,
0043     eOuterRy = 3,
0044     eHalfPhiSector = 4,
0045     eAveragePhi = 5,
0046     eSize = 6
0047   };
0048 
0049   EllipseBounds() = delete;
0050 
0051   /// Constructor for full of an ellipsoid ring
0052   ///
0053   /// @param innerRx The inner ellipse radius in x
0054   /// @param innerRy The inner ellipse radius in y
0055   /// @param outerRx The outer ellipse radius in x
0056   /// @param outerRy The outer ellipse radius in y
0057   /// @param halfPhi spanning phi sector (is set to pi as default)
0058   /// @param averagePhi average phi (is set to 0. as default)
0059   EllipseBounds(double innerRx, double innerRy, double outerRx, double outerRy,
0060                 double halfPhi = M_PI, double averagePhi = 0.) noexcept(false)
0061       : m_values({innerRx, innerRy, outerRx, outerRy, halfPhi, averagePhi}),
0062         m_boundingBox(m_values[eInnerRy], m_values[eOuterRy]) {
0063     checkConsistency();
0064   }
0065 
0066   /// Constructor - from fixed size array
0067   ///
0068   /// @param values The parameter values
0069   EllipseBounds(const std::array<double, eSize>& values) noexcept(false)
0070       : m_values(values), m_boundingBox(values[eInnerRy], values[eOuterRy]) {
0071     checkConsistency();
0072   }
0073 
0074   ~EllipseBounds() override = default;
0075 
0076   BoundsType type() const final;
0077 
0078   /// Return the bound values as dynamically sized vector
0079   ///
0080   /// @return this returns a copy of the internal values
0081   std::vector<double> values() const final;
0082 
0083   /// This method checks if the point given in the local coordinates is between
0084   /// two ellipsoids if only tol0 is given and additional in the phi sector is
0085   /// tol1 is given
0086   ///
0087   /// @param lposition Local position (assumed to be in right surface frame)
0088   /// @param bcheck boundary check directive
0089   /// @return boolean indicator for the success of this operation
0090   bool inside(const Vector2& lposition,
0091               const BoundaryCheck& bcheck) const final;
0092 
0093   /// Return the vertices
0094   ///
0095   /// @param lseg the number of segments used to approximate
0096   /// and eventually curved line, here it refers to the full 2PI Ellipse
0097   ///
0098   /// @note the number of segments to may be altered by also providing
0099   /// the extremas in all direction
0100   ///
0101   /// @return vector for vertices in 2D
0102   std::vector<Vector2> vertices(unsigned int lseg) const final;
0103 
0104   // Bounding box representation
0105   const RectangleBounds& boundingBox() const final;
0106 
0107   /// Output Method for std::ostream
0108   std::ostream& toStream(std::ostream& sl) const final;
0109 
0110   /// Access to the bound values
0111   /// @param bValue the class nested enum for the array access
0112   double get(BoundValues bValue) const { return m_values[bValue]; }
0113 
0114  private:
0115   std::array<double, eSize> m_values;
0116   RectangleBounds m_boundingBox;
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 inline std::vector<double> EllipseBounds::values() const {
0124   std::vector<double> valvector;
0125   valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
0126   return valvector;
0127 }
0128 
0129 inline void EllipseBounds::checkConsistency() noexcept(false) {
0130   if (get(eInnerRx) >= get(eOuterRx) || get(eInnerRx) < 0. ||
0131       get(eOuterRx) <= 0.) {
0132     throw std::invalid_argument("EllipseBounds: invalid along x axis");
0133   }
0134   if (get(eInnerRy) >= get(eOuterRy) || get(eInnerRy) < 0. ||
0135       get(eOuterRy) <= 0.) {
0136     throw std::invalid_argument("EllipseBounds: invalid along y axis.");
0137   }
0138   if (get(eHalfPhiSector) < 0. || get(eHalfPhiSector) > M_PI) {
0139     throw std::invalid_argument("EllipseBounds: invalid phi sector setup.");
0140   }
0141   if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
0142     throw std::invalid_argument("EllipseBounds: invalid phi positioning.");
0143   }
0144 }
0145 
0146 }  // namespace Acts