File indexing completed on 2025-01-18 09:12:33
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 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(
0072 {Acts::AxisDirection::AxisZ, Acts::AxisDirection::AxisR});
0073
0074
0075 auto rootVolumeFinder = builder.construct(tContext, rootVolumes);
0076
0077 Acts::Experimental::GeometryIdGenerator::Config generatorConfig;
0078 Acts::Experimental::GeometryIdGenerator generator(
0079 generatorConfig,
0080 Acts::getDefaultLogger("SequentialIdGenerator", Acts::Logging::VERBOSE));
0081 auto cache = generator.generateCache();
0082 for (auto& vol : rootVolumes) {
0083 generator.assignGeometryId(cache, *vol);
0084 }
0085
0086 auto detectorIndexed = Detector::makeShared("IndexedDetector", rootVolumes,
0087 std::move(rootVolumeFinder));
0088
0089 BOOST_CHECK_EQUAL(
0090 detectorIndexed->findDetectorVolume(tContext, {10., 0., 0.}),
0091 innerV.get());
0092 BOOST_CHECK_EQUAL(
0093 detectorIndexed->findDetectorVolume(tContext, {25., 0., -93.}),
0094 middleLV.get());
0095 BOOST_CHECK_EQUAL(
0096 detectorIndexed->findDetectorVolume(tContext, {35., 0., 0.}),
0097 middleDV.get());
0098 BOOST_CHECK_EQUAL(
0099 detectorIndexed->findDetectorVolume(tContext, {55., 0., 0.}),
0100 middleUV.get());
0101 BOOST_CHECK_EQUAL(
0102 detectorIndexed->findDetectorVolume(tContext, {40., 0., 92.}),
0103 middleRV.get());
0104 BOOST_CHECK_EQUAL(
0105 detectorIndexed->findDetectorVolume(tContext, {65., 0., 0.}),
0106 outerV.get());
0107 }
0108
0109 BOOST_AUTO_TEST_SUITE_END()