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