Back to home page

EIC code displayed by LXR

 
 

    


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

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