File indexing completed on 2025-10-19 07:58:37
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsPlugins/GeoModel/detail/GeoIntersectionAnnulusConverter.hpp"
0010
0011 #include "Acts/Definitions/Common.hpp"
0012 #include "Acts/Definitions/Units.hpp"
0013 #include "Acts/Surfaces/AnnulusBounds.hpp"
0014 #include "Acts/Surfaces/DiscSurface.hpp"
0015 #include "Acts/Surfaces/Surface.hpp"
0016 #include "Acts/Surfaces/detail/AnnulusBoundsHelper.hpp"
0017 #include "ActsPlugins/GeoModel/GeoModelConversionError.hpp"
0018
0019 #include <algorithm>
0020
0021 #include <GeoModelKernel/GeoFullPhysVol.h>
0022 #include <GeoModelKernel/GeoGenericTrap.h>
0023 #include <GeoModelKernel/GeoLogVol.h>
0024 #include <GeoModelKernel/GeoShape.h>
0025 #include <GeoModelKernel/GeoShapeIntersection.h>
0026 #include <GeoModelKernel/GeoShapeShift.h>
0027 #include <GeoModelKernel/GeoTubs.h>
0028
0029 using namespace Acts;
0030 using namespace Acts::detail;
0031
0032 Result<ActsPlugins::GeoModelSensitiveSurface>
0033 ActsPlugins::detail::GeoIntersectionAnnulusConverter::operator()(
0034 const PVConstLink& geoPV, const GeoShapeIntersection& geoIntersection,
0035 const Transform3& absTransform, SurfaceBoundFactory& boundFactory,
0036 bool sensitive) const {
0037
0038 static constexpr double unitLength =
0039 UnitConstants::mm / GeoModelKernelUnits::millimeter;
0040
0041
0042 const GeoShape* opA = geoIntersection.getOpA();
0043 const GeoShape* opB = geoIntersection.getOpB();
0044
0045 const GeoTubs* tubs = dynamic_cast<const GeoTubs*>(opA);
0046 if (tubs != nullptr) {
0047
0048 double rMin = unitLength * tubs->getRMin();
0049 double rMax = unitLength * tubs->getRMax();
0050
0051
0052 const GeoShapeShift* shapeShift = dynamic_cast<const GeoShapeShift*>(opB);
0053 if (shapeShift != nullptr) {
0054 const Transform3& shift = shapeShift->getX();
0055 const GeoGenericTrap* trap =
0056 dynamic_cast<const GeoGenericTrap*>(shapeShift->getOp());
0057 if (trap != nullptr) {
0058 double thickness = 2 * unitLength * trap->getZHalfLength();
0059
0060 auto trapVertices = trap->getVertices();
0061
0062 std::vector<Vector2> faceVertices(trapVertices.begin(),
0063 trapVertices.begin() + 4u);
0064
0065 std::ranges::sort(faceVertices, std::greater{}, [](const auto& f) {
0066 return (VectorHelpers::phi(f));
0067 });
0068
0069
0070 std::vector<Vector3> faceVertices3D;
0071 for (const auto& v : faceVertices) {
0072 faceVertices3D.push_back(
0073 shift * Vector3{unitLength * v.x(), unitLength * v.y(), 0.});
0074 }
0075
0076 faceVertices.clear();
0077 for (auto& v : faceVertices3D) {
0078 faceVertices.push_back(v.block<2, 1>(0, 0));
0079 }
0080
0081 auto [annulusBounds, annulusTransform] =
0082 AnnulusBoundsHelper::create(absTransform, rMin, rMax, faceVertices);
0083 if (!sensitive) {
0084 auto surface = Surface::makeShared<DiscSurface>(
0085 annulusTransform, boundFactory.insert(annulusBounds));
0086 return std::make_tuple(nullptr, surface);
0087 }
0088
0089
0090 auto detectorElement =
0091 GeoModelDetectorElement::createDetectorElement<DiscSurface>(
0092 geoPV, boundFactory.insert(annulusBounds), annulusTransform,
0093 thickness);
0094 auto surface = detectorElement->surface().getSharedPtr();
0095 return std::make_tuple(detectorElement, surface);
0096 }
0097 return std::make_tuple(nullptr, nullptr);
0098 }
0099 return std::make_tuple(nullptr, nullptr);
0100 }
0101 return std::make_tuple(nullptr, nullptr);
0102 }