Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-05 08:55:51

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 //clang-format off
0012 #include "ActsPlugins/GeoModel/GeoModelDetectorObjectFactory.hpp"
0013 //clang-format on
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Surfaces/RectangleBounds.hpp"
0016 #include "Acts/Surfaces/Surface.hpp"
0017 #include "Acts/Surfaces/SurfaceBounds.hpp"
0018 #include "Acts/Surfaces/TrapezoidBounds.hpp"
0019 #include "ActsPlugins/GeoModel/GeoModelConverters.hpp"
0020 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0021 
0022 #include <GeoModelKernel/GeoFullPhysVol.h>
0023 #include <GeoModelKernel/GeoLogVol.h>
0024 #include <GeoModelKernel/GeoMaterial.h>
0025 #include <GeoModelKernel/GeoShapeSubtraction.h>
0026 #include <GeoModelKernel/GeoTrap.h>
0027 #include <GeoModelKernel/GeoTrd.h>
0028 #include <GeoModelKernel/GeoVPhysVol.h>
0029 
0030 using namespace Acts;
0031 using namespace ActsPlugins;
0032 
0033 GeometryContext tContext;
0034 RotationMatrix3 idRotation = RotationMatrix3::Identity();
0035 Transform3 idTransform = Transform3::Identity();
0036 
0037 namespace ActsTests {
0038 
0039 BOOST_AUTO_TEST_SUITE(GeoModelSuite)
0040 
0041 // GeoBox conversion test case
0042 BOOST_AUTO_TEST_CASE(GeoSubToSensitiveConversion) {
0043   auto material = make_intrusive<GeoMaterial>("Material", 1.0);
0044 
0045   // BOX object
0046   double hlX = 200, hlY = 100, hlZ = 2;
0047   auto shapeA = make_intrusive<GeoBox>(hlX, hlY, hlZ);
0048   // Trapezoid object
0049   auto shapeB = make_intrusive<GeoTrd>(2, 2, 50, 80, 60);
0050 
0051   // create subtraction
0052   auto geoSub = make_intrusive<GeoShapeSubtraction>(shapeA, shapeB);
0053   auto logSub = make_intrusive<GeoLogVol>("LogVolume", geoSub, material);
0054   auto fphysSub = make_intrusive<GeoFullPhysVol>(logSub);
0055 
0056   // create pars for conversion
0057   GeoModelDetectorObjectFactory::Config gmConfig;
0058   GeometryContext gContext;
0059   GeoModelDetectorObjectFactory::Cache subCache;
0060 
0061   // create factory instance
0062   GeoModelDetectorObjectFactory factory(gmConfig);
0063 
0064   // convert GeoFullPhysVol (to surfaces)
0065   factory.convertFpv("Sub", fphysSub, subCache, gContext);
0066 
0067   GeoModelSensitiveSurface subSensSurface = subCache.sensitiveSurfaces[0];
0068   std::shared_ptr<Surface> subSurface = std::get<1>(subSensSurface);
0069   const auto* subBounds =
0070       dynamic_cast<const RectangleBounds*>(&subSurface->bounds());
0071   BOOST_CHECK(subBounds->halfLengthX() == hlX);
0072   BOOST_CHECK(subBounds->halfLengthY() == hlY);
0073 }
0074 
0075 BOOST_AUTO_TEST_SUITE_END()
0076 
0077 }  // namespace ActsTests