File indexing completed on 2025-11-05 08:55:30
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
0076
0077 struct Navigator {
0078 const TrackingVolume* currentVolume(const NavigatorState& state) const {
0079 return state.currentVolume;
0080 }
0081 };
0082
0083 BOOST_AUTO_TEST_SUITE(PropagatorSuite)
0084
0085 BOOST_AUTO_TEST_CASE(volume_material_interaction_test) {
0086
0087 auto htrans = Transform3(Translation3{-10., -10., 0.});
0088 auto bound = std::make_shared<CuboidVolumeBounds>(1_m, 1_m, 1_m);
0089 auto mat = makeSilicon();
0090 auto volMat = std::make_shared<const HomogeneousVolumeMaterial>(mat);
0091 auto volume = std::make_shared<TrackingVolume>(htrans, bound, volMat);
0092
0093
0094 State state;
0095 state.stepping.particleHypothesis =
0096 ParticleHypothesis(static_cast<PdgParticle>(11), 10., AnyCharge{9.});
0097 state.stepping.pos = Vector3(1., 2., 3.);
0098 state.stepping.dir = Vector3(4., 5., 6.);
0099 state.stepping.t = 7.;
0100 state.stepping.p = 8.;
0101 state.stepping.q = 9.;
0102 state.stepping.absCharge = std::abs(state.stepping.q);
0103 state.stepping.covTransport = true;
0104 state.options.direction = Direction::Backward();
0105 state.navigation.currentVolume = volume.get();
0106
0107 Stepper stepper;
0108 Navigator navigator;
0109
0110
0111 detail::VolumeMaterialInteraction volMatInt(volume.get(), state, stepper);
0112 BOOST_CHECK_EQUAL(volMatInt.volume.trackingVolume, volume.get());
0113 BOOST_CHECK_EQUAL(volMatInt.pos, stepper.position(state.stepping));
0114 BOOST_CHECK_EQUAL(volMatInt.time, stepper.time(state.stepping));
0115 BOOST_CHECK_EQUAL(volMatInt.dir, stepper.direction(state.stepping));
0116 BOOST_CHECK_EQUAL(volMatInt.momentum,
0117 stepper.absoluteMomentum(state.stepping));
0118 BOOST_CHECK_EQUAL(volMatInt.absQ, std::abs(stepper.charge(state.stepping)));
0119 CHECK_CLOSE_ABS(volMatInt.qOverP, stepper.qOverP(state.stepping), 1e-6);
0120 BOOST_CHECK_EQUAL(volMatInt.mass, state.stepping.particleHypothesis.mass());
0121 BOOST_CHECK_EQUAL(volMatInt.absPdg,
0122 state.stepping.particleHypothesis.absolutePdg());
0123 BOOST_CHECK_EQUAL(volMatInt.performCovarianceTransport,
0124 state.stepping.covTransport);
0125 BOOST_CHECK_EQUAL(volMatInt.navDir, state.options.direction);
0126
0127
0128 bool result = volMatInt.evaluateMaterialSlab(state, navigator);
0129 BOOST_CHECK(result);
0130 BOOST_CHECK_EQUAL(volMatInt.slab.material(), mat);
0131 BOOST_CHECK_EQUAL(volMatInt.slab.thickness(), 1.);
0132 BOOST_CHECK_EQUAL(volMatInt.pathCorrection, 0.);
0133
0134
0135 state.navigation.currentVolume = nullptr;
0136 result = volMatInt.evaluateMaterialSlab(state, navigator);
0137 BOOST_CHECK(!result);
0138 BOOST_CHECK_EQUAL(volMatInt.pathCorrection, 0.);
0139 }
0140
0141 BOOST_AUTO_TEST_SUITE_END()
0142
0143 }