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