Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 08:21:46

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/Definitions/Algebra.hpp"
0013 #include "Acts/Definitions/Common.hpp"
0014 #include "Acts/Definitions/Direction.hpp"
0015 #include "Acts/Definitions/TrackParametrization.hpp"
0016 #include "Acts/Definitions/Units.hpp"
0017 #include "Acts/EventData/BoundTrackParameters.hpp"
0018 #include "Acts/Geometry/GeometryContext.hpp"
0019 #include "Acts/Geometry/GeometryIdentifier.hpp"
0020 #include "Acts/MagneticField/ConstantBField.hpp"
0021 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0022 #include "Acts/MagneticField/MagneticFieldProvider.hpp"
0023 #include "Acts/MagneticField/NullBField.hpp"
0024 #include "Acts/Propagator/EigenStepper.hpp"
0025 #include "Acts/Propagator/Propagator.hpp"
0026 #include "Acts/Propagator/StraightLineStepper.hpp"
0027 #include "Acts/Propagator/VoidNavigator.hpp"
0028 #include "Acts/Surfaces/PerigeeSurface.hpp"
0029 #include "Acts/Surfaces/PlaneSurface.hpp"
0030 #include "Acts/Surfaces/Surface.hpp"
0031 #include "Acts/Utilities/Intersection.hpp"
0032 #include "Acts/Utilities/Logger.hpp"
0033 #include "Acts/Utilities/Result.hpp"
0034 #include "Acts/Vertexing/ImpactPointEstimator.hpp"
0035 #include "Acts/Vertexing/Vertex.hpp"
0036 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0037 
0038 #include <cmath>
0039 #include <limits>
0040 #include <memory>
0041 #include <numbers>
0042 #include <optional>
0043 #include <utility>
0044 #include <vector>
0045 
0046 namespace ActsTests {
0047 
0048 namespace bd = boost::unit_test::data;
0049 
0050 using namespace Acts;
0051 using namespace Acts::UnitLiterals;
0052 using Acts::VectorHelpers::makeVector4;
0053 
0054 using MagneticField = ConstantBField;
0055 using StraightPropagator = Propagator<StraightLineStepper>;
0056 using Stepper = EigenStepper<>;
0057 using Propagator = Acts::Propagator<Stepper>;
0058 using Estimator = ImpactPointEstimator;
0059 using StraightLineEstimator = ImpactPointEstimator;
0060 
0061 const auto geoContext = GeometryContext::dangerouslyDefaultConstruct();
0062 const MagneticFieldContext magFieldContext;
0063 
0064 MagneticFieldProvider::Cache magFieldCache() {
0065   return NullBField{}.makeCache(magFieldContext);
0066 }
0067 
0068 // perigee track parameters dataset
0069 // only non-zero distances are tested
0070 auto d0s = bd::make({-25_um, 25_um});
0071 auto l0s = bd::make({-1_mm, 1_mm});
0072 auto t0s = bd::make({-2_ns, 2_ns});
0073 auto phis = bd::make({0_degree, -45_degree, 45_degree});
0074 auto thetas = bd::make({90_degree, 20_degree, 160_degree});
0075 auto ps = bd::make({0.4_GeV, 1_GeV, 10_GeV});
0076 auto qs = bd::make({-1_e, 1_e});
0077 // Cartesian products over all parameters
0078 auto tracksWithoutIPs = t0s * phis * thetas * ps * qs;
0079 auto IPs = d0s * l0s;
0080 auto tracks = IPs * tracksWithoutIPs;
0081 
0082 // vertex parameters dataset
0083 auto vx0s = bd::make({0_um, -10_um, 10_um});
0084 auto vy0s = bd::make({0_um, -10_um, 10_um});
0085 auto vz0s = bd::make({0_mm, -25_mm, 25_mm});
0086 auto vt0s = bd::make({0_ns, -2_ns, 2_ns});
0087 // Cartesian products over all parameters
0088 auto vertices = vx0s * vy0s * vz0s * vt0s;
0089 
0090 // Construct an impact point estimator for a constant bfield along z.
0091 Estimator makeEstimator(double bZ) {
0092   auto field = std::make_shared<MagneticField>(Vector3(0, 0, bZ));
0093   Stepper stepper(field);
0094   Estimator::Config cfg(field,
0095                         std::make_shared<Propagator>(
0096                             std::move(stepper), VoidNavigator(),
0097                             getDefaultLogger("Prop", Logging::Level::WARNING)));
0098   return Estimator(cfg);
0099 }
0100 
0101 // Construct a diagonal track covariance w/ reasonable values.
0102 BoundMatrix makeBoundParametersCovariance(double stdDevTime = 30_ps) {
0103   BoundVector stddev;
0104   stddev[eBoundLoc0] = 15_um;
0105   stddev[eBoundLoc1] = 100_um;
0106   stddev[eBoundTime] = stdDevTime;
0107   stddev[eBoundPhi] = 1_degree;
0108   stddev[eBoundTheta] = 1_degree;
0109   stddev[eBoundQOverP] = 1_e / 100_GeV;
0110   return stddev.cwiseProduct(stddev).asDiagonal();
0111 }
0112 
0113 // Construct a diagonal vertex covariance w/ reasonable values.
0114 SquareMatrix4 makeVertexCovariance() {
0115   Vector4 stddev;
0116   stddev[ePos0] = 10_um;
0117   stddev[ePos1] = 10_um;
0118   stddev[ePos2] = 75_um;
0119   stddev[eTime] = 1_ns;
0120   return stddev.cwiseProduct(stddev).asDiagonal();
0121 }
0122 
0123 // random value between 0 and 1
0124 std::uniform_real_distribution<double> uniformDist(0.0, 1.0);
0125 // random sign
0126 std::uniform_real_distribution<double> signDist(-1, 1);
0127 
0128 BOOST_AUTO_TEST_SUITE(VertexingSuite)
0129 
0130 // Check `calculateDistance`, `estimate3DImpactParameters`, and
0131 // `getVertexCompatibility`.
0132 BOOST_DATA_TEST_CASE(SingleTrackDistanceParametersCompatibility3D, tracks, d0,
0133                      l0, t0, phi, theta, p, q) {
0134   auto particleHypothesis = ParticleHypothesis::pion();
0135 
0136   BoundVector par;
0137   par[eBoundLoc0] = d0;
0138   par[eBoundLoc1] = l0;
0139   par[eBoundTime] = t0;
0140   par[eBoundPhi] = phi;
0141   par[eBoundTheta] = theta;
0142   par[eBoundQOverP] = particleHypothesis.qOverP(p, q);
0143 
0144   Estimator ipEstimator = makeEstimator(2_T);
0145   Estimator::State state{magFieldCache()};
0146   // reference position and corresponding perigee surface
0147   Vector3 refPosition(0., 0., 0.);
0148   auto perigeeSurface = Surface::makeShared<PerigeeSurface>(refPosition);
0149   // create the track
0150   BoundTrackParameters myTrack(
0151       perigeeSurface, par, makeBoundParametersCovariance(), particleHypothesis);
0152 
0153   // initial distance to the reference position in the perigee frame
0154   double distT = std::hypot(d0, l0);
0155   double dist3 =
0156       ipEstimator.calculateDistance(geoContext, myTrack, refPosition, state)
0157           .value();
0158   // estimated 3D distance should be less than the 2d distance in the perigee
0159   // frame. it should be equal if the track is a transverse track w/ theta =
0160   // 90deg. in that case there might be numerical deviations and we need to
0161   // check that it is less or equal within the numerical tolerance.
0162   BOOST_CHECK((dist3 < distT) ||
0163               (theta == 90_degree && std::abs(dist3 - distT) < 1_nm));
0164 
0165   // estimate parameters at the closest point in 3d
0166   auto res = ipEstimator.estimate3DImpactParameters(
0167       geoContext, magFieldContext, myTrack, refPosition, state);
0168   BoundTrackParameters trackAtIP3d = *res;
0169   const auto& atPerigee = myTrack.parameters();
0170   const auto& atIp3d = trackAtIP3d.parameters();
0171 
0172   // all parameters except the helix invariants theta, q/p should be changed.
0173   // Exception: for a transverse track (theta = 90 deg) the 2D and 3D PCA
0174   // coincide and the point surface measurement frame aligns with the perigee
0175   // frame, so the local position is unchanged.
0176   if (theta != 90_degree) {
0177     BOOST_CHECK_NE(atPerigee[eBoundLoc0], atIp3d[eBoundLoc0]);
0178     BOOST_CHECK_NE(atPerigee[eBoundLoc1], atIp3d[eBoundLoc1]);
0179   }
0180   // BOOST_CHECK_NE(atPerigee[eBoundTime], atIp3d[eBoundTime]);
0181   // BOOST_CHECK_NE(atPerigee[eBoundPhi], atIp3d[eBoundPhi]);
0182   CHECK_CLOSE_ABS(atPerigee[eBoundTheta], atIp3d[eBoundTheta], 0.01_mrad);
0183   CHECK_CLOSE_REL(atPerigee[eBoundQOverP], atIp3d[eBoundQOverP],
0184                   std::numeric_limits<double>::epsilon());
0185 
0186   // check that we get sensible compatibility scores
0187   // this is a chi2-like value and should always be positive
0188   auto compatibility =
0189       ipEstimator.getVertexCompatibility(geoContext, &trackAtIP3d, refPosition)
0190           .value();
0191   BOOST_CHECK_GT(compatibility, 0);
0192 }
0193 
0194 BOOST_DATA_TEST_CASE(TimeAtPca, tracksWithoutIPs* vertices, t0, phi, theta, p,
0195                      q, vx0, vy0, vz0, vt0) {
0196   using Propagator = Acts::Propagator<Stepper>;
0197   using PropagatorOptions = Propagator::Options<>;
0198   using StraightPropagator = Acts::Propagator<StraightLineStepper>;
0199 
0200   // Set up quantities for constant B field
0201   auto field = std::make_shared<MagneticField>(Vector3(0, 0, 2_T));
0202   Stepper stepper(field);
0203   auto propagator = std::make_shared<Propagator>(std::move(stepper));
0204   Estimator::Config cfg(field, propagator);
0205   Estimator ipEstimator(cfg);
0206   Estimator::State ipState{magFieldCache()};
0207 
0208   // Set up quantities for B = 0
0209   auto zeroField = std::make_shared<MagneticField>(Vector3(0, 0, 0));
0210   StraightLineStepper straightLineStepper;
0211   auto straightLinePropagator =
0212       std::make_shared<StraightPropagator>(straightLineStepper);
0213   StraightLineEstimator::Config zeroFieldCfg(zeroField, straightLinePropagator);
0214   StraightLineEstimator zeroFieldIPEstimator(zeroFieldCfg);
0215   StraightLineEstimator::State zeroFieldIPState{magFieldCache()};
0216 
0217   // Vertex position and vertex object
0218   Vector4 vtxPos(vx0, vy0, vz0, vt0);
0219   Vertex vtx(vtxPos, makeVertexCovariance(), {});
0220 
0221   // Perigee surface at vertex position
0222   auto vtxPerigeeSurface =
0223       Surface::makeShared<PerigeeSurface>(vtxPos.head<3>());
0224 
0225   // Track parameter vector for a track that originates at the vertex.
0226   // Note that 2D and 3D PCA coincide since the track passes exactly through the
0227   // vertex.
0228   BoundVector paramVec;
0229   paramVec[eBoundLoc0] = 0.;
0230   paramVec[eBoundLoc1] = 0.;
0231   paramVec[eBoundTime] = t0;
0232   paramVec[eBoundPhi] = phi;
0233   paramVec[eBoundTheta] = theta;
0234   paramVec[eBoundQOverP] = q / p;
0235 
0236   BoundTrackParameters params(vtxPerigeeSurface, paramVec,
0237                               makeBoundParametersCovariance(),
0238                               ParticleHypothesis::pion());
0239 
0240   // Correct quantities for checking if IP estimation worked
0241   // Time of the track with respect to the vertex
0242   double corrTimeDiff = t0 - vt0;
0243 
0244   // Momentum direction at vertex (i.e., at 3D PCA)
0245   double cosPhi = std::cos(phi);
0246   double sinPhi = std::sin(phi);
0247   double sinTheta = std::sin(theta);
0248   Vector3 corrMomDir =
0249       Vector3(cosPhi * sinTheta, sinPhi * sinTheta, std::cos(theta));
0250 
0251   // Arbitrary reference point
0252   Vector3 refPoint(2_mm, -2_mm, -5_mm);
0253 
0254   // Perigee surface at vertex position
0255   auto refPerigeeSurface = Surface::makeShared<PerigeeSurface>(refPoint);
0256 
0257   // Set up the propagator options (they are the same with and without B field)
0258   PropagatorOptions pOptions(geoContext, magFieldContext);
0259   Intersection3D intersection =
0260       refPerigeeSurface
0261           ->intersect(geoContext, params.position(geoContext),
0262                       params.direction(), BoundaryTolerance::Infinite())
0263           .closest();
0264   pOptions.direction =
0265       Direction::fromScalarZeroAsPositive(intersection.pathLength());
0266 
0267   StraightPropagator::Options<> straightPOptions(geoContext, magFieldContext);
0268   straightPOptions.direction = pOptions.direction;
0269 
0270   // Propagate to the 2D PCA of the reference point in a constant B field
0271   auto result = propagator->propagate(params, *refPerigeeSurface, pOptions);
0272   BOOST_CHECK(result.ok());
0273   const auto& refParams = *result->endParameters;
0274 
0275   // Propagate to the 2D PCA of the reference point when B = 0
0276   auto zeroFieldResult = straightLinePropagator->propagate(
0277       params, *refPerigeeSurface, straightPOptions);
0278   BOOST_CHECK(zeroFieldResult.ok());
0279   const auto& zeroFieldRefParams = *zeroFieldResult->endParameters;
0280 
0281   BOOST_TEST_CONTEXT(
0282       "Check time at 2D PCA (i.e., function getImpactParameters) for helical "
0283       "tracks") {
0284     // Calculate impact parameters
0285     auto ipParams = ipEstimator
0286                         .getImpactParameters(refParams, vtx, geoContext,
0287                                              magFieldContext, true)
0288                         .value();
0289     // Spatial impact parameters should be 0 because the track passes through
0290     // the vertex
0291     CHECK_CLOSE_ABS(ipParams.d0, 0., 30_nm);
0292     CHECK_CLOSE_ABS(ipParams.z0, 0., 100_nm);
0293     // Time impact parameter should correspond to the time where the track
0294     // passes through the vertex
0295     CHECK_CLOSE_OR_SMALL(ipParams.deltaT.value(), std::abs(corrTimeDiff), 1e-5,
0296                          1e-3);
0297   }
0298 
0299   auto checkGetDistanceAndMomentum = [&vtxPos, &corrMomDir, corrTimeDiff](
0300                                          const auto& ipe, const auto& rParams,
0301                                          auto& state) {
0302     // Find 4D distance and momentum of the track at the vertex starting from
0303     // the perigee representation at the reference position
0304     auto distAndMom = ipe.template getDistanceAndMomentum<4>(
0305                              geoContext, rParams, vtxPos, state)
0306                           .value();
0307 
0308     Vector4 distVec = distAndMom.first;
0309     Vector3 momDir = distAndMom.second;
0310 
0311     // Check quantities:
0312     // Spatial distance should be 0 as track passes through the vertex
0313     double dist = distVec.head<3>().norm();
0314     CHECK_CLOSE_ABS(dist, 0., 30_nm);
0315     // Distance in time should correspond to the time of the track in a
0316     // coordinate system with the vertex as the origin since the track passes
0317     // exactly through the vertex
0318     CHECK_CLOSE_OR_SMALL(distVec[3], corrTimeDiff, 1e-5, 1e-4);
0319     // Momentum direction should correspond to the momentum direction at the
0320     // vertex
0321     CHECK_CLOSE_OR_SMALL(momDir, corrMomDir, 1e-5, 1e-4);
0322   };
0323 
0324   BOOST_TEST_CONTEXT(
0325       "Check time at 3D PCA (i.e., function getDistanceAndMomentum) for "
0326       "straight tracks") {
0327     checkGetDistanceAndMomentum(zeroFieldIPEstimator, zeroFieldRefParams,
0328                                 zeroFieldIPState);
0329   }
0330   BOOST_TEST_CONTEXT(
0331       "Check time at 3D PCA (i.e., function getDistanceAndMomentum) for "
0332       "helical tracks") {
0333     checkGetDistanceAndMomentum(ipEstimator, refParams, ipState);
0334   }
0335 }
0336 
0337 BOOST_DATA_TEST_CASE(VertexCompatibility4D, IPs* vertices, d0, l0, vx0, vy0,
0338                      vz0, vt0) {
0339   // Set up RNG
0340   int seed = 31415;
0341   std::mt19937 gen(seed);
0342 
0343   // Impact point estimator
0344   Estimator ipEstimator = makeEstimator(2_T);
0345 
0346   // Vertex position
0347   Vector4 vtxPos(vx0, vy0, vz0, vt0);
0348 
0349   // Dummy coordinate system with origin at vertex
0350   Transform3 coordinateSystem;
0351   // First three columns correspond to coordinate system axes
0352   coordinateSystem.matrix().block<3, 3>(0, 0) = SquareMatrix<3>::Identity();
0353   // Fourth column corresponds to origin of the coordinate system
0354   coordinateSystem.matrix().block<3, 1>(0, 3) = vtxPos.head<3>();
0355 
0356   // Dummy plane surface
0357   std::shared_ptr<PlaneSurface> planeSurface =
0358       Surface::makeShared<PlaneSurface>(coordinateSystem);
0359 
0360   // Create two track parameter vectors that are alike except that one is closer
0361   // to the vertex in time. Note that momenta don't play a role in the
0362   // computation and we set the angles and q/p to 0.
0363   // Time offsets
0364   double timeDiffFactor = uniformDist(gen);
0365   double timeDiffClose = timeDiffFactor * 0.1_ps;
0366   double timeDiffFar = timeDiffFactor * 0.11_ps;
0367 
0368   // Different random signs for the time offsets
0369   double sgnClose = std::copysign(1., signDist(gen));
0370   double sgnFar = std::copysign(1., signDist(gen));
0371 
0372   BoundVector paramVecClose = BoundVector::Zero();
0373   paramVecClose[eBoundLoc0] = d0;
0374   paramVecClose[eBoundLoc1] = l0;
0375   paramVecClose[eBoundPhi] = 0;
0376   paramVecClose[eBoundTheta] = std::numbers::pi / 2;
0377   paramVecClose[eBoundQOverP] = 0;
0378   paramVecClose[eBoundTime] = vt0 + sgnClose * timeDiffClose;
0379 
0380   BoundVector paramVecFar = paramVecClose;
0381   paramVecFar[eBoundTime] = vt0 + sgnFar * timeDiffFar;
0382 
0383   // Track whose time is similar to the vertex time
0384   BoundTrackParameters paramsClose(planeSurface, paramVecClose,
0385                                    makeBoundParametersCovariance(30_ns),
0386                                    ParticleHypothesis::pion());
0387 
0388   // Track whose time is similar to the vertex time but with a larger time
0389   // variance
0390   BoundTrackParameters paramsCloseLargerCov(
0391       planeSurface, paramVecClose, makeBoundParametersCovariance(31_ns),
0392       ParticleHypothesis::pion());
0393 
0394   // Track whose time differs slightly more from the vertex time
0395   BoundTrackParameters paramsFar(planeSurface, paramVecFar,
0396                                  makeBoundParametersCovariance(30_ns),
0397                                  ParticleHypothesis::pion());
0398 
0399   // Calculate the 4D vertex compatibilities of the three tracks
0400   double compatibilityClose =
0401       ipEstimator.getVertexCompatibility(geoContext, &paramsClose, vtxPos)
0402           .value();
0403   double compatibilityCloseLargerCov =
0404       ipEstimator
0405           .getVertexCompatibility(geoContext, &paramsCloseLargerCov, vtxPos)
0406           .value();
0407   double compatibilityFar =
0408       ipEstimator.getVertexCompatibility(geoContext, &paramsFar, vtxPos)
0409           .value();
0410 
0411   // The track who is closer in time must have a better (i.e., smaller)
0412   // compatibility
0413   BOOST_CHECK_LT(compatibilityClose, compatibilityFar);
0414   // The track with the larger covariance must be the most compatible
0415   BOOST_CHECK_LT(compatibilityCloseLargerCov, compatibilityClose);
0416 }
0417 
0418 // Compare calculations w/ known good values from Athena.
0419 //
0420 // Checks the results for a single track with the same test values as in Athena
0421 // unit test algorithm
0422 //
0423 //   Tracking/TrkVertexFitter/TrkVertexFitterUtils/test/ImpactPointEstimator_test
0424 //
0425 BOOST_AUTO_TEST_CASE(SingleTrackDistanceParametersAthenaRegression) {
0426   Estimator ipEstimator = makeEstimator(1.9971546939_T);
0427   Estimator::State state{magFieldCache()};
0428 
0429   // Use same values as in Athena unit test
0430   Vector4 pos1(2_mm, 1_mm, -10_mm, 0_ns);
0431   Vector3 mom1(400_MeV, 600_MeV, 200_MeV);
0432   Vector3 vtxPos(1.2_mm, 0.8_mm, -7_mm);
0433 
0434   // Start creating some track parameters
0435   auto perigeeSurface =
0436       Surface::makeShared<PerigeeSurface>(pos1.segment<3>(ePos0));
0437   // Some fixed track parameter values
0438   auto params1 = BoundTrackParameters::create(
0439                      geoContext, perigeeSurface, pos1, mom1, 1_e / mom1.norm(),
0440                      BoundMatrix::Identity(), ParticleHypothesis::pion())
0441                      .value();
0442 
0443   // Compare w/ desired result from Athena unit test
0444   auto distance =
0445       ipEstimator.calculateDistance(geoContext, params1, vtxPos, state).value();
0446   CHECK_CLOSE_ABS(distance, 3.10391_mm, 10_nm);
0447 
0448   auto res2 = ipEstimator.estimate3DImpactParameters(
0449       geoContext, magFieldContext, params1, vtxPos, state);
0450   BOOST_CHECK(res2.ok());
0451   BoundTrackParameters endParams = *res2;
0452   Vector3 surfaceCenter = endParams.referenceSurface().center(geoContext);
0453 
0454   BOOST_CHECK_EQUAL(surfaceCenter, vtxPos);
0455 }
0456 
0457 // Test the Impact3d Point estimator 2d and 3d lifetimes sign
0458 // on a single track.
0459 
0460 BOOST_AUTO_TEST_CASE(Lifetimes2d3d) {
0461   Estimator ipEstimator = makeEstimator(2_T);
0462 
0463   // Create a track from a decay
0464   BoundVector trk_par;
0465   trk_par[eBoundLoc0] = 200_um;
0466   trk_par[eBoundLoc1] = 300_um;
0467   trk_par[eBoundTime] = 1_ns;
0468   trk_par[eBoundPhi] = 45_degree;
0469   trk_par[eBoundTheta] = 45_degree;
0470   trk_par[eBoundQOverP] = 1_e / 10_GeV;
0471 
0472   Vector4 ip_pos{0., 0., 0., 0.};
0473   Vertex ip_vtx(ip_pos, makeVertexCovariance(), {});
0474 
0475   // Form the bound track parameters at the ip
0476   auto perigeeSurface = Surface::makeShared<PerigeeSurface>(ip_pos.head<3>());
0477   BoundTrackParameters track(perigeeSurface, trk_par,
0478                              makeBoundParametersCovariance(),
0479                              ParticleHypothesis::pion());
0480 
0481   Vector3 direction{0., 1., 0.};
0482   auto lifetimes_signs = ipEstimator.getLifetimeSignOfTrack(
0483       track, ip_vtx, direction, geoContext, magFieldContext);
0484 
0485   // Check if the result is OK
0486   BOOST_CHECK(lifetimes_signs.ok());
0487 
0488   // Check that d0 sign is positive
0489   BOOST_CHECK_GT((*lifetimes_signs).first, 0.);
0490 
0491   // Check that z0 sign is negative
0492   BOOST_CHECK_LT((*lifetimes_signs).second, 0.);
0493 
0494   // Check the 3d sign
0495 
0496   auto sign3d = ipEstimator.get3DLifetimeSignOfTrack(
0497       track, ip_vtx, direction, geoContext, magFieldContext);
0498 
0499   // Check result is OK
0500   BOOST_CHECK(sign3d.ok());
0501 
0502   // Check 3D sign (should be positive)
0503   BOOST_CHECK_GT((*sign3d), 0.);
0504 }
0505 
0506 // Check `.getImpactParameters`.
0507 BOOST_DATA_TEST_CASE(SingeTrackImpactParameters, tracks* vertices, d0, l0, t0,
0508                      phi, theta, p, q, vx0, vy0, vz0, vt0) {
0509   BoundVector par;
0510   par[eBoundLoc0] = d0;
0511   par[eBoundLoc1] = l0;
0512   par[eBoundTime] = t0;
0513   par[eBoundPhi] = phi;
0514   par[eBoundTheta] = theta;
0515   par[eBoundQOverP] = q / p;
0516   Vector4 vtxPos;
0517   vtxPos[ePos0] = vx0;
0518   vtxPos[ePos1] = vy0;
0519   vtxPos[ePos2] = vz0;
0520   vtxPos[eTime] = vt0;
0521 
0522   Estimator ipEstimator = makeEstimator(1_T);
0523   Estimator::State state{magFieldCache()};
0524 
0525   // reference position and corresponding perigee surface
0526   Vector3 refPosition(0., 0., 0.);
0527   auto perigeeSurface = Surface::makeShared<PerigeeSurface>(refPosition);
0528   // create track and vertex
0529   BoundTrackParameters track(perigeeSurface, par,
0530                              makeBoundParametersCovariance(),
0531                              ParticleHypothesis::pionLike(std::abs(q)));
0532   Vertex myConstraint(vtxPos, makeVertexCovariance(), {});
0533 
0534   // check that computed impact parameters are meaningful
0535   ImpactParametersAndSigma output =
0536       ipEstimator
0537           .getImpactParameters(track, myConstraint, geoContext, magFieldContext)
0538           .value();
0539   BOOST_CHECK_NE(output.d0, 0.);
0540   BOOST_CHECK_NE(output.z0, 0.);
0541   // TODO what about the other struct members? can the parameter space be
0542   // restricted further?
0543 }
0544 
0545 BOOST_AUTO_TEST_SUITE_END()
0546 
0547 }  // namespace ActsTests