9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/unit_test.hpp>
54 using namespace Acts::UnitLiterals;
63 using StraightLineEstimator =
75 auto d0s = bd::make({-25_um, 25_um});
76 auto l0s = bd::make({-1_mm, 1_mm});
77 auto t0s = bd::make({-2_ns, 2_ns});
78 auto phis = bd::make({0_degree, -45_degree, 45_degree});
79 auto thetas = bd::make({90_degree, 20_degree, 160_degree});
80 auto ps = bd::make({0.4_GeV, 1_GeV, 10_GeV});
81 auto qs = bd::make({-1_e, 1_e});
83 auto tracksWithoutIPs = t0s * phis *
thetas *
ps * qs;
85 auto tracks = IPs * tracksWithoutIPs;
88 auto vx0s = bd::make({0_um, -10_um, 10_um});
89 auto vy0s = bd::make({0_um, -10_um, 10_um});
90 auto vz0s = bd::make({0_mm, -25_mm, 25_mm});
91 auto vt0s = bd::make({0_ns, -2_ns, 2_ns});
93 auto vertices = vx0s * vy0s * vz0s * vt0s;
96 Estimator makeEstimator(
double bZ) {
97 auto field = std::make_shared<MagneticField>(
Vector3(0, 0, bZ));
100 std::make_shared<Propagator>(
103 return Estimator(
cfg);
108 double stdDevTime = 30_ps) {
116 return stddev.cwiseProduct(stddev).asDiagonal();
122 stddev[
ePos0] = 10_um;
123 stddev[
ePos1] = 10_um;
124 stddev[
ePos2] = 75_um;
125 stddev[
eTime] = 1_ns;
126 return stddev.cwiseProduct(stddev).asDiagonal();
130 std::uniform_real_distribution<> uniformDist(0.0, 1.0);
132 std::uniform_real_distribution<> signDist(-1, 1);
135 BOOST_AUTO_TEST_SUITE(VertexingImpactPointEstimator)
151 Estimator ipEstimator = makeEstimator(2_T);
152 Estimator::State
state(magFieldCache());
154 Vector3 refPosition(0., 0., 0.);
155 auto perigeeSurface = Surface::makeShared<PerigeeSurface>(refPosition);
161 double distT = std::hypot(d0, l0);
163 ipEstimator.calculateDistance(
geoContext, myTrack, refPosition, state)
169 BOOST_CHECK((dist3 < distT) or
170 (theta == 90_degree and std::abs(dist3 - distT) < 1_nm));
173 auto res = ipEstimator.estimate3DImpactParameters(
177 const auto& atIp3d = trackAtIP3d.
parameters();
180 BOOST_CHECK_NE(atPerigee[
eBoundLoc0], atIp3d[eBoundLoc0]);
181 BOOST_CHECK_NE(atPerigee[
eBoundLoc1], atIp3d[eBoundLoc1]);
186 std::numeric_limits<ActsScalar>::epsilon());
192 .getVertexCompatibility<3>(
geoContext, &trackAtIP3d, refPosition)
194 BOOST_CHECK_GT(compatibility, 0);
198 q, vx0, vy0, vz0, vt0) {
203 auto field = std::make_shared<MagneticField>(
Vector3(0, 0, 2_T));
205 auto propagator = std::make_shared<Propagator>(
std::move(stepper));
207 Estimator ipEstimator(cfg);
208 Estimator::State ipState(magFieldCache());
211 auto zeroField = std::make_shared<MagneticField>(
Vector3(0, 0, 0));
213 auto straightLinePropagator =
214 std::make_shared<StraightPropagator>(straightLineStepper);
216 StraightLineEstimator zeroFieldIPEstimator(zeroFieldCfg);
217 StraightLineEstimator::State zeroFieldIPState(magFieldCache());
220 Vector4 vtxPos(vx0, vy0, vz0, vt0);
224 auto vtxPerigeeSurface =
225 Surface::makeShared<PerigeeSurface>(vtxPos.head<3>());
239 makeBoundParametersCovariance(),
247 double cosPhi = std::cos(
phi);
248 double sinPhi = std::sin(
phi);
249 double sinTheta = std::sin(
theta);
251 Vector3(cosPhi * sinTheta, sinPhi * sinTheta, std::cos(
theta));
254 Vector3 refPoint(2_mm, -2_mm, -5_mm);
257 auto refPerigeeSurface = Surface::makeShared<PerigeeSurface>(refPoint);
261 auto intersection = refPerigeeSurface
269 auto result = propagator->propagate(params, *refPerigeeSurface, pOptions);
270 BOOST_CHECK(result.ok());
271 const auto& refParams = *result->endParameters;
274 auto zeroFieldResult =
275 straightLinePropagator->propagate(params, *refPerigeeSurface, pOptions);
276 BOOST_CHECK(zeroFieldResult.ok());
277 const auto& zeroFieldRefParams = *zeroFieldResult->endParameters;
280 "Check time at 2D PCA (i.e., function getImpactParameters) for helical "
283 auto ipParams = ipEstimator
284 .getImpactParameters(refParams, vtx,
geoContext,
297 auto checkGetDistanceAndMomentum = [&vtxPos, &corrMomDir, corrTimeDiff](
298 const auto& ipe,
const auto& rParams,
302 auto distAndMom = ipe.template getDistanceAndMomentum<4>(
307 Vector3 momDir = distAndMom.second;
323 "Check time at 3D PCA (i.e., function getDistanceAndMomentum) for "
325 checkGetDistanceAndMomentum(zeroFieldIPEstimator, zeroFieldRefParams,
329 "Check time at 3D PCA (i.e., function getDistanceAndMomentum) for "
331 checkGetDistanceAndMomentum(ipEstimator, refParams, ipState);
339 std::mt19937
gen(seed);
342 Estimator ipEstimator = makeEstimator(2_T);
345 Vector4 vtxPos(vx0, vy0, vz0, vt0);
352 coordinateSystem.matrix().block<3, 1>(0, 3) = vtxPos.head<3>();
355 std::shared_ptr<PlaneSurface> planeSurface =
356 Surface::makeShared<PlaneSurface>(coordinateSystem);
362 double timeDiffFactor = uniformDist(gen);
363 double timeDiffClose = timeDiffFactor * 0.1_ps;
364 double timeDiffFar = timeDiffFactor * 0.11_ps;
367 double sgnClose = signDist(gen) < 0 ? -1. : 1.;
368 double sgnFar = signDist(gen) < 0 ? -1. : 1.;
373 paramVecClose[
eBoundTime] = vt0 + sgnClose * timeDiffClose;
376 paramVecFar[
eBoundTime] = vt0 + sgnFar * timeDiffFar;
380 makeBoundParametersCovariance(30_ns),
386 planeSurface, paramVecClose, makeBoundParametersCovariance(31_ns),
391 makeBoundParametersCovariance(30_ns),
395 double compatibilityClose =
396 ipEstimator.getVertexCompatibility<4>(
geoContext, ¶msClose, vtxPos)
398 double compatibilityCloseLargerCov =
400 .getVertexCompatibility<4>(
geoContext, ¶msCloseLargerCov, vtxPos)
402 double compatibilityFar =
403 ipEstimator.getVertexCompatibility<4>(
geoContext, ¶msFar, vtxPos)
408 BOOST_CHECK(compatibilityClose < compatibilityFar);
410 BOOST_CHECK(compatibilityCloseLargerCov < compatibilityClose);
421 Estimator ipEstimator = makeEstimator(1.9971546939_T);
422 Estimator::State
state(magFieldCache());
425 Vector4 pos1(2_mm, 1_mm, -10_mm, 0_ns);
426 Vector3 mom1(400_MeV, 600_MeV, 200_MeV);
427 Vector3 vtxPos(1.2_mm, 0.8_mm, -7_mm);
430 auto perigeeSurface =
431 Surface::makeShared<PerigeeSurface>(pos1.segment<3>(
ePos0));
434 perigeeSurface,
geoContext, pos1, mom1, 1_e / mom1.norm(),
435 BoundTrackParameters::CovarianceMatrix::Identity(),
441 ipEstimator.calculateDistance(
geoContext, params1, vtxPos, state).value();
444 auto res2 = ipEstimator.estimate3DImpactParameters(
446 BOOST_CHECK(res2.ok());
450 BOOST_CHECK_EQUAL(surfaceCenter, vtxPos);
457 Estimator ipEstimator = makeEstimator(2_T);
468 Vector4 ip_pos{0., 0., 0., 0.};
472 auto perigeeSurface = Surface::makeShared<PerigeeSurface>(ip_pos.head<3>());
474 makeBoundParametersCovariance(),
478 auto lifetimes_signs = ipEstimator.getLifetimeSignOfTrack(
482 BOOST_CHECK(lifetimes_signs.ok());
485 BOOST_CHECK((*lifetimes_signs).first > 0.);
488 BOOST_CHECK((*lifetimes_signs).second < 0.);
492 auto sign3d = ipEstimator.get3DLifetimeSignOfTrack(
496 BOOST_CHECK(sign3d.ok());
499 BOOST_CHECK((*sign3d) > 0.);
518 Estimator ipEstimator = makeEstimator(1_T);
519 Estimator::State
state(magFieldCache());
522 Vector3 refPosition(0., 0., 0.);
523 auto perigeeSurface = Surface::makeShared<PerigeeSurface>(refPosition);
526 makeBoundParametersCovariance(),
535 BOOST_CHECK_NE(output.d0, 0.);
536 BOOST_CHECK_NE(output.z0, 0.);
541 BOOST_AUTO_TEST_SUITE_END()