File indexing completed on 2025-01-19 09:23:34
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/BoundaryCheck.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 BoundaryCheck& bcheck = BoundaryCheck(true)) const final;
0083
0084
0085 std::ostream& toStream(std::ostream& sl) const final;
0086
0087
0088
0089 double get(BoundValues bValue) const { return m_values[bValue]; }
0090
0091
0092 double rMin() const final;
0093
0094
0095 double rMax() const final;
0096
0097
0098 double rCenter() const;
0099
0100
0101 double stereo() const;
0102
0103
0104 double halfPhiSector() const;
0105
0106
0107 double halfLengthY() const;
0108
0109
0110 bool coversFullAzimuth() const final;
0111
0112
0113
0114 bool insideRadialBounds(double R, double tolerance = 0.) const final;
0115
0116
0117 double binningValueR() const final;
0118
0119
0120 double binningValuePhi() const final;
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131 std::vector<Vector2> vertices(unsigned int lseg) const final;
0132
0133 private:
0134 std::array<double, eSize> m_values;
0135
0136
0137 double m_ymax = 0;
0138
0139
0140
0141 void checkConsistency() noexcept(false);
0142
0143
0144
0145
0146
0147 Vector2 toLocalCartesian(const Vector2& lposition) const;
0148
0149
0150
0151
0152
0153 ActsMatrix<2, 2> jacobianToLocalCartesian(const Vector2& lposition) const;
0154 };
0155
0156 inline double DiscTrapezoidBounds::rMin() const {
0157 return get(eMinR);
0158 }
0159
0160 inline double DiscTrapezoidBounds::rMax() const {
0161 return get(eMaxR);
0162 }
0163
0164 inline double DiscTrapezoidBounds::stereo() const {
0165 return get(eStereo);
0166 }
0167
0168 inline double DiscTrapezoidBounds::halfPhiSector() const {
0169 auto minHalfPhi = std::asin(get(eHalfLengthXminR) / get(eMinR));
0170 auto maxHalfPhi = std::asin(get(eHalfLengthXmaxR) / get(eMaxR));
0171 return std::max(minHalfPhi, maxHalfPhi);
0172 }
0173
0174 inline double DiscTrapezoidBounds::rCenter() const {
0175 double rmin = get(eMinR);
0176 double rmax = get(eMaxR);
0177 double hxmin = get(eHalfLengthXminR);
0178 double hxmax = get(eHalfLengthXmaxR);
0179 auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin);
0180 auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax);
0181 return 0.5 * (hmin + hmax);
0182 }
0183
0184 inline double DiscTrapezoidBounds::halfLengthY() const {
0185 double rmin = get(eMinR);
0186 double rmax = get(eMaxR);
0187 double hxmin = get(eHalfLengthXminR);
0188 double hxmax = get(eHalfLengthXmaxR);
0189 auto hmin = std::sqrt(rmin * rmin - hxmin * hxmin);
0190 auto hmax = std::sqrt(rmax * rmax - hxmax * hxmax);
0191 return 0.5 * (hmax - hmin);
0192 }
0193
0194 inline bool DiscTrapezoidBounds::coversFullAzimuth() const {
0195 return false;
0196 }
0197
0198 inline bool DiscTrapezoidBounds::insideRadialBounds(double R,
0199 double tolerance) const {
0200 return (R + tolerance > get(eMinR) && R - tolerance < get(eMaxR));
0201 }
0202
0203 inline double DiscTrapezoidBounds::binningValueR() const {
0204 return 0.5 * (get(eMinR) + get(eMaxR));
0205 }
0206
0207 inline double DiscTrapezoidBounds::binningValuePhi() const {
0208 return get(eAveragePhi);
0209 }
0210
0211 inline std::vector<double> DiscTrapezoidBounds::values() const {
0212 std::vector<double> valvector;
0213 valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
0214 return valvector;
0215 }
0216
0217 inline void DiscTrapezoidBounds::checkConsistency() noexcept(false) {
0218 if (get(eMinR) < 0. || get(eMaxR) <= 0. || get(eMinR) > get(eMaxR)) {
0219 throw std::invalid_argument("DiscTrapezoidBounds: invalid radial setup.");
0220 }
0221 if (get(eHalfLengthXminR) < 0. || get(eHalfLengthXmaxR) <= 0.) {
0222 throw std::invalid_argument("DiscTrapezoidBounds: negative length given.");
0223 }
0224 if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
0225 throw std::invalid_argument(
0226 "DiscTrapezoidBounds: invalid phi positioning.");
0227 }
0228 }
0229
0230 }