File indexing completed on 2025-07-14 08:12:34
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Geometry/GeometryContext.hpp"
0012 #include "Acts/Plugins/GeoModel/GeoModelConverters.hpp"
0013 #include "Acts/Surfaces/RectangleBounds.hpp"
0014 #include "Acts/Surfaces/Surface.hpp"
0015 #include "Acts/Surfaces/SurfaceBounds.hpp"
0016 #include "Acts/Surfaces/TrapezoidBounds.hpp"
0017 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0018
0019 #include <GeoModelKernel/GeoBox.h>
0020 #include <GeoModelKernel/GeoFullPhysVol.h>
0021 #include <GeoModelKernel/GeoLogVol.h>
0022 #include <GeoModelKernel/GeoMaterial.h>
0023 #include <GeoModelKernel/GeoTrap.h>
0024 #include <GeoModelKernel/GeoTrd.h>
0025 #include <GeoModelKernel/GeoVPhysVol.h>
0026
0027 Acts::GeometryContext tContext;
0028 Acts::RotationMatrix3 idRotation = Acts::RotationMatrix3::Identity();
0029 Acts::Transform3 idTransform = Acts::Transform3::Identity();
0030
0031 BOOST_AUTO_TEST_SUITE(GeoModelPlugin)
0032
0033
0034 BOOST_AUTO_TEST_CASE(GeoBoxToSensitiveConversion) {
0035 auto material = make_intrusive<GeoMaterial>("Material", 1.0);
0036
0037
0038
0039 auto boxXY = make_intrusive<GeoBox>(100, 200, 2);
0040 auto logXY = make_intrusive<GeoLogVol>("LogVolumeXY", boxXY, material);
0041 auto fphysXY = make_intrusive<GeoFullPhysVol>(logXY);
0042
0043 PVConstLink physXY{make_intrusive<GeoFullPhysVol>(logXY)};
0044
0045 Acts::SurfaceBoundFactory boundFactory{};
0046 auto converted = Acts::GeoBoxConverter{}.toSensitiveSurface(
0047 physXY, Acts::Transform3::Identity(), boundFactory);
0048
0049 BOOST_CHECK(converted.ok());
0050
0051 auto [elementXY, surfaceXY] = converted.value();
0052
0053 BOOST_CHECK(surfaceXY->type() == Acts::Surface::SurfaceType::Plane);
0054
0055
0056 const Acts::RectangleBounds* rBoundsXY =
0057 dynamic_cast<const Acts::RectangleBounds*>(&(surfaceXY->bounds()));
0058 BOOST_CHECK(rBoundsXY != nullptr);
0059 CHECK_CLOSE_ABS(rBoundsXY->halfLengthX(), 100, 1e-6);
0060 CHECK_CLOSE_ABS(rBoundsXY->halfLengthY(), 200, 1e-6);
0061
0062
0063 const Acts::Transform3& transformXY = surfaceXY->transform(tContext);
0064 BOOST_CHECK(transformXY.isApprox(idTransform));
0065
0066
0067 auto boxYZ = make_intrusive<GeoBox>(2, 200, 300);
0068 auto logYZ = make_intrusive<GeoLogVol>("LogVolumeYZ", boxYZ, material);
0069 auto fphysYZ = make_intrusive<GeoFullPhysVol>(logYZ);
0070
0071 converted = Acts::GeoBoxConverter{}.toSensitiveSurface(
0072 fphysYZ, Acts::Transform3::Identity(), boundFactory);
0073
0074 BOOST_CHECK(converted.ok());
0075
0076 auto [elementYZ, surfaceYZ] = converted.value();
0077
0078 BOOST_CHECK(surfaceYZ->type() == Acts::Surface::SurfaceType::Plane);
0079 const Acts::RectangleBounds* rBoundsYZ =
0080 dynamic_cast<const Acts::RectangleBounds*>(&(surfaceYZ->bounds()));
0081 BOOST_CHECK(rBoundsYZ != nullptr);
0082 CHECK_CLOSE_ABS(rBoundsYZ->halfLengthX(), 200, 1e-6);
0083 CHECK_CLOSE_ABS(rBoundsYZ->halfLengthY(), 300, 1e-6);
0084
0085
0086 const Acts::Transform3& transformYZ = surfaceYZ->transform(tContext);
0087
0088 Acts::RotationMatrix3 rotationYZ = transformYZ.rotation();
0089 BOOST_CHECK(rotationYZ.col(0).isApprox(idRotation.col(1)));
0090 BOOST_CHECK(rotationYZ.col(1).isApprox(idRotation.col(2)));
0091 BOOST_CHECK(rotationYZ.col(2).isApprox(idRotation.col(0)));
0092
0093
0094 auto boxXZ = make_intrusive<GeoBox>(400, 2, 300);
0095 auto logXZ = make_intrusive<GeoLogVol>("LogVolumeXZ", boxXZ, material);
0096 auto fphysXZ = make_intrusive<GeoFullPhysVol>(logXZ);
0097
0098 converted = Acts::GeoBoxConverter{}.toSensitiveSurface(
0099 fphysXZ, Acts::Transform3::Identity(), boundFactory);
0100
0101 BOOST_CHECK(converted.ok());
0102
0103 auto [elementXZ, surfaceXZ] = converted.value();
0104
0105 BOOST_CHECK(surfaceXZ->type() == Acts::Surface::SurfaceType::Plane);
0106
0107
0108 const Acts::RectangleBounds* rBoundsXZ =
0109 dynamic_cast<const Acts::RectangleBounds*>(&(surfaceXZ->bounds()));
0110
0111 BOOST_CHECK(rBoundsXZ != nullptr);
0112 CHECK_CLOSE_ABS(rBoundsXZ->halfLengthX(), 300, 1e-6);
0113 CHECK_CLOSE_ABS(rBoundsXZ->halfLengthY(), 400, 1e-6);
0114
0115
0116 const Acts::Transform3& transformXZ = surfaceXZ->transform(tContext);
0117
0118 Acts::RotationMatrix3 rotationXZ = transformXZ.rotation();
0119 BOOST_CHECK(rotationXZ.col(0).isApprox(idRotation.col(2)));
0120 BOOST_CHECK(rotationXZ.col(1).isApprox(idRotation.col(0)));
0121 BOOST_CHECK(rotationXZ.col(2).isApprox(idRotation.col(1)));
0122 }
0123
0124 BOOST_AUTO_TEST_SUITE_END()