File indexing completed on 2025-11-05 08:55:15
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/Detector/DetectorVolume.hpp"
0013 #include "Acts/Detector/GeometryIdGenerator.hpp"
0014 #include "Acts/Detector/IndexedRootVolumeFinderBuilder.hpp"
0015 #include "Acts/Detector/PortalGenerators.hpp"
0016 #include "Acts/Geometry/CylinderVolumeBounds.hpp"
0017 #include "Acts/Geometry/GeometryContext.hpp"
0018 #include "Acts/Navigation/DetectorVolumeFinders.hpp"
0019 #include "Acts/Navigation/InternalNavigation.hpp"
0020 #include "Acts/Navigation/PortalNavigation.hpp"
0021 #include "Acts/Utilities/Logger.hpp"
0022
0023 using namespace Acts;
0024 using namespace Acts::Experimental;
0025
0026 GeometryContext tContext;
0027 Logging::Level logLevel = Logging::VERBOSE;
0028
0029 namespace ActsTests {
0030
0031 BOOST_AUTO_TEST_SUITE(DetectorSuite)
0032
0033 BOOST_AUTO_TEST_CASE(IndexedRootVolumeFinderBuilderCylindrical) {
0034 auto portalGenerator = defaultPortalGenerator();
0035
0036 auto innerB = std::make_unique<CylinderVolumeBounds>(0., 20., 100);
0037 auto innerV = DetectorVolumeFactory::construct(
0038 portalGenerator, tContext, "Inner", Transform3::Identity(),
0039 std::move(innerB), tryAllPortals());
0040
0041 auto middleLB = std::make_unique<CylinderVolumeBounds>(20., 60., 5);
0042 auto middleLT = Transform3::Identity();
0043 middleLT.pretranslate(Vector3(0., 0., -95));
0044 auto middleLV = DetectorVolumeFactory::construct(
0045 portalGenerator, tContext, "MiddleLeft", middleLT, std::move(middleLB),
0046 tryAllPortals());
0047
0048 auto middleDB = std::make_unique<CylinderVolumeBounds>(20., 40., 90);
0049 auto middleDV = DetectorVolumeFactory::construct(
0050 portalGenerator, tContext, "MiddleDown", Transform3::Identity(),
0051 std::move(middleDB), tryAllPortals());
0052
0053 auto middleUB = std::make_unique<CylinderVolumeBounds>(40., 60., 90);
0054 auto middleUV = DetectorVolumeFactory::construct(
0055 portalGenerator, tContext, "MiddleUp", Transform3::Identity(),
0056 std::move(middleUB), tryAllPortals());
0057
0058 auto middleRB = std::make_unique<CylinderVolumeBounds>(20., 60., 5);
0059 auto middleRT = Transform3::Identity();
0060 middleRT.pretranslate(Vector3(0., 0., 95));
0061 auto middleRV = DetectorVolumeFactory::construct(
0062 portalGenerator, tContext, "middleRight", middleRT, std::move(middleRB),
0063 tryAllPortals());
0064
0065 auto outerB = std::make_unique<CylinderVolumeBounds>(60., 120., 100);
0066 auto outerV = DetectorVolumeFactory::construct(
0067 portalGenerator, tContext, "Outer", Transform3::Identity(),
0068 std::move(outerB), tryAllPortals());
0069
0070 std::vector<std::shared_ptr<DetectorVolume>> rootVolumes = {
0071 innerV, middleLV, middleDV, middleUV, middleRV, outerV};
0072
0073 IndexedRootVolumeFinderBuilder builder(
0074 {AxisDirection::AxisZ, AxisDirection::AxisR});
0075
0076
0077 auto rootVolumeFinder = builder.construct(tContext, rootVolumes);
0078
0079 Experimental::GeometryIdGenerator::Config generatorConfig;
0080 Experimental::GeometryIdGenerator generator(
0081 generatorConfig,
0082 getDefaultLogger("SequentialIdGenerator", Logging::VERBOSE));
0083 auto cache = generator.generateCache();
0084 for (auto& vol : rootVolumes) {
0085 generator.assignGeometryId(cache, *vol);
0086 }
0087
0088 auto detectorIndexed = Detector::makeShared("IndexedDetector", rootVolumes,
0089 std::move(rootVolumeFinder));
0090
0091 BOOST_CHECK_EQUAL(
0092 detectorIndexed->findDetectorVolume(tContext, {10., 0., 0.}),
0093 innerV.get());
0094 BOOST_CHECK_EQUAL(
0095 detectorIndexed->findDetectorVolume(tContext, {25., 0., -93.}),
0096 middleLV.get());
0097 BOOST_CHECK_EQUAL(
0098 detectorIndexed->findDetectorVolume(tContext, {35., 0., 0.}),
0099 middleDV.get());
0100 BOOST_CHECK_EQUAL(
0101 detectorIndexed->findDetectorVolume(tContext, {55., 0., 0.}),
0102 middleUV.get());
0103 BOOST_CHECK_EQUAL(
0104 detectorIndexed->findDetectorVolume(tContext, {40., 0., 92.}),
0105 middleRV.get());
0106 BOOST_CHECK_EQUAL(
0107 detectorIndexed->findDetectorVolume(tContext, {65., 0., 0.}),
0108 outerV.get());
0109 }
0110
0111 BOOST_AUTO_TEST_SUITE_END()
0112
0113 }