Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:13:10

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 "Acts/Plugins/GeoModel/GeoModelDetectorObjectFactory.hpp"
0015 //clang-format on
0016 #include "Acts/Geometry/GeometryContext.hpp"
0017 #include "Acts/Geometry/TrapezoidVolumeBounds.hpp"
0018 #include "Acts/Plugins/GeoModel/GeoModelConverters.hpp"
0019 #include "Acts/Surfaces/Surface.hpp"
0020 #include "Acts/Surfaces/SurfaceBounds.hpp"
0021 #include "Acts/Surfaces/TrapezoidBounds.hpp"
0022 #include "Acts/Tests/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 BOOST_AUTO_TEST_SUITE(GeoModelPlugin)
0030 
0031 // GeoBox conversion test case
0032 BOOST_AUTO_TEST_CASE(GeoTrdToVolumeConversion) {
0033   auto material = new GeoMaterial("Material", 1.0);
0034   // Let's create a GeoFullPhysVol object
0035   double geoHlX1 = 2, geoHlX2 = 2, geoHlY1 = 50, geoHlY2 = 80, geoHlZ = 60;
0036   auto trd = new GeoTrd(geoHlX1, geoHlX1, geoHlY1, geoHlY2, geoHlZ);
0037   auto logTrd = new GeoLogVol("Trd", trd, material);
0038   auto physTrd = make_intrusive<GeoFullPhysVol>(logTrd);
0039 
0040   // this should produce an error while converting
0041   auto errTrd = new GeoTrd(2, 3, 25, 40, 30);
0042   auto errLogTrd = new GeoLogVol("Trd", errTrd, material);
0043   auto errPhysTrd = make_intrusive<GeoFullPhysVol>(errLogTrd);
0044 
0045   // create pars for conversion
0046   Acts::GeoModelDetectorObjectFactory::Config gmConfig;
0047   gmConfig.convertBox = {"Trd"};
0048   Acts::GeometryContext gContext;
0049   Acts::GeoModelDetectorObjectFactory::Cache gmCache;
0050   Acts::GeoModelDetectorObjectFactory::Cache errCache;
0051 
0052   // create factory instance
0053   Acts::GeoModelDetectorObjectFactory factory(gmConfig);
0054 
0055   // test error case
0056   BOOST_CHECK_THROW(factory.convertFpv("Trd", errPhysTrd, errCache, gContext),
0057                     std::runtime_error);
0058   factory.convertFpv("Trd", physTrd, gmCache, gContext);
0059   std::shared_ptr<Acts::Experimental::DetectorVolume> volumeTrd =
0060       gmCache.boundingBoxes[0];
0061   const auto* bounds = dynamic_cast<const Acts::TrapezoidVolumeBounds*>(
0062       &volumeTrd->volumeBounds());
0063   std::vector<double> convHls = bounds->values();
0064   // note: GeoTrd and Acts use different coordinates
0065   BOOST_CHECK(geoHlX1 == convHls[3]);
0066   BOOST_CHECK(geoHlX2 == convHls[3]);
0067   BOOST_CHECK(geoHlY1 == convHls[0]);
0068   BOOST_CHECK(geoHlY2 == convHls[1]);
0069   BOOST_CHECK(geoHlZ == convHls[2]);
0070 }
0071 
0072 BOOST_AUTO_TEST_SUITE_END()