Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-31 07:49:01

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/data/test_case.hpp>
0010 #include <boost/test/unit_test.hpp>
0011 
0012 #include "Acts/Geometry/GeometryContext.hpp"
0013 #include "Acts/MagneticField/ConstantBField.hpp"
0014 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0015 #include "Acts/Propagator/EigenStepper.hpp"
0016 #include "Acts/Propagator/Propagator.hpp"
0017 #include "Acts/Propagator/RiddersStepper.hpp"
0018 
0019 #include "PropagationDatasets.hpp"
0020 #include "PropagationTests.hpp"
0021 
0022 namespace {
0023 
0024 namespace ds = ActsTests::PropagationDatasets;
0025 
0026 using namespace Acts;
0027 using namespace UnitLiterals;
0028 
0029 using MagneticField = ConstantBField;
0030 using Stepper = EigenStepper<>;
0031 using TestPropagator = Propagator<Stepper>;
0032 using RiddersStepper = Experimental::RiddersStepper<Stepper>;
0033 using TestPropagator = Propagator<Stepper>;
0034 using TestRiddersPropagator = Propagator<RiddersStepper>;
0035 
0036 // absolute parameter tolerances for position, direction, and absolute momentum
0037 constexpr auto epsPos = 1_um;
0038 constexpr auto epsTime = 1_um;
0039 constexpr auto epsDir = 0.125_mrad;
0040 constexpr auto epsMom = 1_eV;
0041 // relative covariance tolerance
0042 constexpr auto epsCov = 0.025;
0043 
0044 const auto geoCtx = GeometryContext::dangerouslyDefaultConstruct();
0045 const MagneticFieldContext magCtx;
0046 
0047 inline TestPropagator makePropagator(double bz) {
0048   auto magField = std::make_shared<MagneticField>(Vector3(0.0, 0.0, bz));
0049   Stepper stepper(std::move(magField));
0050   return TestPropagator(std::move(stepper));
0051 }
0052 
0053 inline TestRiddersPropagator makeRiddersPropagator(double bz) {
0054   auto magField = std::make_shared<MagneticField>(Vector3(0.0, 0.0, bz));
0055   RiddersStepper stepper(std::move(magField));
0056   return TestRiddersPropagator(std::move(stepper));
0057 }
0058 
0059 }  // namespace
0060 
0061 BOOST_AUTO_TEST_SUITE(PropagationEigenConstant)
0062 
0063 // check that the propagation is reversible and self-consistent
0064 
0065 BOOST_DATA_TEST_CASE(ForwardBackward,
0066                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0067                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0068                      phi, theta, p, q, s, bz) {
0069   runForwardBackwardTest(makePropagator(bz), geoCtx, magCtx,
0070                          makeParametersCurvilinear(phi, theta, p, q), s, epsPos,
0071                          epsTime, epsDir, epsMom);
0072 }
0073 
0074 // check that reachable surfaces are correctly reached
0075 
0076 // True forward/backward tracks do not work with z cylinders
0077 BOOST_DATA_TEST_CASE(ToCylinderAlongZ,
0078                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0079                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0080                      phi, theta, p, q, s, bz) {
0081   runToSurfaceTest(makePropagator(bz), geoCtx, magCtx,
0082                    makeParametersCurvilinear(phi, theta, p, q), s,
0083                    ZCylinderSurfaceBuilder(), epsPos, epsTime, epsDir, epsMom);
0084 }
0085 
0086 BOOST_DATA_TEST_CASE(ToDisc,
0087                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0088                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0089                      phi, theta, p, q, s, bz) {
0090   runToSurfaceTest(makePropagator(bz), geoCtx, magCtx,
0091                    makeParametersCurvilinear(phi, theta, p, q), s,
0092                    DiscSurfaceBuilder(), epsPos, epsTime, epsDir, epsMom);
0093 }
0094 
0095 BOOST_DATA_TEST_CASE(ToPlane,
0096                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0097                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0098                      phi, theta, p, q, s, bz) {
0099   runToSurfaceTest(makePropagator(bz), geoCtx, magCtx,
0100                    makeParametersCurvilinear(phi, theta, p, q), s,
0101                    PlaneSurfaceBuilder(), epsPos, epsTime, epsDir, epsMom);
0102 }
0103 
0104 // True forward/backward tracks do not work with z straws
0105 BOOST_DATA_TEST_CASE(ToStrawAlongZ,
0106                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0107                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0108                      phi, theta, p, q, s, bz) {
0109   runToSurfaceTest(makePropagator(bz), geoCtx, magCtx,
0110                    makeParametersCurvilinear(phi, theta, p, q), s,
0111                    ZStrawSurfaceBuilder(), epsPos, epsTime, epsDir, epsMom);
0112 }
0113 
0114 // check covariance transport using the ridders propagator for comparison
0115 // Covariance transport does not work for theta close to poles
0116 BOOST_DATA_TEST_CASE(CovarianceCurvilinear,
0117                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0118                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0119                      phi, theta, p, q, s, bz) {
0120   runForwardComparisonTest(
0121       makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
0122       makeParametersCurvilinearWithCovariance(phi, theta, p, q), s, epsPos,
0123       epsTime, epsDir, epsMom, epsCov);
0124 }
0125 
0126 BOOST_DATA_TEST_CASE(
0127     CovarianceToCylinderAlongZ,
0128     ds::phiWithoutAmbiguity* ds::thetaWithoutBeam* ds::absMomentum*
0129         ds::chargeNonZero* ds::pathLength* ds::magneticField,
0130     phi, theta, p, q, s, bz) {
0131   runToSurfaceComparisonTest(
0132       makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
0133       makeParametersCurvilinearWithCovariance(phi, theta, p, q), s,
0134       ZCylinderSurfaceBuilder(), epsPos, epsTime, epsDir, epsMom, epsCov);
0135 }
0136 
0137 BOOST_DATA_TEST_CASE(CovarianceToDisc,
0138                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0139                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0140                      phi, theta, p, q, s, bz) {
0141   runToSurfaceComparisonTest(
0142       makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
0143       makeParametersCurvilinearWithCovariance(phi, theta, p, q), s,
0144       DiscSurfaceBuilder(), epsPos, epsTime, epsDir, epsMom, epsCov);
0145 }
0146 
0147 BOOST_DATA_TEST_CASE(CovarianceToPlane,
0148                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0149                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0150                      phi, theta, p, q, s, bz) {
0151   runToSurfaceComparisonTest(
0152       makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
0153       makeParametersCurvilinearWithCovariance(phi, theta, p, q), s,
0154       PlaneSurfaceBuilder(), epsPos, epsTime, epsDir, epsMom, epsCov);
0155 }
0156 
0157 BOOST_DATA_TEST_CASE(CovarianceToStrawAlongZ,
0158                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0159                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0160                      phi, theta, p, q, s, bz) {
0161   // the numerical covariance transport to straw surfaces does not seem to be
0162   // stable. use a higher tolerance for now.
0163   runToSurfaceComparisonTest(
0164       makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
0165       makeParametersCurvilinearWithCovariance(phi, theta, p, q), s,
0166       ZStrawSurfaceBuilder(), epsPos, epsTime, epsDir, epsMom, 0.125);
0167 }
0168 
0169 BOOST_AUTO_TEST_SUITE_END()