Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-17 08:01:04

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/CuboidVolumeBounds.hpp"
0017 #include "Acts/Geometry/GeometryContext.hpp"
0018 #include "Acts/Surfaces/RectangleBounds.hpp"
0019 #include "Acts/Surfaces/Surface.hpp"
0020 #include "Acts/Surfaces/SurfaceBounds.hpp"
0021 #include "Acts/Surfaces/TrapezoidBounds.hpp"
0022 #include "ActsPlugins/GeoModel/GeoModelConverters.hpp"
0023 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0024 
0025 #include <GeoModelKernel/GeoBox.h>
0026 #include <GeoModelKernel/GeoFullPhysVol.h>
0027 #include <GeoModelKernel/GeoLogVol.h>
0028 #include <GeoModelKernel/GeoMaterial.h>
0029 #include <GeoModelKernel/GeoTrap.h>
0030 #include <GeoModelKernel/GeoTrd.h>
0031 #include <GeoModelKernel/GeoVPhysVol.h>
0032 
0033 using namespace Acts;
0034 using namespace ActsPlugins;
0035 
0036 namespace ActsTests {
0037 
0038 BOOST_AUTO_TEST_SUITE(GeoModelSuite)
0039 
0040 // GeoBox conversion test case
0041 BOOST_AUTO_TEST_CASE(GeoBoxToSensitiveConversion) {
0042   auto material = make_intrusive<GeoMaterial>("Material", 1.0);
0043   // Let's create a GeoFullPhysVol object
0044 
0045   // (BOX object) - XY
0046   std::vector<double> hls = {100, 200, 2};
0047   auto box = make_intrusive<GeoBox>(hls[0], hls[1], hls[2]);
0048   auto logBox = make_intrusive<GeoLogVol>("Box", box, material);
0049   auto physBox = make_intrusive<GeoFullPhysVol>(logBox);
0050 
0051   // create pars for conversion
0052   GeoModelDetectorObjectFactory::Config gmConfig;
0053   gmConfig.convertBox = {"Box"};
0054   GeometryContext gContext;
0055   GeoModelDetectorObjectFactory::Cache gmCache;
0056 
0057   // create factory instance
0058   GeoModelDetectorObjectFactory factory(gmConfig);
0059 
0060   factory.convertFpv("Box", physBox, gmCache, gContext);
0061   BOOST_CHECK(!gmCache.volumeBoxFPVs.empty());
0062   const auto& volumeBox = gmCache.volumeBoxFPVs[0].volume;
0063   const auto* bounds =
0064       dynamic_cast<const CuboidVolumeBounds*>(&volumeBox->volumeBounds());
0065   std::vector<double> convHls = bounds->values();
0066   for (std::size_t i = 0; i < hls.size(); i++) {
0067     BOOST_CHECK(hls[i] == convHls[i]);
0068   }
0069 }
0070 
0071 BOOST_AUTO_TEST_SUITE_END()
0072 
0073 }  // namespace ActsTests