File indexing completed on 2025-01-19 09:23:34
0001
0002
0003
0004
0005
0006
0007
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/PlanarBounds.hpp"
0015 #include "Acts/Surfaces/RectangleBounds.hpp"
0016 #include "Acts/Surfaces/SurfaceBounds.hpp"
0017
0018 #include <algorithm>
0019 #include <array>
0020 #include <cmath>
0021 #include <iosfwd>
0022 #include <stdexcept>
0023 #include <vector>
0024
0025 namespace Acts {
0026
0027
0028
0029
0030
0031 class DiamondBounds : public PlanarBounds {
0032 public:
0033 enum BoundValues {
0034 eHalfLengthXnegY = 0,
0035 eHalfLengthXzeroY = 1,
0036 eHalfLengthXposY = 2,
0037 eHalfLengthYneg = 3,
0038 eHalfLengthYpos = 4,
0039 eSize = 5
0040 };
0041
0042 DiamondBounds() = delete;
0043
0044
0045
0046
0047
0048
0049
0050
0051 DiamondBounds(double halfXnegY, double halfXzeroY, double halfXposY,
0052 double halfYneg, double halfYpos) noexcept(false)
0053 : m_values({halfXnegY, halfXzeroY, halfXposY, halfYneg, halfYpos}),
0054 m_boundingBox(
0055 Vector2{
0056 -(*std::max_element(m_values.begin(), m_values.begin() + 2)),
0057 -halfYneg},
0058 Vector2{*std::max_element(m_values.begin(), m_values.begin() + 2),
0059 halfYpos}) {
0060 checkConsistency();
0061 }
0062
0063
0064
0065
0066 DiamondBounds(const std::array<double, eSize>& values) noexcept(false)
0067 : m_values(values),
0068 m_boundingBox(
0069 Vector2{-(*std::max_element(values.begin(), values.begin() + 2)),
0070 -values[eHalfLengthYneg]},
0071 Vector2{*std::max_element(values.begin(), values.begin() + 2),
0072 values[eHalfLengthYpos]}) {}
0073
0074 ~DiamondBounds() override = default;
0075
0076 BoundsType type() const final;
0077
0078
0079
0080
0081 std::vector<double> values() const final;
0082
0083
0084
0085
0086
0087
0088
0089
0090 bool inside(const Vector2& lposition,
0091 const BoundaryCheck& bcheck) const final;
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101 std::vector<Vector2> vertices(unsigned int lseg = 1) const final;
0102
0103
0104 const RectangleBounds& boundingBox() const final;
0105
0106
0107
0108
0109 std::ostream& toStream(std::ostream& sl) const final;
0110
0111
0112
0113 double get(BoundValues bValue) const { return m_values[bValue]; }
0114
0115 private:
0116 std::array<double, eSize> m_values;
0117 RectangleBounds m_boundingBox;
0118
0119
0120
0121 void checkConsistency() noexcept(false);
0122 };
0123
0124 inline std::vector<double> DiamondBounds::values() const {
0125 std::vector<double> valvector;
0126 valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
0127 return valvector;
0128 }
0129
0130 inline void DiamondBounds::checkConsistency() noexcept(false) {
0131 if (std::any_of(m_values.begin(), m_values.end(),
0132 [](auto v) { return v <= 0.; })) {
0133 throw std::invalid_argument("DiamondBounds: negative half length.");
0134 }
0135 if (get(eHalfLengthXnegY) > get(eHalfLengthXzeroY) ||
0136 get(eHalfLengthXposY) > get(eHalfLengthXzeroY)) {
0137 throw std::invalid_argument("DiamondBounds: not a diamond shape.");
0138 }
0139 }
0140
0141 }