File indexing completed on 2025-01-18 09:12:45
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
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::ExternalNavigationDelegate 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::EndOfWorld 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::SingleDetectorVolumeNavigation svu(volumeB.get());
0064 svu.update(tContext, nState);
0065
0066 BOOST_CHECK_EQUAL(nState.currentVolume, volumeB.get());
0067
0068 BOOST_CHECK_THROW(Acts::Experimental::SingleDetectorVolumeNavigation(nullptr),
0069 std::invalid_argument);
0070 }
0071
0072
0073 BOOST_AUTO_TEST_CASE(VolumeArrayUpdate) {
0074 std::vector<double> 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::BoundVolumesGrid1Navigation bvg(
0079 zArray, Acts::AxisDirection::AxisZ, volumes);
0080
0081 nState.currentVolume = nullptr;
0082
0083
0084 nState.position = Acts::Vector3(0., 0., -150.);
0085 bvg.update(tContext, nState);
0086 BOOST_CHECK_EQUAL(nState.currentVolume, volumeA.get());
0087
0088 nState.position = Acts::Vector3(0., 0., 600.);
0089 bvg.update(tContext, nState);
0090 BOOST_CHECK_EQUAL(nState.currentVolume, volumeD.get());
0091
0092
0093 Acts::Transform3 shift300 = Acts::Transform3::Identity();
0094 shift300.pretranslate(Acts::Vector3(0, 0, 300));
0095
0096 Acts::Experimental::BoundVolumesGrid1Navigation bvgs(
0097 zArray, Acts::AxisDirection::AxisZ, volumes, shift300.inverse());
0098
0099
0100 nState.position = Acts::Vector3(0., 0., 150.);
0101 bvgs.update(tContext, nState);
0102 BOOST_CHECK_EQUAL(nState.currentVolume, volumeA.get());
0103 }
0104
0105 BOOST_AUTO_TEST_SUITE_END()