File indexing completed on 2025-12-13 09:23:28
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/Surfaces/RectangleBounds.hpp"
0013 #include "Acts/Surfaces/Surface.hpp"
0014 #include "Acts/Surfaces/SurfaceBounds.hpp"
0015 #include "Acts/Surfaces/TrapezoidBounds.hpp"
0016 #include "ActsPlugins/GeoModel/GeoModelConverters.hpp"
0017 #include "ActsTests/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 using namespace Acts;
0028 using namespace ActsPlugins;
0029
0030 GeometryContext tContext;
0031 RotationMatrix3 idRotation = RotationMatrix3::Identity();
0032 Transform3 idTransform = Transform3::Identity();
0033
0034 namespace ActsTests {
0035
0036 BOOST_AUTO_TEST_SUITE(GeoModelSuite)
0037
0038
0039 BOOST_AUTO_TEST_CASE(GeoBoxToSensitiveConversion) {
0040 auto material = make_intrusive<GeoMaterial>("Material", 1.0);
0041
0042
0043
0044 auto boxXY = make_intrusive<GeoBox>(100, 200, 2);
0045 auto logXY = make_intrusive<GeoLogVol>("LogVolumeXY", boxXY, material);
0046 auto fphysXY = make_intrusive<GeoFullPhysVol>(logXY);
0047
0048 PVConstLink physXY{make_intrusive<GeoFullPhysVol>(logXY)};
0049
0050 SurfaceBoundFactory boundFactory{};
0051 auto converted = GeoBoxConverter{}.toSensitiveSurface(
0052 physXY, Transform3::Identity(), boundFactory);
0053
0054 BOOST_CHECK(converted.ok());
0055
0056 auto [elementXY, surfaceXY] = converted.value();
0057
0058 BOOST_CHECK(surfaceXY->type() == Surface::SurfaceType::Plane);
0059
0060
0061 const RectangleBounds* rBoundsXY =
0062 dynamic_cast<const RectangleBounds*>(&(surfaceXY->bounds()));
0063 BOOST_CHECK(rBoundsXY != nullptr);
0064 CHECK_CLOSE_ABS(rBoundsXY->halfLengthX(), 100, 1e-6);
0065 CHECK_CLOSE_ABS(rBoundsXY->halfLengthY(), 200, 1e-6);
0066
0067
0068 const Transform3& transformXY = surfaceXY->transform(tContext);
0069 BOOST_CHECK(transformXY.isApprox(idTransform));
0070
0071
0072 auto boxYZ = make_intrusive<GeoBox>(2, 200, 300);
0073 auto logYZ = make_intrusive<GeoLogVol>("LogVolumeYZ", boxYZ, material);
0074 auto fphysYZ = make_intrusive<GeoFullPhysVol>(logYZ);
0075
0076 converted = GeoBoxConverter{}.toSensitiveSurface(
0077 fphysYZ, Transform3::Identity(), boundFactory);
0078
0079 BOOST_CHECK(converted.ok());
0080
0081 auto [elementYZ, surfaceYZ] = converted.value();
0082
0083 BOOST_CHECK(surfaceYZ->type() == Surface::SurfaceType::Plane);
0084 const RectangleBounds* rBoundsYZ =
0085 dynamic_cast<const RectangleBounds*>(&(surfaceYZ->bounds()));
0086 BOOST_CHECK(rBoundsYZ != nullptr);
0087 CHECK_CLOSE_ABS(rBoundsYZ->halfLengthX(), 200, 1e-6);
0088 CHECK_CLOSE_ABS(rBoundsYZ->halfLengthY(), 300, 1e-6);
0089
0090
0091 const Transform3& transformYZ = surfaceYZ->transform(tContext);
0092
0093 RotationMatrix3 rotationYZ = transformYZ.rotation();
0094 BOOST_CHECK(rotationYZ.col(0).isApprox(idRotation.col(1)));
0095 BOOST_CHECK(rotationYZ.col(1).isApprox(idRotation.col(2)));
0096 BOOST_CHECK(rotationYZ.col(2).isApprox(idRotation.col(0)));
0097
0098
0099 auto boxXZ = make_intrusive<GeoBox>(400, 2, 300);
0100 auto logXZ = make_intrusive<GeoLogVol>("LogVolumeXZ", boxXZ, material);
0101 auto fphysXZ = make_intrusive<GeoFullPhysVol>(logXZ);
0102
0103 converted = GeoBoxConverter{}.toSensitiveSurface(
0104 fphysXZ, Transform3::Identity(), boundFactory);
0105
0106 BOOST_CHECK(converted.ok());
0107
0108 auto [elementXZ, surfaceXZ] = converted.value();
0109
0110 BOOST_CHECK(surfaceXZ->type() == Surface::SurfaceType::Plane);
0111
0112
0113 const RectangleBounds* rBoundsXZ =
0114 dynamic_cast<const RectangleBounds*>(&(surfaceXZ->bounds()));
0115
0116 BOOST_CHECK(rBoundsXZ != nullptr);
0117 CHECK_CLOSE_ABS(rBoundsXZ->halfLengthX(), 300, 1e-6);
0118 CHECK_CLOSE_ABS(rBoundsXZ->halfLengthY(), 400, 1e-6);
0119
0120
0121 const Transform3& transformXZ = surfaceXZ->transform(tContext);
0122
0123 RotationMatrix3 rotationXZ = transformXZ.rotation();
0124 BOOST_CHECK(rotationXZ.col(0).isApprox(idRotation.col(2)));
0125 BOOST_CHECK(rotationXZ.col(1).isApprox(idRotation.col(0)));
0126 BOOST_CHECK(rotationXZ.col(2).isApprox(idRotation.col(1)));
0127 }
0128
0129 BOOST_AUTO_TEST_SUITE_END()
0130
0131 }