File indexing completed on 2025-06-30 08:07:08
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010 #include "Acts/Definitions/Algebra.hpp"
0011 #include "Acts/Definitions/TrackParametrization.hpp"
0012 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0013 #include "Acts/Surfaces/DiscBounds.hpp"
0014 #include "Acts/Surfaces/SurfaceBounds.hpp"
0015 #include "Acts/Utilities/detail/periodic.hpp"
0016
0017 #include <algorithm>
0018 #include <array>
0019 #include <cmath>
0020 #include <iosfwd>
0021 #include <stdexcept>
0022 #include <vector>
0023
0024 namespace Acts {
0025
0026
0027
0028
0029
0030
0031
0032 class DiscTrapezoidBounds : public DiscBounds {
0033 public:
0034 enum BoundValues : int {
0035 eHalfLengthXminR = 0,
0036 eHalfLengthXmaxR = 1,
0037 eMinR = 2,
0038 eMaxR = 3,
0039 eAveragePhi = 4,
0040 eStereo = 5,
0041 eSize = 6
0042 };
0043
0044 DiscTrapezoidBounds() = delete;
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 DiscTrapezoidBounds(double halfXminR, double halfXmaxR, double minR,
0055 double maxR, double avgPhi = M_PI_2,
0056 double stereo = 0.) noexcept(false);
0057
0058
0059
0060
0061 DiscTrapezoidBounds(const std::array<double, eSize>& values) noexcept(false)
0062 : m_values(values) {
0063 checkConsistency();
0064 }
0065
0066 ~DiscTrapezoidBounds() override = default;
0067
0068 SurfaceBounds::BoundsType type() const final;
0069
0070
0071
0072
0073 std::vector<double> values() const final;
0074
0075
0076
0077
0078
0079
0080
0081 bool inside(const Vector2& lposition,
0082 const BoundaryTolerance& boundaryTolerance =
0083 BoundaryTolerance::None()) const final;
0084
0085
0086 std::ostream& toStream(std::ostream& sl) const final;
0087
0088
0089
0090 double get(BoundValues bValue) const { return m_values[bValue]; }
0091
0092
0093 double rMin() const final;
0094
0095
0096 double rMax() const final;
0097
0098
0099 double rCenter() const;
0100
0101
0102 double stereo() const;
0103
0104
0105 double halfPhiSector() const;
0106
0107
0108 double halfLengthY() const;
0109
0110
0111 bool coversFullAzimuth() const final;
0112
0113
0114
0115 bool insideRadialBounds(double R, double tolerance = 0.) const final;
0116
0117
0118 double binningValueR() const final;
0119
0120
0121 double binningValuePhi() const final;
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132 std::vector<Vector2> vertices(unsigned int lseg) const final;
0133
0134 private:
0135 std::array<double, eSize> m_values;
0136
0137
0138 double m_ymax = 0;
0139
0140
0141
0142 void checkConsistency() noexcept(false);
0143
0144
0145
0146
0147
0148 Vector2 toLocalCartesian(const Vector2& lposition) const;
0149
0150
0151
0152
0153
0154 ActsMatrix<2, 2> jacobianToLocalCartesian(const Vector2& lposition) const;
0155 };
0156
0157 inline double DiscTrapezoidBounds::rMin() const {
0158 return get(eMinR);
0159 }
0160
0161 inline double DiscTrapezoidBounds::rMax() const {
0162 return get(eMaxR);
0163 }
0164
0165 inline double DiscTrapezoidBounds::stereo() const {
0166 return get(eStereo);
0167 }
0168
0169 inline double DiscTrapezoidBounds::halfPhiSector() const {
0170 auto minHalfPhi = std::asin(get(eHalfLengthXminR) / get(eMinR));
0171 auto maxHalfPhi = std::asin(get(eHalfLengthXmaxR) / get(eMaxR));
0172 return std::max(minHalfPhi, maxHalfPhi);
0173 }
0174
0175 inline double DiscTrapezoidBounds::rCenter() const {
0176 double rmin = get(eMinR);
0177 double rmax = get(eMaxR);
0178 double hxmin = get(eHalfLengthXminR);
0179 double hxmax = get(eHalfLengthXmaxR);
0180 auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin);
0181 auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax);
0182 return 0.5 * (hmin + hmax);
0183 }
0184
0185 inline double DiscTrapezoidBounds::halfLengthY() const {
0186 double rmin = get(eMinR);
0187 double rmax = get(eMaxR);
0188 double hxmin = get(eHalfLengthXminR);
0189 double hxmax = get(eHalfLengthXmaxR);
0190 auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin);
0191 auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax);
0192 return 0.5 * (hmax - hmin);
0193 }
0194
0195 inline bool DiscTrapezoidBounds::coversFullAzimuth() const {
0196 return false;
0197 }
0198
0199 inline bool DiscTrapezoidBounds::insideRadialBounds(double R,
0200 double tolerance) const {
0201 return (R + tolerance > get(eMinR) && R - tolerance < get(eMaxR));
0202 }
0203
0204 inline double DiscTrapezoidBounds::binningValueR() const {
0205 return 0.5 * (get(eMinR) + get(eMaxR));
0206 }
0207
0208 inline double DiscTrapezoidBounds::binningValuePhi() const {
0209 return get(eAveragePhi);
0210 }
0211
0212 inline std::vector<double> DiscTrapezoidBounds::values() const {
0213 std::vector<double> valvector;
0214 valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
0215 return valvector;
0216 }
0217
0218 inline void DiscTrapezoidBounds::checkConsistency() noexcept(false) {
0219 if (get(eMinR) < 0. || get(eMaxR) <= 0. || get(eMinR) > get(eMaxR)) {
0220 throw std::invalid_argument("DiscTrapezoidBounds: invalid radial setup.");
0221 }
0222 if (get(eHalfLengthXminR) < 0. || get(eHalfLengthXmaxR) <= 0.) {
0223 throw std::invalid_argument("DiscTrapezoidBounds: negative length given.");
0224 }
0225 if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
0226 throw std::invalid_argument(
0227 "DiscTrapezoidBounds: invalid phi positioning.");
0228 }
0229 }
0230
0231 }