File indexing completed on 2025-09-17 08:02:26
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012
0013 #include <stdexcept>
0014
0015 namespace Acts {
0016
0017 BoundaryTolerance::ToleranceMode BoundaryTolerance::toleranceMode() const {
0018 using enum ToleranceMode;
0019
0020 if (isInfinite()) {
0021 return Extend;
0022 }
0023
0024 if (isNone()) {
0025 return None;
0026 }
0027
0028 if (const auto* absoluteEuclidean = getVariantPtr<AbsoluteEuclideanParams>();
0029 absoluteEuclidean != nullptr) {
0030 if (absoluteEuclidean->tolerance == 0) {
0031 return None;
0032 } else if (absoluteEuclidean->tolerance > 0) {
0033 return Extend;
0034 } else {
0035 return Shrink;
0036 }
0037 }
0038
0039 if (const auto* chi2Bound = getVariantPtr<Chi2BoundParams>();
0040 chi2Bound != nullptr) {
0041 if (chi2Bound->maxChi2 == 0) {
0042 return None;
0043 } else if (chi2Bound->maxChi2 >= 0) {
0044 return Extend;
0045 } else {
0046 return Shrink;
0047 }
0048 }
0049
0050 if (const auto* chi2Cartesian = getVariantPtr<Chi2CartesianParams>();
0051 chi2Cartesian != nullptr) {
0052 if (chi2Cartesian->maxChi2 == 0) {
0053 return None;
0054 } else if (chi2Cartesian->maxChi2 >= 0) {
0055 return Extend;
0056 } else {
0057 return Shrink;
0058 }
0059 }
0060
0061 throw std::logic_error("Unsupported tolerance type");
0062 }
0063
0064 bool BoundaryTolerance::isTolerated(
0065 const Vector2& boundDelta, const SquareMatrix2& boundToCartesian) const {
0066 if (isInfinite()) {
0067 return true;
0068 }
0069
0070 if (isNone()) {
0071 return boundDelta == Vector2::Zero();
0072 }
0073
0074 if (const auto* chi2Bound = getVariantPtr<Chi2BoundParams>();
0075 chi2Bound != nullptr) {
0076 double chi2 =
0077 boundDelta.transpose() * chi2Bound->weightMatrix() * boundDelta;
0078 return std::copysign(chi2, chi2Bound->maxChi2) <= chi2Bound->maxChi2;
0079 }
0080
0081 Vector2 cartesianDelta = boundToCartesian * boundDelta;
0082
0083 if (const auto* absoluteEuclidean = getVariantPtr<AbsoluteEuclideanParams>();
0084 absoluteEuclidean != nullptr) {
0085 return std::copysign(cartesianDelta.norm(), absoluteEuclidean->tolerance) <=
0086 absoluteEuclidean->tolerance;
0087 }
0088
0089 if (const auto* chi2Cartesian = getVariantPtr<Chi2CartesianParams>();
0090 chi2Cartesian != nullptr) {
0091 double chi2 = cartesianDelta.transpose() * chi2Cartesian->weightMatrix() *
0092 cartesianDelta;
0093 return std::copysign(chi2, chi2Cartesian->maxChi2) <=
0094 chi2Cartesian->maxChi2;
0095 }
0096
0097 throw std::logic_error("Unsupported tolerance type");
0098 }
0099
0100 }