-
Notifications
You must be signed in to change notification settings - Fork 256
Expand file tree
/
Copy pathBoundaryTolerance.cpp
More file actions
116 lines (96 loc) · 3.26 KB
/
Copy pathBoundaryTolerance.cpp
File metadata and controls
116 lines (96 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// This file is part of the ACTS project.
//
// Copyright (C) 2016 CERN for the benefit of the ACTS project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#include "Acts/Surfaces/BoundaryTolerance.hpp"
#include "Acts/Definitions/Algebra.hpp"
#include <stdexcept>
namespace Acts {
BoundaryTolerance::ToleranceMode BoundaryTolerance::toleranceMode() const {
using enum ToleranceMode;
if (isInfinite()) {
return Extend;
}
if (isNone()) {
return None;
}
if (const auto* absoluteEuclidean = getVariantPtr<AbsoluteEuclideanParams>();
absoluteEuclidean != nullptr) {
if (absoluteEuclidean->tolerance == 0) {
return None;
} else if (absoluteEuclidean->tolerance > 0) {
return Extend;
} else {
return Shrink;
}
}
if (const auto* chi2Bound = getVariantPtr<Chi2BoundParams>();
chi2Bound != nullptr) {
if (chi2Bound->maxChi2 == 0) {
return None;
} else if (chi2Bound->maxChi2 >= 0) {
return Extend;
} else {
return Shrink;
}
}
if (const auto* chi2Cartesian = getVariantPtr<Chi2CartesianParams>();
chi2Cartesian != nullptr) {
if (chi2Cartesian->maxChi2 == 0) {
return None;
} else if (chi2Cartesian->maxChi2 >= 0) {
return Extend;
} else {
return Shrink;
}
}
throw std::logic_error("Unsupported tolerance type");
}
bool BoundaryTolerance::isTolerated(
const Vector2& boundDelta, const SquareMatrix2& boundToCartesian) const {
if (isInfinite()) {
return true;
}
if (isNone()) {
return boundDelta == Vector2::Zero();
}
if (const auto* chi2Bound = getVariantPtr<Chi2BoundParams>();
chi2Bound != nullptr) {
double chi2 =
boundDelta.transpose() * chi2Bound->weightMatrix() * boundDelta;
return std::copysign(chi2, chi2Bound->maxChi2) <= chi2Bound->maxChi2;
}
Vector2 cartesianDelta = boundToCartesian * boundDelta;
if (const auto* absoluteEuclidean = getVariantPtr<AbsoluteEuclideanParams>();
absoluteEuclidean != nullptr) {
return std::copysign(cartesianDelta.norm(), absoluteEuclidean->tolerance) <=
absoluteEuclidean->tolerance;
}
if (const auto* chi2Cartesian = getVariantPtr<Chi2CartesianParams>();
chi2Cartesian != nullptr) {
double chi2 = cartesianDelta.transpose() * chi2Cartesian->weightMatrix() *
cartesianDelta;
return std::copysign(chi2, chi2Cartesian->maxChi2) <=
chi2Cartesian->maxChi2;
}
throw std::logic_error("Unsupported tolerance type");
}
void BoundaryTolerance::print(std::ostream& ostr) const {
if (isInfinite()) {
ostr << "no boundary limit applied";
} else if (isNone()) {
ostr << "strict boundary limit";
} else if (hasAbsoluteEuclidean()) {
ostr << "boundary limit dX < " << asAbsoluteEuclidean().tolerance;
} else if (hasChi2Bound()) {
ostr << "local chi2 " << asChi2Bound().maxChi2 << " with weights:\n"
<< asChi2Bound().weightMatrix() << "\n";
} else if (hasChi2Cartesian()) {
ostr << "local chi2 " << asChi2Cartesian().maxChi2 << " with weights:\n"
<< asChi2Cartesian().weightMatrix() << "\n";
}
}
} // namespace Acts