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
8
11#include "GaudiKernel/MsgStream.h"
15#include "Identifier/Identifier.h"
20#include "itksw/pix/endec/DecCore.hpp"
21#include <chrono>
22#include <limits>
23#include <cstdint> //for uint8_t etc.
24
33
34
36{
37 public:
38
39 ITkPixelDecodingPhaseIIRDOAlg(const std::string &name, ISvcLocator *pSvcLocator);
40
41 virtual StatusCode initialize() override;
42
43 virtual StatusCode execute (const EventContext& ctx) const override;
44
45 virtual StatusCode finalize() override;
46
47
48 private:
49
50 typedef std::vector< std::vector<uint32_t >> ITkPacketCollection;
51
53 { this, "ROBDataProvider", "ROBDataProviderSvc" };
54
56 {this, "PixelCablingKey", "ITkPixelCablingData", "Cond Key of Pixel Cabling"};
57
59 {this, "pixelRDOKey", "PixelRDOs", "StoreGate Key of Pixel RDOs"};
60
61 std::vector<uint32_t> m_sourceIDs;
62
64
65 const Gaudi::Property<uint32_t> m_n_rdos_est {this, "nRDOs", 1300000, "Estimated number of RDOs per event"};
66
67};
68
70 struct ScopedTimer {
71 std::string m_label;
72 std::chrono::time_point<std::chrono::high_resolution_clock> m_start;
73 MsgStream& m_msg_source;
74
75 ScopedTimer(std::string lbl, MsgStream& src) : m_label(std::move(lbl)), m_start(std::chrono::high_resolution_clock::now()), m_msg_source(src) {}
77 auto end = std::chrono::high_resolution_clock::now();
78 auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(end - m_start).count();
79 m_msg_source << MSG::DEBUG << m_label << " took " << ms << " ms" << endmsg;
80 }
81
82 };
83}
84
86 //Forms pixel RDOs from the decoded hits & fills them into a container
88
89 public:
91 PhaseIIPixelRawDataContainerMT::ContainerPtr rdo_container_dest, const PixelID* idHelper) :
92 m_rdo_container_dest(rdo_container_dest),
93 m_cont_coll(cont_coll),
94 m_dest_range_guard(rdo_container_dest),
96 m_idHelper(idHelper)
97 {};
98
100
101 //Obligatory members for the interface
112
113 inline void evt_next([[maybe_unused]] uint8_t tag) {};
114
115 inline void evt_done() {
116 };
117
118 inline void add_hit(uint16_t col, uint16_t row, uint16_t tot){
119 //Translate the col, row into module coordinates
120 // after that, row and col are phi_index and eta_index, respectively
122
123 //Set dummy values at 0 for these:
124 int bcid = 0;
125 int lvl0a = 0;
126 int lvl0d = 0;
127
130 std::array<std::int16_t,2>{static_cast<std::int16_t>(row), static_cast<std::int16_t>(col)},
131 PhaseII::PixelRawDataContainer::makeWord( tot, bcid, lvl0a, lvl0d ));
132 };
133
134 inline void add_hmap([[maybe_unused]] uint8_t qcol,
135 [[maybe_unused]] uint8_t qrow,
136 [[maybe_unused]] uint16_t hmap,
137 [[maybe_unused]] uint64_t tots)
138 {};
139
140 inline void add_qcore([[maybe_unused]] uint8_t qcol,
141 [[maybe_unused]] uint8_t qrow,
142 [[maybe_unused]] uint64_t qtot)
143 {};
144
145 inline uint8_t on_error([[maybe_unused]] itksw::pix::endec::intf::EventError error) {return 0;};
146 //end of interface-mandated methods
147
148 inline void registerLastModule() {
149 if (!m_dest_range_guard.empty()) {
150 // register the RDO range for this module, or erase the newly added
151 if (!m_cont_coll->registerOrEraseNewData(m_currentIdentifierHash,m_dest_range_guard.range())) {
153 }
154 // in the process of adding hits to the original container, its capacity may have
155 // been exceeded and the container may have been changed for the current module. To
156 // ensure that the same container is used for the next module get the container, that
157 // contains the hits for the current module from the the range_guard.
159 m_n_rdos += m_dest_range_guard.range().size();
160 }
161 }
162
163 //this is needed to properly identify the module.
164 inline void setOfflineID(const uint32_t& offlineID){
165 m_offlineID = offlineID;
166 };
167
168 //this is needed to properly translate hits on a quad
169 inline void setChipID(const uint8_t& chipID){
170 m_chipID = chipID;
171 }
172
173 //translate
175 m_transform = transform;
176 }
177
178
179 private:
180
181 // the RDO (=hits) container
183
184 // the collection of RDO containers
186
187 // RDO container range guard
189
190 // current offline ID hash
191 unsigned int m_currentIdentifierHash{std::numeric_limits<unsigned int>::max()};
192
193 // statistics
194 unsigned int m_n_rejected_work{};
195
196 // module offline ID as defined in InnerDetector/InDetDetDescr/InDetIdentifier/InDetIdentifier/PixelID.h
197 uint32_t m_offlineID = 0;
198
199 // front-end chip ID, from 0 to 4 for merged quads, 0 otherwise
200 uint8_t m_chipID = 0;
201
202 // RDO counter
203 uint32_t m_n_rdos = 0;
204
205 //offline identifier
207
208 //transform type for cabling package
210
211 // Identifier helper
213 };
214
215 //This prints the decoded hits on the screen,
216 //useful for testing purposes
218 public:
219 TestEventCallback(MsgStream& src): m_msg_source(src) {};
221
222 inline void evt_init(uint8_t tag) {
223 m_msg_source << MSG::DEBUG << "evt_init(" << tag << ")" << std::endl;
224 }
225
226 inline void evt_next(uint8_t tag) {
227 m_msg_source << MSG::DEBUG << "evt_next(" << tag << ")" << std::endl;
228 }
229
230 inline void evt_done() {
231 m_msg_source << MSG::DEBUG << "evt_done()" << std::endl;
232 }
233
234 inline void add_hit(uint16_t col, uint16_t row, uint16_t tot) {
235 m_msg_source << MSG::DEBUG << "add_hit(" << col << "," << row << "," << tot << ")" << std::endl;
236 }
237
238 inline void add_hmap(uint8_t qcol, uint8_t qrow, uint16_t hmap, uint64_t tots) {
239 m_msg_source << MSG::DEBUG << "add_hmap(qcol=" << qcol << ",qrow=" << qrow
240 << ",hmap=" << hmap << ",tots=" << tots << ")" << std::endl;
241 }
242
243 inline void add_qcore(uint8_t qcol, uint8_t qrow, uint64_t qtot) {
244 m_msg_source << MSG::DEBUG << "add_qcore(qcol=" << qcol << ",qrow=" << qrow
245 << ",qtot=" << qtot << ")" << std::endl;
246 }
247
248 inline uint8_t on_error(itksw::pix::endec::intf::EventError error) {
249 m_msg_source << MSG::DEBUG << "on_error(" << error.code << ")" << std::endl;
250 return 0;
251 }
252
253 MsgStream& m_msg_source;
254
255 };
256}
257
258
259#endif
260
#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