File indexing completed on 2025-10-21 08:03:46
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsPlugins/GeoModel/detail/GeoBoxConverter.hpp"
0010
0011 #include "Acts/Definitions/Common.hpp"
0012 #include "Acts/Definitions/Units.hpp"
0013 #include "Acts/Surfaces/PlaneSurface.hpp"
0014 #include "Acts/Surfaces/RectangleBounds.hpp"
0015 #include "Acts/Surfaces/Surface.hpp"
0016 #include "ActsPlugins/GeoModel/GeoModelConversionError.hpp"
0017
0018 #include <GeoModelKernel/GeoBox.h>
0019 #include <GeoModelKernel/GeoFullPhysVol.h>
0020 #include <GeoModelKernel/GeoLogVol.h>
0021 #include <GeoModelKernel/GeoShape.h>
0022 #include <GeoModelKernel/Units.h>
0023
0024 using namespace Acts;
0025
0026 Result<ActsPlugins::GeoModelSensitiveSurface>
0027 ActsPlugins::detail::GeoBoxConverter::operator()(
0028 const PVConstLink& geoPV, const GeoBox& geoBox,
0029 const Transform3& absTransform, SurfaceBoundFactory& boundFactory,
0030 bool sensitive) const {
0031
0032 static constexpr double unitLength =
0033 UnitConstants::mm / GeoModelKernelUnits::millimeter;
0034
0035
0036 Transform3 transform = Transform3::Identity();
0037 transform.translation() = unitLength * absTransform.translation();
0038 auto rotation = absTransform.rotation();
0039
0040 std::vector<double> halfLengths = {geoBox.getXHalfLength(),
0041 geoBox.getYHalfLength(),
0042 geoBox.getZHalfLength()};
0043
0044 auto minElement = std::min_element(halfLengths.begin(), halfLengths.end());
0045 auto zIndex = std::distance(halfLengths.begin(), minElement);
0046 std::size_t yIndex = zIndex > 0u ? zIndex - 1u : 2u;
0047 std::size_t xIndex = yIndex > 0u ? yIndex - 1u : 2u;
0048
0049 Vector3 colX = rotation.col(xIndex);
0050 Vector3 colY = rotation.col(yIndex);
0051 Vector3 colZ = rotation.col(zIndex);
0052 rotation.col(0) = colX;
0053 rotation.col(1) = colY;
0054 rotation.col(2) = colZ;
0055 transform.linear() = rotation;
0056
0057
0058 double halfX = unitLength * halfLengths[xIndex];
0059 double halfY = unitLength * halfLengths[yIndex];
0060 auto rectangleBounds = boundFactory.makeBounds<RectangleBounds>(halfX, halfY);
0061 if (!sensitive) {
0062 auto surface =
0063 Surface::makeShared<PlaneSurface>(transform, rectangleBounds);
0064 return std::make_tuple(nullptr, surface);
0065 }
0066
0067 auto detectorElement =
0068 GeoModelDetectorElement::createDetectorElement<PlaneSurface>(
0069 geoPV, rectangleBounds, transform,
0070 2 * unitLength * halfLengths[zIndex]);
0071 auto surface = detectorElement->surface().getSharedPtr();
0072
0073 return std::make_tuple(detectorElement, surface);
0074 }