50 {
51#define WARNING_WITH_LINE(msg) ATH_MSG_WARNING(__func__ << "():" << __LINE__<< " " << msg)
52
53
54 MdtCsmReadOut csmReadOut;
55 MdtAmtReadOut amtReadOut;
56 MdtHptdcReadOut hptdcReadOut;
57
60
61
62
63 try {
64 robFrag.check();
65 } catch (const eformat::Issue& ex) {
67 return StatusCode::FAILURE;
68 }
69
70
71
73
74 if (nstat) {
76 robFrag.status(it);
77
78 if (*it) {
80
81
82
83
84
85
86
87 return StatusCode::FAILURE;
88 }
89 }
90
91
92
93 const unsigned int size = robFrag.rod_ndata();
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
114
115
116 SourceIdentifier sid(robFrag.rod_source_id());
117
121
122
124 robFrag.rod_data(vint);
125
126 ATH_MSG_DEBUG(
"**********Decoder dumping the words******** ");
127
128 if (size > 0) {
130 for (
unsigned int i = 0;
i <
size;
i++)
ATH_MSG_DEBUG(
"word " << i <<
" = " << MSG::hex << vint[i] << MSG::dec);
131 } else {
133 return StatusCode::FAILURE;
134 }
135
137
138 if (csmReadOut.
is_BOB()) {
140
142 } else {
145 << MSG::dec);
146 }
147
148 if (size < 2) {
150 return StatusCode::FAILURE;
151 }
152 ++wordPos;
154 if (csmReadOut.
is_EOB()) {
156 ", 0x" <<
static_cast<unsigned int>(
cabling_data.mrod) << MSG::dec);
157 return StatusCode::SUCCESS;
158 }
159
160 SG::ReadCondHandle<MuonMDT_CablingMap> readHandle{
m_readKey};
161 const MuonMDT_CablingMap* readCdo{*readHandle};
162 if (!readCdo) {
164 return StatusCode::FAILURE;
165 }
166 auto&
msg = msgStream();
167 while (!csmReadOut.
is_EOB()) {
168 while ((!csmReadOut.
is_BOL()) && (!csmReadOut.
is_EOB())) {
169 wordPos += 1;
170 if (wordPos >= size) {
172 return StatusCode::FAILURE;
173 }
175 }
176
177 if (csmReadOut.
is_BOL()) {
179 }
else if (csmReadOut.
is_EOB()) {
181 return StatusCode::FAILURE;
182 }
183
184
185
186
188
189
190
191
195
198
199 Identifier moduleId{0};
200 IdentifierHash idHash{0};
202
203 ATH_MSG_DEBUG(
"getOfflineIdfromOnlineID result: " << cabling_data);
204
205 if (!cab) {
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230 } else {
231
232
233
234
235
237
238
239 std::unique_ptr<MdtCsm> collection{nullptr};
243 ++m_nCache;
244 } else {
246 collection = std::make_unique<MdtCsm>(moduleId, idHash);
247 ++m_nNotCache;
248 }
249
250
251 if (collection)
252 collection->set_values(collection->identify(), collection->identifyHash(),
cabling_data.subdetectorId,
cabling_data.mrod,
254
255 wordPos += 1;
256 if (wordPos >= size) {
258 return StatusCode::FAILURE;
259 }
262
263
264 wordPos += 1;
265 if (wordPos >= size) {
267 return StatusCode::FAILURE;
268 }
271 while (!csmReadOut.
is_TWC()) {
273
274 ATH_MSG_DEBUG(
" Decoding data from TDC number : " << tdcNum);
275
276
277 wordPos += 1;
278 if (wordPos >= size) {
280 return StatusCode::FAILURE;
281 }
282
284
285 std::unique_ptr<MdtAmtHit> amtHit{nullptr};
286
287
288 while (!((isHpTdc ? hptdcReadOut.
is_EOT() : amtReadOut.
is_EOT()) ||
289 (isHpTdc ? hptdcReadOut.
is_BOT() : amtReadOut.
is_BOT()) ||
290 (isHpTdc ? csmReadOut.
is_TWC() : amtReadOut.
is_TWC()))) {
292 int tdcCounts;
294
295
296
297
298
299 if ((isHpTdc ? hptdcReadOut.
is_TSM() : amtReadOut.
is_TSM()) &&
302
303 amtHit = std::make_unique<MdtAmtHit>(tdcNum, chanNum);
304 amtHit->setValues((isHpTdc ? hptdcReadOut.
coarse() : amtReadOut.
coarse()),
305 (isHpTdc ? hptdcReadOut.
fine() : amtReadOut.
fine()), 0);
306 amtHit->addData(vint[wordPos]);
307 leadingHitMap.insert(std::make_pair(chanNum, std::move(amtHit)));
308 }
else if ((isHpTdc ? hptdcReadOut.
is_TSM() : amtReadOut.
is_TSM()) &&
311 leading_amt_map::iterator chanPosition = leadingHitMap.find(chanNum);
312
313 if (chanPosition != leadingHitMap.end()) {
314
315 amtHit = std::move(chanPosition->second);
318 int tdcCountsFirst = coarse * 32 + fine;
319
320
321 tdcCounts =
322 isHpTdc ? hptdcReadOut.
coarse() * 32 + hptdcReadOut.
fine() : amtReadOut.
coarse() * 32 + amtReadOut.
fine();
323 int width = tdcCounts - tdcCountsFirst;
324
325 amtHit->setValues(coarse, fine,
width);
326 amtHit->addData(vint[wordPos]);
327 collection->push_back(std::move(amtHit));
328
329
330 leadingHitMap.erase(chanPosition);
331 } else {
332 ATH_MSG_DEBUG(
"failure: corresponding leading edge not found for the trailing edge tdc: " << tdcNum <<
" chan: "
333 << chanNum);
334 }
335
336 }
else if ((isHpTdc ? hptdcReadOut.
is_TCM() : amtReadOut.
is_TCM()) && collection) {
338
339 amtHit = std::make_unique<MdtAmtHit>(tdcNum, chanNum);
340 amtHit->setValues((isHpTdc ? hptdcReadOut.
coarse() : amtReadOut.
coarse()),
341 (isHpTdc ? hptdcReadOut.
fine() : amtReadOut.
fine()),
342 (isHpTdc ? hptdcReadOut.
width() : amtReadOut.
width()));
343 amtHit->addData(vint[wordPos]);
344 collection->push_back(std::move(amtHit));
345 }
346
347
348 wordPos += 1;
349 if (wordPos >= size) {
351 return StatusCode::FAILURE;
352 }
353
355
356 if (isHpTdc) csmReadOut.
decodeWord(vint[wordPos]);
357
358 }
359
360 if (collection) {
361 for (auto& itHit : leadingHitMap) { collection->push_back(std::move(itHit.second)); }
362 }
363 leadingHitMap.clear();
364
365
366
367 if ((isHpTdc ? hptdcReadOut.
is_EOT() : amtReadOut.
is_EOT())) {
368 wordPos += 1;
369 if (wordPos >= size) {
371 return StatusCode::FAILURE;
372 }
373 }
376 }
378
379
380 }
381 wordPos += 1;
382 if (wordPos >= size) {
384 return StatusCode::FAILURE;
385 }
387 }
388 return StatusCode::SUCCESS;
389}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define WARNING_WITH_LINE(msg)
StatusCode addOrDelete(std::unique_ptr< T > ptr)
IDC_WriteHandle getWriteHandle(IdentifierHash hash)
friend class IDC_WriteHandle
void decodeWord(uint32_t dataWord)
void decodeWord(uint32_t dataWord)
void decodeWord(uint32_t dataWord)
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::ReadCondHandleKey< MuonMDT_CablingMap > m_readKey
std::map< uint16_t, std::unique_ptr< MdtAmtHit > > leading_amt_map
MdtCablingData CablingData
bool getOfflineId(CablingData &cabling_data, MsgStream &log) const
return the offline id given the online id
bool getMultiLayerCode(const CablingData &map_data, Identifier &multiLayer, IdentifierHash &mdtHashId, MsgStream &log) const
Transforms the identifier to an IdentifierHash corresponding to the multilayer In this case,...
const DataType * PointerType