File indexing completed on 2025-01-18 09:10:45
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Common.hpp"
0013 #include "Acts/Detector/DetectorComponents.hpp"
0014 #include "Acts/Detector/Portal.hpp"
0015 #include "Acts/Geometry/CylinderVolumeBounds.hpp"
0016 #include "Acts/Geometry/GeometryContext.hpp"
0017 #include "Acts/Geometry/VolumeBounds.hpp"
0018 #include "Acts/Utilities/Logger.hpp"
0019
0020 #include <array>
0021 #include <limits>
0022 #include <map>
0023 #include <memory>
0024 #include <vector>
0025
0026 namespace Acts::Experimental {
0027
0028 class DetectorVolume;
0029 class Portal;
0030
0031 namespace detail::CylindricalDetectorHelper {
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 DetectorComponent::PortalContainer connectInR(
0045 const GeometryContext& gctx,
0046 std::vector<std::shared_ptr<DetectorVolume>>& volumes,
0047 const std::vector<unsigned int>& selectedOnly = {},
0048 Acts::Logging::Level logLevel = Acts::Logging::INFO);
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061 DetectorComponent::PortalContainer connectInZ(
0062 const GeometryContext& gctx,
0063 std::vector<std::shared_ptr<DetectorVolume>>& volumes,
0064 const std::vector<unsigned int>& selectedOnly = {},
0065 Acts::Logging::Level logLevel = Acts::Logging::INFO);
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078 DetectorComponent::PortalContainer connectInPhi(
0079 const GeometryContext& gctx,
0080 std::vector<std::shared_ptr<DetectorVolume>>& volumes,
0081 const std::vector<unsigned int>& selectedOnly = {},
0082 Acts::Logging::Level logLevel = Acts::Logging::INFO);
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094 DetectorComponent::PortalContainer wrapInZR(
0095 const GeometryContext& gctx,
0096 std::vector<std::shared_ptr<DetectorVolume>>& volumes,
0097 Acts::Logging::Level logLevel = Acts::Logging::INFO);
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110 DetectorComponent::PortalContainer connectInR(
0111 const GeometryContext& gctx,
0112 const std::vector<DetectorComponent::PortalContainer>& containers,
0113 const std::vector<unsigned int>& selectedOnly = {},
0114 Acts::Logging::Level logLevel = Acts::Logging::INFO);
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127 DetectorComponent::PortalContainer connectInZ(
0128 const GeometryContext& gctx,
0129 const std::vector<DetectorComponent::PortalContainer>& containers,
0130 const std::vector<unsigned int>& selectedOnly = {},
0131 Acts::Logging::Level logLevel = Acts::Logging::INFO);
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144 DetectorComponent::PortalContainer connectInPhi(
0145 const GeometryContext& gctx,
0146 const std::vector<DetectorComponent::PortalContainer>& containers,
0147 const std::vector<unsigned int>& selectedOnly = {},
0148 Acts::Logging::Level logLevel = Acts::Logging::INFO);
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160 DetectorComponent::PortalContainer wrapInZR(
0161 const GeometryContext& gctx,
0162 const std::vector<DetectorComponent::PortalContainer>& containers,
0163 Acts::Logging::Level logLevel = Acts::Logging::INFO);
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176 template <typename volume_container_t>
0177 std::array<std::vector<double>, 3u> rzphiBoundaries(
0178 const GeometryContext& gctx, const volume_container_t& volumes,
0179 double precision = 0.,
0180 Acts::Logging::Level logLevel = Acts::Logging::INFO) {
0181
0182 ACTS_LOCAL_LOGGER(getDefaultLogger("CylindricalDetectorHelper", logLevel));
0183
0184 ACTS_DEBUG("Estimate R/z/phi boundaries of " << volumes.size()
0185 << " volumes.");
0186
0187
0188 std::array<std::set<double>, 3u> uniqueBoundaries;
0189 auto insertWithPrecision = [&](std::size_t is, double value) -> void {
0190 if (precision == 0.) {
0191 uniqueBoundaries[is].insert(value);
0192 return;
0193 }
0194 uniqueBoundaries[is].insert(std::round(value / precision) * precision);
0195 };
0196
0197
0198 for (const auto& v : volumes) {
0199 if (v->volumeBounds().type() == VolumeBounds::BoundsType::eCylinder) {
0200 const auto& bValues = v->volumeBounds().values();
0201
0202 double rMin = bValues[CylinderVolumeBounds::BoundValues::eMinR];
0203 double rMax = bValues[CylinderVolumeBounds::BoundValues::eMaxR];
0204 double zCenter = v->transform(gctx).translation().z();
0205 double zHalfLength =
0206 bValues[CylinderVolumeBounds::BoundValues::eHalfLengthZ];
0207 double zMin = zCenter - zHalfLength;
0208 double zMax = zCenter + zHalfLength;
0209 double phiCenter =
0210 bValues[CylinderVolumeBounds::BoundValues::eAveragePhi];
0211 double phiSector =
0212 bValues[CylinderVolumeBounds::BoundValues::eHalfPhiSector];
0213 double phiMin = phiCenter - phiSector;
0214 double phiMax = phiCenter + phiSector;
0215
0216 insertWithPrecision(0u, rMin);
0217 insertWithPrecision(0u, rMax);
0218 insertWithPrecision(1u, zMin);
0219 insertWithPrecision(1u, zMax);
0220 insertWithPrecision(2u, phiMin);
0221 insertWithPrecision(2u, phiMax);
0222 }
0223 }
0224
0225 ACTS_VERBOSE("- did yield " << uniqueBoundaries[0u].size()
0226 << " boundaries in R.");
0227 ACTS_VERBOSE("- did yield " << uniqueBoundaries[1u].size()
0228 << " boundaries in z.");
0229 ACTS_VERBOSE("- did yield " << uniqueBoundaries[2u].size()
0230 << " boundaries in phi.");
0231
0232 return {{std::vector<double>(uniqueBoundaries[0].begin(),
0233 uniqueBoundaries[0].end()),
0234 std::vector<double>(uniqueBoundaries[1].begin(),
0235 uniqueBoundaries[1].end()),
0236 std::vector<double>(uniqueBoundaries[2].begin(),
0237 uniqueBoundaries[2].end())}};
0238 }
0239
0240 }
0241 }