File indexing completed on 2025-08-05 08:09:23
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Tolerance.hpp"
0013 #include "Acts/Surfaces/BoundaryCheck.hpp"
0014 #include "Acts/Surfaces/SurfaceBounds.hpp"
0015 #include "Acts/Utilities/detail/periodic.hpp"
0016
0017 #include <array>
0018 #include <cmath>
0019 #include <cstddef>
0020 #include <iostream>
0021 #include <stdexcept>
0022 #include <vector>
0023
0024 namespace Acts {
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 class CylinderBounds : public SurfaceBounds {
0051 public:
0052 enum BoundValues : int {
0053 eR = 0,
0054 eHalfLengthZ = 1,
0055 eHalfPhiSector = 2,
0056 eAveragePhi = 3,
0057 eBevelMinZ = 4,
0058 eBevelMaxZ = 5,
0059 eSize = 6
0060 };
0061
0062 CylinderBounds() = delete;
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072 CylinderBounds(double r, double halfZ, double halfPhi = M_PI,
0073 double avgPhi = 0., double bevelMinZ = 0.,
0074 double bevelMaxZ = 0.) noexcept(false)
0075 : m_values({r, halfZ, halfPhi, avgPhi, bevelMinZ, bevelMaxZ}),
0076 m_closed(std::abs(halfPhi - M_PI) < s_epsilon) {
0077 checkConsistency();
0078 }
0079
0080
0081
0082
0083 CylinderBounds(const std::array<double, eSize>& values) noexcept(false)
0084 : m_values(values),
0085 m_closed(std::abs(values[eHalfPhiSector] - M_PI) < s_epsilon) {
0086 checkConsistency();
0087 }
0088
0089 ~CylinderBounds() override = default;
0090
0091 BoundsType type() const final;
0092
0093
0094
0095
0096 std::vector<double> values() const final;
0097
0098
0099
0100
0101
0102
0103
0104
0105 bool inside(const Vector2& lposition,
0106 const BoundaryCheck& bcheck) const final;
0107
0108
0109
0110
0111
0112
0113
0114 bool inside3D(const Vector3& position,
0115 const BoundaryCheck& bcheck = BoundaryCheck(true)) const;
0116
0117
0118
0119 double get(BoundValues bValue) const { return m_values[bValue]; }
0120
0121
0122 bool coversFullAzimuth() const;
0123
0124
0125
0126
0127
0128 std::vector<Vector3> createCircles(const Transform3 trans,
0129 std::size_t lseg) const;
0130
0131
0132 std::ostream& toStream(std::ostream& sl) const final;
0133
0134 private:
0135
0136 std::array<double, eSize> m_values;
0137
0138 bool m_closed{false};
0139
0140
0141
0142 void checkConsistency() noexcept(false);
0143
0144
0145
0146 Vector2 shifted(const Vector2& lposition) const;
0147
0148
0149 ActsMatrix<2, 2> jacobian() const;
0150 };
0151
0152 inline std::vector<double> CylinderBounds::values() const {
0153 std::vector<double> valvector;
0154 valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
0155 return valvector;
0156 }
0157
0158 inline bool CylinderBounds::coversFullAzimuth() const {
0159 return m_closed;
0160 }
0161
0162 inline void CylinderBounds::checkConsistency() noexcept(false) {
0163 if (get(eR) <= 0.) {
0164 throw std::invalid_argument("CylinderBounds: invalid radial setup.");
0165 }
0166 if (get(eHalfLengthZ) <= 0.) {
0167 throw std::invalid_argument("CylinderBounds: invalid length setup.");
0168 }
0169 if (get(eHalfPhiSector) <= 0. || get(eHalfPhiSector) > M_PI) {
0170 throw std::invalid_argument("CylinderBounds: invalid phi sector setup.");
0171 }
0172 if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
0173 throw std::invalid_argument("CylinderBounds: invalid phi positioning.");
0174 }
0175 if (get(eBevelMinZ) != detail::radian_sym(get(eBevelMinZ))) {
0176 throw std::invalid_argument("CylinderBounds: invalid bevel at min Z.");
0177 }
0178 if (get(eBevelMaxZ) != detail::radian_sym(get(eBevelMaxZ))) {
0179 throw std::invalid_argument("CylinderBounds: invalid bevel at max Z.");
0180 }
0181 }
0182
0183 }