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