Warning, file /acts/Tests/UnitTests/Core/EventData/CorrectedTransformFreeToBoundTests.cpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/TrackParametrization.hpp"
0013 #include "Acts/Definitions/Units.hpp"
0014 #include "Acts/EventData/detail/CorrectedTransformationFreeToBound.hpp"
0015 #include "Acts/Geometry/GeometryContext.hpp"
0016 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0017 #include "Acts/Surfaces/CurvilinearSurface.hpp"
0018 #include "Acts/Surfaces/PlaneSurface.hpp"
0019 #include "Acts/Utilities/Intersection.hpp"
0020 #include "Acts/Utilities/UnitVectors.hpp"
0021 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0022
0023 #include <cmath>
0024 #include <memory>
0025 #include <numbers>
0026 #include <optional>
0027 #include <tuple>
0028
0029 using namespace Acts;
0030 using namespace Acts::UnitLiterals;
0031
0032 namespace {
0033 constexpr double eps = 0.01;
0034 }
0035
0036 namespace ActsTests {
0037
0038 BOOST_AUTO_TEST_SUITE(EventDataSuite)
0039
0040 BOOST_AUTO_TEST_CASE(CorrectedFreeToBoundTrackParameters) {
0041 GeometryContext geoCtx;
0042
0043 const auto loc0 = 0.0;
0044 const auto loc1 = 0.0;
0045 const auto phi = 0.0;
0046 const auto theta = std::numbers::pi / 4.;
0047 const auto qOverP = 1 / 1_GeV;
0048 const auto t = 1_ns;
0049
0050 const auto resLoc0 = 0.0;
0051 const auto resLoc1 = 0.0;
0052 const auto resPhi = 0.25;
0053 const auto resTheta = 0.25;
0054 const auto resQOverP = 0.01 / 1_GeV;
0055 const auto resTime = 0.01_ns;
0056
0057
0058 double distance = 10_mm;
0059 std::shared_ptr<PlaneSurface> eSurface =
0060 CurvilinearSurface(Vector3(distance, 0, 0), Vector3::UnitX())
0061 .planeSurface();
0062
0063
0064 BoundVector sBoundParams = BoundVector::Zero();
0065 sBoundParams << loc0, loc1, phi, theta, qOverP, t;
0066
0067
0068 BoundSquareMatrix sBoundCov = BoundSquareMatrix::Zero();
0069 sBoundCov(eBoundLoc0, eBoundLoc0) = resLoc0 * resLoc0;
0070 sBoundCov(eBoundLoc1, eBoundLoc1) = resLoc1 * resLoc1;
0071 sBoundCov(eBoundPhi, eBoundPhi) = resPhi * resPhi;
0072 sBoundCov(eBoundTheta, eBoundTheta) = resTheta * resTheta;
0073 sBoundCov(eBoundQOverP, eBoundQOverP) = resQOverP * resQOverP;
0074 sBoundCov(eBoundTime, eBoundTime) = resTime * resTime;
0075
0076 Vector3 dir = makeDirectionFromPhiTheta(phi, theta);
0077
0078
0079 Intersection3D intersection =
0080 eSurface
0081 ->intersect(geoCtx, Vector3(0, 0, 0), dir, BoundaryTolerance::None())
0082 .closest();
0083 Vector3 tpos = intersection.position();
0084 double s = intersection.pathLength();
0085
0086 BOOST_CHECK_EQUAL(s, distance * std::numbers::sqrt2);
0087
0088
0089 FreeVector eFreeParams = FreeVector::Zero();
0090 eFreeParams.segment<3>(eFreePos0) = tpos;
0091 eFreeParams[eFreeTime] = t;
0092 eFreeParams.segment<3>(eFreeDir0) = dir;
0093 eFreeParams[eFreeQOverP] = qOverP;
0094
0095
0096 BoundToFreeMatrix boundToFreeJac =
0097 eSurface->boundToFreeJacobian(geoCtx, tpos, dir);
0098
0099
0100 FreeMatrix transportJac = FreeMatrix::Identity();
0101 transportJac(eFreePos0, eFreeDir0) = s;
0102 transportJac(eFreePos1, eFreeDir1) = s;
0103 transportJac(eFreePos2, eFreeDir2) = s;
0104
0105
0106 FreeSquareMatrix sFreeCov =
0107 boundToFreeJac * sBoundCov * boundToFreeJac.transpose();
0108
0109 FreeSquareMatrix eFreeCov =
0110 transportJac * sFreeCov * transportJac.transpose();
0111
0112
0113
0114 BOOST_TEST_INFO("Transform free parameters vector onto surface "
0115 << eSurface->name());
0116
0117
0118 auto freeToBoundCorrection = FreeToBoundCorrection(true);
0119 BOOST_CHECK(freeToBoundCorrection);
0120
0121 auto transformer =
0122 detail::CorrectedFreeToBoundTransformer(freeToBoundCorrection);
0123 auto correctedRes = transformer(eFreeParams, eFreeCov, *eSurface, geoCtx);
0124
0125 BOOST_CHECK(correctedRes.has_value());
0126 auto correctedValue = correctedRes.value();
0127 BoundVector eCorrectedBoundParams = std::get<BoundVector>(correctedValue);
0128 BoundSquareMatrix eCorrectedBoundCov =
0129 std::get<BoundSquareMatrix>(correctedValue);
0130
0131
0132 BOOST_CHECK_EQUAL(eCorrectedBoundParams[eBoundLoc0], loc0);
0133 BOOST_CHECK_EQUAL(eCorrectedBoundParams[eBoundPhi], phi);
0134 CHECK_CLOSE_REL(eCorrectedBoundParams[eBoundLoc1], 11.2563, eps);
0135
0136 BOOST_TEST_INFO("Corrected Bound Params: \n" << eCorrectedBoundParams);
0137 BOOST_TEST_INFO("Corrected Bound Covariance: \n" << eCorrectedBoundCov);
0138
0139
0140
0141
0142 CHECK_CLOSE_REL(eCorrectedBoundCov(eBoundLoc0, eBoundLoc0), std::pow(2.5, 2),
0143 eps);
0144 }
0145
0146 BOOST_AUTO_TEST_SUITE_END()
0147
0148 }