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