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