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