Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-09 07:49:46

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/DiscBounds.hpp"
0014 #include "Acts/Surfaces/SurfaceBounds.hpp"
0015 
0016 #include <array>
0017 #include <iosfwd>
0018 #include <numbers>
0019 #include <vector>
0020 
0021 namespace Acts {
0022 
0023 /// @class RadialBounds
0024 ///
0025 /// Class to describe the bounds for a planar DiscSurface.
0026 /// By providing an argument for hphisec, the bounds can
0027 /// be restricted to a phi-range around the center position.
0028 ///
0029 class RadialBounds : public DiscBounds {
0030  public:
0031   enum BoundValues {
0032     eMinR = 0,
0033     eMaxR = 1,
0034     eHalfPhiSector = 2,
0035     eAveragePhi = 3,
0036     eSize = 4
0037   };
0038 
0039   /// Constructor for full disc of symmetric disc around phi=0
0040   ///
0041   /// @param minR The inner radius (0 for full disc)
0042   /// @param maxR The outer radius
0043   /// @param halfPhi The half opening angle (Pi for full angular coverage)
0044   /// @param avgPhi The average phi for the disc/ring sector
0045   explicit RadialBounds(double minR, double maxR,
0046                         double halfPhi = std::numbers::pi,
0047                         double avgPhi = 0.) noexcept(false)
0048       : m_values({minR, maxR, halfPhi, avgPhi}) {
0049     checkConsistency();
0050   }
0051 
0052   /// Constructor from array values
0053   ///
0054   /// @param values The bound values
0055   explicit RadialBounds(const std::array<double, eSize>& values) noexcept(false)
0056       : m_values(values) {
0057     checkConsistency();
0058   }
0059 
0060   BoundsType type() const final { return SurfaceBounds::eDisc; }
0061 
0062   /// Return the bound values as dynamically sized vector
0063   ///
0064   /// @return this returns a copy of the internal values
0065   std::vector<double> values() const final;
0066 
0067   /// For disc surfaces the local position in (r,phi) is checked
0068   ///
0069   /// @param lposition local position to be checked
0070   /// @param boundaryTolerance boundary check directive
0071   ///
0072   /// @return is a boolean indicating the operation success
0073   bool inside(const Vector2& lposition,
0074               const BoundaryTolerance& boundaryTolerance) const final;
0075 
0076   /// Outstream operator
0077   ///
0078   /// @param sl is the ostream to be dumped into
0079   std::ostream& toStream(std::ostream& sl) const final;
0080 
0081   /// Return method for inner Radius
0082   double rMin() const final { return get(eMinR); }
0083 
0084   /// Return method for outer Radius
0085   double rMax() const final { return get(eMaxR); }
0086 
0087   /// Access to the bound values
0088   /// @param bValue the class nested enum for the array access
0089   double get(BoundValues bValue) const { return m_values[bValue]; }
0090 
0091   /// Returns true for full phi coverage
0092   bool coversFullAzimuth() const final {
0093     return (get(eHalfPhiSector) == std::numbers::pi);
0094   }
0095 
0096   /// Checks if this is inside the radial coverage
0097   /// given the a tolerance
0098   bool insideRadialBounds(double R, double tolerance = 0.) const final {
0099     return (R + tolerance > get(eMinR) && R - tolerance < get(eMaxR));
0100   }
0101 
0102   /// Return a reference radius for binning
0103   double binningValueR() const final { return 0.5 * (get(eMinR) + get(eMaxR)); }
0104 
0105   /// Return a reference radius for binning
0106   double binningValuePhi() const final { return get(eAveragePhi); }
0107 
0108  private:
0109   std::array<double, eSize> m_values;
0110 
0111   /// Check the input values for consistency, will throw a logic_exception
0112   /// if consistency is not given
0113   void checkConsistency() noexcept(false);
0114 
0115   /// Private helper method to shift a local position
0116   /// within the bounds
0117   ///
0118   /// @param lposition The local position in polar coordinates
0119   Vector2 shifted(const Vector2& lposition) const;
0120 
0121   /// This method returns the xy coordinates of vertices along
0122   /// the radial bounds
0123   ///
0124   /// @param lseg the number of segments used to approximate
0125   /// and eventually curved line
0126   ///
0127   /// @note that the extremas are given, which may slightly alter the
0128   /// number of segments returned
0129   ///
0130   /// @return vector for vertices in 2D
0131   std::vector<Vector2> vertices(unsigned int lseg) const final;
0132 };
0133 
0134 }  // namespace Acts