Back to home page

EIC code displayed by LXR

 
 

    


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 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
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   // construct two parallel plane surfaces with normal in x direction
0058   double distance = 10_mm;
0059   std::shared_ptr<PlaneSurface> eSurface =
0060       CurvilinearSurface(Vector3(distance, 0, 0), Vector3::UnitX())
0061           .planeSurface();
0062 
0063   // the bound parameters at the starting plane
0064   BoundVector sBoundParams = BoundVector::Zero();
0065   sBoundParams << loc0, loc1, phi, theta, qOverP, t;
0066 
0067   // the bound parameters covariance at the starting  plane
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   // the intersection of the track with the end surface
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   // construct the free parameters vector
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   // the jacobian from local to global at the starting position
0096   BoundToFreeMatrix boundToFreeJac =
0097       eSurface->boundToFreeJacobian(geoCtx, tpos, dir);
0098 
0099   // the transport jacobian without B field
0100   FreeMatrix transportJac = FreeMatrix::Identity();
0101   transportJac(eFreePos0, eFreeDir0) = s;
0102   transportJac(eFreePos1, eFreeDir1) = s;
0103   transportJac(eFreePos2, eFreeDir2) = s;
0104 
0105   // the free covariance at the start position
0106   FreeSquareMatrix sFreeCov =
0107       boundToFreeJac * sBoundCov * boundToFreeJac.transpose();
0108   // the free covariance at the end position
0109   FreeSquareMatrix eFreeCov =
0110       transportJac * sFreeCov * transportJac.transpose();
0111 
0112   // convert free parameters to bound parameters with non-linear correction
0113 
0114   BOOST_TEST_INFO("Transform free parameters vector onto surface "
0115                   << eSurface->name());
0116 
0117   // the corrected transformation
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   // the loc0, phi are the same as that without correction
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   // the error for loc0 is the same as that without correction:
0139   // loc0 at end position = distance * tan(theta) * sin(phi),
0140   // dloc0/dphi = distance * tan(theta) * cos(phi) = distance,
0141   // resolution of loc0 at end position = dloc0/dphi * resLoc0 = 2.5
0142   CHECK_CLOSE_REL(eCorrectedBoundCov(eBoundLoc0, eBoundLoc0), std::pow(2.5, 2),
0143                   eps);
0144 }
0145 
0146 BOOST_AUTO_TEST_SUITE_END()
0147 
0148 }  // namespace ActsTests