File indexing completed on 2025-07-03 07:53:14
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Plugins/GeoModel/detail/GeoBoxConverter.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/PlaneSurface.hpp"
0015 #include "Acts/Surfaces/RectangleBounds.hpp"
0016 #include "Acts/Surfaces/Surface.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 Acts::Result<Acts::GeoModelSensitiveSurface>
0025 Acts::detail::GeoBoxConverter::operator()(const PVConstLink& geoPV,
0026 const GeoBox& geoBox,
0027 const Transform3& absTransform,
0028 SurfaceBoundFactory& boundFactory,
0029 bool sensitive) const {
0030
0031 static constexpr double unitLength =
0032 Acts::UnitConstants::mm / GeoModelKernelUnits::millimeter;
0033
0034
0035 Transform3 transform = Transform3::Identity();
0036 transform.translation() = unitLength * absTransform.translation();
0037 auto rotation = absTransform.rotation();
0038
0039 std::vector<double> halfLengths = {geoBox.getXHalfLength(),
0040 geoBox.getYHalfLength(),
0041 geoBox.getZHalfLength()};
0042
0043 auto minElement = std::min_element(halfLengths.begin(), halfLengths.end());
0044 auto zIndex = std::distance(halfLengths.begin(), minElement);
0045 std::size_t yIndex = zIndex > 0u ? zIndex - 1u : 2u;
0046 std::size_t xIndex = yIndex > 0u ? yIndex - 1u : 2u;
0047
0048 Vector3 colX = rotation.col(xIndex);
0049 Vector3 colY = rotation.col(yIndex);
0050 Vector3 colZ = rotation.col(zIndex);
0051 rotation.col(0) = colX;
0052 rotation.col(1) = colY;
0053 rotation.col(2) = colZ;
0054 transform.linear() = rotation;
0055
0056
0057 double halfX = unitLength * halfLengths[xIndex];
0058 double halfY = unitLength * halfLengths[yIndex];
0059 auto rectangleBounds =
0060 boundFactory.makeBounds<Acts::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 }