File indexing completed on 2025-08-05 08:09:40
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Surfaces/DiscTrapezoidBounds.hpp"
0010
0011 #include "Acts/Definitions/TrackParametrization.hpp"
0012
0013 #include <cmath>
0014 #include <iomanip>
0015 #include <iostream>
0016 #include <utility>
0017
0018 Acts::DiscTrapezoidBounds::DiscTrapezoidBounds(double halfXminR,
0019 double halfXmaxR, double minR,
0020 double maxR, double avgPhi,
0021 double stereo) noexcept(false)
0022 : m_values({halfXminR, halfXmaxR, minR, maxR, avgPhi, stereo}) {
0023 checkConsistency();
0024 m_ymax = std::sqrt(get(eMaxR) * get(eMaxR) -
0025 get(eHalfLengthXmaxR) * get(eHalfLengthXmaxR));
0026 }
0027
0028 Acts::SurfaceBounds::BoundsType Acts::DiscTrapezoidBounds::type() const {
0029 return SurfaceBounds::eDiscTrapezoid;
0030 }
0031
0032 Acts::Vector2 Acts::DiscTrapezoidBounds::toLocalCartesian(
0033 const Acts::Vector2& lposition) const {
0034 return {lposition[eBoundLoc0] *
0035 std::sin(lposition[eBoundLoc1] - get(eAveragePhi)),
0036 lposition[eBoundLoc0] *
0037 std::cos(lposition[eBoundLoc1] - get(eAveragePhi))};
0038 }
0039
0040 Acts::ActsMatrix<2, 2> Acts::DiscTrapezoidBounds::jacobianToLocalCartesian(
0041 const Acts::Vector2& lposition) const {
0042 ActsMatrix<2, 2> jacobian;
0043 jacobian(0, eBoundLoc0) = std::sin(lposition[eBoundLoc1] - get(eAveragePhi));
0044 jacobian(1, eBoundLoc0) = std::cos(lposition[eBoundLoc1] - get(eAveragePhi));
0045 jacobian(0, eBoundLoc1) =
0046 lposition[eBoundLoc0] * std::cos(lposition[eBoundLoc1]);
0047 jacobian(1, eBoundLoc1) =
0048 lposition[eBoundLoc0] * -std::sin(lposition[eBoundLoc1]);
0049 return jacobian;
0050 }
0051
0052 bool Acts::DiscTrapezoidBounds::inside(
0053 const Acts::Vector2& lposition, const Acts::BoundaryCheck& bcheck) const {
0054 Vector2 vertices[] = {{get(eHalfLengthXminR), get(eMinR)},
0055 {get(eHalfLengthXmaxR), m_ymax},
0056 {-get(eHalfLengthXmaxR), m_ymax},
0057 {-get(eHalfLengthXminR), get(eMinR)}};
0058 auto jacobian = jacobianToLocalCartesian(lposition);
0059 return bcheck.transformed(jacobian).isInside(toLocalCartesian(lposition),
0060 vertices);
0061 }
0062
0063 std::vector<Acts::Vector2> Acts::DiscTrapezoidBounds::vertices(
0064 unsigned int ) const {
0065 Vector2 cAxis(std::cos(get(eAveragePhi)), std::sin(get(eAveragePhi)));
0066 Vector2 nAxis(cAxis.y(), -cAxis.x());
0067 auto ymin = std::sqrt(get(eMinR) * get(eMinR) -
0068 get(eHalfLengthXminR) * get(eHalfLengthXminR));
0069 auto halfY = (m_ymax - ymin) / 2;
0070 return {-halfY * cAxis - get(eHalfLengthXminR) * nAxis,
0071 -halfY * cAxis + get(eHalfLengthXminR) * nAxis,
0072 halfY * cAxis + get(eHalfLengthXmaxR) * nAxis,
0073 halfY * cAxis - get(eHalfLengthXmaxR) * nAxis};
0074 }
0075
0076
0077 std::ostream& Acts::DiscTrapezoidBounds::toStream(std::ostream& sl) const {
0078 sl << std::setiosflags(std::ios::fixed);
0079 sl << std::setprecision(7);
0080 sl << "Acts::DiscTrapezoidBounds: (innerRadius, outerRadius, "
0081 "halfLengthXminR, "
0082 "halfLengthXmaxR, halfLengthY, halfPhiSector, averagePhi, rCenter, "
0083 "stereo) = ";
0084 sl << "(" << get(eMinR) << ", " << get(eMaxR) << ", " << get(eHalfLengthXminR)
0085 << ", " << get(eHalfLengthXmaxR) << ", " << halfLengthY() << ", "
0086 << halfPhiSector() << ", " << get(eAveragePhi) << ", " << rCenter() << ", "
0087 << stereo() << ")";
0088 sl << std::setprecision(-1);
0089 return sl;
0090 }