Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-08 09:25:35

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/GenericRungeKuttaStepper.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 = GenericRungeKuttaStepper;
0031 using RiddersStepper = Experimental::RiddersStepper<Stepper>;
0032 using TestPropagator = Propagator<Stepper>;
0033 using TestRiddersPropagator = Propagator<RiddersStepper>;
0034 
0035 constexpr auto epsPos = 1_um;
0036 constexpr auto epsTime = 1_um;
0037 constexpr auto epsDir = 0.125_mrad;
0038 constexpr auto epsMom = 1_eV;
0039 constexpr auto epsCov = 0.025;
0040 
0041 // A step to the straight-line distance of a surface passes a surface
0042 // perpendicular to the track by about |(q/p) T x B|^2 h^3 / 3, which is up to
0043 // about 2 mm for these datasets. The next step goes back, so accept
0044 // intersections that far behind the track. Only for planes and discs: they
0045 // have one intersection, while the target cylinder can have its second
0046 // intersection within 1 cm behind the track.
0047 struct TargetReached : public SurfaceReached {
0048   TargetReached() : SurfaceReached(-1_cm) {}
0049 };
0050 
0051 const auto geoCtx = GeometryContext::dangerouslyDefaultConstruct();
0052 const MagneticFieldContext magCtx;
0053 
0054 inline TestPropagator makePropagator(double bz) {
0055   auto magField = std::make_shared<MagneticField>(Vector3(0.0, 0.0, bz));
0056   Stepper stepper(std::move(magField));
0057   return TestPropagator(std::move(stepper));
0058 }
0059 
0060 inline TestRiddersPropagator makeRiddersPropagator(double bz) {
0061   auto magField = std::make_shared<MagneticField>(Vector3(0.0, 0.0, bz));
0062   RiddersStepper stepper(std::move(magField));
0063   return TestRiddersPropagator(std::move(stepper));
0064 }
0065 
0066 }  // namespace
0067 
0068 BOOST_AUTO_TEST_SUITE(PropagationGenericRungeKuttaConstant)
0069 
0070 BOOST_DATA_TEST_CASE(ForwardBackward,
0071                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0072                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0073                      phi, theta, p, q, s, bz) {
0074   runForwardBackwardTest(makePropagator(bz), geoCtx, magCtx,
0075                          makeParametersCurvilinear(phi, theta, p, q), s, epsPos,
0076                          epsTime, epsDir, epsMom);
0077 }
0078 
0079 BOOST_DATA_TEST_CASE(ToCylinderAlongZ,
0080                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0081                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0082                      phi, theta, p, q, s, bz) {
0083   runToSurfaceTest(makePropagator(bz), geoCtx, magCtx,
0084                    makeParametersCurvilinear(phi, theta, p, q), s,
0085                    ZCylinderSurfaceBuilder(), 1_um, 1_um, 0.125_mrad, epsMom);
0086 }
0087 
0088 BOOST_DATA_TEST_CASE(ToDisc,
0089                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0090                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0091                      phi, theta, p, q, s, bz) {
0092   runToSurfaceTest(makePropagator(bz), geoCtx, magCtx,
0093                    makeParametersCurvilinear(phi, theta, p, q), s,
0094                    DiscSurfaceBuilder(), 1_um, 1_um, 0.125_mrad, epsMom,
0095                    TargetReached());
0096 }
0097 
0098 BOOST_DATA_TEST_CASE(ToPlane,
0099                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0100                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0101                      phi, theta, p, q, s, bz) {
0102   runToSurfaceTest(makePropagator(bz), geoCtx, magCtx,
0103                    makeParametersCurvilinear(phi, theta, p, q), s,
0104                    PlaneSurfaceBuilder(), 1_um, 1_um, 0.125_mrad, epsMom,
0105                    TargetReached());
0106 }
0107 
0108 BOOST_DATA_TEST_CASE(ToStrawAlongZ,
0109                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0110                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0111                      phi, theta, p, q, s, bz) {
0112   runToSurfaceTest(makePropagator(bz), geoCtx, magCtx,
0113                    makeParametersCurvilinear(phi, theta, p, q), s,
0114                    ZStrawSurfaceBuilder(), 1_um, 1_um, 0.125_mrad, epsMom);
0115 }
0116 
0117 BOOST_DATA_TEST_CASE(CovarianceCurvilinear,
0118                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0119                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0120                      phi, theta, p, q, s, bz) {
0121   runForwardComparisonTest(
0122       makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
0123       makeParametersCurvilinearWithCovariance(phi, theta, p, q), s, epsPos,
0124       epsTime, epsDir, epsMom, epsCov);
0125 }
0126 
0127 BOOST_DATA_TEST_CASE(
0128     CovarianceToCylinderAlongZ,
0129     ds::phiWithoutAmbiguity* ds::thetaWithoutBeam* ds::absMomentum*
0130         ds::chargeNonZero* ds::pathLength* ds::magneticField,
0131     phi, theta, p, q, s, bz) {
0132   runToSurfaceComparisonTest(
0133       makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
0134       makeParametersCurvilinearWithCovariance(phi, theta, p, q), s,
0135       ZCylinderSurfaceBuilder(), 1_um, 1_um, 0.125_mrad, epsMom, epsCov);
0136 }
0137 
0138 BOOST_DATA_TEST_CASE(CovarianceToDisc,
0139                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0140                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0141                      phi, theta, p, q, s, bz) {
0142   runToSurfaceComparisonTest(
0143       makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
0144       makeParametersCurvilinearWithCovariance(phi, theta, p, q), s,
0145       DiscSurfaceBuilder(), 1_um, 1_um, 0.125_mrad, epsMom, epsCov,
0146       TargetReached());
0147 }
0148 
0149 BOOST_DATA_TEST_CASE(CovarianceToPlane,
0150                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0151                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0152                      phi, theta, p, q, s, bz) {
0153   runToSurfaceComparisonTest(
0154       makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
0155       makeParametersCurvilinearWithCovariance(phi, theta, p, q), s,
0156       PlaneSurfaceBuilder(), 1_um, 1_um, 0.125_mrad, epsMom, epsCov,
0157       TargetReached());
0158 }
0159 
0160 BOOST_DATA_TEST_CASE(CovarianceToStrawAlongZ,
0161                      ds::phi* ds::thetaWithoutBeam* ds::absMomentum*
0162                          ds::chargeNonZero* ds::pathLength* ds::magneticField,
0163                      phi, theta, p, q, s, bz) {
0164   // the numerical covariance transport to straw surfaces does not seem to be
0165   // stable. use a higher tolerance for now.
0166   runToSurfaceComparisonTest(
0167       makePropagator(bz), makeRiddersPropagator(bz), geoCtx, magCtx,
0168       makeParametersCurvilinearWithCovariance(phi, theta, p, q), s,
0169       ZStrawSurfaceBuilder(), 1_um, 1_um, 0.125_mrad, epsMom, 0.125);
0170 }
0171 
0172 BOOST_AUTO_TEST_SUITE_END()