ATLAS Offline Software
Loading...
Searching...
No Matches
ITkPixelCablingData.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef ITkPixelCablingData_h
5#define ITkPixelCablingData_h
12
14
15// Athena includes
16#include "Identifier/Identifier.h"
19//STL
20#include <unordered_map>
21#include <iosfwd>
22
23namespace ITkPixelCabling {
24
25 //types of modules we have
33
34 //types of coordinate transformations
35 //kept separate from the chip types
36 //in case per-module specifics are
37 //needed
44
45 //We need to know what module type
46 //we're dealing with from the readout
47 //PoV, so that we can translate accordingly.
48 template <class ID>
54
55 //define transforms, assuming
56 // Y | 2 | 3 |
57 // | 0 | 1 |
58 // X
59 //to be confirmed and revisited
60
61 using TransformFn = void(*)(uint16_t&, uint16_t&);
62
63 //LUT for quad translation functions indexed by chip ID
64 //The RD53C/ITkPixV2 chip dimensions are 400 columns, 384 rows,
65 //indexing starts at 0, hence the possible values of col in [0, 399]
66 //and row in [0, 383]. A quad is 2x2 chips, hence the total dimensions
67 //of 800 columns and 768 rows, again indexed from 0, i. e. col in [0, 799]
68 //and row in [0, 767].
69 static constexpr TransformFn nominalQuadTable[4] = {
70 []([[maybe_unused]] uint16_t& col, uint16_t& row){row = 383 - row;},
71 []([[maybe_unused]] uint16_t& col, uint16_t& row){row = 383 - row; col += 400;},
72 []([[maybe_unused]] uint16_t& col, uint16_t& row){row = 767 - row;},
73 []([[maybe_unused]] uint16_t& col, uint16_t& row){row = 767 - row; col += 400;}
74 };
75
76 static constexpr TransformFn ibTransformFn =
77 [](uint16_t& col, uint16_t& row){
78 row = 2 * (383 - row) + (col & 1);
79 col >>= 1;
80 };
81
82 static constexpr TransformFn iecTransformFn =
83 [](uint16_t& col, uint16_t& row) {
84 std::swap(col, row);
85 };
86
87 static inline void chipToModuleTransform(const TransformType& transform, const uint8_t& chipID, uint16_t& col, uint16_t& row){
88 switch (transform){
90 nominalQuadTable[chipID](col, row);
91 break;
93 ibTransformFn(col, row);
94 break;
96 iecTransformFn(col, row);
97 break;
99 break;
100 }
101 }
102
103}
104
106public:
108 friend std::istream& operator>>(std::istream & is, ITkPixelCablingData & cabling);
110 friend std::ostream& operator<<(std::ostream & os, const ITkPixelCablingData & cabling);
111 bool empty() const;
112 std::size_t size() const;
113 ITkPixelOnlineId onlineId(const Identifier & id) const;
115
118
119 //Add entry to the offline->online map. This is only for producing test streams,
120 //from MC, and needs to propagate the type of the module. We also can at most map
121 //with 4-fold degeneracy due to non-merged quads, which have 4 online IDs mapped to
122 //a single offline ID.
123 void addEntryOffOn(const Identifier& idOff, const ITkPixelOnlineId& idOn);
124 void addEntryOffOn(const Identifier& idOff, const ITkPixelCabling::ModuleInfo<ITkPixelOnlineId>& moduleInfo);
125
126 //Add entry to the online->offline map. This is for decoding. For quick access,
127 //these maps can also cache the type of the module, so that we know how to translate
128 //the hit coordinates from chip to module
129 void addEntryOnOff(const ITkPixelOnlineId& idOn, const Identifier& idOff);
131
132 void print() const;
133
134 //Add entries to the
135
136private:
137 //offline->online base map
138 std::unordered_map<Identifier, ITkPixelOnlineId> m_offline2OnlineMap;
139
140 //offline->online base map with info on module type
141 std::unordered_map<Identifier, ITkPixelCabling::ModuleInfo<ITkPixelOnlineId>> m_offline2ModuleInfoMap;
142
143 //simple online->offline map
144 std::unordered_map<ITkPixelOnlineId, Identifier> m_online2OfflineMap;
145
146 //online->offline map with info on module type
147 std::unordered_map<ITkPixelOnlineId, ITkPixelCabling::ModuleInfo<Identifier>> m_online2ModuleInfoMap;
148
149 //online base -> module type
150 std::unordered_map<ITkPixelOnlineId, ITkPixelCabling::ModuleType> m_online2ModuleType;
151
152 //offline -> module type
153 std::unordered_map<Identifier, ITkPixelCabling::ModuleType> m_offline2ModuleType;
154
155};
156// Magic "CLassID" for storage/retrieval in StoreGate
157// These values produced using clid script.
158// "clid ITkPixelCablingData"
159// 140860927 ITkPixelCablingData
161//"clid -cs ITkPixelCablingData"
162//143807283
164#endif
std::vector< Identifier > ID
Hold mappings of ranges to condition objects.
#define CONDCONT_DEF(...)
Definition CondCont.h:1413
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
ITkPixelOnlineId onlineId(const Identifier &id) const
ITkPixelCabling::ModuleInfo< ITkPixelOnlineId > onlineModuleInfo(const Identifier &id) const
Identifier offlineId(const ITkPixelOnlineId &id) const
std::unordered_map< ITkPixelOnlineId, ITkPixelCabling::ModuleInfo< Identifier > > m_online2ModuleInfoMap
void addEntryOnOff(const ITkPixelOnlineId &idOn, const Identifier &idOff)
std::size_t size() const
std::unordered_map< Identifier, ITkPixelOnlineId > m_offline2OnlineMap
std::unordered_map< Identifier, ITkPixelCabling::ModuleInfo< ITkPixelOnlineId > > m_offline2ModuleInfoMap
friend std::ostream & operator<<(std::ostream &os, const ITkPixelCablingData &cabling)
stream insertion for debugging
std::unordered_map< Identifier, ITkPixelCabling::ModuleType > m_offline2ModuleType
std::unordered_map< ITkPixelOnlineId, Identifier > m_online2OfflineMap
std::unordered_map< ITkPixelOnlineId, ITkPixelCabling::ModuleType > m_online2ModuleType
ITkPixelCabling::ModuleInfo< Identifier > offlineModuleInfo(const ITkPixelOnlineId &id) const
friend std::istream & operator>>(std::istream &is, ITkPixelCablingData &cabling)
stream extraction to read value from stream into ITkPixelCablingData
void addEntryOffOn(const Identifier &idOff, const ITkPixelOnlineId &idOn)
static constexpr TransformFn nominalQuadTable[4]
static constexpr TransformFn ibTransformFn
static constexpr TransformFn iecTransformFn
static void chipToModuleTransform(const TransformType &transform, const uint8_t &chipID, uint16_t &col, uint16_t &row)
void(*)(uint16_t &, uint16_t &) TransformFn
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)