Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-15 08:06:08

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 
0011 // switching format off to avoid conflicting declaration in GeoModel
0012 // needed until Acts GeoModel bumps to 6.5
0013 //clang-format off
0014 #include "ActsPlugins/GeoModel/GeoModelDetectorObjectFactory.hpp"
0015 //clang-format on
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 // GeoBox conversion test case
0037 BOOST_AUTO_TEST_CASE(GeoTrdToVolumeConversion) {
0038   auto material = make_intrusive<GeoMaterial>("Material", 1.0);
0039   // Let's create a GeoFullPhysVol object
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   // this should produce an error while converting
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   // create pars for conversion
0051   GeoModelDetectorObjectFactory::Config gmConfig;
0052   gmConfig.convertBox = {"Trd"};
0053   GeometryContext gContext;
0054   GeoModelDetectorObjectFactory::Cache gmCache;
0055   GeoModelDetectorObjectFactory::Cache errCache;
0056 
0057   // create factory instance
0058   GeoModelDetectorObjectFactory factory(gmConfig);
0059 
0060   // test error case
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   // note: GeoTrd and Acts use different coordinates
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 }  // namespace ActsTests