File indexing completed on 2025-10-23 08:23:48
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsPlugins/GeoModel/detail/GeoShiftConverter.hpp"
0010
0011 #include "Acts/Surfaces/PlaneSurface.hpp"
0012 #include "Acts/Surfaces/StrawSurface.hpp"
0013 #include "Acts/Surfaces/TrapezoidBounds.hpp"
0014 #include "ActsPlugins/GeoModel/GeoModelConversionError.hpp"
0015 #include "ActsPlugins/GeoModel/detail/GeoBoxConverter.hpp"
0016 #include "ActsPlugins/GeoModel/detail/GeoTrdConverter.hpp"
0017 #include "ActsPlugins/GeoModel/detail/GeoTubeConverter.hpp"
0018
0019 #include <GeoModelKernel/GeoShapeShift.h>
0020 #include <GeoModelKernel/GeoTube.h>
0021
0022 using namespace Acts;
0023
0024 namespace ActsPlugins::detail {
0025
0026 namespace {
0027
0028 template <typename ContainedShape, typename Converter, typename Surface,
0029 typename Bounds>
0030 Result<GeoModelSensitiveSurface> impl(PVConstLink geoPV,
0031 const GeoShapeShift& geoShift,
0032 const Transform3& absTransform,
0033 SurfaceBoundFactory& boundFactory,
0034 bool sensitive) {
0035 auto trd = dynamic_cast<const ContainedShape*>(geoShift.getOp());
0036
0037 if (trd == nullptr) {
0038 return GeoModelConversionError::WrongShapeForConverter;
0039 ;
0040 }
0041
0042 const Transform3& shift = geoShift.getX();
0043
0044 const auto& conversionRes =
0045 Converter{}(geoPV, *trd, absTransform * shift, boundFactory, sensitive);
0046 if (!conversionRes.ok()) {
0047 return conversionRes.error();
0048 }
0049 auto [el, surface] = conversionRes.value();
0050
0051
0052 const auto& bounds = static_cast<const Bounds&>(surface->bounds());
0053 auto sharedBounds = boundFactory.makeBounds<Bounds>(bounds);
0054
0055
0056
0057 if (!sensitive) {
0058 auto newSurface = Surface::template makeShared<Surface>(
0059 surface->transform({}), sharedBounds);
0060 return std::make_tuple(nullptr, newSurface);
0061 }
0062
0063 auto newEl = GeoModelDetectorElement::createDetectorElement<Surface>(
0064 el->physicalVolume(), sharedBounds, el->transform({}), el->thickness());
0065 auto newSurface = newEl->surface().getSharedPtr();
0066 return std::make_tuple(newEl, newSurface);
0067 }
0068
0069 }
0070
0071 Result<GeoModelSensitiveSurface> GeoShiftConverter::operator()(
0072 const PVConstLink& geoPV, const GeoShapeShift& geoShift,
0073 const Transform3& absTransform, SurfaceBoundFactory& boundFactory,
0074 bool sensitive) const {
0075 auto r = impl<GeoTrd, detail::GeoTrdConverter, PlaneSurface, TrapezoidBounds>(
0076 geoPV, geoShift, absTransform, boundFactory, sensitive);
0077
0078 if (r.ok()) {
0079 return r;
0080 }
0081
0082 r = impl<GeoBox, detail::GeoBoxConverter, PlaneSurface, RectangleBounds>(
0083 geoPV, geoShift, absTransform, boundFactory, sensitive);
0084
0085 if (r.ok()) {
0086 return r;
0087 }
0088
0089
0090 r = impl<GeoTube, detail::GeoTubeConverter, StrawSurface, LineBounds>(
0091 geoPV, geoShift, absTransform, boundFactory, sensitive);
0092
0093 if (r.ok()) {
0094 return r;
0095 }
0096
0097 return GeoModelConversionError::WrongShapeForConverter;
0098 }
0099
0100 }