File indexing completed on 2026-12-01 09:21:51
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Direction.hpp"
0013 #include "Acts/Definitions/PdgParticle.hpp"
0014 #include "Acts/Definitions/Units.hpp"
0015 #include "Acts/EventData/ParticleHypothesis.hpp"
0016 #include "Acts/Geometry/CuboidVolumeBounds.hpp"
0017 #include "Acts/Geometry/TrackingVolume.hpp"
0018 #include "Acts/Material/HomogeneousVolumeMaterial.hpp"
0019 #include "Acts/Material/MaterialSlab.hpp"
0020 #include "Acts/Propagator/detail/VolumeMaterialInteraction.hpp"
0021 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0022 #include "ActsTests/CommonHelpers/PredefinedMaterials.hpp"
0023
0024 #include <memory>
0025
0026 using namespace Acts;
0027 using namespace Acts::UnitLiterals;
0028
0029 namespace ActsTests {
0030
0031
0032 struct StepperState {
0033 ParticleHypothesis particleHypothesis = ParticleHypothesis::pion();
0034 Vector3 pos{}, dir{};
0035 double t = 0, p = 0, q = 0;
0036 bool covTransport = false;
0037 double absCharge = UnitConstants::e;
0038 };
0039
0040
0041 struct NavigatorState {
0042 TrackingVolume* currentVolume = nullptr;
0043 };
0044
0045
0046 struct State {
0047 struct {
0048 Direction direction = Direction::Forward();
0049 } options;
0050
0051 StepperState stepping;
0052 NavigatorState navigation;
0053 };
0054
0055
0056 struct Stepper {
0057 Stepper() = default;
0058
0059 Vector3 position(const StepperState& state) const { return state.pos; }
0060
0061 double time(const StepperState& state) const { return state.t; }
0062
0063 Vector3 direction(const StepperState& state) const { return state.dir; }
0064
0065 double qOverP(const StepperState& state) const { return state.q / state.p; }
0066
0067 double absoluteMomentum(const StepperState& state) const { return state.p; }
0068
0069 double charge(const StepperState& state) const { return state.q; };
0070
0071 ParticleHypothesis particleHypothesis(const StepperState& state) const {
0072 return state.particleHypothesis;
0073 };
0074
0075 bool hasCovariance(const StepperState& state) const {
0076 return state.covTransport;
0077 }
0078 };
0079
0080
0081 struct Navigator {
0082 const TrackingVolume* currentVolume(const NavigatorState& state) const {
0083 return state.currentVolume;
0084 }
0085 };
0086
0087 BOOST_AUTO_TEST_SUITE(PropagatorSuite)
0088
0089 BOOST_AUTO_TEST_CASE(volume_material_interaction_test) {
0090
0091 auto htrans = Transform3(Translation3{-10., -10., 0.});
0092 auto bound = std::make_shared<CuboidVolumeBounds>(1_m, 1_m, 1_m);
0093 auto mat = makeSilicon();
0094 auto volMat = std::make_shared<const HomogeneousVolumeMaterial>(mat);
0095 auto volume = std::make_shared<TrackingVolume>(htrans, bound, volMat);
0096
0097
0098 State state;
0099 state.stepping.particleHypothesis = ParticleHypothesis(
0100 static_cast<PdgParticle>(11), 10., ChargeHypothesis{9.});
0101 state.stepping.pos = Vector3(1., 2., 3.);
0102 state.stepping.dir = Vector3(4., 5., 6.);
0103 state.stepping.t = 7.;
0104 state.stepping.p = 8.;
0105 state.stepping.q = 9.;
0106 state.stepping.absCharge = std::abs(state.stepping.q);
0107 state.stepping.covTransport = true;
0108 state.options.direction = Direction::Backward();
0109 state.navigation.currentVolume = volume.get();
0110
0111 Stepper stepper;
0112 Navigator navigator;
0113
0114
0115 detail::VolumeMaterialInteraction volMatInt(volume.get(), state, stepper);
0116 BOOST_CHECK_EQUAL(volMatInt.volume.trackingVolume, volume.get());
0117 BOOST_CHECK_EQUAL(volMatInt.pos, stepper.position(state.stepping));
0118 BOOST_CHECK_EQUAL(volMatInt.time, stepper.time(state.stepping));
0119 BOOST_CHECK_EQUAL(volMatInt.dir, stepper.direction(state.stepping));
0120 BOOST_CHECK_EQUAL(volMatInt.momentum,
0121 stepper.absoluteMomentum(state.stepping));
0122 BOOST_CHECK_EQUAL(volMatInt.absQ, std::abs(stepper.charge(state.stepping)));
0123 CHECK_CLOSE_ABS(volMatInt.qOverP, stepper.qOverP(state.stepping), 1e-6);
0124 BOOST_CHECK_EQUAL(volMatInt.mass, state.stepping.particleHypothesis.mass());
0125 BOOST_CHECK_EQUAL(volMatInt.absPdg,
0126 state.stepping.particleHypothesis.absolutePdg());
0127 BOOST_CHECK_EQUAL(volMatInt.performCovarianceTransport,
0128 state.stepping.covTransport);
0129 BOOST_CHECK_EQUAL(volMatInt.navDir, state.options.direction);
0130
0131
0132 bool result = volMatInt.evaluateMaterialSlab(state, navigator);
0133 BOOST_CHECK(result);
0134 BOOST_CHECK_EQUAL(volMatInt.slab.material(), mat);
0135 BOOST_CHECK_EQUAL(volMatInt.slab.thickness(), 1.);
0136 BOOST_CHECK_EQUAL(volMatInt.pathCorrection, 0.);
0137
0138
0139 state.navigation.currentVolume = nullptr;
0140 result = volMatInt.evaluateMaterialSlab(state, navigator);
0141 BOOST_CHECK(!result);
0142 BOOST_CHECK_EQUAL(volMatInt.pathCorrection, 0.);
0143 }
0144
0145 BOOST_AUTO_TEST_SUITE_END()
0146
0147 }