File indexing completed on 2025-01-18 09:12:35
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/data/test_case.hpp>
0010 #include <boost/test/unit_test.hpp>
0011
0012 #include "Acts/Definitions/Algebra.hpp"
0013 #include "Acts/Definitions/TrackParametrization.hpp"
0014 #include "Acts/Definitions/Units.hpp"
0015 #include "Acts/EventData/TransformationHelpers.hpp"
0016 #include "Acts/Geometry/GeometryContext.hpp"
0017 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0018 #include "Acts/Utilities/UnitVectors.hpp"
0019
0020 #include <algorithm>
0021 #include <limits>
0022 #include <numbers>
0023 #include <utility>
0024 #include <vector>
0025
0026 #include "TrackParametersDatasets.hpp"
0027
0028 using namespace Acts;
0029 using namespace Acts::UnitLiterals;
0030
0031 namespace {
0032 constexpr auto eps = std::numeric_limits<double>::epsilon();
0033 }
0034
0035 BOOST_AUTO_TEST_SUITE(TransformBoundToFree)
0036
0037 BOOST_DATA_TEST_CASE(
0038 Parameters,
0039 surfaces* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsNonZero,
0040 surface, l0, l1, time, phi, theta, p, q) {
0041 GeometryContext geoCtx;
0042
0043 Vector2 loc(l0, l1);
0044 Vector3 dir = makeDirectionFromPhiTheta(phi, theta);
0045
0046 Vector3 pos = surface->localToGlobal(geoCtx, loc, dir);
0047
0048 const auto qOverP = q / p;
0049
0050
0051 BoundVector bv = BoundVector::Zero();
0052 bv[eBoundLoc0] = l0;
0053 bv[eBoundLoc1] = l1;
0054 bv[eBoundTime] = time;
0055 bv[eBoundPhi] = phi;
0056 bv[eBoundTheta] = theta;
0057 bv[eBoundQOverP] = qOverP;
0058
0059
0060 FreeVector fv = transformBoundToFreeParameters(*surface, geoCtx, bv);
0061
0062 CHECK_CLOSE_OR_SMALL(fv.segment<3>(eFreePos0), pos, eps, eps);
0063 CHECK_CLOSE_OR_SMALL(fv[eFreeTime], bv[eBoundTime], eps, eps);
0064 CHECK_CLOSE_REL(fv.segment<3>(eFreeDir0).norm(), 1, eps);
0065 CHECK_CLOSE_OR_SMALL(fv.segment<3>(eFreeDir0), dir, eps, eps);
0066 CHECK_CLOSE_OR_SMALL(fv[eFreeQOverP], bv[eBoundQOverP], eps, eps);
0067 }
0068
0069 BOOST_AUTO_TEST_SUITE_END()
0070
0071 BOOST_AUTO_TEST_SUITE(TransformFreeToBound)
0072
0073 BOOST_DATA_TEST_CASE(
0074 GlobalToBoundTrackParameters,
0075 surfaces* posSymmetric* posSymmetric* ts* phis* thetas* ps* qsNonZero,
0076 surface, l0, l1, time, phiInput, theta, p, q) {
0077
0078 const auto phi = ((0 < theta) && (theta < std::numbers::pi)) ? phiInput : 0.;
0079 const auto qOverP = q / p;
0080
0081 GeometryContext geoCtx;
0082 Vector2 loc(l0, l1);
0083 Vector3 dir = makeDirectionFromPhiTheta(phi, theta);
0084
0085 Vector3 pos = surface->localToGlobal(geoCtx, loc, dir);
0086
0087
0088 {
0089 BOOST_TEST_INFO("Transform free parameters vector onto surface "
0090 << surface->name());
0091
0092 FreeVector fv = FreeVector::Zero();
0093 fv[eFreePos0] = pos[ePos0];
0094 fv[eFreePos1] = pos[ePos1];
0095 fv[eFreePos2] = pos[ePos2];
0096 fv[eFreeTime] = time;
0097 fv[eFreeDir0] = dir[eMom0];
0098 fv[eFreeDir1] = dir[eMom1];
0099 fv[eFreeDir2] = dir[eMom2];
0100 fv[eFreeQOverP] = qOverP;
0101 BoundVector bv =
0102 transformFreeToBoundParameters(fv, *surface, geoCtx).value();
0103 CHECK_CLOSE_OR_SMALL(bv[eBoundLoc0], l0, eps, eps);
0104 CHECK_CLOSE_OR_SMALL(bv[eBoundLoc1], l1, eps, eps);
0105 CHECK_CLOSE_OR_SMALL(bv[eBoundTime], time, eps, eps);
0106 CHECK_CLOSE_OR_SMALL(bv[eBoundPhi], phi, eps, eps);
0107 CHECK_CLOSE_OR_SMALL(bv[eBoundTheta], theta, eps, eps);
0108 CHECK_CLOSE_OR_SMALL(bv[eBoundQOverP], qOverP, eps, eps);
0109 }
0110
0111
0112 {
0113 Vector3 posOff = pos + surface->normal(geoCtx, loc) * 0.5;
0114 BOOST_TEST_INFO("Transform free parameters vector onto surface "
0115 << surface->name());
0116
0117 FreeVector fv = FreeVector::Zero();
0118 fv[eFreePos0] = posOff[ePos0];
0119 fv[eFreePos1] = posOff[ePos1];
0120 fv[eFreePos2] = posOff[ePos2];
0121 fv[eFreeTime] = time;
0122 fv[eFreeDir0] = dir[eMom0];
0123 fv[eFreeDir1] = dir[eMom1];
0124 fv[eFreeDir2] = dir[eMom2];
0125 fv[eFreeQOverP] = qOverP;
0126 auto res = transformFreeToBoundParameters(fv, *surface, geoCtx);
0127 BOOST_CHECK(!res.ok());
0128 }
0129
0130
0131 {
0132 BOOST_TEST_INFO("Transform free parameters components onto surface "
0133 << surface->name());
0134
0135 BoundVector bv =
0136 transformFreeToBoundParameters(pos, time, dir, qOverP, *surface, geoCtx)
0137 .value();
0138 CHECK_CLOSE_OR_SMALL(bv[eBoundLoc0], l0, eps, eps);
0139 CHECK_CLOSE_OR_SMALL(bv[eBoundLoc1], l1, eps, eps);
0140 CHECK_CLOSE_OR_SMALL(bv[eBoundTime], time, eps, eps);
0141 CHECK_CLOSE_OR_SMALL(bv[eBoundPhi], phi, eps, eps);
0142 CHECK_CLOSE_OR_SMALL(bv[eBoundTheta], theta, eps, eps);
0143 CHECK_CLOSE_OR_SMALL(bv[eBoundQOverP], qOverP, eps, eps);
0144 }
0145
0146
0147 {
0148 BOOST_TEST_INFO("Transform free parameters components onto surface "
0149 << surface->name());
0150
0151 Vector3 posOff = pos + surface->normal(geoCtx, loc) * 0.5;
0152 auto res = transformFreeToBoundParameters(posOff, time, dir, qOverP,
0153 *surface, geoCtx);
0154 BOOST_CHECK(!res.ok());
0155 }
0156 }
0157
0158 BOOST_DATA_TEST_CASE(GlobalToCurvilinearParameters,
0159 ts* phis* thetas* ps* qsNonZero, time, phiInput, theta, p,
0160 q) {
0161
0162 const auto phi = ((0 < theta) && (theta < std::numbers::pi)) ? phiInput : 0.;
0163 const auto qOverP = q / p;
0164
0165 GeometryContext geoCtx;
0166 Vector3 dir = makeDirectionFromPhiTheta(phi, theta);
0167
0168
0169 {
0170 BoundVector bv = transformFreeToCurvilinearParameters(time, dir, qOverP);
0171 CHECK_SMALL(bv[eBoundLoc0], eps);
0172 CHECK_SMALL(bv[eBoundLoc1], eps);
0173 CHECK_CLOSE_OR_SMALL(bv[eBoundTime], time, eps, eps);
0174 CHECK_CLOSE_OR_SMALL(bv[eBoundPhi], phi, eps, eps);
0175 CHECK_CLOSE_OR_SMALL(bv[eBoundTheta], theta, eps, eps);
0176 CHECK_CLOSE_OR_SMALL(bv[eBoundQOverP], qOverP, eps, eps);
0177 }
0178
0179 {
0180 BoundVector bv =
0181 transformFreeToCurvilinearParameters(time, phi, theta, qOverP);
0182 CHECK_SMALL(bv[eBoundLoc0], eps);
0183 CHECK_SMALL(bv[eBoundLoc1], eps);
0184 CHECK_CLOSE_OR_SMALL(bv[eBoundTime], time, eps, eps);
0185 CHECK_CLOSE_OR_SMALL(bv[eBoundPhi], phi, eps, eps);
0186 CHECK_CLOSE_OR_SMALL(bv[eBoundTheta], theta, eps, eps);
0187 CHECK_CLOSE_OR_SMALL(bv[eBoundQOverP], qOverP, eps, eps);
0188 }
0189 }
0190
0191 BOOST_AUTO_TEST_SUITE_END()