Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-22 07:52:56

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 "ActsPlugins/GeoModel/detail/GeoSubtractionConverter.hpp"
0010 
0011 #include "Acts/Definitions/Common.hpp"
0012 #include "Acts/Definitions/Units.hpp"
0013 #include "Acts/Surfaces/DiamondBounds.hpp"
0014 #include "Acts/Surfaces/PlaneSurface.hpp"
0015 #include "Acts/Surfaces/RectangleBounds.hpp"
0016 #include "Acts/Surfaces/Surface.hpp"
0017 #include "Acts/Surfaces/TrapezoidBounds.hpp"
0018 #include "ActsPlugins/GeoModel/GeoModelConversionError.hpp"
0019 #include "ActsPlugins/GeoModel/GeoModelConverters.hpp"
0020 #include "ActsPlugins/GeoModel/IGeoShapeConverter.hpp"
0021 
0022 #include <GeoModelKernel/GeoBox.h>
0023 #include <GeoModelKernel/GeoLogVol.h>
0024 #include <GeoModelKernel/GeoPhysVol.h>
0025 #include <GeoModelKernel/GeoShape.h>
0026 #include <GeoModelKernel/GeoShapeShift.h>
0027 #include <GeoModelKernel/Units.h>
0028 
0029 using namespace Acts;
0030 
0031 Result<ActsPlugins::GeoModelSensitiveSurface>
0032 ActsPlugins::detail::GeoSubtractionConverter::operator()(
0033     [[maybe_unused]] const PVConstLink& geoPV,
0034     const GeoShapeSubtraction& geoSub, const Transform3& absTransform,
0035     SurfaceBoundFactory& boundFactory, [[maybe_unused]] bool sensitive) const {
0036   const GeoShape* shapeA = geoSub.getOpA();
0037   int shapeId = shapeA->typeID();
0038   std::shared_ptr<const IGeoShapeConverter> converter =
0039       geoShapesConverters(shapeId);
0040   if (converter == nullptr) {
0041     throw std::runtime_error("The converter for " + shapeA->type() +
0042                              " is nullptr");
0043   }
0044   // Material and name for the PVConstLink declaration are dummie variables
0045   auto material = make_intrusive<GeoMaterial>("Material", 1.0);
0046   auto logA = make_intrusive<GeoLogVol>("", shapeA, material);
0047   PVConstLink pvA = make_intrusive<GeoPhysVol>(logA);
0048 
0049   // recursively call the the converter
0050   auto converted =
0051       converter->toSensitiveSurface(pvA, absTransform, boundFactory);
0052   if (converted.ok()) {
0053     return converted.value();
0054   } else {
0055     throw std::runtime_error("Unexpected error in the conversion of " +
0056                              shapeA->type());
0057   }
0058 }