File indexing completed on 2026-08-22 08:17:08
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Surfaces/RadialBounds.hpp"
0010
0011 #include "Acts/Surfaces/detail/VerticesHelper.hpp"
0012 #include "Acts/Utilities/detail/OstreamStateGuard.hpp"
0013 #include "Acts/Utilities/detail/periodic.hpp"
0014
0015 #include <iomanip>
0016 #include <iostream>
0017 #include <stdexcept>
0018
0019 namespace Acts {
0020
0021 std::vector<double> RadialBounds::values() const {
0022 return {m_values.begin(), m_values.end()};
0023 }
0024
0025 void RadialBounds::checkConsistency() noexcept(false) {
0026 if (get(eMinR) < 0. || get(eMaxR) <= 0. || get(eMinR) > get(eMaxR)) {
0027 throw std::invalid_argument("RadialBounds: invalid radial setup");
0028 }
0029 if (get(eHalfPhiSector) < 0. || get(eHalfPhiSector) > std::numbers::pi) {
0030 throw std::invalid_argument("RadialBounds: invalid phi sector setup.");
0031 }
0032 if (get(eAveragePhi) != detail::radian_sym(get(eAveragePhi))) {
0033 throw std::invalid_argument("RadialBounds: invalid phi positioning.");
0034 }
0035 }
0036
0037 SquareMatrix2 RadialBounds::boundToCartesianJacobian(
0038 const Vector2& lposition) const {
0039 SquareMatrix2 j;
0040 j(0, 0) = std::cos(lposition[1] - get(eAveragePhi));
0041 j(0, 1) = -lposition[0] * std::sin(lposition[1] - get(eAveragePhi));
0042 j(1, 0) = std::sin(lposition[1] - get(eAveragePhi));
0043 j(1, 1) = lposition[0] * std::cos(lposition[1] - get(eAveragePhi));
0044 return j;
0045 }
0046
0047 SquareMatrix2 RadialBounds::boundToCartesianMetric(
0048 const Vector2& lposition) const {
0049 SquareMatrix2 m;
0050 m(0, 0) = 1;
0051 m(0, 1) = 0;
0052 m(1, 0) = 0;
0053 m(1, 1) = lposition[0] * lposition[0];
0054 return m;
0055 }
0056
0057 Vector2 RadialBounds::shifted(const Vector2& lposition) const {
0058 Vector2 tmp;
0059 tmp[0] = lposition[0];
0060 tmp[1] = detail::radian_sym(lposition[1] - get(eAveragePhi));
0061 return tmp;
0062 }
0063
0064 bool RadialBounds::inside(const Vector2& lposition) const {
0065 return detail::VerticesHelper::isInsideRectangle(
0066 shifted(lposition), Vector2(get(eMinR), -get(eHalfPhiSector)),
0067 Vector2(get(eMaxR), get(eHalfPhiSector)));
0068 }
0069
0070 Vector2 RadialBounds::closestPoint(const Vector2& lposition,
0071 const SquareMatrix2& metric) const {
0072 return detail::VerticesHelper::computeClosestPointOnAlignedBox(
0073 Vector2(get(eMinR), -get(eHalfPhiSector)),
0074 Vector2(get(eMaxR), get(eHalfPhiSector)), shifted(lposition), metric);
0075 }
0076
0077 std::vector<Vector2> RadialBounds::vertices(unsigned int lseg) const {
0078 return detail::VerticesHelper::circularVertices(
0079 get(eMinR), get(eMaxR), get(eAveragePhi), get(eHalfPhiSector), lseg);
0080 }
0081
0082 Vector2 RadialBounds::center() const {
0083
0084
0085 double rCentroid = 0.5 * (get(eMinR) + get(eMaxR));
0086 double phiCentroid = get(eAveragePhi);
0087 return Vector2(rCentroid, phiCentroid);
0088 }
0089
0090 std::ostream& RadialBounds::toStream(std::ostream& sl) const {
0091 detail::OstreamStateGuard guard{sl};
0092 sl << std::fixed << std::setprecision(7);
0093 sl << "Acts::RadialBounds: (innerRadius, outerRadius, hPhiSector, "
0094 "averagePhi) = ";
0095 sl << "(" << get(eMinR) << ", " << get(eMaxR) << ", " << get(eHalfPhiSector)
0096 << ", " << get(eAveragePhi) << ")";
0097 return sl;
0098 }
0099
0100 }