Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:36

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