Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-25 07:57:00

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/Geometry/GeometryContext.hpp"
0014 #include "Acts/Propagator/detail/JacobianEngine.hpp"
0015 #include "Acts/Surfaces/CurvilinearSurface.hpp"
0016 #include "Acts/Surfaces/PlaneSurface.hpp"
0017 
0018 using namespace Acts;
0019 
0020 namespace ActsTest {
0021 
0022 BOOST_AUTO_TEST_SUITE(PropagatorSuite)
0023 
0024 /// These tests do not test for a correct covariance transport but only for the
0025 /// correct conservation or modification of certain variables. A test suite for
0026 /// the numerical correctness is performed in the integration tests.
0027 ///
0028 BOOST_AUTO_TEST_CASE(jacobian_engine_to_bound) {
0029   // Create a test context
0030   GeometryContext tgContext = GeometryContext();
0031 
0032   // Build a start vector
0033   Vector3 position{1., 2., 3.};
0034   double time = 4.;
0035   Vector3 direction = Vector3(5., 2., 7.).normalized();
0036   double qop = 0.125;
0037 
0038   // Build a surface
0039   std::shared_ptr<PlaneSurface> pSurface =
0040       CurvilinearSurface(position, direction).planeSurface();
0041 
0042   // Other rotated surface
0043   Vector3 odirection = Vector3(6., 2., 8.).normalized();
0044   std::shared_ptr<PlaneSurface> oSurface =
0045       CurvilinearSurface(position, odirection).planeSurface();
0046 
0047   // The free parameter vector
0048   FreeVector freeParameters;
0049   freeParameters << position[0], position[1], position[2], time, direction[0],
0050       direction[1], direction[2], qop;
0051   // And its associated bound vector
0052   BoundVector boundParameters;
0053   boundParameters << 0., 0., VectorHelpers::phi(direction),
0054       VectorHelpers::theta(direction), qop, time;
0055 
0056   // Build covariance matrices for bound and free case
0057   BoundSquareMatrix boundCovariance = 0.025 * BoundSquareMatrix::Identity();
0058   FreeSquareMatrix freeCovariance = 0.025 * FreeSquareMatrix::Identity();
0059 
0060   FreeMatrix noTransportJacobian = FreeMatrix::Identity();
0061   FreeMatrix realTransportJacobian = 2 * FreeMatrix::Identity();
0062 
0063   FreeToPathMatrix freeToPathDerivatives =
0064       pSurface->freeToPathDerivative(tgContext, position, direction);
0065   BoundToFreeMatrix boundToFreeJacobian =
0066       pSurface->boundToFreeJacobian(tgContext, position, direction);
0067 
0068   // (1) curvilinear/bound to bound transport jacobian
0069   // a) test without actual transport into the same surface
0070   BoundMatrix b2bTransportJacobian;
0071   FreeToBoundMatrix freeToBoundJacobian;
0072   detail::boundToBoundTransportJacobian(
0073       tgContext, *pSurface, freeParameters, boundToFreeJacobian,
0074       noTransportJacobian, freeToBoundJacobian, freeToPathDerivatives,
0075       b2bTransportJacobian);
0076   BoundSquareMatrix newBoundCovariance =
0077       b2bTransportJacobian * boundCovariance * b2bTransportJacobian.transpose();
0078   BOOST_CHECK(boundCovariance.isApprox(newBoundCovariance));
0079   // b) test without actual transport but to a new surface
0080   detail::boundToBoundTransportJacobian(
0081       tgContext, *oSurface, freeParameters, boundToFreeJacobian,
0082       noTransportJacobian, freeToBoundJacobian, freeToPathDerivatives,
0083       b2bTransportJacobian);
0084   newBoundCovariance =
0085       b2bTransportJacobian * boundCovariance * b2bTransportJacobian.transpose();
0086   BOOST_CHECK(!boundCovariance.isApprox(newBoundCovariance));
0087   // c) test to "the same" surface with transport
0088   // (not really senseful, but should give a different result)
0089   detail::boundToBoundTransportJacobian(
0090       tgContext, *pSurface, freeParameters, boundToFreeJacobian,
0091       realTransportJacobian, freeToBoundJacobian, freeToPathDerivatives,
0092       b2bTransportJacobian);
0093   newBoundCovariance =
0094       b2bTransportJacobian * boundCovariance * b2bTransportJacobian.transpose();
0095   BOOST_CHECK(!boundCovariance.isApprox(newBoundCovariance));
0096 
0097   FreeToBoundMatrix f2bTransportJacobian;
0098   detail::freeToBoundTransportJacobian(
0099       tgContext, *pSurface, freeParameters, noTransportJacobian,
0100       freeToPathDerivatives, f2bTransportJacobian);
0101 
0102   newBoundCovariance =
0103       f2bTransportJacobian * freeCovariance * f2bTransportJacobian.transpose();
0104   BOOST_CHECK(!boundCovariance.isApprox(newBoundCovariance));
0105 }
0106 
0107 /// These tests do not test for a correct covariance transport but only for the
0108 /// correct conservation or modification of certain variables. A test suite for
0109 /// the numerical correctness is performed in the integration tests.
0110 ///
0111 BOOST_AUTO_TEST_CASE(jacobian_engine_to_curvilinear) {
0112   // Create a test context
0113   GeometryContext tgContext = GeometryContext();
0114 
0115   // Build a start vector
0116   Vector3 position{1., 2., 3.};
0117   Vector3 direction = Vector3(5., 2., 7.).normalized();
0118 
0119   // Build a surface, starting surface for curvilinear
0120   std::shared_ptr<PlaneSurface> pSurface =
0121       CurvilinearSurface(position, direction).planeSurface();
0122 
0123   // Build covariance matrices for bound and free case
0124   BoundSquareMatrix boundCovariance = 0.025 * BoundSquareMatrix::Identity();
0125   FreeSquareMatrix freeCovariance = 0.025 * FreeSquareMatrix::Identity();
0126 
0127   FreeMatrix noTransportJacobian = FreeMatrix::Identity();
0128   FreeToBoundMatrix freeToBoundJacobian;
0129 
0130   FreeToPathMatrix freeToPathDerivatives =
0131       pSurface->freeToPathDerivative(tgContext, position, direction);
0132   BoundToFreeMatrix boundToFreeJacobian =
0133       CurvilinearSurface(direction).boundToFreeJacobian();
0134 
0135   // (1) curvilinear/bound to curvilinear transport jacobian
0136   // a) test without actual transport into the same surface
0137   BoundMatrix b2cTransportJacobian;
0138   detail::boundToCurvilinearTransportJacobian(
0139       direction, boundToFreeJacobian, noTransportJacobian, freeToBoundJacobian,
0140       freeToPathDerivatives, b2cTransportJacobian);
0141   BoundSquareMatrix newBoundCovariance =
0142       b2cTransportJacobian * boundCovariance * b2cTransportJacobian.transpose();
0143   BOOST_CHECK(boundCovariance.isApprox(newBoundCovariance));
0144   // b) test to another curvilinear frame at the same point (no transport)
0145   detail::boundToCurvilinearTransportJacobian(
0146       Vector3(4., 5., 6.).normalized(), boundToFreeJacobian,
0147       noTransportJacobian, freeToBoundJacobian, freeToPathDerivatives,
0148       b2cTransportJacobian);
0149   newBoundCovariance =
0150       b2cTransportJacobian * boundCovariance * b2cTransportJacobian.transpose();
0151   BOOST_CHECK(!boundCovariance.isApprox(newBoundCovariance));
0152 
0153   FreeToBoundMatrix f2cTransportJacobian =
0154       detail::freeToCurvilinearTransportJacobian(direction, noTransportJacobian,
0155                                                  freeToPathDerivatives);
0156 
0157   newBoundCovariance =
0158       f2cTransportJacobian * freeCovariance * f2cTransportJacobian.transpose();
0159   BOOST_CHECK(!boundCovariance.isApprox(newBoundCovariance));
0160 }
0161 
0162 /// These tests do not test for a correct covariance transport but only for the
0163 /// correct conservation or modification of certain variables. A test suite for
0164 /// the numerical correctness is performed in the integration tests.
0165 ///
0166 BOOST_AUTO_TEST_CASE(jacobian_engine_to_free) {
0167   // Create a test context
0168   GeometryContext tgContext = GeometryContext();
0169 
0170   // Build a start vector
0171   Vector3 position{1., 2., 3.};
0172   Vector3 direction = Vector3(5., 2., 7.).normalized();
0173 
0174   // Build a surface, starting surface for curvilinear
0175   std::shared_ptr<PlaneSurface> pSurface =
0176       CurvilinearSurface(position, direction).planeSurface();
0177 
0178   // Build covariance matrices for bound and free case
0179   BoundSquareMatrix boundCovariance = 0.025 * BoundSquareMatrix::Identity();
0180   FreeSquareMatrix freeCovariance = 0.025 * FreeSquareMatrix::Identity();
0181 
0182   FreeMatrix noTransportJacobian = FreeMatrix::Identity();
0183 
0184   BoundToFreeMatrix boundToFreeJacobian =
0185       pSurface->boundToFreeJacobian(tgContext, position, direction);
0186 
0187   // (1) bound to free
0188   BoundToFreeMatrix b2fTransportJacobian = detail::boundToFreeTransportJacobian(
0189       boundToFreeJacobian, noTransportJacobian);
0190 
0191   FreeMatrix newFreeCovariance1 =
0192       b2fTransportJacobian * boundCovariance * b2fTransportJacobian.transpose();
0193   BOOST_CHECK(!newFreeCovariance1.isApprox(freeCovariance));
0194 
0195   // (2) curvilinear to free
0196   boundToFreeJacobian = CurvilinearSurface(direction).boundToFreeJacobian();
0197   BoundToFreeMatrix c2fTransportJacobian = detail::boundToFreeTransportJacobian(
0198       boundToFreeJacobian, noTransportJacobian);
0199 
0200   FreeMatrix newFreeCovariance2 =
0201       c2fTransportJacobian * boundCovariance * c2fTransportJacobian.transpose();
0202   BOOST_CHECK(!newFreeCovariance2.isApprox(freeCovariance));
0203   // But those should be similar/equal
0204   BOOST_CHECK(newFreeCovariance1.isApprox(newFreeCovariance2));
0205 }
0206 
0207 BOOST_AUTO_TEST_SUITE_END()
0208 
0209 }  // namespace ActsTest