File indexing completed on 2025-08-06 08:11:24
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/Geometry/GeometryContext.hpp"
0013 #include "Acts/Navigation/DetectorVolumeUpdaters.hpp"
0014 #include "Acts/Navigation/NavigationDelegates.hpp"
0015 #include "Acts/Navigation/NavigationState.hpp"
0016 #include "Acts/Utilities/BinningType.hpp"
0017
0018 #include <memory>
0019 #include <stdexcept>
0020 #include <vector>
0021
0022
0023 Acts::GeometryContext tContext;
0024
0025 namespace Acts::Experimental {
0026 class DetectorVolume {};
0027 }
0028
0029 auto volumeA = std::make_shared<Acts::Experimental::DetectorVolume>();
0030 auto volumeB = std::make_shared<Acts::Experimental::DetectorVolume>();
0031 auto volumeC = std::make_shared<Acts::Experimental::DetectorVolume>();
0032 auto volumeD = std::make_shared<Acts::Experimental::DetectorVolume>();
0033
0034 Acts::Experimental::NavigationState nState;
0035
0036 BOOST_AUTO_TEST_SUITE(Experimental)
0037
0038
0039
0040
0041
0042 BOOST_AUTO_TEST_CASE(UnconnectedUpdate) {
0043 Acts::Experimental::DetectorVolumeUpdater ucUpdater;
0044 BOOST_CHECK(!ucUpdater.connected());
0045 }
0046
0047
0048 BOOST_AUTO_TEST_CASE(EndOfWorldUpdate) {
0049 nState.currentVolume = volumeA.get();
0050 BOOST_CHECK_EQUAL(nState.currentVolume, volumeA.get());
0051
0052 Acts::Experimental::EndOfWorldImpl eow;
0053 eow.update(tContext, nState);
0054
0055 BOOST_CHECK_EQUAL(nState.currentVolume, nullptr);
0056 }
0057
0058
0059 BOOST_AUTO_TEST_CASE(SingleVolumeUpdate) {
0060 nState.currentVolume = volumeA.get();
0061 BOOST_CHECK_EQUAL(nState.currentVolume, volumeA.get());
0062
0063 Acts::Experimental::SingleDetectorVolumeImpl svu(volumeB.get());
0064 svu.update(tContext, nState);
0065
0066 BOOST_CHECK_EQUAL(nState.currentVolume, volumeB.get());
0067
0068 BOOST_CHECK_THROW(Acts::Experimental::SingleDetectorVolumeImpl(nullptr),
0069 std::invalid_argument);
0070 }
0071
0072
0073 BOOST_AUTO_TEST_CASE(VolumeArrayUpdate) {
0074 std::vector<Acts::ActsScalar> zArray = {-200, -100, 100, 400, 1000};
0075
0076 std::vector<const Acts::Experimental::DetectorVolume*> volumes = {
0077 volumeA.get(), volumeB.get(), volumeC.get(), volumeD.get()};
0078 Acts::Experimental::BoundVolumesGrid1Impl bvg(zArray, Acts::binZ, volumes);
0079
0080 nState.currentVolume = nullptr;
0081
0082
0083 nState.position = Acts::Vector3(0., 0., -150.);
0084 bvg.update(tContext, nState);
0085 BOOST_CHECK_EQUAL(nState.currentVolume, volumeA.get());
0086
0087 nState.position = Acts::Vector3(0., 0., 600.);
0088 bvg.update(tContext, nState);
0089 BOOST_CHECK_EQUAL(nState.currentVolume, volumeD.get());
0090
0091
0092 Acts::Transform3 shift300 = Acts::Transform3::Identity();
0093 shift300.pretranslate(Acts::Vector3(0, 0, 300));
0094
0095 Acts::Experimental::BoundVolumesGrid1Impl bvgs(zArray, Acts::binZ, volumes,
0096 shift300.inverse());
0097
0098
0099 nState.position = Acts::Vector3(0., 0., 150.);
0100 bvgs.update(tContext, nState);
0101 BOOST_CHECK_EQUAL(nState.currentVolume, volumeA.get());
0102 }
0103
0104 BOOST_AUTO_TEST_SUITE_END()