ATLAS Offline Software
Loading...
Searching...
No Matches
ITkPixelDecodingPhaseIIRDOAlg.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ITKPIXEL_DECODINGPHASEIIRDOALG_H
6#define ITKPIXEL_DECODINGPHASEIIRDOALG_H
7
14
17#include "GaudiKernel/MsgStream.h"
21#include "Identifier/Identifier.h"
26#include "itksw/pix/endec/DecCore.hpp"
27#include <chrono>
28#include <limits>
29#include <cstdint> //for uint8_t etc.
30
39
40
42{
43 public:
44
45 ITkPixelDecodingPhaseIIRDOAlg(const std::string &name, ISvcLocator *pSvcLocator);
46
47 virtual StatusCode initialize() override;
48
49 virtual StatusCode execute (const EventContext& ctx) const override;
50
51 virtual StatusCode finalize() override;
52
53
54 private:
55
56 typedef std::vector< std::vector<uint32_t >> ITkPacketCollection;
57
59 { this, "ROBDataProvider", "ROBDataProviderSvc" };
60
62 {this, "PixelCablingKey", "ITkPixelCablingData", "Cond Key of Pixel Cabling"};
63
65 {this, "pixelRDOKey", "PixelRDOs", "StoreGate Key of Pixel RDOs"};
66
67 std::vector<uint32_t> m_sourceIDs;
68
70
71 const Gaudi::Property<uint32_t> m_n_rdos_est {this, "nRDOs", 1300000, "Estimated number of RDOs per event"};
72
73};
74
76 struct ScopedTimer {
77 std::string m_label;
78 std::chrono::time_point<std::chrono::high_resolution_clock> m_start;
79 MsgStream& m_msg_source;
80
81 ScopedTimer(std::string lbl, MsgStream& src) : m_label(std::move(lbl)), m_start(std::chrono::high_resolution_clock::now()), m_msg_source(src) {}
83 auto end = std::chrono::high_resolution_clock::now();
84 auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(end - m_start).count();
85 m_msg_source << MSG::DEBUG << m_label << " took " << ms << " ms" << endmsg;
86 }
87
88 };
89}
90
92 //Forms pixel RDOs from the decoded hits & fills them into a container
94
95 public:
97 PhaseIIPixelRawDataContainerMT::ContainerPtr rdo_container_dest, const PixelID* idHelper) :
98 m_rdo_container_dest(rdo_container_dest),
99 m_cont_coll(cont_coll),
100 m_dest_range_guard(rdo_container_dest),
102 m_idHelper(idHelper)
103 {};
104
106
107 //Obligatory members for the interface
118
119 inline void evt_next([[maybe_unused]] uint8_t tag) {};
120
121 inline void evt_done() {
122 };
123
124 inline void add_hit(uint16_t col, uint16_t row, uint16_t tot){
125 //Translate the col, row into module coordinates
126 // after that, row and col are phi_index and eta_index, respectively
128
129 //Set dummy values at 0 for these:
130 int bcid = 0;
131 int lvl0a = 0;
132 int lvl0d = 0;
133
136 std::array<std::int16_t,2>{static_cast<std::int16_t>(row), static_cast<std::int16_t>(col)},
137 PhaseII::PixelRawDataContainer::makeWord( tot, bcid, lvl0a, lvl0d ));
138 };
139
140 inline void add_hmap([[maybe_unused]] uint8_t qcol,
141 [[maybe_unused]] uint8_t qrow,
142 [[maybe_unused]] uint16_t hmap,
143 [[maybe_unused]] uint64_t tots)
144 {};
145
146 inline void add_qcore([[maybe_unused]] uint8_t qcol,
147 [[maybe_unused]] uint8_t qrow,
148 [[maybe_unused]] uint64_t qtot)
149 {};
150
151 inline uint8_t on_error([[maybe_unused]] itksw::pix::endec::intf::EventError error) {return 0;};
152 //end of interface-mandated methods
153
154 inline void registerLastModule() {
155 if (!m_dest_range_guard.empty()) {
156 // register the RDO range for this module, or erase the newly added
157 if (!m_cont_coll->registerOrEraseNewData(m_currentIdentifierHash,m_dest_range_guard.range())) {
159 }
160 // in the process of adding hits to the original container, its capacity may have
161 // been exceeded and the container may have been changed for the current module. To
162 // ensure that the same container is used for the next module get the container, that
163 // contains the hits for the current module from the the range_guard.
165 m_n_rdos += m_dest_range_guard.range().size();
166 }
167 }
168
169 //this is needed to properly identify the module.
170 inline void setOfflineID(const uint32_t& offlineID){
171 m_offlineID = offlineID;
172 };
173
174 //this is needed to properly translate hits on a quad
175 inline void setChipID(const uint8_t& chipID){
176 m_chipID = chipID;
177 }
178
179 //translate
181 m_transform = transform;
182 }
183
184
185 private:
186
187 // the RDO (=hits) container
189
190 // the collection of RDO containers
192
193 // RDO container range guard
195
196 // current offline ID hash
197 unsigned int m_currentIdentifierHash{std::numeric_limits<unsigned int>::max()};
198
199 // statistics
200 unsigned int m_n_rejected_work{};
201
202 // module offline ID as defined in InnerDetector/InDetDetDescr/InDetIdentifier/InDetIdentifier/PixelID.h
203 uint32_t m_offlineID = 0;
204
205 // front-end chip ID, from 0 to 4 for merged quads, 0 otherwise
206 uint8_t m_chipID = 0;
207
208 // RDO counter
209 uint32_t m_n_rdos = 0;
210
211 //offline identifier
213
214 //transform type for cabling package
216
217 // Identifier helper
219 };
220
221 //This prints the decoded hits on the screen,
222 //useful for testing purposes
224 public:
225 TestEventCallback(MsgStream& src): m_msg_source(src) {};
227
228 inline void evt_init(uint8_t tag) {
229 m_msg_source << MSG::DEBUG << "evt_init(" << tag << ")" << std::endl;
230 }
231
232 inline void evt_next(uint8_t tag) {
233 m_msg_source << MSG::DEBUG << "evt_next(" << tag << ")" << std::endl;
234 }
235
236 inline void evt_done() {
237 m_msg_source << MSG::DEBUG << "evt_done()" << std::endl;
238 }
239
240 inline void add_hit(uint16_t col, uint16_t row, uint16_t tot) {
241 m_msg_source << MSG::DEBUG << "add_hit(" << col << "," << row << "," << tot << ")" << std::endl;
242 }
243
244 inline void add_hmap(uint8_t qcol, uint8_t qrow, uint16_t hmap, uint64_t tots) {
245 m_msg_source << MSG::DEBUG << "add_hmap(qcol=" << qcol << ",qrow=" << qrow
246 << ",hmap=" << hmap << ",tots=" << tots << ")" << std::endl;
247 }
248
249 inline void add_qcore(uint8_t qcol, uint8_t qrow, uint64_t qtot) {
250 m_msg_source << MSG::DEBUG << "add_qcore(qcol=" << qcol << ",qrow=" << qrow
251 << ",qtot=" << qtot << ")" << std::endl;
252 }
253
254 inline uint8_t on_error(itksw::pix::endec::intf::EventError error) {
255 m_msg_source << MSG::DEBUG << "on_error(" << error.code << ")" << std::endl;
256 return 0;
257 }
258
259 MsgStream& m_msg_source;
260
261 };
262}
263
264
265#endif
266
#define endmsg
PhaseII::IndexedRangesMT< PhaseII::PixelRawDataContainer > PhaseIIPixelRawDataContainerMT
A container derived from PhaseIIPixelRawDataContainer which extends the container by a dynamic contai...
This is an Identifier helper class for the Pixel subdetector.
Property holding a SG store/key/clid from which a ReadHandle is made.
An algorithm that can be simultaneously executed in multiple threads.
ServiceHandle< IROBDataProviderSvc > m_robDataProviderSvc
SG::WriteHandleKey< PhaseIIPixelRawDataContainer > m_pixelRDOKey
SG::ReadCondHandleKey< ITkPixelCablingData > m_pixelCablingKey
std::vector< std::vector< uint32_t > > ITkPacketCollection
virtual StatusCode execute(const EventContext &ctx) const override
const Gaudi::Property< uint32_t > m_n_rdos_est
ITkPixelDecodingPhaseIIRDOAlg(const std::string &name, ISvcLocator *pSvcLocator)
Helper class to keep track of a range of elements added to the end of a container.
typename DynamicContainerListHelper< PhaseII::PixelRawDataContainer >::ContainerPtr ContainerPtr
static std::uint32_t makeWord(int tot, int bcid, int lvl1a, int lvl1d)
uint8_t on_error(itksw::pix::endec::intf::EventError error)
void add_hmap(uint8_t qcol, uint8_t qrow, uint16_t hmap, uint64_t tots)
void add_qcore(uint8_t qcol, uint8_t qrow, uint64_t qtot)
PhaseIIPixelRawDataContainerMT::ContainerPtr m_rdo_container_dest
void setTransformType(const ITkPixelCabling::TransformType &transform)
void add_hit(uint16_t col, uint16_t row, uint16_t tot)
PhaseII::ContainerRangeGuard< PhaseII::DataRange, PhaseIIPixelRawDataContainerMT::ContainerPtr > m_dest_range_guard
PhaseIIRDOCallback(PhaseIIPixelRawDataContainerMT *cont_coll, PhaseIIPixelRawDataContainerMT::ContainerPtr rdo_container_dest, const PixelID *idHelper)
void add_hmap(uint8_t qcol, uint8_t qrow, uint16_t hmap, uint64_t tots)
void add_qcore(uint8_t qcol, uint8_t qrow, uint64_t qtot)
void add_hit(uint16_t col, uint16_t row, uint16_t tot)
uint8_t on_error(itksw::pix::endec::intf::EventError error)
This is an Identifier helper class for the Pixel subdetector.
Definition PixelID.h:69
Property holding a SG store/key/clid from which a WriteHandle is made.
static void chipToModuleTransform(const TransformType &transform, const uint8_t &chipID, uint16_t &col, uint16_t &row)
void addDataForModule(T_RawDataContainerCollection &rdo_container_collection, ContainerRangeGuard< T_RawDataContainerPtr, T_RangeType > &range_guard, T_Coordinates &&coordinates, std::uint32_t data_word)
convenience method to add data to an RDO container, add a new RDO container, copy the data added for ...
STL namespace.
std::chrono::time_point< std::chrono::high_resolution_clock > m_start