File indexing completed on 2026-07-17 07:51:34
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/Geometry/CuboidVolumeBuilder.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Geometry/TrackingGeometry.hpp"
0016 #include "Acts/Geometry/TrackingGeometryBuilder.hpp"
0017 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0018 #include "Acts/Material/HomogeneousVolumeMaterial.hpp"
0019 #include "Acts/Material/Interactions.hpp"
0020 #include "Acts/Material/Material.hpp"
0021 #include "Acts/Surfaces/CylinderSurface.hpp"
0022 #include "Acts/Surfaces/DiscSurface.hpp"
0023 #include "Acts/Surfaces/PlaneSurface.hpp"
0024 #include "Acts/Surfaces/RectangleBounds.hpp"
0025 #include "Acts/Surfaces/StrawSurface.hpp"
0026 #include "Acts/Utilities/Logger.hpp"
0027 #include "Acts/Utilities/MathHelpers.hpp"
0028 #include "Acts/Utilities/UnitVectors.hpp"
0029 #include "Acts/Utilities/detail/periodic.hpp"
0030 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0031 #include "ActsTests/CommonHelpers/PredefinedMaterials.hpp"
0032
0033 #include <utility>
0034
0035 inline std::shared_ptr<const Acts::TrackingGeometry> createDenseBlock(
0036 const Acts::GeometryContext& geoCtx) {
0037 using namespace Acts;
0038 using namespace ActsTests;
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>(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 BoundMatrix corr = BoundMatrix::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 BoundMatrix 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, 0, std::nullopt,
0202 ParticleHypothesis::pion0().withMomentumHypothesis(absMom));
0203 }
0204
0205
0206
0207
0208
0209
0210 inline void checkParametersConsistency(const Acts::BoundTrackParameters& cmp,
0211 const Acts::BoundTrackParameters& ref,
0212 const Acts::GeometryContext& geoCtx,
0213 double epsPos, double epsTime,
0214 double epsDir, double epsMom) {
0215 using namespace Acts;
0216
0217
0218 CHECK_CLOSE_ABS(cmp.template get<eBoundLoc0>(),
0219 ref.template get<eBoundLoc0>(), epsPos);
0220 CHECK_CLOSE_ABS(cmp.template get<eBoundLoc1>(),
0221 ref.template get<eBoundLoc1>(), epsPos);
0222 CHECK_CLOSE_ABS(cmp.template get<eBoundTime>(),
0223 ref.template get<eBoundTime>(), epsTime);
0224
0225 CHECK_SMALL(detail::radian_sym(cmp.template get<eBoundPhi>() -
0226 ref.template get<eBoundPhi>()),
0227 epsDir);
0228 CHECK_CLOSE_ABS(cmp.template get<eBoundTheta>(),
0229 ref.template get<eBoundTheta>(), epsDir);
0230 CHECK_CLOSE_ABS(cmp.template get<eBoundQOverP>(),
0231 ref.template get<eBoundQOverP>(), epsMom);
0232
0233 CHECK_CLOSE_ABS(cmp.position(geoCtx), ref.position(geoCtx), epsPos);
0234 CHECK_CLOSE_ABS(cmp.time(), ref.time(), epsTime);
0235 CHECK_CLOSE_ABS(cmp.direction(), ref.direction(), epsDir);
0236 CHECK_CLOSE_ABS(cmp.absoluteMomentum(), ref.absoluteMomentum(), epsMom);
0237
0238 BOOST_CHECK_EQUAL(cmp.charge(), ref.charge());
0239 }
0240
0241
0242
0243
0244 inline void checkCovarianceConsistency(const Acts::BoundTrackParameters& cmp,
0245 const Acts::BoundTrackParameters& ref,
0246 double relativeTolerance) {
0247
0248 if (cmp.covariance().has_value()) {
0249
0250 BOOST_CHECK(ref.covariance().has_value());
0251 }
0252 if (ref.covariance().has_value()) {
0253
0254 BOOST_CHECK(cmp.covariance().has_value());
0255 }
0256 if (cmp.covariance().has_value() && ref.covariance().has_value()) {
0257 CHECK_CLOSE_COVARIANCE(cmp.covariance().value(), ref.covariance().value(),
0258 relativeTolerance);
0259 }
0260 }
0261
0262
0263
0264
0265 inline Acts::Transform3 createCurvilinearTransform(
0266 const Acts::BoundTrackParameters& params,
0267 const Acts::GeometryContext& geoCtx) {
0268 using namespace Acts;
0269
0270 Vector3 unitW = params.direction();
0271 auto [unitU, unitV] = createCurvilinearUnitVectors(unitW);
0272
0273 RotationMatrix3 rotation = RotationMatrix3::Zero();
0274 rotation.col(0) = unitU;
0275 rotation.col(1) = unitV;
0276 rotation.col(2) = unitW;
0277 Translation3 offset(params.position(geoCtx));
0278 Transform3 toGlobal = offset * rotation;
0279
0280 return toGlobal;
0281 }
0282
0283
0284 struct ZCylinderSurfaceBuilder {
0285 std::shared_ptr<Acts::CylinderSurface> operator()(
0286 const Acts::BoundTrackParameters& params,
0287 const Acts::GeometryContext& geoCtx) {
0288 using namespace Acts;
0289
0290 auto radius = params.position(geoCtx).template head<2>().norm();
0291 auto halfz = std::numeric_limits<double>::max();
0292 return Surface::makeShared<CylinderSurface>(Transform3::Identity(), radius,
0293 halfz);
0294 }
0295 };
0296
0297
0298 struct DiscSurfaceBuilder {
0299 std::shared_ptr<Acts::DiscSurface> operator()(
0300 const Acts::BoundTrackParameters& params,
0301 const Acts::GeometryContext& geoCtx) {
0302 using namespace Acts;
0303 using namespace UnitLiterals;
0304
0305 auto cl = createCurvilinearTransform(params, geoCtx);
0306
0307
0308
0309
0310 Vector3 localOffset = Vector3::Zero();
0311 localOffset[ePos0] = 1_cm;
0312 localOffset[ePos1] = -1_cm;
0313 Vector3 globalOriginDelta = cl.linear() * localOffset;
0314 cl.pretranslate(globalOriginDelta);
0315
0316 return Surface::makeShared<DiscSurface>(cl);
0317 }
0318 };
0319
0320
0321 struct PlaneSurfaceBuilder {
0322 std::shared_ptr<Acts::PlaneSurface> operator()(
0323 const Acts::BoundTrackParameters& params,
0324 const Acts::GeometryContext& geoCtx) {
0325 using namespace Acts;
0326
0327 return Surface::makeShared<PlaneSurface>(
0328 createCurvilinearTransform(params, geoCtx));
0329 }
0330 };
0331
0332
0333 struct ZStrawSurfaceBuilder {
0334 std::shared_ptr<Acts::StrawSurface> operator()(
0335 const Acts::BoundTrackParameters& params,
0336 const Acts::GeometryContext& geoCtx) {
0337 using namespace Acts;
0338
0339 return Surface::makeShared<StrawSurface>(
0340 Transform3(Translation3(params.position(geoCtx))));
0341 }
0342 };
0343
0344
0345
0346
0347
0348
0349 template <typename propagator_t,
0350 typename options_t = typename propagator_t::template Options<>>
0351 inline std::pair<Acts::BoundTrackParameters, double> transportFreely(
0352 const propagator_t& propagator, const Acts::GeometryContext& geoCtx,
0353 const Acts::MagneticFieldContext& magCtx,
0354 const Acts::BoundTrackParameters& initialParams, double pathLength) {
0355 using namespace Acts;
0356 using namespace UnitLiterals;
0357
0358
0359 options_t options(geoCtx, magCtx);
0360 options.direction = Direction::fromScalar(pathLength);
0361 options.pathLimit = pathLength;
0362
0363 auto result = propagator.propagate(initialParams, options);
0364 BOOST_CHECK(result.ok());
0365 BOOST_CHECK(result.value().endParameters);
0366
0367 return {*result.value().endParameters, result.value().pathLength};
0368 }
0369
0370
0371 template <typename propagator_t,
0372 typename options_t = typename propagator_t::template Options<>>
0373 inline std::pair<Acts::BoundTrackParameters, double> transportToSurface(
0374 const propagator_t& propagator, const Acts::GeometryContext& geoCtx,
0375 const Acts::MagneticFieldContext& magCtx,
0376 const Acts::BoundTrackParameters& initialParams,
0377 const Acts::Surface& targetSurface, double pathLimit) {
0378 using namespace Acts;
0379 using namespace UnitLiterals;
0380
0381
0382 options_t options(geoCtx, magCtx);
0383 options.direction = Direction::Forward();
0384 options.pathLimit = pathLimit;
0385
0386 auto result = propagator.propagate(initialParams, targetSurface, options);
0387 BOOST_CHECK(result.ok());
0388 BOOST_CHECK(result.value().endParameters);
0389
0390 return {*result.value().endParameters, result.value().pathLength};
0391 }
0392
0393
0394
0395
0396
0397
0398 template <typename propagator_t,
0399 typename options_t = typename propagator_t::template Options<>>
0400 inline void runForwardBackwardTest(
0401 const propagator_t& propagator, const Acts::GeometryContext& geoCtx,
0402 const Acts::MagneticFieldContext& magCtx,
0403 const Acts::BoundTrackParameters& initialParams, double pathLength,
0404 double epsPos, double epsTime, double epsDir, double epsMom) {
0405
0406 auto [fwdParams, fwdPathLength] = transportFreely<propagator_t, options_t>(
0407 propagator, geoCtx, magCtx, initialParams, pathLength);
0408 CHECK_CLOSE_ABS(fwdPathLength, pathLength, epsPos);
0409
0410 auto [bwdParams, bwdPathLength] = transportFreely<propagator_t, options_t>(
0411 propagator, geoCtx, magCtx, fwdParams, -pathLength);
0412 CHECK_CLOSE_ABS(bwdPathLength, -pathLength, epsPos);
0413
0414 checkParametersConsistency(initialParams, bwdParams, geoCtx, epsPos, epsTime,
0415 epsDir, epsMom);
0416 }
0417
0418
0419
0420
0421
0422 template <typename propagator_t, typename surface_builder_t,
0423 typename options_t = typename propagator_t::template Options<>>
0424 inline void runToSurfaceTest(const propagator_t& propagator,
0425 const Acts::GeometryContext& geoCtx,
0426 const Acts::MagneticFieldContext& magCtx,
0427 const Acts::BoundTrackParameters& initialParams,
0428 double pathLength,
0429 surface_builder_t&& buildTargetSurface,
0430 double epsPos, double epsTime, double epsDir,
0431 double epsMom) {
0432
0433 auto [freeParams, freePathLength] = transportFreely<propagator_t, options_t>(
0434 propagator, geoCtx, magCtx, initialParams, pathLength);
0435 CHECK_CLOSE_ABS(freePathLength, pathLength, epsPos);
0436
0437 auto surface = buildTargetSurface(freeParams, geoCtx);
0438 BOOST_CHECK(surface);
0439
0440
0441
0442 auto [surfParams, surfPathLength] =
0443 transportToSurface<propagator_t, options_t>(propagator, geoCtx, magCtx,
0444 initialParams, *surface,
0445 1.5 * pathLength);
0446 CHECK_CLOSE_ABS(surfPathLength, pathLength, epsPos);
0447
0448
0449 CHECK_CLOSE_ABS(surfParams.position(geoCtx), freeParams.position(geoCtx),
0450 epsPos);
0451 CHECK_CLOSE_ABS(surfParams.time(), freeParams.time(), epsTime);
0452 CHECK_CLOSE_ABS(surfParams.direction(), freeParams.direction(), epsDir);
0453 CHECK_CLOSE_ABS(surfParams.absoluteMomentum(), freeParams.absoluteMomentum(),
0454 epsMom);
0455 CHECK_CLOSE_ABS(surfPathLength, freePathLength, epsPos);
0456 }
0457
0458
0459
0460
0461
0462 template <typename cmp_propagator_t, typename ref_propagator_t>
0463 inline void runForwardComparisonTest(
0464 const cmp_propagator_t& cmpPropagator,
0465 const ref_propagator_t& refPropagator, const Acts::GeometryContext& geoCtx,
0466 const Acts::MagneticFieldContext& magCtx,
0467 const Acts::BoundTrackParameters& initialParams, double pathLength,
0468 double epsPos, double epsTime, double epsDir, double epsMom,
0469 double tolCov) {
0470
0471 auto [cmpParams, cmpPath] = transportFreely<cmp_propagator_t>(
0472 cmpPropagator, geoCtx, magCtx, initialParams, pathLength);
0473 auto [refParams, refPath] = transportFreely<ref_propagator_t>(
0474 refPropagator, geoCtx, magCtx, initialParams, pathLength);
0475
0476 checkParametersConsistency(cmpParams, refParams, geoCtx, epsPos, epsTime,
0477 epsDir, epsMom);
0478 checkCovarianceConsistency(cmpParams, refParams, tolCov);
0479 CHECK_CLOSE_ABS(cmpPath, pathLength, epsPos);
0480 CHECK_CLOSE_ABS(refPath, pathLength, epsPos);
0481 CHECK_CLOSE_ABS(cmpPath, refPath, epsPos);
0482 }
0483
0484
0485
0486
0487
0488 template <typename cmp_propagator_t, typename ref_propagator_t,
0489 typename surface_builder_t>
0490 inline void runToSurfaceComparisonTest(
0491 const cmp_propagator_t& cmpPropagator,
0492 const ref_propagator_t& refPropagator, const Acts::GeometryContext& geoCtx,
0493 const Acts::MagneticFieldContext& magCtx,
0494 const Acts::BoundTrackParameters& initialParams, double pathLength,
0495 surface_builder_t&& buildTargetSurface, double epsPos, double epsTime,
0496 double epsDir, double epsMom, double tolCov) {
0497
0498 auto [freeParams, freePathLength] = transportFreely<ref_propagator_t>(
0499 refPropagator, geoCtx, magCtx, initialParams, pathLength);
0500 CHECK_CLOSE_ABS(freePathLength, pathLength, epsPos);
0501
0502
0503 auto surface = buildTargetSurface(freeParams, geoCtx);
0504 BOOST_CHECK(surface);
0505
0506
0507
0508 auto [cmpParams, cmpPath] = transportToSurface<cmp_propagator_t>(
0509 cmpPropagator, geoCtx, magCtx, initialParams, *surface, 1.5 * pathLength);
0510 auto [refParams, refPath] = transportToSurface<ref_propagator_t>(
0511 refPropagator, geoCtx, magCtx, initialParams, *surface, 1.5 * pathLength);
0512
0513 checkParametersConsistency(cmpParams, refParams, geoCtx, epsPos, epsTime,
0514 epsDir, epsMom);
0515 checkCovarianceConsistency(cmpParams, refParams, tolCov);
0516 CHECK_CLOSE_ABS(cmpPath, pathLength, epsPos);
0517 CHECK_CLOSE_ABS(refPath, pathLength, epsPos);
0518 CHECK_CLOSE_ABS(cmpPath, refPath, epsPos);
0519 }
0520
0521 template <typename propagator_t>
0522 inline void runDenseForwardTest(
0523 const propagator_t& propagator, const Acts::GeometryContext& geoCtx,
0524 const Acts::MagneticFieldContext& magCtx, double p, double q,
0525 const Acts::Surface& targetSurface, const Acts::Material& material,
0526 double thickness, const Acts::Logger& logger = Acts::getDummyLogger()) {
0527 using namespace Acts;
0528 using namespace UnitLiterals;
0529
0530 const auto particleHypothesis = ParticleHypothesis::muon();
0531 const float mass = particleHypothesis.mass();
0532 const float absQ = std::abs(q);
0533 const double initialQOverP = particleHypothesis.qOverP(p, q);
0534 const auto initialParams = BoundTrackParameters::createCurvilinear(
0535 Vector4(-1.5_m, 0, 0, 0), Vector3::UnitX(), initialQOverP,
0536 BoundVector::Constant(1e-16).asDiagonal(), particleHypothesis);
0537
0538 typename propagator_t::template Options<> options(geoCtx, magCtx);
0539 options.maxSteps = 10000;
0540 options.stepping.maxStepSize = 100_mm;
0541 options.stepping.dense.meanEnergyLoss = true;
0542 options.stepping.dense.momentumCutOff = 1_MeV;
0543
0544 const auto result =
0545 propagator.propagate(initialParams, targetSurface, options);
0546
0547 BOOST_CHECK(result.ok());
0548 CHECK_CLOSE_REL(3_m, result->pathLength, 1e-6);
0549 BOOST_CHECK(result->endParameters);
0550
0551 BoundTrackParameters endParams = result->endParameters.value();
0552
0553 BOOST_CHECK(endParams.covariance());
0554 CHECK_CLOSE_ABS(initialParams.position(geoCtx) + Acts::Vector3(3_m, 0, 0),
0555 endParams.position(geoCtx), 1e-6);
0556 CHECK_CLOSE_ABS(initialParams.direction(), endParams.direction(), 1e-6);
0557
0558 const auto& cov = endParams.covariance().value();
0559
0560 const double endQOverP = endParams.qOverP();
0561 const double endP = endParams.absoluteMomentum();
0562 const double endEloss =
0563 Acts::fastHypot(p, mass) - Acts::fastHypot(endP, mass);
0564 const double endErrX = std::sqrt(cov(eBoundLoc0, eBoundLoc0));
0565 const double endErrY = std::sqrt(cov(eBoundLoc1, eBoundLoc1));
0566 const double endErrQOverP = std::sqrt(cov(eBoundQOverP, eBoundQOverP));
0567 const double endErrP =
0568 (absQ / std::pow(endParams.qOverP(), 2)) * endErrQOverP;
0569 const double endErrE = (p / Acts::fastHypot(p, mass)) * endErrP;
0570 const double endErrTheta = std::sqrt(cov(eBoundTheta, eBoundTheta));
0571 const double endErrPhi = std::sqrt(cov(eBoundPhi, eBoundPhi));
0572
0573 ACTS_VERBOSE("input q/p = " << initialQOverP);
0574 ACTS_VERBOSE("input p = " << p);
0575 ACTS_VERBOSE("output q/p = " << endQOverP);
0576 ACTS_VERBOSE("output p = " << endP);
0577 ACTS_VERBOSE("output t = " << endParams.time());
0578 ACTS_VERBOSE("output eloss = " << endEloss);
0579 ACTS_VERBOSE("output err x = " << endErrX);
0580 ACTS_VERBOSE("output err y = " << endErrY);
0581 ACTS_VERBOSE("output err q/p = " << endErrQOverP);
0582 ACTS_VERBOSE("output err p = " << endErrP);
0583 ACTS_VERBOSE("output err E = " << endErrE);
0584 ACTS_VERBOSE("output err theta = " << endErrTheta);
0585 ACTS_VERBOSE("output err phi = " << endErrPhi);
0586
0587 BOOST_CHECK_CLOSE(endErrX, endErrY, 1e-6);
0588 BOOST_CHECK_CLOSE(endErrTheta, endErrPhi, 1e-6);
0589
0590 const float elossInitial = computeEnergyLossMean(
0591 MaterialSlab(material, thickness), particleHypothesis.absolutePdg(), mass,
0592 initialQOverP, absQ);
0593 const float elossFinal = computeEnergyLossMean(
0594 MaterialSlab(material, thickness), particleHypothesis.absolutePdg(), mass,
0595 endQOverP, absQ);
0596
0597 ACTS_VERBOSE("ref eloss initial = " << elossInitial);
0598 ACTS_VERBOSE("ref eloss final = " << elossFinal);
0599
0600
0601
0602 BOOST_CHECK_LT(endEloss, elossInitial);
0603 BOOST_CHECK_GT(endEloss, elossFinal);
0604
0605 const float theta0Initial = computeMultipleScatteringTheta0(
0606 MaterialSlab(material, thickness), particleHypothesis.absolutePdg(), mass,
0607 initialQOverP, absQ);
0608 const float theta0Final = computeMultipleScatteringTheta0(
0609 MaterialSlab(material, thickness), particleHypothesis.absolutePdg(), mass,
0610 endQOverP, absQ);
0611
0612 ACTS_VERBOSE("ref theta0 initial = " << theta0Initial);
0613 ACTS_VERBOSE("ref theta0 final = " << theta0Final);
0614
0615
0616 BOOST_CHECK_GE(endErrTheta, theta0Initial);
0617 BOOST_CHECK_LT(endErrTheta, theta0Final);
0618 CHECK_CLOSE_REL(endErrTheta, 0.5 * (theta0Initial + theta0Final), 0.1);
0619
0620
0621
0622 const auto estimateVarX = [&](double qOverP, std::size_t substeps) {
0623 double previousTheta0 = 0;
0624 double varAngle = 0;
0625 double varPosition = 0;
0626 double covAnglePosition = 0;
0627
0628 const auto step = [&](double substep, double theta0) {
0629 double deltaVarTheta = square(theta0) - square(previousTheta0);
0630 double deltaVarPos = varAngle * square(substep) +
0631 2 * covAnglePosition * substep +
0632 deltaVarTheta * (square(substep) / 3);
0633 double deltaCovAnglePosition =
0634 varAngle * substep + deltaVarTheta * substep / 2;
0635 previousTheta0 = theta0;
0636 varAngle += deltaVarTheta;
0637 varPosition += deltaVarPos;
0638 covAnglePosition += deltaCovAnglePosition;
0639 };
0640
0641
0642 for (std::size_t i = 0; i < substeps; ++i) {
0643 const float theta0 = computeMultipleScatteringTheta0(
0644 MaterialSlab(material, (i + 1) * thickness / substeps),
0645 particleHypothesis.absolutePdg(), mass, qOverP, absQ);
0646 step(thickness / substeps, theta0);
0647 }
0648
0649
0650 step(1_m, previousTheta0);
0651
0652 return varPosition;
0653 };
0654
0655
0656 const double lowerBoundVarX = estimateVarX(initialQOverP, 10);
0657
0658 const double upperBoundVarX = estimateVarX(endQOverP, 10);
0659
0660 const double lowerBoundSigmaX = std::sqrt(lowerBoundVarX);
0661 const double upperBoundSigmaX = std::sqrt(upperBoundVarX);
0662
0663 ACTS_VERBOSE("ref lower bound sigma x = " << lowerBoundSigmaX);
0664 ACTS_VERBOSE("ref upper bound sigma x = " << upperBoundSigmaX);
0665
0666 BOOST_CHECK_GT(endErrX, lowerBoundSigmaX);
0667 BOOST_CHECK_LT(endErrX, upperBoundSigmaX);
0668 CHECK_CLOSE_REL(endErrX, 0.5 * (lowerBoundSigmaX + upperBoundSigmaX), 0.2);
0669
0670 const float qOverPSigma = computeEnergyLossLandauSigmaQOverP(
0671 MaterialSlab(material, thickness), mass, initialQOverP, absQ);
0672
0673 ACTS_VERBOSE("ref sigma q/p = " << qOverPSigma);
0674
0675 CHECK_CLOSE_REL(endErrQOverP, qOverPSigma, 1e-4);
0676 }