File indexing completed on 2026-11-20 09:27:58
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsPlugins/Detray/DetraySurfaceIdMap.hpp"
0010
0011 #include <format>
0012 #include <stdexcept>
0013
0014 namespace ActsPlugins {
0015
0016 DetraySurfaceIdMap::DetraySurfaceIdMap(std::span<const Entry> entries) {
0017 m_fromDetray.reserve(entries.size());
0018 m_toDetray.reserve(entries.size());
0019 for (const auto& [detrayId, surface] : entries) {
0020 if (surface == nullptr) {
0021 throw std::invalid_argument(
0022 std::format("DetraySurfaceIdMap: null surface for detray id {}",
0023 detrayId.value()));
0024 }
0025 const Acts::GeometryIdentifier id = surface->geometryId();
0026 if (m_fromDetray.contains(detrayId) || m_toDetray.contains(id)) {
0027 throw std::invalid_argument(
0028 std::format("DetraySurfaceIdMap: duplicate surface (detray id {}, "
0029 "ACTS id {})",
0030 detrayId.value(), id));
0031 }
0032 m_fromDetray.emplace(detrayId, surface);
0033 m_toDetray.emplace(id, detrayId);
0034 }
0035 }
0036
0037 std::optional<detray::geometry::identifier> DetraySurfaceIdMap::toDetray(
0038 Acts::GeometryIdentifier id) const {
0039 auto it = m_toDetray.find(id);
0040 if (it == m_toDetray.end()) {
0041 return std::nullopt;
0042 }
0043 return it->second;
0044 }
0045
0046 std::optional<Acts::GeometryIdentifier> DetraySurfaceIdMap::fromDetray(
0047 detray::geometry::identifier detrayId) const {
0048 const Acts::Surface* actsSurface = surface(detrayId);
0049 if (actsSurface == nullptr) {
0050 return std::nullopt;
0051 }
0052 return actsSurface->geometryId();
0053 }
0054
0055 const Acts::Surface* DetraySurfaceIdMap::surface(
0056 detray::geometry::identifier detrayId) const {
0057 auto it = m_fromDetray.find(detrayId);
0058 return it == m_fromDetray.end() ? nullptr : it->second;
0059 }
0060
0061 }