File indexing completed on 2025-10-15 08:06:08
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011
0012
0013
0014 #include "ActsPlugins/GeoModel/GeoModelDetectorObjectFactory.hpp"
0015
0016 #include "Acts/Geometry/GeometryContext.hpp"
0017 #include "Acts/Geometry/TrapezoidVolumeBounds.hpp"
0018 #include "Acts/Surfaces/Surface.hpp"
0019 #include "Acts/Surfaces/SurfaceBounds.hpp"
0020 #include "Acts/Surfaces/TrapezoidBounds.hpp"
0021 #include "ActsPlugins/GeoModel/GeoModelConverters.hpp"
0022 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0023
0024 #include <GeoModelKernel/GeoFullPhysVol.h>
0025 #include <GeoModelKernel/GeoLogVol.h>
0026 #include <GeoModelKernel/GeoMaterial.h>
0027 #include <GeoModelKernel/GeoTrd.h>
0028
0029 using namespace Acts;
0030 using namespace ActsPlugins;
0031
0032 namespace ActsTests {
0033
0034 BOOST_AUTO_TEST_SUITE(GeoModelSuite)
0035
0036
0037 BOOST_AUTO_TEST_CASE(GeoTrdToVolumeConversion) {
0038 auto material = make_intrusive<GeoMaterial>("Material", 1.0);
0039
0040 double geoHlX1 = 2, geoHlX2 = 2, geoHlY1 = 50, geoHlY2 = 80, geoHlZ = 60;
0041 auto trd = make_intrusive<GeoTrd>(geoHlX1, geoHlX1, geoHlY1, geoHlY2, geoHlZ);
0042 auto logTrd = make_intrusive<GeoLogVol>("Trd", trd, material);
0043 auto physTrd = make_intrusive<GeoFullPhysVol>(logTrd);
0044
0045
0046 auto errTrd = make_intrusive<GeoTrd>(2, 3, 25, 40, 30);
0047 auto errLogTrd = make_intrusive<GeoLogVol>("Trd", errTrd, material);
0048 auto errPhysTrd = make_intrusive<GeoFullPhysVol>(errLogTrd);
0049
0050
0051 GeoModelDetectorObjectFactory::Config gmConfig;
0052 gmConfig.convertBox = {"Trd"};
0053 GeometryContext gContext;
0054 GeoModelDetectorObjectFactory::Cache gmCache;
0055 GeoModelDetectorObjectFactory::Cache errCache;
0056
0057
0058 GeoModelDetectorObjectFactory factory(gmConfig);
0059
0060
0061 BOOST_CHECK_THROW(factory.convertFpv("Trd", errPhysTrd, errCache, gContext),
0062 std::invalid_argument);
0063 factory.convertFpv("Trd", physTrd, gmCache, gContext);
0064
0065 BOOST_CHECK(!gmCache.volumeBoxFPVs.empty());
0066 const auto& volumeTrd = gmCache.volumeBoxFPVs[0].volume;
0067 const auto* bounds =
0068 dynamic_cast<const TrapezoidVolumeBounds*>(&volumeTrd->volumeBounds());
0069 std::vector<double> convHls = bounds->values();
0070
0071 BOOST_CHECK(geoHlX1 == convHls[3]);
0072 BOOST_CHECK(geoHlX2 == convHls[3]);
0073 BOOST_CHECK(geoHlY1 == convHls[0]);
0074 BOOST_CHECK(geoHlY2 == convHls[1]);
0075 BOOST_CHECK(geoHlZ == convHls[2]);
0076 }
0077
0078 BOOST_AUTO_TEST_SUITE_END()
0079
0080 }