ATLAS Offline Software
Loading...
Searching...
No Matches
GeometryIdMapping.h
Go to the documentation of this file.
1// Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2#ifndef ACTSTRKEVENT_GEOMETRYIDMAPPING_H
3#define ACTSTRKEVENT_GEOMETRYIDMAPPING_H
4
5#include "Identifier/Identifier.h"
6
7#include <cstddef>
8#include <cstdint>
9#include <optional>
10#include <unordered_map>
11
12namespace ActsTrk {
13
30
32 public:
33 using detray_id_type = std::uint64_t;
34 using acts_id_type = std::uint64_t;
35
36 GeometryIdMapping() = default;
37
39 void reserve(std::size_t nSurfaces) {
40 m_detrayToActs.reserve(nSurfaces);
41 m_detrayToAthena.reserve(nSurfaces);
42 m_actsToDetray.reserve(nSurfaces);
43 m_athenaToDetray.reserve(nSurfaces);
44 m_athenaToDetDescIndex.reserve(nSurfaces);
45 }
46
50 void addEntry(detray_id_type detrayId, acts_id_type actsId,
51 std::optional<Identifier> athenaId = std::nullopt) {
52
53
54 m_detrayToActs.emplace(detrayId,actsId);
55 m_actsToDetray.emplace(actsId, detrayId);
56
57 if (athenaId.has_value()) {
58 m_detrayToAthena.emplace(detrayId,athenaId->get_compact());
59 m_athenaToDetray.emplace(athenaId->get_compact(), detrayId);
60 }
61 }
62
63 void addDetDescIndex(detray_id_type detray_id, unsigned int index) {
64 m_detrayToDetDescIndex[detray_id] = index;
65 auto ath_opt = detrayToAthena(detray_id);
66 if (ath_opt.has_value()) {
67 m_athenaToDetDescIndex[ath_opt->get_compact()] = index;
68 }
69 }
70
73 std::optional<acts_id_type> detrayToActs(detray_id_type detrayId) const {
74 auto it = m_detrayToActs.find(detrayId);
75 return it == m_detrayToActs.end() ? std::nullopt
76 : std::optional{it->second};
77 }
78 std::optional<detray_id_type> actsToDetray(acts_id_type actsId) const {
79 auto it = m_actsToDetray.find(actsId);
80 return it == m_actsToDetray.end() ? std::nullopt
81 : std::optional{it->second};
82 }
83
84
87 std::optional<Identifier> detrayToAthena(detray_id_type detrayId) const {
88 auto it = m_detrayToAthena.find(detrayId);
89 if (it == m_detrayToAthena.end()) return std::nullopt;
90 return Identifier(it->second);
91 }
92 std::optional<detray_id_type> athenaToDetray(const Identifier& athenaId) const {
93 auto it = m_athenaToDetray.find(athenaId.get_compact());
94 return it == m_athenaToDetray.end() ? std::nullopt
95 : std::optional{it->second};
96 }
97
98
99 std::optional<Identifier> actsToAthena(acts_id_type actsId) const {
100 auto d = actsToDetray(actsId);
101 return d ? detrayToAthena(*d) : std::nullopt;
102 }
103 std::optional<acts_id_type> athenaToActs(const Identifier& athenaId) const {
104 auto d = athenaToDetray(athenaId);
105 return d ? detrayToActs(*d) : std::nullopt;
106 }
107 std::optional<size_t> detrayToDetDescIndex(detray_id_type detray_id) const {
108 auto it = m_detrayToDetDescIndex.find(detray_id);
109 return it == m_detrayToDetDescIndex.end() ? std::nullopt : std::optional(it->second);
110 }
111 std::optional<size_t> athenaToDetDescIndex(const Identifier& athenaId) const {
112 auto it = m_athenaToDetDescIndex.find(athenaId.get_compact());
113 return it == m_athenaToDetDescIndex.end() ? std::nullopt : std::optional(it->second);
114 }
115
116 std::size_t size() const { return m_detrayToActs.size(); }
117 const std::unordered_map<detray_id_type, Identifier::value_type>&
119
120 private:
121 std::unordered_map<detray_id_type, acts_id_type> m_detrayToActs;
122 std::unordered_map<detray_id_type, Identifier::value_type> m_detrayToAthena;
123
124 std::unordered_map<acts_id_type, detray_id_type> m_actsToDetray;
125 std::unordered_map<Identifier::value_type, detray_id_type> m_athenaToDetray;
126 std::unordered_map<detray_id_type, size_t> m_detrayToDetDescIndex;
127 std::unordered_map<Identifier::value_type, detray_id_type> m_athenaToDetDescIndex;
128};
129
130} // namespace ActsTrk
131
132// Needed to record/retrieve this via StoreGate
134
136
137#endif // ACTSTRKEVENT_GEOMETRYIDMAPPING_H
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Lookup table between the three surface-identifier "worlds" used across the ACTS / Detray / Athena tra...
std::unordered_map< acts_id_type, detray_id_type > m_actsToDetray
std::optional< acts_id_type > detrayToActs(detray_id_type detrayId) const
std::unordered_map< detray_id_type, Identifier::value_type > m_detrayToAthena
std::optional< size_t > athenaToDetDescIndex(const Identifier &athenaId) const
std::unordered_map< detray_id_type, size_t > m_detrayToDetDescIndex
const std::unordered_map< detray_id_type, Identifier::value_type > & detrayToAthenaMap() const
std::optional< detray_id_type > actsToDetray(acts_id_type actsId) const
std::optional< acts_id_type > athenaToActs(const Identifier &athenaId) const
std::unordered_map< detray_id_type, acts_id_type > m_detrayToActs
std::optional< Identifier > detrayToAthena(detray_id_type detrayId) const
std::optional< Identifier > actsToAthena(acts_id_type actsId) const
std::optional< size_t > detrayToDetDescIndex(detray_id_type detray_id) const
std::unordered_map< Identifier::value_type, detray_id_type > m_athenaToDetDescIndex
void addDetDescIndex(detray_id_type detray_id, unsigned int index)
std::optional< detray_id_type > athenaToDetray(const Identifier &athenaId) const
std::unordered_map< Identifier::value_type, detray_id_type > m_athenaToDetray
void reserve(std::size_t nSurfaces)
Reserve storage for nSurfaces detray surfaces.
void addEntry(detray_id_type detrayId, acts_id_type actsId, std::optional< Identifier > athenaId=std::nullopt)
Register one detray surface, it has to have a corresponding ACTS surface athenaId is optional,...
value_type get_compact() const
Get the compact id.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition index.py:1