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 }
45
49 void addEntry(detray_id_type detrayId, acts_id_type actsId,
50 std::optional<Identifier> athenaId = std::nullopt) {
51
52
53 m_detrayToActs.emplace(detrayId,actsId);
54 m_actsToDetray.emplace(actsId, detrayId);
55
56 if (athenaId.has_value()) {
57 m_detrayToAthena.emplace(detrayId,athenaId->get_compact());
58 m_athenaToDetray.emplace(athenaId->get_compact(), detrayId);
59 }
60 }
61
62 void addDetDescIndex(detray_id_type detray_id, unsigned int index) {
63 m_detrayToDetDescIndex[detray_id] = index;
64 }
65
68 std::optional<acts_id_type> detrayToActs(detray_id_type detrayId) const {
69 auto it = m_detrayToActs.find(detrayId);
70 return it == m_detrayToActs.end() ? std::nullopt
71 : std::optional{it->second};
72 }
73 std::optional<detray_id_type> actsToDetray(acts_id_type actsId) const {
74 auto it = m_actsToDetray.find(actsId);
75 return it == m_actsToDetray.end() ? std::nullopt
76 : std::optional{it->second};
77 }
78
79
82 std::optional<Identifier> detrayToAthena(detray_id_type detrayId) const {
83 auto it = m_detrayToAthena.find(detrayId);
84 if (it == m_detrayToAthena.end()) return std::nullopt;
85 return Identifier(it->second);
86 }
87 std::optional<detray_id_type> athenaToDetray(const Identifier& athenaId) const {
88 auto it = m_athenaToDetray.find(athenaId.get_compact());
89 return it == m_athenaToDetray.end() ? std::nullopt
90 : std::optional{it->second};
91 }
92
93
94 std::optional<Identifier> actsToAthena(acts_id_type actsId) const {
95 auto d = actsToDetray(actsId);
96 return d ? detrayToAthena(*d) : std::nullopt;
97 }
98 std::optional<acts_id_type> athenaToActs(const Identifier& athenaId) const {
99 auto d = athenaToDetray(athenaId);
100 return d ? detrayToActs(*d) : std::nullopt;
101 }
102
103 std::size_t size() const { return m_detrayToActs.size(); }
104 const std::unordered_map<detray_id_type, Identifier::value_type>&
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
112 private:
113 std::unordered_map<detray_id_type, acts_id_type> m_detrayToActs;
114 std::unordered_map<detray_id_type, Identifier::value_type> m_detrayToAthena;
115
116 std::unordered_map<acts_id_type, detray_id_type> m_actsToDetray;
117 std::unordered_map<Identifier::value_type, detray_id_type> m_athenaToDetray;
118
119 std::unordered_map<detray_id_type, size_t> m_detrayToDetDescIndex;
120};
121
122} // namespace ActsTrk
123
124// Needed to record/retrieve this via StoreGate
126
128
129#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::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
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