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 <cstdint>
8#include <limits>
9#include <optional>
10#include <unordered_map>
11#include <vector>
12
13namespace ActsTrk {
14
31
33 public:
34 using detray_id_type = std::uint64_t;
35 using acts_id_type = std::uint64_t;
36
37 GeometryIdMapping() = default;
38
40 void reserve(std::size_t nSurfaces) {
41 m_detrayToActs.reserve(nSurfaces);
42 m_detrayToAthena.reserve(nSurfaces);
43 m_actsToDetray.reserve(nSurfaces);
44 m_athenaToDetray.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
65 std::optional<acts_id_type> detrayToActs(detray_id_type detrayId) const {
66 auto it = m_detrayToActs.find(detrayId);
67 return it == m_detrayToActs.end() ? std::nullopt
68 : std::optional{it->second};
69 }
70 std::optional<detray_id_type> actsToDetray(acts_id_type actsId) const {
71 auto it = m_actsToDetray.find(actsId);
72 return it == m_actsToDetray.end() ? std::nullopt
73 : std::optional{it->second};
74 }
75
76
79 std::optional<Identifier> detrayToAthena(detray_id_type detrayId) const {
80 auto it = m_detrayToAthena.find(detrayId);
81 if (it == m_detrayToAthena.end()) return std::nullopt;
82 return Identifier(it->second);
83 }
84 std::optional<detray_id_type> athenaToDetray(const Identifier& athenaId) const {
85 auto it = m_athenaToDetray.find(athenaId.get_compact());
86 return it == m_athenaToDetray.end() ? std::nullopt
87 : std::optional{it->second};
88 }
89
90
91 std::optional<Identifier> actsToAthena(acts_id_type actsId) const {
92 auto d = actsToDetray(actsId);
93 return d ? detrayToAthena(*d) : std::nullopt;
94 }
95 std::optional<acts_id_type> athenaToActs(const Identifier& athenaId) const {
96 auto d = athenaToDetray(athenaId);
97 return d ? detrayToActs(*d) : std::nullopt;
98 }
99
100 std::size_t size() const { return m_detrayToActs.size(); }
101 const std::unordered_map<detray_id_type, Identifier::value_type>&
103
104 private:
105 std::unordered_map<detray_id_type, acts_id_type> m_detrayToActs;
106 std::unordered_map<detray_id_type, Identifier::value_type> m_detrayToAthena;
107
108 std::unordered_map<acts_id_type, detray_id_type> m_actsToDetray;
109 std::unordered_map<Identifier::value_type, detray_id_type> m_athenaToDetray;
110};
111
112} // namespace ActsTrk
113
114// Needed to record/retrieve this via StoreGate
116
118
119#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
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< 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...