File indexing completed on 2025-10-17 08:01:05
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/Surface.hpp"
0013 #include "Acts/Surfaces/SurfaceBounds.hpp"
0014 #include "Acts/Surfaces/TrapezoidBounds.hpp"
0015 #include "ActsPlugins/GeoModel/GeoModelConverters.hpp"
0016 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0017
0018 #include <GeoModelKernel/GeoFullPhysVol.h>
0019 #include <GeoModelKernel/GeoLogVol.h>
0020 #include <GeoModelKernel/GeoMaterial.h>
0021 #include <GeoModelKernel/GeoTrd.h>
0022
0023 using namespace Acts;
0024 using namespace ActsPlugins;
0025
0026 GeometryContext tContext;
0027 RotationMatrix3 idRotation = RotationMatrix3::Identity();
0028 Transform3 idTransform = Transform3::Identity();
0029
0030 namespace ActsTests {
0031
0032 BOOST_AUTO_TEST_SUITE(GeoModelSuite)
0033
0034
0035 BOOST_AUTO_TEST_CASE(GeoTrfToSensitiveConversion) {
0036 auto material = make_intrusive<GeoMaterial>("Material", 1.0);
0037
0038
0039
0040
0041
0042 auto trapYZ = make_intrusive<GeoTrd>(2, 2, 50, 80, 60);
0043 auto logYZ = make_intrusive<GeoLogVol>("LogVolumeYZ", trapYZ, material);
0044 auto fphysYZ = make_intrusive<GeoFullPhysVol>(logYZ);
0045
0046 PVConstLink physYZ{make_intrusive<GeoFullPhysVol>(logYZ)};
0047
0048 SurfaceBoundFactory boundFactory{};
0049 auto converted =
0050 GeoTrdConverter{}.toSensitiveSurface(physYZ, idTransform, boundFactory);
0051
0052 BOOST_CHECK(converted.ok());
0053
0054 auto [elementYZ, surfaceYZ] = converted.value();
0055
0056
0057 const TrapezoidBounds* tBoundsYZ =
0058 dynamic_cast<const TrapezoidBounds*>(&(surfaceYZ->bounds()));
0059
0060 BOOST_CHECK(tBoundsYZ != nullptr);
0061 CHECK_CLOSE_ABS(
0062 tBoundsYZ->get(TrapezoidBounds::BoundValues::eHalfLengthXnegY), 50, 1e-6);
0063 CHECK_CLOSE_ABS(
0064 tBoundsYZ->get(TrapezoidBounds::BoundValues::eHalfLengthXposY), 80, 1e-6);
0065 CHECK_CLOSE_ABS(tBoundsYZ->get(TrapezoidBounds::BoundValues::eHalfLengthY),
0066 60, 1e-6);
0067
0068
0069 const Transform3& transformYZ = surfaceYZ->transform(tContext);
0070
0071 RotationMatrix3 rotationYZ = transformYZ.rotation();
0072 BOOST_CHECK(rotationYZ.col(0).isApprox(idRotation.col(1)));
0073 BOOST_CHECK(rotationYZ.col(1).isApprox(idRotation.col(2)));
0074 BOOST_CHECK(rotationYZ.col(2).isApprox(idRotation.col(0)));
0075
0076
0077
0078
0079 auto trapYZs = make_intrusive<GeoTrd>(2, 2, 80, 50, 60);
0080 auto logYZs = make_intrusive<GeoLogVol>("LogVolumeYZs", trapYZs, material);
0081 auto fphysYZs = make_intrusive<GeoFullPhysVol>(logYZs);
0082
0083 converted =
0084 GeoTrdConverter{}.toSensitiveSurface(fphysYZs, idTransform, boundFactory);
0085
0086 BOOST_CHECK(converted.ok());
0087
0088 auto [elementYZs, surfaceYZs] = converted.value();
0089
0090
0091 const TrapezoidBounds* tBoundsYZs =
0092 dynamic_cast<const TrapezoidBounds*>(&(surfaceYZs->bounds()));
0093
0094 BOOST_CHECK(tBoundsYZs != nullptr);
0095 CHECK_CLOSE_ABS(
0096 tBoundsYZs->get(TrapezoidBounds::BoundValues::eHalfLengthXnegY), 50,
0097 1e-6);
0098 CHECK_CLOSE_ABS(
0099 tBoundsYZs->get(TrapezoidBounds::BoundValues::eHalfLengthXposY), 80,
0100 1e-6);
0101 CHECK_CLOSE_ABS(tBoundsYZs->get(TrapezoidBounds::BoundValues::eHalfLengthY),
0102 60, 1e-6);
0103
0104
0105 const Transform3& transformYZs = surfaceYZs->transform(tContext);
0106
0107 RotationMatrix3 rotationYZs = transformYZs.rotation();
0108 BOOST_CHECK(rotationYZs.col(0).isApprox(idRotation.col(1)));
0109 BOOST_CHECK(rotationYZs.col(1).isApprox(-idRotation.col(2)));
0110 BOOST_CHECK(rotationYZs.col(2).isApprox(-idRotation.col(0)));
0111
0112
0113 auto trapXZ = make_intrusive<GeoTrd>(50, 80, 2, 2, 60);
0114 auto logXZ = make_intrusive<GeoLogVol>("LogVolumeXZ", trapXZ, material);
0115 auto fphysXZ = make_intrusive<GeoFullPhysVol>(logXZ);
0116
0117 converted =
0118 GeoTrdConverter{}.toSensitiveSurface(fphysXZ, idTransform, boundFactory);
0119
0120 BOOST_CHECK(converted.ok());
0121
0122 auto [elementXZ, surfaceXZ] = converted.value();
0123
0124
0125 const TrapezoidBounds* tBoundsXZ =
0126 dynamic_cast<const TrapezoidBounds*>(&(surfaceXZ->bounds()));
0127
0128 BOOST_CHECK(tBoundsXZ != nullptr);
0129 CHECK_CLOSE_ABS(
0130 tBoundsXZ->get(TrapezoidBounds::BoundValues::eHalfLengthXnegY), 50, 1e-6);
0131 CHECK_CLOSE_ABS(
0132 tBoundsXZ->get(TrapezoidBounds::BoundValues::eHalfLengthXposY), 80, 1e-6);
0133 CHECK_CLOSE_ABS(tBoundsXZ->get(TrapezoidBounds::BoundValues::eHalfLengthY),
0134 60, 1e-6);
0135
0136
0137 const Transform3& transformXZ = surfaceXZ->transform(tContext);
0138
0139 RotationMatrix3 rotationXZ = transformXZ.rotation();
0140 BOOST_CHECK(rotationXZ.col(0).isApprox(idRotation.col(0)));
0141 BOOST_CHECK(rotationXZ.col(1).isApprox(idRotation.col(2)));
0142 BOOST_CHECK(rotationXZ.col(2).isApprox(-1 * idRotation.col(1)));
0143
0144
0145 auto trapXZs = make_intrusive<GeoTrd>(80, 50, 2, 2, 60);
0146 auto logXZs = make_intrusive<GeoLogVol>("LogVolumeXZs", trapXZs, material);
0147 auto fphysXZs = make_intrusive<GeoFullPhysVol>(logXZs);
0148
0149 PVConstLink physXZs{make_intrusive<GeoFullPhysVol>(logXZs)};
0150
0151 converted =
0152 GeoTrdConverter{}.toSensitiveSurface(physXZs, idTransform, boundFactory);
0153
0154 BOOST_CHECK(converted.ok());
0155
0156 auto [elementXZs, surfaceXZs] = converted.value();
0157
0158
0159 const TrapezoidBounds* tBoundsXZs =
0160 dynamic_cast<const TrapezoidBounds*>(&(surfaceXZs->bounds()));
0161
0162 BOOST_CHECK(tBoundsXZs != nullptr);
0163 CHECK_CLOSE_ABS(
0164 tBoundsXZs->get(TrapezoidBounds::BoundValues::eHalfLengthXnegY), 50,
0165 1e-6);
0166 CHECK_CLOSE_ABS(
0167 tBoundsXZs->get(TrapezoidBounds::BoundValues::eHalfLengthXposY), 80,
0168 1e-6);
0169 CHECK_CLOSE_ABS(tBoundsXZs->get(TrapezoidBounds::BoundValues::eHalfLengthY),
0170 60, 1e-6);
0171
0172
0173 const Transform3& transformXZs = surfaceXZs->transform(tContext);
0174
0175 RotationMatrix3 rotationXZs = transformXZs.rotation();
0176 BOOST_CHECK(rotationXZs.col(0).isApprox(idRotation.col(0)));
0177 BOOST_CHECK(rotationXZs.col(1).isApprox(-idRotation.col(2)));
0178 BOOST_CHECK(rotationXZs.col(2).isApprox(idRotation.col(1)));
0179
0180
0181 auto trapDouble = make_intrusive<GeoTrd>(50, 80, 50, 80, 60);
0182 auto logDouble =
0183 make_intrusive<GeoLogVol>("LogVolumeDouble", trapDouble, material);
0184 auto fphysDouble = make_intrusive<GeoFullPhysVol>(logDouble);
0185
0186 BOOST_CHECK_THROW(GeoTrdConverter{}.toSensitiveSurface(
0187 fphysDouble, idTransform, boundFactory),
0188 std::invalid_argument);
0189 }
0190
0191 BOOST_AUTO_TEST_SUITE_END()
0192
0193 }