File indexing completed on 2025-07-09 07:50:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Direction.hpp"
0012 #include "Acts/Definitions/Units.hpp"
0013 #include "Acts/EventData/TrackParameters.hpp"
0014 #include "Acts/Geometry/CuboidVolumeBuilder.hpp"
0015 #include "Acts/Geometry/GeometryContext.hpp"
0016 #include "Acts/Geometry/TrackingGeometry.hpp"
0017 #include "Acts/Geometry/TrackingGeometryBuilder.hpp"
0018 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0019 #include "Acts/Material/HomogeneousVolumeMaterial.hpp"
0020 #include "Acts/Material/Interactions.hpp"
0021 #include "Acts/Material/Material.hpp"
0022 #include "Acts/Surfaces/CylinderSurface.hpp"
0023 #include "Acts/Surfaces/DiscSurface.hpp"
0024 #include "Acts/Surfaces/PlaneSurface.hpp"
0025 #include "Acts/Surfaces/RectangleBounds.hpp"
0026 #include "Acts/Surfaces/StrawSurface.hpp"
0027 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0028 #include "Acts/Tests/CommonHelpers/PredefinedMaterials.hpp"
0029 #include "Acts/Utilities/Logger.hpp"
0030 #include "Acts/Utilities/MathHelpers.hpp"
0031 #include "Acts/Utilities/UnitVectors.hpp"
0032 #include "Acts/Utilities/detail/periodic.hpp"
0033
0034 #include <utility>
0035
0036 inline std::shared_ptr<const Acts::TrackingGeometry> createDenseBlock(
0037 const Acts::GeometryContext& geoCtx) {
0038 using namespace Acts;
0039 using namespace UnitLiterals;
0040
0041 CuboidVolumeBuilder::VolumeConfig vConf;
0042 vConf.position = {0., 0., 0.};
0043 vConf.length = {4_m, 4_m, 4_m};
0044 vConf.volumeMaterial =
0045 std::make_shared<const HomogeneousVolumeMaterial>(Test::makeBeryllium());
0046 CuboidVolumeBuilder::Config conf;
0047 conf.volumeCfg.push_back(vConf);
0048 conf.position = {0., 0., 0.};
0049 conf.length = {4_m, 4_m, 4_m};
0050 CuboidVolumeBuilder cvb(conf);
0051 TrackingGeometryBuilder::Config tgbCfg;
0052 tgbCfg.trackingVolumeBuilders.push_back(
0053 [=](const auto& context, const auto& inner, const auto&) {
0054 return cvb.trackingVolume(context, inner, nullptr);
0055 });
0056
0057 return TrackingGeometryBuilder(tgbCfg).trackingGeometry(geoCtx);
0058 }
0059
0060 inline std::tuple<std::shared_ptr<const Acts::TrackingGeometry>,
0061 std::vector<const Acts::Surface*>>
0062 createDenseTelescope(const Acts::GeometryContext& geoCtx,
0063 Acts::Material material, double thickness) {
0064 using namespace Acts;
0065 using namespace UnitLiterals;
0066
0067 CuboidVolumeBuilder::Config conf;
0068 conf.position = {0., 0., 0.};
0069 conf.length = {4_m, 2_m, 2_m};
0070
0071 {
0072 CuboidVolumeBuilder::VolumeConfig start;
0073 start.position = {-1_m, 0, 0};
0074 start.length = {1_m, 1_m, 1_m};
0075 start.name = "start";
0076
0077 conf.volumeCfg.push_back(start);
0078 }
0079
0080 if (thickness < 1_m) {
0081 CuboidVolumeBuilder::VolumeConfig gap;
0082 gap.position = {-0.25 * (1_m + thickness), 0, 0};
0083 gap.length = {0.5 * (1_m - thickness), 1_m, 1_m};
0084 gap.name = "gap1";
0085
0086 conf.volumeCfg.push_back(gap);
0087 }
0088
0089 {
0090 CuboidVolumeBuilder::VolumeConfig dense;
0091 dense.position = {0, 0, 0};
0092 dense.length = {thickness, 1_m, 1_m};
0093 dense.volumeMaterial =
0094 std::make_shared<const HomogeneousVolumeMaterial>(material);
0095 dense.name = "dense";
0096
0097 conf.volumeCfg.push_back(dense);
0098 }
0099
0100 if (thickness < 1_m) {
0101 CuboidVolumeBuilder::VolumeConfig gap;
0102 gap.position = {0.25 * (1_m + thickness), 0, 0};
0103 gap.length = {0.5 * (1_m - thickness), 1_m, 1_m};
0104 gap.name = "gap2";
0105
0106 conf.volumeCfg.push_back(gap);
0107 }
0108
0109 {
0110 CuboidVolumeBuilder::SurfaceConfig surface;
0111 surface.position = {1.5_m, 0, 0};
0112 surface.rotation =
0113 Eigen::AngleAxisd(std::numbers::pi / 2, Eigen::Vector3d::UnitY())
0114 .matrix();
0115 surface.rBounds = std::make_shared<RectangleBounds>(1_m, 1_m);
0116
0117 CuboidVolumeBuilder::LayerConfig layer;
0118 layer.surfaceCfg.push_back(surface);
0119
0120 CuboidVolumeBuilder::VolumeConfig end;
0121 end.position = {1_m, 0, 0};
0122 end.length = {1_m, 1_m, 1_m};
0123 end.layerCfg.push_back(layer);
0124 end.name = "end";
0125
0126 conf.volumeCfg.push_back(end);
0127 }
0128
0129 CuboidVolumeBuilder cvb(conf);
0130
0131 TrackingGeometryBuilder::Config tgbCfg;
0132 tgbCfg.trackingVolumeBuilders.push_back(
0133 [=](const auto& context, const auto& inner, const auto&) {
0134 return cvb.trackingVolume(context, inner, nullptr);
0135 });
0136 auto detector = TrackingGeometryBuilder(tgbCfg).trackingGeometry(geoCtx);
0137
0138 std::vector<const Surface*> surfaces;
0139 detector->visitSurfaces(
0140 [&](const Surface* surface) { surfaces.push_back(surface); });
0141
0142 return {std::move(detector), std::move(surfaces)};
0143 }
0144
0145
0146
0147
0148 inline Acts::BoundTrackParameters makeParametersCurvilinear(double phi,
0149 double theta,
0150 double absMom,
0151 double charge) {
0152 using namespace Acts;
0153 using namespace UnitLiterals;
0154
0155 Vector4 pos4 = Vector4::Zero();
0156 auto particleHypothesis = ParticleHypothesis::pionLike(std::abs(charge));
0157 return BoundTrackParameters::createCurvilinear(
0158 pos4, phi, theta, particleHypothesis.qOverP(absMom, charge), std::nullopt,
0159 particleHypothesis);
0160 }
0161
0162
0163 inline Acts::BoundTrackParameters makeParametersCurvilinearWithCovariance(
0164 double phi, double theta, double absMom, double charge) {
0165 using namespace Acts;
0166 using namespace UnitLiterals;
0167
0168 BoundVector stddev = BoundVector::Zero();
0169
0170 stddev[eBoundLoc0] = 15_um;
0171 stddev[eBoundLoc1] = 80_um;
0172 stddev[eBoundTime] = 20_ps;
0173 stddev[eBoundPhi] = 20_mrad;
0174 stddev[eBoundTheta] = 30_mrad;
0175 stddev[eBoundQOverP] = 1_e / 10_GeV;
0176 BoundSquareMatrix corr = BoundSquareMatrix::Identity();
0177 corr(eBoundLoc0, eBoundLoc1) = corr(eBoundLoc1, eBoundLoc0) = 0.125;
0178 corr(eBoundLoc0, eBoundPhi) = corr(eBoundPhi, eBoundLoc0) = 0.25;
0179 corr(eBoundLoc1, eBoundTheta) = corr(eBoundTheta, eBoundLoc1) = -0.25;
0180 corr(eBoundTime, eBoundQOverP) = corr(eBoundQOverP, eBoundTime) = 0.125;
0181 corr(eBoundPhi, eBoundTheta) = corr(eBoundTheta, eBoundPhi) = -0.25;
0182 corr(eBoundPhi, eBoundQOverP) = corr(eBoundPhi, eBoundQOverP) = -0.125;
0183 corr(eBoundTheta, eBoundQOverP) = corr(eBoundTheta, eBoundQOverP) = 0.5;
0184 BoundSquareMatrix cov = stddev.asDiagonal() * corr * stddev.asDiagonal();
0185
0186 Vector4 pos4 = Vector4::Zero();
0187 auto particleHypothesis = ParticleHypothesis::pionLike(std::abs(charge));
0188 return BoundTrackParameters::createCurvilinear(
0189 pos4, phi, theta, particleHypothesis.qOverP(absMom, charge), cov,
0190 particleHypothesis);
0191 }
0192
0193
0194 inline Acts::BoundTrackParameters makeParametersCurvilinearNeutral(
0195 double phi, double theta, double absMom) {
0196 using namespace Acts;
0197 using namespace UnitLiterals;
0198
0199 Vector4 pos4 = Vector4::Zero();
0200 return BoundTrackParameters::createCurvilinear(
0201 pos4, phi, theta, 1 / absMom, std::nullopt, ParticleHypothesis::pion0());
0202 }
0203
0204
0205
0206
0207
0208
0209 inline void checkParametersConsistency(const Acts::BoundTrackParameters& cmp,
0210 const Acts::BoundTrackParameters& ref,
0211 const Acts::GeometryContext& geoCtx,
0212 double epsPos, double epsDir,
0213 double epsMom) {
0214 using namespace Acts;
0215
0216
0217 CHECK_CLOSE_ABS(cmp.template get<eBoundLoc0>(),
0218 ref.template get<eBoundLoc0>(), epsPos);
0219 CHECK_CLOSE_ABS(cmp.template get<eBoundLoc1>(),
0220 ref.template get<eBoundLoc1>(), epsPos);
0221 CHECK_CLOSE_ABS(cmp.template get<eBoundTime>(),
0222 ref.template get<eBoundTime>(), epsPos);
0223
0224 CHECK_SMALL(detail::radian_sym(cmp.template get<eBoundPhi>() -
0225 ref.template get<eBoundPhi>()),
0226 epsDir);
0227 CHECK_CLOSE_ABS(cmp.template get<eBoundTheta>(),
0228 ref.template get<eBoundTheta>(), epsDir);
0229 CHECK_CLOSE_ABS(cmp.template get<eBoundQOverP>(),
0230 ref.template get<eBoundQOverP>(), epsMom);
0231
0232 CHECK_CLOSE_ABS(cmp.position(geoCtx), ref.position(geoCtx), epsPos);
0233 CHECK_CLOSE_ABS(cmp.time(), ref.time(), epsPos);
0234 CHECK_CLOSE_ABS(cmp.direction(), ref.direction(), epsDir);
0235 CHECK_CLOSE_ABS(cmp.absoluteMomentum(), ref.absoluteMomentum(), epsMom);
0236
0237 BOOST_CHECK_EQUAL(cmp.charge(), ref.charge());
0238 }
0239
0240
0241
0242
0243 inline void checkCovarianceConsistency(const Acts::BoundTrackParameters& cmp,
0244 const Acts::BoundTrackParameters& ref,
0245 double relativeTolerance) {
0246
0247 if (cmp.covariance().has_value()) {
0248
0249 BOOST_CHECK(ref.covariance().has_value());
0250 }
0251 if (ref.covariance().has_value()) {
0252
0253 BOOST_CHECK(cmp.covariance().has_value());
0254 }
0255 if (cmp.covariance().has_value() && ref.covariance().has_value()) {
0256 CHECK_CLOSE_COVARIANCE(cmp.covariance().value(), ref.covariance().value(),
0257 relativeTolerance);
0258 }
0259 }
0260
0261
0262
0263
0264 inline Acts::Transform3 createCurvilinearTransform(
0265 const Acts::BoundTrackParameters& params,
0266 const Acts::GeometryContext& geoCtx) {
0267 using namespace Acts;
0268
0269 Vector3 unitW = params.direction();
0270 auto [unitU, unitV] = createCurvilinearUnitVectors(unitW);
0271
0272 RotationMatrix3 rotation = RotationMatrix3::Zero();
0273 rotation.col(0) = unitU;
0274 rotation.col(1) = unitV;
0275 rotation.col(2) = unitW;
0276 Translation3 offset(params.position(geoCtx));
0277 Transform3 toGlobal = offset * rotation;
0278
0279 return toGlobal;
0280 }
0281
0282
0283 struct ZCylinderSurfaceBuilder {
0284 std::shared_ptr<Acts::CylinderSurface> operator()(
0285 const Acts::BoundTrackParameters& params,
0286 const Acts::GeometryContext& geoCtx) {
0287 using namespace Acts;
0288
0289 auto radius = params.position(geoCtx).template head<2>().norm();
0290 auto halfz = std::numeric_limits<double>::max();
0291 return Surface::makeShared<CylinderSurface>(Transform3::Identity(), radius,
0292 halfz);
0293 }
0294 };
0295
0296
0297 struct DiscSurfaceBuilder {
0298 std::shared_ptr<Acts::DiscSurface> operator()(
0299 const Acts::BoundTrackParameters& params,
0300 const Acts::GeometryContext& geoCtx) {
0301 using namespace Acts;
0302 using namespace UnitLiterals;
0303
0304 auto cl = createCurvilinearTransform(params, geoCtx);
0305
0306
0307
0308
0309 Vector3 localOffset = Vector3::Zero();
0310 localOffset[ePos0] = 1_cm;
0311 localOffset[ePos1] = -1_cm;
0312 Vector3 globalOriginDelta = cl.linear() * localOffset;
0313 cl.pretranslate(globalOriginDelta);
0314
0315 return Surface::makeShared<DiscSurface>(cl);
0316 }
0317 };
0318
0319
0320 struct PlaneSurfaceBuilder {
0321 std::shared_ptr<Acts::PlaneSurface> operator()(
0322 const Acts::BoundTrackParameters& params,
0323 const Acts::GeometryContext& geoCtx) {
0324 using namespace Acts;
0325
0326 return Surface::makeShared<PlaneSurface>(
0327 createCurvilinearTransform(params, geoCtx));
0328 }
0329 };
0330
0331
0332 struct ZStrawSurfaceBuilder {
0333 std::shared_ptr<Acts::StrawSurface> operator()(
0334 const Acts::BoundTrackParameters& params,
0335 const Acts::GeometryContext& geoCtx) {
0336 using namespace Acts;
0337
0338 return Surface::makeShared<StrawSurface>(
0339 Transform3(Translation3(params.position(geoCtx))));
0340 }
0341 };
0342
0343
0344
0345
0346
0347
0348 template <typename propagator_t,
0349 typename options_t = typename propagator_t::template Options<>>
0350 inline std::pair<Acts::BoundTrackParameters, double> transportFreely(
0351 const propagator_t& propagator, const Acts::GeometryContext& geoCtx,
0352 const Acts::MagneticFieldContext& magCtx,
0353 const Acts::BoundTrackParameters& initialParams, double pathLength) {
0354 using namespace Acts;
0355 using namespace UnitLiterals;
0356
0357
0358 options_t options(geoCtx, magCtx);
0359 options.direction = Direction::fromScalar(pathLength);
0360 options.pathLimit = pathLength;
0361 options.surfaceTolerance = 1_nm;
0362 options.stepping.stepTolerance = 1_nm;
0363
0364 auto result = propagator.propagate(initialParams, options);
0365 BOOST_CHECK(result.ok());
0366 BOOST_CHECK(result.value().endParameters);
0367
0368 return {*result.value().endParameters, result.value().pathLength};
0369 }
0370
0371
0372 template <typename propagator_t,
0373 typename options_t = typename propagator_t::template Options<>>
0374 inline std::pair<Acts::BoundTrackParameters, double> transportToSurface(
0375 const propagator_t& propagator, const Acts::GeometryContext& geoCtx,
0376 const Acts::MagneticFieldContext& magCtx,
0377 const Acts::BoundTrackParameters& initialParams,
0378 const Acts::Surface& targetSurface, double pathLimit) {
0379 using namespace Acts;
0380 using namespace UnitLiterals;
0381
0382
0383 options_t options(geoCtx, magCtx);
0384 options.direction = Direction::Forward();
0385 options.pathLimit = pathLimit;
0386 options.surfaceTolerance = 1_nm;
0387 options.stepping.stepTolerance = 1_nm;
0388
0389 auto result = propagator.propagate(initialParams, targetSurface, options);
0390 BOOST_CHECK(result.ok());
0391 BOOST_CHECK(result.value().endParameters);
0392
0393 return {*result.value().endParameters, result.value().pathLength};
0394 }
0395
0396
0397
0398
0399
0400
0401 template <typename propagator_t,
0402 typename options_t = typename propagator_t::template Options<>>
0403 inline void runForwardBackwardTest(
0404 const propagator_t& propagator, const Acts::GeometryContext& geoCtx,
0405 const Acts::MagneticFieldContext& magCtx,
0406 const Acts::BoundTrackParameters& initialParams, double pathLength,
0407 double epsPos, double epsDir, double epsMom) {
0408
0409 auto [fwdParams, fwdPathLength] = transportFreely<propagator_t, options_t>(
0410 propagator, geoCtx, magCtx, initialParams, pathLength);
0411 CHECK_CLOSE_ABS(fwdPathLength, pathLength, epsPos);
0412
0413 auto [bwdParams, bwdPathLength] = transportFreely<propagator_t, options_t>(
0414 propagator, geoCtx, magCtx, fwdParams, -pathLength);
0415 CHECK_CLOSE_ABS(bwdPathLength, -pathLength, epsPos);
0416
0417 checkParametersConsistency(initialParams, bwdParams, geoCtx, epsPos, epsDir,
0418 epsMom);
0419 }
0420
0421
0422
0423
0424
0425 template <typename propagator_t, typename surface_builder_t,
0426 typename options_t = typename propagator_t::template Options<>>
0427 inline void runToSurfaceTest(const propagator_t& propagator,
0428 const Acts::GeometryContext& geoCtx,
0429 const Acts::MagneticFieldContext& magCtx,
0430 const Acts::BoundTrackParameters& initialParams,
0431 double pathLength,
0432 surface_builder_t&& buildTargetSurface,
0433 double epsPos, double epsDir, double epsMom) {
0434
0435 auto [freeParams, freePathLength] = transportFreely<propagator_t, options_t>(
0436 propagator, geoCtx, magCtx, initialParams, pathLength);
0437 CHECK_CLOSE_ABS(freePathLength, pathLength, epsPos);
0438
0439 auto surface = buildTargetSurface(freeParams, geoCtx);
0440 BOOST_CHECK(surface);
0441
0442
0443
0444 auto [surfParams, surfPathLength] =
0445 transportToSurface<propagator_t, options_t>(propagator, geoCtx, magCtx,
0446 initialParams, *surface,
0447 1.5 * pathLength);
0448 CHECK_CLOSE_ABS(surfPathLength, pathLength, epsPos);
0449
0450
0451 CHECK_CLOSE_ABS(surfParams.position(geoCtx), freeParams.position(geoCtx),
0452 epsPos);
0453 CHECK_CLOSE_ABS(surfParams.time(), freeParams.time(), epsPos);
0454 CHECK_CLOSE_ABS(surfParams.direction(), freeParams.direction(), epsDir);
0455 CHECK_CLOSE_ABS(surfParams.absoluteMomentum(), freeParams.absoluteMomentum(),
0456 epsMom);
0457 CHECK_CLOSE_ABS(surfPathLength, freePathLength, epsPos);
0458 }
0459
0460
0461
0462
0463
0464 template <typename cmp_propagator_t, typename ref_propagator_t>
0465 inline void runForwardComparisonTest(
0466 const cmp_propagator_t& cmpPropagator,
0467 const ref_propagator_t& refPropagator, const Acts::GeometryContext& geoCtx,
0468 const Acts::MagneticFieldContext& magCtx,
0469 const Acts::BoundTrackParameters& initialParams, double pathLength,
0470 double epsPos, double epsDir, double epsMom, double tolCov) {
0471
0472 auto [cmpParams, cmpPath] = transportFreely<cmp_propagator_t>(
0473 cmpPropagator, geoCtx, magCtx, initialParams, pathLength);
0474 auto [refParams, refPath] = transportFreely<ref_propagator_t>(
0475 refPropagator, geoCtx, magCtx, initialParams, pathLength);
0476
0477 checkParametersConsistency(cmpParams, refParams, geoCtx, epsPos, epsDir,
0478 epsMom);
0479 checkCovarianceConsistency(cmpParams, refParams, tolCov);
0480 CHECK_CLOSE_ABS(cmpPath, pathLength, epsPos);
0481 CHECK_CLOSE_ABS(refPath, pathLength, epsPos);
0482 CHECK_CLOSE_ABS(cmpPath, refPath, epsPos);
0483 }
0484
0485
0486
0487
0488
0489 template <typename cmp_propagator_t, typename ref_propagator_t,
0490 typename surface_builder_t>
0491 inline void runToSurfaceComparisonTest(
0492 const cmp_propagator_t& cmpPropagator,
0493 const ref_propagator_t& refPropagator, const Acts::GeometryContext& geoCtx,
0494 const Acts::MagneticFieldContext& magCtx,
0495 const Acts::BoundTrackParameters& initialParams, double pathLength,
0496 surface_builder_t&& buildTargetSurface, double epsPos, double epsDir,
0497 double epsMom, double tolCov) {
0498
0499 auto [freeParams, freePathLength] = transportFreely<ref_propagator_t>(
0500 refPropagator, geoCtx, magCtx, initialParams, pathLength);
0501 CHECK_CLOSE_ABS(freePathLength, pathLength, epsPos);
0502
0503
0504 auto surface = buildTargetSurface(freeParams, geoCtx);
0505 BOOST_CHECK(surface);
0506
0507
0508
0509 auto [cmpParams, cmpPath] = transportToSurface<cmp_propagator_t>(
0510 cmpPropagator, geoCtx, magCtx, initialParams, *surface, 1.5 * pathLength);
0511 auto [refParams, refPath] = transportToSurface<ref_propagator_t>(
0512 refPropagator, geoCtx, magCtx, initialParams, *surface, 1.5 * pathLength);
0513
0514 checkParametersConsistency(cmpParams, refParams, geoCtx, epsPos, epsDir,
0515 epsMom);
0516 checkCovarianceConsistency(cmpParams, refParams, tolCov);
0517 CHECK_CLOSE_ABS(cmpPath, pathLength, epsPos);
0518 CHECK_CLOSE_ABS(refPath, pathLength, epsPos);
0519 CHECK_CLOSE_ABS(cmpPath, refPath, epsPos);
0520 }
0521
0522 template <typename propagator_t>
0523 inline void runDenseForwardTest(
0524 const propagator_t& propagator, const Acts::GeometryContext& geoCtx,
0525 const Acts::MagneticFieldContext& magCtx, double p, double q,
0526 const Acts::Surface& targetSurface, const Acts::Material& material,
0527 double thickness, const Acts::Logger& logger = Acts::getDummyLogger()) {
0528 using namespace Acts;
0529 using namespace UnitLiterals;
0530
0531 const auto particleHypothesis = ParticleHypothesis::muon();
0532 const float mass = particleHypothesis.mass();
0533 const float absQ = std::abs(q);
0534 const double initialQOverP = particleHypothesis.qOverP(p, q);
0535 const auto initialParams = BoundTrackParameters::createCurvilinear(
0536 Vector4(-1.5_m, 0, 0, 0), Vector3::UnitX(), initialQOverP,
0537 BoundVector::Constant(1e-16).asDiagonal(), particleHypothesis);
0538
0539 typename propagator_t::template Options<> options(geoCtx, magCtx);
0540 options.maxSteps = 10000;
0541 options.stepping.maxStepSize = 100_mm;
0542 options.stepping.dense.meanEnergyLoss = true;
0543 options.stepping.dense.momentumCutOff = 1_MeV;
0544
0545 const auto result =
0546 propagator.propagate(initialParams, targetSurface, options);
0547
0548 BOOST_CHECK(result.ok());
0549 CHECK_CLOSE_REL(3_m, result->pathLength, 1e-6);
0550 BOOST_CHECK(result->endParameters);
0551
0552 BoundTrackParameters endParams = result->endParameters.value();
0553
0554 BOOST_CHECK(endParams.covariance());
0555 CHECK_CLOSE_ABS(initialParams.position(geoCtx) + Acts::Vector3(3_m, 0, 0),
0556 endParams.position(geoCtx), 1e-6);
0557 CHECK_CLOSE_ABS(initialParams.direction(), endParams.direction(), 1e-6);
0558
0559 const auto& cov = endParams.covariance().value();
0560
0561 const double endQOverP = endParams.qOverP();
0562 const double endP = endParams.absoluteMomentum();
0563 const double endEloss =
0564 Acts::fastHypot(p, mass) - Acts::fastHypot(endP, mass);
0565 const double endErrX = std::sqrt(cov(eBoundLoc0, eBoundLoc0));
0566 const double endErrY = std::sqrt(cov(eBoundLoc1, eBoundLoc1));
0567 const double endErrQOverP = std::sqrt(cov(eBoundQOverP, eBoundQOverP));
0568 const double endErrP =
0569 (absQ / std::pow(endParams.qOverP(), 2)) * endErrQOverP;
0570 const double endErrE = (p / Acts::fastHypot(p, mass)) * endErrP;
0571 const double endErrTheta = std::sqrt(cov(eBoundTheta, eBoundTheta));
0572 const double endErrPhi = std::sqrt(cov(eBoundPhi, eBoundPhi));
0573
0574 ACTS_VERBOSE("input q/p = " << initialQOverP);
0575 ACTS_VERBOSE("input p = " << p);
0576 ACTS_VERBOSE("output q/p = " << endQOverP);
0577 ACTS_VERBOSE("output p = " << endP);
0578 ACTS_VERBOSE("output t = " << endParams.time());
0579 ACTS_VERBOSE("output eloss = " << endEloss);
0580 ACTS_VERBOSE("output err x = " << endErrX);
0581 ACTS_VERBOSE("output err y = " << endErrY);
0582 ACTS_VERBOSE("output err q/p = " << endErrQOverP);
0583 ACTS_VERBOSE("output err p = " << endErrP);
0584 ACTS_VERBOSE("output err E = " << endErrE);
0585 ACTS_VERBOSE("output err theta = " << endErrTheta);
0586 ACTS_VERBOSE("output err phi = " << endErrPhi);
0587
0588 BOOST_CHECK_CLOSE(endErrX, endErrY, 1e-6);
0589 BOOST_CHECK_CLOSE(endErrTheta, endErrPhi, 1e-6);
0590
0591 const float elossInitial = computeEnergyLossMean(
0592 MaterialSlab(material, thickness), particleHypothesis.absolutePdg(), mass,
0593 initialQOverP, absQ);
0594 const float elossFinal = computeEnergyLossMean(
0595 MaterialSlab(material, thickness), particleHypothesis.absolutePdg(), mass,
0596 endQOverP, absQ);
0597
0598 ACTS_VERBOSE("ref eloss initial = " << elossInitial);
0599 ACTS_VERBOSE("ref eloss final = " << elossFinal);
0600
0601
0602
0603 BOOST_CHECK_LT(endEloss, elossInitial);
0604 BOOST_CHECK_GT(endEloss, elossFinal);
0605
0606 const float theta0Initial = computeMultipleScatteringTheta0(
0607 MaterialSlab(material, thickness), particleHypothesis.absolutePdg(), mass,
0608 initialQOverP, absQ);
0609 const float theta0Final = computeMultipleScatteringTheta0(
0610 MaterialSlab(material, thickness), particleHypothesis.absolutePdg(), mass,
0611 endQOverP, absQ);
0612
0613 ACTS_VERBOSE("ref theta0 initial = " << theta0Initial);
0614 ACTS_VERBOSE("ref theta0 final = " << theta0Final);
0615
0616
0617 BOOST_CHECK_GE(endErrTheta, theta0Initial);
0618 BOOST_CHECK_LT(endErrTheta, theta0Final);
0619 CHECK_CLOSE_REL(endErrTheta, 0.5 * (theta0Initial + theta0Final), 0.1);
0620
0621
0622
0623 const auto estimateVarX = [&](double qOverP, std::size_t substeps) {
0624 double previousTheta0 = 0;
0625 double varAngle = 0;
0626 double varPosition = 0;
0627 double covAnglePosition = 0;
0628
0629 const auto step = [&](double substep, double theta0) {
0630 double deltaVarTheta = square(theta0) - square(previousTheta0);
0631 double deltaVarPos = varAngle * square(substep) +
0632 2 * covAnglePosition * substep +
0633 deltaVarTheta * (square(substep) / 3);
0634 double deltaCovAnglePosition =
0635 varAngle * substep + deltaVarTheta * substep / 2;
0636 previousTheta0 = theta0;
0637 varAngle += deltaVarTheta;
0638 varPosition += deltaVarPos;
0639 covAnglePosition += deltaCovAnglePosition;
0640 };
0641
0642
0643 for (std::size_t i = 0; i < substeps; ++i) {
0644 const float theta0 = computeMultipleScatteringTheta0(
0645 MaterialSlab(material, (i + 1) * thickness / substeps),
0646 particleHypothesis.absolutePdg(), mass, qOverP, absQ);
0647 step(thickness / substeps, theta0);
0648 }
0649
0650
0651 step(1_m, previousTheta0);
0652
0653 return varPosition;
0654 };
0655
0656
0657 const double lowerBoundVarX = estimateVarX(initialQOverP, 10);
0658
0659 const double upperBoundVarX = estimateVarX(endQOverP, 10);
0660
0661 const double lowerBoundSigmaX = std::sqrt(lowerBoundVarX);
0662 const double upperBoundSigmaX = std::sqrt(upperBoundVarX);
0663
0664 ACTS_VERBOSE("ref lower bound sigma x = " << lowerBoundSigmaX);
0665 ACTS_VERBOSE("ref upper bound sigma x = " << upperBoundSigmaX);
0666
0667 BOOST_CHECK_GT(endErrX, lowerBoundSigmaX);
0668 BOOST_CHECK_LT(endErrX, upperBoundSigmaX);
0669 CHECK_CLOSE_REL(endErrX, 0.5 * (lowerBoundSigmaX + upperBoundSigmaX), 0.2);
0670
0671 const float qOverPSigma = computeEnergyLossLandauSigmaQOverP(
0672 MaterialSlab(material, thickness), mass, initialQOverP, absQ);
0673
0674 ACTS_VERBOSE("ref sigma q/p = " << qOverPSigma);
0675
0676 CHECK_CLOSE_REL(endErrQOverP, qOverPSigma, 1e-4);
0677 }