File indexing completed on 2025-02-23 09:15:34
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 bool sensitive) const {
0029
0030 static constexpr double unitLength =
0031 Acts::UnitConstants::mm / GeoModelKernelUnits::millimeter;
0032
0033
0034 Transform3 transform = Transform3::Identity();
0035 transform.translation() = unitLength * absTransform.translation();
0036 auto rotation = absTransform.rotation();
0037
0038 std::vector<double> halfLengths = {geoBox.getXHalfLength(),
0039 geoBox.getYHalfLength(),
0040 geoBox.getZHalfLength()};
0041
0042 auto minElement = std::min_element(halfLengths.begin(), halfLengths.end());
0043 auto zIndex = std::distance(halfLengths.begin(), minElement);
0044 std::size_t yIndex = zIndex > 0u ? zIndex - 1u : 2u;
0045 std::size_t xIndex = yIndex > 0u ? yIndex - 1u : 2u;
0046
0047 Vector3 colX = rotation.col(xIndex);
0048 Vector3 colY = rotation.col(yIndex);
0049 Vector3 colZ = rotation.col(zIndex);
0050 rotation.col(0) = colX;
0051 rotation.col(1) = colY;
0052 rotation.col(2) = colZ;
0053 transform.linear() = rotation;
0054
0055
0056 double halfX = unitLength * halfLengths[xIndex];
0057 double halfY = unitLength * halfLengths[yIndex];
0058 auto rectangleBounds = std::make_shared<Acts::RectangleBounds>(halfX, halfY);
0059 if (!sensitive) {
0060 auto surface =
0061 Surface::makeShared<PlaneSurface>(transform, rectangleBounds);
0062 return std::make_tuple(nullptr, surface);
0063 }
0064
0065 auto detectorElement =
0066 GeoModelDetectorElement::createDetectorElement<PlaneSurface>(
0067 geoPV, rectangleBounds, transform,
0068 2 * unitLength * halfLengths[zIndex]);
0069 auto surface = detectorElement->surface().getSharedPtr();
0070
0071 return std::make_tuple(detectorElement, surface);
0072 }