File indexing completed on 2025-02-23 09:15:34
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, bool sensitive) const {
0033
0034 static constexpr double unitLength =
0035 Acts::UnitConstants::mm / GeoModelKernelUnits::millimeter;
0036
0037
0038 const GeoShape* opA = geoIntersection.getOpA();
0039 const GeoShape* opB = geoIntersection.getOpB();
0040
0041 const GeoTubs* tubs = dynamic_cast<const GeoTubs*>(opA);
0042 if (tubs != nullptr) {
0043
0044 double rMin = unitLength * tubs->getRMin();
0045 double rMax = unitLength * tubs->getRMax();
0046
0047
0048 const GeoShapeShift* shapeShift = dynamic_cast<const GeoShapeShift*>(opB);
0049 if (shapeShift != nullptr) {
0050 const Transform3& shift = shapeShift->getX();
0051 const GeoGenericTrap* trap =
0052 dynamic_cast<const GeoGenericTrap*>(shapeShift->getOp());
0053 if (trap != nullptr) {
0054 double thickness = 2 * unitLength * trap->getZHalfLength();
0055
0056 auto trapVertices = trap->getVertices();
0057
0058 std::vector<Vector2> faceVertices(trapVertices.begin(),
0059 trapVertices.begin() + 4u);
0060
0061 std::ranges::sort(faceVertices, std::greater{}, [](const auto& f) {
0062 return (VectorHelpers::phi(f));
0063 });
0064
0065
0066 std::vector<Vector3> faceVertices3D;
0067 for (const auto& v : faceVertices) {
0068 faceVertices3D.push_back(
0069 shift * Vector3{unitLength * v.x(), unitLength * v.y(), 0.});
0070 }
0071
0072 faceVertices.clear();
0073 for (auto& v : faceVertices3D) {
0074 faceVertices.push_back(v.block<2, 1>(0, 0));
0075 }
0076
0077 auto [annulusBounds, annulusTransform] =
0078 Acts::detail::AnnulusBoundsHelper::create(absTransform, rMin, rMax,
0079 faceVertices);
0080 if (!sensitive) {
0081 auto surface =
0082 Surface::makeShared<DiscSurface>(annulusTransform, annulusBounds);
0083 return std::make_tuple(nullptr, surface);
0084 }
0085
0086
0087 auto detectorElement =
0088 GeoModelDetectorElement::createDetectorElement<DiscSurface>(
0089 geoPV, annulusBounds, annulusTransform, thickness);
0090 auto surface = detectorElement->surface().getSharedPtr();
0091 return std::make_tuple(detectorElement, surface);
0092 }
0093 return std::make_tuple(nullptr, nullptr);
0094 }
0095 return std::make_tuple(nullptr, nullptr);
0096 }
0097 return std::make_tuple(nullptr, nullptr);
0098 }