ATLAS Offline Software
Loading...
Searching...
No Matches
LArLATOMEDecoder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#define DETAIL_DUMP_ON false
6#define ADC_DUMP_ON false
7#define VALIDATE_DUMP_ON false
8
10
11#include "eformat/Issue.h"
12#include "eformat/index.h" // for helper
14#include "GaudiKernel/MsgStream.h"
16
18#include "LArByteStream/Mon.h"
21
24
29#include <bit>
30
31
32
33
34
35static const InterfaceID IID_ILArLATOMEDecoder("LArLATOMEDecoder", 1, 0);
36
37using namespace OFFLINE_FRAGMENTS_NAMESPACE;
38
39LArLATOMEDecoder::LArLATOMEDecoder(const std::string& type, const std::string& name, const IInterface* parent)
40 : AthAlgTool(type, name, parent), m_sc2ccMappingTool("CaloSuperCellIDTool") {
41 declareInterface<LArLATOMEDecoder>(this);
42}
43
44const InterfaceID& LArLATOMEDecoder::interfaceID() {
46}
47
49
50 ATH_CHECK(detStore()->retrieve(m_onlineId, "LArOnline_SuperCellID"));
51
52 ATH_CHECK(m_sc2ccMappingTool.retrieve());
53 ATH_CHECK(m_cablingKeySC.initialize());
54
55 return StatusCode::SUCCESS;
56}
57
58StatusCode LArLATOMEDecoder::convert(const RawEvent* re, const LArLATOMEMapping* map, const LArOnOffIdMapping* onoffmap, const LArCalibLineMapping* clmap,
60 LArLATOMEHeaderContainer* header_coll) const {
61
62 if(!re) return StatusCode::FAILURE;;
63 bool ret = false;
64 // Check fragment validity:
65 try {
66 ret = re->check();
67 } catch (eformat::Issue& ex) {
68 ATH_MSG_WARNING("Exception while checking eformat fragment validity: " << ex.what());
69 ret = false;
70 }
71 if (!ret) {
72 ATH_MSG_ERROR("Got invalid RawEvent fragment");
73 return StatusCode::FAILURE;
74 }
75 // Build TOC
76 std::map<eformat::SubDetectorGroup, std::vector<const uint32_t*> > robIndex;
77 eformat::helper::build_toc(*re, robIndex);
78 for (const auto& mapit : robIndex)
79 ATH_MSG_DEBUG("Rob Index subdetgroup is " << std::hex << mapit.first);
80 std::map<eformat::SubDetectorGroup, std::vector<const uint32_t*> >::const_iterator robIt = robIndex.find(eformat::LAR);
81 if (robIt != robIndex.end()) {
82 const std::vector<const uint32_t*>& robs = robIt->second;
83 for (const uint32_t* pRob : robs) {
84 try {
85 ROBFragment robFrag(pRob);
86 uint32_t latomeSourceID = robFrag.rod_source_id();
88 if (!(latomeSourceID & 0x1000)) {
89 ATH_MSG_DEBUG(" discarding non latome source ID " << std::hex << latomeSourceID);
90 continue;
91 }
92 ATH_MSG_DEBUG(" found latome source ID " << std::hex << latomeSourceID);
93 }
94 const std::vector<HWIdentifier> LATOME_Channels = map->getChFromSource(latomeSourceID); // this is a cache for all the channels for a given LATOMEID
95 EventProcess ev(this, 0, 0, 0, 0, accdigits, caccdigits, header_coll);
96 ev.fillCollection(&robFrag, &LATOME_Channels, onoffmap, clmap);
97 } catch (eformat::Issue& ex) {
98 ATH_MSG_WARNING(" exception thrown by ROBFragment, badly corrupted event. Abort decoding ");
99 if (accdigits)
100 accdigits->clear();
101 if (caccdigits)
102 caccdigits->clear();
103 if (header_coll)
104 header_coll->clear();
105 break;
106 }
107 } // end loop over robs
108 } // end if got LAr-RODs
109
110 return StatusCode::SUCCESS;
111}
112
113StatusCode LArLATOMEDecoder::convert(const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>& robFrags, const LArLATOMEMapping* map,
114 LArDigitContainer* adc_coll, LArDigitContainer* adc_bas_coll, LArRawSCContainer* et_coll, LArRawSCContainer* et_id_coll,
115 LArLATOMEHeaderContainer* header_coll) const {
116
117 // Check fragment validity:
118 // Build TOC
119 if (robFrags.size() > 0) {
120 for (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment* pRob : robFrags) {
121 try {
122 uint32_t latomeSourceID = pRob->rod_source_id();
123 if (m_protectSourceId) {
124 if (!(latomeSourceID & 0x1000)) {
125 ATH_MSG_DEBUG(" discarding non latome source ID " << std::hex << latomeSourceID);
126 continue;
127 }
128 ATH_MSG_DEBUG(" found latome source ID " << std::hex << latomeSourceID);
129 }
130 EventProcess ev(this, adc_coll, adc_bas_coll, et_coll, et_id_coll, 0, 0, header_coll);
131 const std::vector<HWIdentifier> LATOME_Channels = map->getChFromSource(latomeSourceID); // this is a cache for all the channels for a given LATOMEID
132 ev.fillCollection(pRob, &LATOME_Channels, nullptr, nullptr);
133 } catch (eformat::Issue& ex) {
134 ATH_MSG_WARNING(" exception thrown by ROBFragment, badly corrupted event. Abort decoding ");
135 if (adc_coll)
136 adc_coll->clear();
137 if (adc_bas_coll)
138 adc_bas_coll->clear();
139 if (et_coll)
140 et_coll->clear();
141 if (et_id_coll)
142 et_id_coll->clear();
143 if (header_coll)
144 header_coll->clear();
145 break;
146 }
147 } // end loop over robs
148 } // end if got LAr-RODs
149 return StatusCode::SUCCESS;
150}
151
153 LArRawSCContainer* et_coll, LArRawSCContainer* et_id_coll, LArAccumulatedDigitContainer* accdigits,
155 : AthMessaging(Gaudi::svcLocator()->service<IMessageSvc>("MessageSvc"), "LArLATOMEDecoder::EventProcess"),
156 m_decoder(decoderInput),
157 m_adc_coll(adc_coll),
158 m_adc_bas_coll(adc_bas_coll),
159 m_et_coll(et_coll),
160 m_et_id_coll(et_id_coll),
161 m_accdigits(accdigits),
162 m_caccdigits(caccdigits),
163 m_header_coll(header_coll) {
164 m_latomeID = 0;
165 m_l1ID = 0;
166 m_ROBFragSize = 0;
167 m_nPackets = 0;
168 m_iPacket = 0;
170 m_monHeaderSize = 0;
171 m_region = 0;
172 m_nStreams = 0;
173 m_streamNumber = 0;
174 m_at0at1Swap = 0;
179 m_at0nBC = 0;
180 m_at1nBC = 0;
181 m_at0BC = 0;
182 m_at1BC = 0;
183 m_activeSC = 0;
184 m_nsc1 = 0;
185 m_nsc2 = 0;
186 m_nsc3 = 0;
187 m_nsc4 = 0;
188 m_nsc5 = 0;
189 m_nsc6 = 0;
190 m_headerDecoded = false;
191
192 m_nBC_rawADC = 0;
193 m_nBC_ADC = 0;
194 m_nBC_E = 0;
195 m_nBC_EID = 0;
196
197 m_nBC_Averaged = 0;
198
199 m_BC_rawADC = 0;
200 m_BC_ADC = 0;
201 m_BC_E = 0;
202 m_BC_EID = 0;
203
204 m_hasRawAdc = false;
205 m_hasAdc = false;
206 m_hasE = false;
207 m_hasEID = false;
208
209 m_isAveraged = (m_caccdigits != 0);
210 m_isAutoCorr = (m_accdigits != 0);
211
212 if (!m_isAveraged && !m_isAutoCorr) {
214 } else {
217 }
218}
219
220inline bool LArLATOMEDecoder::EventProcess::compareOrSet(Word& param, Word value, bool compare) {
221 if (!compare) {
222 param = value;
223 return true;
224 }
225 return param == value;
226}
227
228unsigned int LArLATOMEDecoder::EventProcess::decodeTrailer(const uint32_t* p, unsigned int offset) {
230 if (std::byteswap(p[offset]) != 0xc0ffee00 || std::byteswap(p[offset + 1] != 0xaaaaaaaa)) {
231 ATH_MSG_WARNING("Problem in trailer at packet " << m_iPacket << " words " << std::hex << std::byteswap(p[offset]) << ", " << std::byteswap(p[offset + 1])
232 << std::dec);
233 }
235 return offset + m_monTrailerSize;
236}
237
238unsigned int LArLATOMEDecoder::EventProcess::decodeHeader(const uint32_t* p, unsigned int offset) {
239
241 int monheadererror = 0;
242 int monheadererrorbit = 0;
243 if (!compareOrSet(m_latomeID, std::byteswap(p[0 + offset]), m_headerDecoded))
244 monheadererror |= (1 << monheadererrorbit++);
245 Word l1IDtmp = m_l1ID;
246 if (!compareOrSet(l1IDtmp, std::byteswap(p[1 + offset]), m_headerDecoded))
247 monheadererror |= (1 << monheadererrorbit++);
248 if (l1IDtmp != m_l1ID) {
249 ATH_MSG_DEBUG("Mon header L1ID " << l1IDtmp << " different from rod header L1ID " << m_l1ID);
250 }
251 ATH_MSG_DEBUG(" latomeID: " << m_latomeID << " l1ID: " << m_l1ID);
252
253 Word monHeaderMarker = std::byteswap(p[2 + offset]);
254 Word monCheckPoint = std::byteswap(p[4 + offset]);
255 if (s_monHeaderMarker != monHeaderMarker) {
256 monheadererror |= (1 << monheadererrorbit++);
257 ATH_MSG_WARNING("Problem in monHeaderMarker: " << monHeaderMarker);
258 }
259 if (s_monCheckPoint != monCheckPoint) {
260 monheadererror |= (1 << monheadererrorbit++);
261 ATH_MSG_WARNING("Problem in monCheckPoint: " << monCheckPoint);
262 }
263
264 if (!compareOrSet(m_nPackets, std::byteswap(p[3 + offset]) >> 24, m_headerDecoded))
265 monheadererror |= (1 << monheadererrorbit++);
266
267 if (m_nPackets == 0xFF) {
268 m_nPackets = 1;
269 m_iPacket = 0;
270 m_nWordsPerPacket = (std::byteswap(p[3 + offset]) & 0xffffff) / 4.;
271 } else {
272 if (m_headerDecoded)
273 ++m_iPacket;
274 else
275 m_iPacket = 0;
276 if (!compareOrSet(m_iPacket, (std::byteswap(p[3 + offset]) >> 16) & 0xf, m_headerDecoded))
277 monheadererror |= (1 << monheadererrorbit++);
278 m_nWordsPerPacket = (std::byteswap(p[3 + offset]) & 0xffff) / 4.;
279 }
280
281 if (!compareOrSet(m_monHeaderSize, std::byteswap(p[5 + offset]), m_headerDecoded))
282 monheadererror |= (1 << monheadererrorbit++);
283
286 if (m_monHeaderSize < 18) {
287 ATH_MSG_WARNING(" Mon header size should not be less that 18 : =" << m_monHeaderSize << " are you reading old data file?");
288 return 0;
289 }
290
291 ATH_MSG_DEBUG(" nPackets: " << m_nPackets << " iPacket: " << m_iPacket << " nWordsPerPacket: " << m_nWordsPerPacket << " monHeaderSize: " << m_monHeaderSize);
292
294 std::ignore = compareOrSet(m_at0at1Swap, (std::byteswap(p[8 + offset])>>30) & 0x1, m_headerDecoded);
295 if (!compareOrSet(m_at0typeRec, std::byteswap(p[9 + offset]), m_headerDecoded))
296 monheadererror |= (1 << monheadererrorbit++);
297 if (!compareOrSet(m_at1typeRec, std::byteswap(p[12 + offset]), m_headerDecoded))
298 monheadererror |= (1 << monheadererrorbit++);
299 monheadererrorbit += 2;
300
301 if (!compareOrSet(m_at0nBC, std::byteswap(p[10 + offset]), m_headerDecoded))
302 monheadererror |= (1 << monheadererrorbit++);
303 if (!compareOrSet(m_at1nBC, std::byteswap(p[13 + offset]), m_headerDecoded))
304 monheadererror |= (1 << monheadererrorbit++);
305 if (!compareOrSet(m_at0BC, std::byteswap(p[11 + offset]), m_headerDecoded))
306 monheadererror |= (1 << monheadererrorbit++);
307 if (!compareOrSet(m_at1BC, std::byteswap(p[14 + offset]), m_headerDecoded))
308 monheadererror |= (1 << monheadererrorbit++);
309 if (!compareOrSet(m_activeSC, std::byteswap(p[15 + offset]), m_headerDecoded))
310 monheadererror |= (1 << monheadererrorbit++);
311 if (!compareOrSet(m_nsc1, std::byteswap(p[16]) >> 24, m_headerDecoded))
312 monheadererror |= (1 << monheadererrorbit++);
313 if (!compareOrSet(m_nsc2, (std::byteswap(p[16]) >> 16) & 0xff, m_headerDecoded))
314 monheadererror |= (1 << monheadererrorbit++);
315 if (!compareOrSet(m_nsc3, (std::byteswap(p[16]) >> 8) & 0xff, m_headerDecoded))
316 monheadererror |= (1 << monheadererrorbit++);
317 if (!compareOrSet(m_nsc4, (std::byteswap(p[16])) & 0xff, m_headerDecoded))
318 monheadererror |= (1 << monheadererrorbit++);
319 if (!compareOrSet(m_nsc5, std::byteswap(p[17]) >> 24, m_headerDecoded))
320 monheadererror |= (1 << monheadererrorbit++);
321 if (!compareOrSet(m_nsc6, (std::byteswap(p[17]) >> 16) & 0xff, m_headerDecoded))
322 monheadererror |= (1 << monheadererrorbit++);
323
324 ATH_MSG_DEBUG("m_at0at1Swap: " << m_at0at1Swap << " at0type " << m_at0typeRec << " at1type " << m_at1typeRec << " at0nBC " << m_at0nBC << " at1nBC " << m_at1nBC << " at0BC " << m_at0BC
325 << " at1BC " << m_at1BC << " nsc1 " << m_nsc1 << " nsc2 " << m_nsc2 << " nsc3 " << m_nsc3 << " nsc4 " << m_nsc4 << " nsc5 "
326 << m_nsc5 << " nsc6 " << m_nsc6);
327
328 if (monheadererror) {
329 ATH_MSG_WARNING(" consistency error in mon checker at packet " << m_iPacket << " errorbits " << std::hex << monheadererror << std::dec);
330 }
331
332 m_headerDecoded = true;
333 return m_monHeaderSize + m_nWordsPerPacket + offset;
334}
335
336inline int LArLATOMEDecoder::EventProcess::signEnergy(unsigned int energy) {
337
338 if (energy & (1 << 17))
339 return energy - pow(2, 18);
340 else
341 return energy;
342}
343
345 unsigned int b = 0;
346 if (at0 == MonDataType::Averaged || at0 == MonDataType::AutoCorr)
347 return 8;
348
350 if (at0 != MonDataType::Invalid)
351 b += 2;
352 if (at1 != MonDataType::Invalid)
353 b += 2;
355 ++b;
356 return b;
357}
358
359inline void LArLATOMEDecoder::EventProcess::increaseWordShift(unsigned int& wordshift) {
360 ++wordshift;
361 if (m_packetEnd[m_iPacket] == wordshift) {
362 ++m_iPacket;
363 wordshift += (m_monHeaderSize + m_monTrailerSize);
364 ATH_MSG_DEBUG("switch packet " << m_iPacket << " " << wordshift);
365 }
366}
367
368inline void LArLATOMEDecoder::EventProcess::increaseByteShift(unsigned int& wordshift, unsigned int& byteshift) {
369 ++byteshift;
370 if (byteshift == 4) {
371 increaseWordShift(wordshift);
372 byteshift = 0;
373 }
374}
375
376inline void LArLATOMEDecoder::EventProcess::decodeByte(unsigned int& byte, unsigned int wordshift, unsigned int byteshift, const uint32_t* p) {
377 byte = ((std::byteswap(p[wordshift])) >> (8 * (4 - 1 - byteshift))) & 0xff;
378}
379
380inline void LArLATOMEDecoder::EventProcess::decodeWord(unsigned int& word, unsigned int& wordshift, unsigned int& byteshift, const uint32_t* p) {
381 unsigned int msb = 0;
382 unsigned int lsb = 0;
383 decodeByte(msb, wordshift, byteshift, p);
384 increaseByteShift(wordshift, byteshift);
385 decodeByte(lsb, wordshift, byteshift, p);
386 increaseByteShift(wordshift, byteshift);
387 word = lsb | (msb << 8);
388}
389
390inline void LArLATOMEDecoder::EventProcess::decodeChannel(unsigned int& wordshift, unsigned int& byteshift, const uint32_t* p, MonDataType at0, MonDataType at1,
391 unsigned int& at0Data, unsigned int& at1Data, unsigned int& saturation, bool& at0val, bool& at1val) {
392
393 // the structure of data is always consisting of 2,3,4 or 5 bytes depending on the recipe.
394 // If there is an energy it means there is the quality/saturation byte thus odd number of bytes. Otherwise ADC or Energy spans <mostly> over 2 bytes.
395 // avoid vectors and loops and bitsets to make it faster (can change later if needed but there is only few configurations so no need to make it infinitely
396 // flexible. use unsigned int everywhere for now since we have 18 bits for energy which does not fit in short, cast later.
397 unsigned int nbytesPerChannel = bytesPerChannel(at0, at1);
398 bool satByte = nbytesPerChannel % 2; // do we have satbyte
399
400 at0val = false;
401 at1val = false;
402 at0Data = 0;
403 at1Data = 0;
404 unsigned int satData = 0;
405 saturation = 0;
406
407 unsigned int word1 = 0;
408 unsigned int word2 = 0;
409 decodeWord(word1, wordshift, byteshift, p);
410 if (nbytesPerChannel > 3) {
411 decodeWord(word2, wordshift, byteshift, p);
412 }
413 at0Data = word1 & 0x7fff;
414 at0val = word1 & 0x8000;
415 if (nbytesPerChannel > 3) {
416 at1Data = word2 & 0x7fff;
417 at1val = word2 & 0x8000;
418 }
419 if (satByte) {
420 decodeByte(satData, wordshift, byteshift, p);
421 increaseByteShift(wordshift, byteshift);
422 }
423
427
429 at0Data = (at0Data << 3) | (satData & 0x7);
430 at1Data = (at1Data << 3) | ((satData & 0x70) >> 4);
431 saturation = ((satData & 0x88) == 0x88);
432 } else if (at1 == MonDataType::Energy && at0 == MonDataType::SelectedEnergy) {
433 at0Data = (at0Data << 3) | ((satData & 0x70) >> 4);
434 at1Data = (at1Data << 3) | (satData & 0x7);
435 saturation = ((satData & 0x88) == 0x88);
436 } else {
438 at0Data = (at0Data << 3) | (satData & 0x7);
439 saturation = (satData & 0x20);
440 }
442 at1Data = (at1Data << 3) | (satData & 0x7);
443 saturation = (satData & 0x20);
444 }
445 }
446}
447
448void LArLATOMEDecoder::EventProcess::fillCollection(const ROBFragment* robFrag, const std::vector<HWIdentifier>* LATOME_Channels, const LArOnOffIdMapping* onoffmap,
449 const LArCalibLineMapping* clmap) {
451 const unsigned int sourceID = robFrag->rob_source_id();
452 m_l1ID = robFrag->rod_lvl1_id();
453 m_ROBFragSize = robFrag->rod_ndata();
454 const uint32_t* p = robFrag->rod_data();
455 const unsigned int n = robFrag->rod_ndata();
456 if (0 == n) {
458 ATH_MSG_DEBUG("Empty fragment, skip ");
459 return;
460 }
461 unsigned int offset = decodeHeader(p, 0);
462
463 m_latomeBCID = robFrag->rod_bc_id();
464 const uint32_t* rod_status = robFrag->rod_status();
465 const unsigned int rod_nstatus = robFrag->rod_nstatus();
466 if (rod_nstatus != 27) {
467 ATH_MSG_WARNING("Inconsistent number of rod header status elements: nstatus= " << rod_nstatus);
468 return;
469 }
470 if (rod_nstatus > 8) {
471 uint32_t status8 = rod_status[8];
472 m_at0type = status8 & 0x3;
473 m_at1type = (status8 >> 2) & 0x3;
474 ATH_MSG_DEBUG("before swap: m_at0type " << m_at0type << ", m_at1type " << m_at1type << "swap value " << m_at0at1Swap);
475 if(m_at0at1Swap==1){
477 ATH_MSG_DEBUG("after swap: m_at0type " << m_at0type << "m_at1type " << m_at1type);
478 }
479
480 }
481 m_nthLATOME = robFrag->rod_source_id();
482 m_LATOMEFW = rod_status[3] & 0x0fff;
483
484 LatomeCalibPatterns pat1, pat2, pat3;
485 pat1.DAC = rod_status[9];
486 pat1.delay = rod_status[10];
487 pat1.patterns.resize(4);
488 for (unsigned int i = 0; i < 4; ++i)
489 pat1.patterns[i] = rod_status[i + 11];
490
491 pat2.DAC = rod_status[15];
492 pat2.delay = rod_status[16];
493 pat2.patterns.resize(4);
494 for (unsigned int i = 0; i < 4; ++i)
495 pat2.patterns[i] = rod_status[i + 17];
496
497 pat3.DAC = rod_status[21];
498 pat3.delay = rod_status[22];
499 pat3.patterns.resize(4);
500 for (unsigned int i = 0; i < 4; ++i)
501 pat3.patterns[i] = rod_status[i + 23];
502
503 m_latomeCalibPatternsInEvent = {std::move(pat1), std::move(pat2), std::move(pat3)};
504
505 const HWIdentifier hwidEmpty;
506
508
509
510 //unsigned int offset = decodeHeader(p, 0);
511 if (offset > m_ROBFragSize) {
512 ATH_MSG_WARNING("Data corruption, offset found at pos 0 (" << offset << ") is larger than the ROB fragment size (" << m_ROBFragSize << "). Ignoring data.");
513 return;
514 }
515
516 if (m_isAveraged) {
517 m_at0type = m_at0typeRec >> 24;
519 if (m_at0type != (int)MonDataType::Averaged) {
520 ATH_MSG_WARNING(" inconsistant data type with requested averaged decoding at0 type " << m_at0type << " " << m_at0typeRec << " " << std::hex << m_l1ID
521 << " " << sourceID << std::dec);
522 return;
523 }
524 }
525 if (m_isAutoCorr) {
526 m_at0type = m_at0typeRec >> 24;
528 if (m_at0type != (int)MonDataType::AutoCorr) {
529 ATH_MSG_WARNING(" inconsistant data type with requested averaged decoding at0 type " << m_at0type << " " << m_at0typeRec << " " << std::hex << m_l1ID
530 << " " << sourceID << std::dec);
531 return;
532 }
533 }
534
535 m_packetEnd.push_back(offset);
536 offset = decodeTrailer(p, offset);
539 for (unsigned int ip = 1; ip < m_nPackets; ++ip) {
540 if (offset > m_ROBFragSize) {
541 ATH_MSG_WARNING("Data corruption, offset found at pos 0 (" << offset << ") is larger than the ROB fragment size (" << m_ROBFragSize << "). Ignoring data.");
542 return;
543 }
544
545 offset = decodeHeader(p, offset);
546 if (offset > m_ROBFragSize) {
547 ATH_MSG_WARNING("Data corruption, offset found at pos 0 (" << offset << ") is larger than the ROB fragment size (" << m_ROBFragSize << "). Ignoring data.");
548 return;
549 }
550 m_packetEnd.push_back(offset);
551 offset = decodeTrailer(p, offset);
552 }
553
554 ATH_MSG_DEBUG(" end of header check computed offset=" << std::dec << offset << " nwords in payload=" << n);
555
557 m_iPacket = 0;
558 if (m_nPackets==0) {
559 ATH_MSG_WARNING("Data corruption, nPackets=0");
560 return;
561 }
562
563 if (m_nPackets>m_packetEnd.size()) {
564 ATH_MSG_WARNING("Data corruption, nPackets " << m_nPackets << " exceeds size " << m_packetEnd.size());
565 return;
566 }
567
568 if (m_packetEnd[m_nPackets - 1] + m_monTrailerSize != n) {
569 ATH_MSG_WARNING("problem in packet size loop " << m_packetEnd[m_nPackets - 1] << " != " << n);
570 }
571
572
573 std::vector<unsigned int> timeslot_nsc = {m_nsc1, m_nsc2, m_nsc3, m_nsc4, m_nsc5, m_nsc6};
574 std::vector<unsigned int> bc_size;
577
578 short nBC = 0;
579 short nBC1 = 0;
580 short startBC1 = 0;
583
584 if (m_isAveraged || m_isAutoCorr) {
585 nBC = m_at0nBC;
586 nBC1 = m_at1nBC;
587 m_nBC_Averaged = nBC;
588 startBC1 = 0;
589 type0 = static_cast<MonDataType>(m_at0type);
590 type1 = static_cast<MonDataType>(m_at1type);
591 for (auto& val : m_averagedRawValuesInEvent) {
592 val.sum.resize(m_nBC_Averaged);
593 val.sumSq.resize(m_nBC_Averaged);
594 val.nTrigValid.resize(m_nBC_Averaged);
595 val.latomeChannel = 99999;
596 }
597 } else {
598 if (m_at1nBC == 0) {
600 }
601
603 if (m_at0nBC >= m_at1nBC) {
604 nBC = m_at0nBC;
605 nBC1 = m_at1nBC;
606 startBC1 = m_at1BC - m_at0BC;
607 type0 = static_cast<MonDataType>(m_at0type);
608 type1 = static_cast<MonDataType>(m_at1type);
609 } else {
610 nBC1 = m_at0nBC;
611 nBC = m_at1nBC;
612 startBC1 = m_at0BC - m_at1BC;
613 type1 = static_cast<MonDataType>(m_at0type);
614 type0 = static_cast<MonDataType>(m_at1type);
615 }
616 } else if (m_at0type != (Word)MonDataType::Invalid) {
617 nBC = m_at0nBC;
618 type0 = static_cast<MonDataType>(m_at0type);
619 } else if (m_at1type != (Word)MonDataType::Invalid) {
620 nBC = m_at1nBC;
621 type0 = static_cast<MonDataType>(m_at1type);
622 } else {
623 ATH_MSG_ERROR("No valid data type in Mon Header");
624 return;
625 }
626
627 switch (type0) {
629 m_hasRawAdc = true;
630 m_nBC_rawADC = nBC;
631 break;
632 case MonDataType::ADC:
633 m_hasAdc = true;
634 m_nBC_ADC = nBC;
635 break;
637 m_hasE = true;
638 m_nBC_E = nBC;
639 break;
641 m_hasEID = true;
642 m_nBC_EID = nBC;
643 break;
645 break;
646 default:
647 ATH_MSG_ERROR("wrong mux0 value " << (Word)type0);
648 return;
649 }
650
651 switch (type1) {
653 m_hasRawAdc = true;
654 m_nBC_rawADC = nBC1;
655 m_BC_rawADC = startBC1;
656 break;
657 case MonDataType::ADC:
658 m_hasAdc = true;
659 m_nBC_ADC = nBC1;
660 m_BC_ADC = startBC1;
661 break;
663 m_hasE = true;
664 m_nBC_E = nBC1;
665 m_BC_E = startBC1;
666 break;
668 m_hasEID = true;
669 m_nBC_EID = nBC1;
670 m_BC_EID = startBC1;
671 break;
673 break;
674 default:
675 ATH_MSG_ERROR("wrong mux1 value " << (Word)type1);
676 return;
677 }
678
679 for (auto& val : m_rawValuesInEvent) {
680 if (m_hasRawAdc)
681 val.adc.resize(m_nBC_rawADC);
682 if (m_hasAdc)
683 val.adc_bas.resize(m_nBC_ADC);
684 if (m_hasE)
685 val.et.resize(m_nBC_E);
686 if (m_hasEID)
687 val.et_id.resize(m_nBC_EID);
688 if (m_hasEID || m_hasE) {
689 val.saturation.resize(std::max(m_nBC_EID, m_nBC_E));
690 }
691
692 val.latomeChannel = 99999;
693 }
694 }
695
696 m_BCIDsInEvent.resize(nBC);
697
698 unsigned int s = m_monHeaderSize;
699 unsigned int bcid = s_nBunches;
700
701 for (short iBC = 0; iBC < nBC; ++iBC) {
702 MonDataType at0 = type0;
703 MonDataType at1 = type1;
704 if (type1 != MonDataType::Invalid) {
705 if (iBC < startBC1 || iBC >= startBC1 + nBC1)
707 }
708 unsigned int nbytesPerChannel = bytesPerChannel(at0, at1);
709
710 int nsc = 0;
711 unsigned int oldipacket = 0;
712 for (unsigned int itimeslot = 0; itimeslot < 6; ++itimeslot) {
713 unsigned int l_bcid = (std::byteswap(p[s]))>>16;
714 if(itimeslot!=0){
715 if(l_bcid!=bcid){
716 ATH_MSG_WARNING( "ERROR: inconsistent BCID between time slots" );
717 }
718 }
719 else{
720 if(bcid!=s_nBunches){
722 unsigned int bcid_c = bcid+1;
723 if(bcid_c==s_nBunches){
724 bcid=0;
725 bcid_c = 0;
726 }
727 if(bcid_c != l_bcid){
728 ATH_MSG_WARNING( "ERROR: BCID not increasing properly between samples, sourceId: " << m_nthLATOME << " L1ID is: " << m_l1ID << ", BCID is from payload: " << l_bcid << ", expected BCID is: " << bcid_c << ", LATOME channel is: " << nsc );
729 }
730 }
731 m_BCIDsInEvent[iBC] = l_bcid;
732 }
733 bcid=l_bcid;
734
735 unsigned int mux = ((std::byteswap(p[s])) >> 8) & 0xff;
739 if (s >= n)
740 break;
741
742 unsigned int timeslotsize = timeslot_nsc[itimeslot];
743 unsigned int nbytes = timeslotsize * nbytesPerChannel;
744 unsigned int n64word = nbytes / 8;
745 if (nbytes % 8)
746 ++n64word;
747 ATH_MSG_DEBUG(" at BC " << iBC << " timeslot " << itimeslot << " " << bcid << " " << mux << " n64word " << n64word << " at0 " << (int)at0 << " at1 "
748 << (int)at1 << " l_bcid " << bcid);
749
750 unsigned int wordshift = s;
751 unsigned int byteshift = 0;
752
754 oldipacket = m_iPacket;
755 for (unsigned int ichan = 0; ichan < timeslotsize; ++ichan) {
756 unsigned int at0Data = 0, at1Data = 0, satData = 0;
757 bool at0val = false, at1val = false;
758
759 // protection against corrupted bytestream data
760 if (nsc > N_LATOME_CHANNELS - 1) {
761 break;
762 // FIXME: should fill some default data to all channels, because clearly this block is corrupted
763 }
764 if (!m_isAveraged && !m_isAutoCorr) {
765 decodeChannel(wordshift, byteshift, p, at0, at1, at0Data, at1Data, satData, at0val, at1val);
766 ATH_MSG_DEBUG(" wordshift " << wordshift << " byteshift " << byteshift << " at0data " << at0Data << " at1Data " << at1Data << " satData " << satData
767 << " at0val " << at0val << " at1val " << at1val << " nsc " << nsc);
768
770 const HWIdentifier SCID = nsc < (int) LATOME_Channels->size() ? (*LATOME_Channels)[nsc] : hwidEmpty;
771 if (SCID == hwidEmpty) {
772 ATH_MSG_DEBUG("No mapping for ch: " << std::dec << nsc);
773 }
774 int RAWValue0 = -999;
775 if (!at0val && SCID != hwidEmpty && at0 != MonDataType::Invalid) {
776 ATH_MSG_DEBUG("at0 bad quality bit for SC:" << nsc << " BC " << iBC << " latome " << robFrag->rod_source_id());
777 } else {
779 RAWValue0 = at0Data;
780 }
781 int defaultADCValue = -1;
782 int defaultEValue = -99999;
783 auto& rawValuesInEvent = m_rawValuesInEvent[nsc];
784 switch (at0) {
786 if ((unsigned)iBC < rawValuesInEvent.adc.size()) {
787 rawValuesInEvent.adc[iBC] = (at0val) ? RAWValue0 : defaultADCValue;
788 }
789 break;
790 case MonDataType::ADC:
791 if ((unsigned)iBC < rawValuesInEvent.adc_bas.size()) {
792 rawValuesInEvent.adc_bas[iBC] = (at0val) ? RAWValue0 : defaultADCValue;
793 }
794 break;
796 if ((unsigned)iBC < rawValuesInEvent.et.size()) {
797 rawValuesInEvent.et[iBC] = (at0val) ? signEnergy(RAWValue0) : defaultEValue;
798 rawValuesInEvent.saturation[iBC] = satData;
799 }
800 break;
802 if ((unsigned)iBC < rawValuesInEvent.et_id.size()) {
803 rawValuesInEvent.et_id[iBC] = (at0val) ? signEnergy(RAWValue0) : defaultEValue;
804 rawValuesInEvent.saturation[iBC] = satData;
805 }
806 break;
808 break;
809 default:
810 ATH_MSG_ERROR("wrong at0 value " << (Word)at0);
811 return;
812 }
813
814 int RAWValue1 = -999;
815 if (!at1val && SCID != hwidEmpty && at1 != MonDataType::Invalid) {
816 ATH_MSG_DEBUG("at1 bad quality bit for SC:" << nsc << " BC " << iBC << " latome " << robFrag->rod_source_id());
817 } else {
819 RAWValue1 = at1Data;
820 }
821
822 const size_t BCidx = iBC - startBC1;
823 switch (at1) {
825 if (BCidx < rawValuesInEvent.adc.size()) {
826 rawValuesInEvent.adc[BCidx] = (at1val) ? RAWValue1 : defaultADCValue;
827 }
828 break;
829 case MonDataType::ADC:
830 if (BCidx < rawValuesInEvent.adc_bas.size()) {
831 rawValuesInEvent.adc_bas[BCidx] = (at1val) ? RAWValue1 : defaultADCValue;
832 }
833 break;
835 if (BCidx < rawValuesInEvent.et.size()) {
836 rawValuesInEvent.et[BCidx] = (at1val) ? signEnergy(RAWValue1) : defaultEValue;
837 rawValuesInEvent.saturation[BCidx] = satData;
838 }
839 break;
841 if (BCidx < rawValuesInEvent.et_id.size()) {
842 m_rawValuesInEvent[nsc].et_id[BCidx] = (at1val) ? signEnergy(RAWValue1) : defaultEValue;
843 m_rawValuesInEvent[nsc].saturation[BCidx] = satData;
844 }
845 break;
847 break;
848 default:
849 ATH_MSG_ERROR("wrong at1 value " << (Word)at1);
850 return;
851 }
852
853 m_rawValuesInEvent[nsc].latomeChannel = nsc;
854
855 } else {
856 if (wordshift % 2) {
857 ATH_MSG_ERROR("inconsistant wordshift in decoding everaged data");
858 return;
859 }
860 unsigned int averageword = std::byteswap(p[wordshift]);
861 wordshift += 1;
862 unsigned int sumSq = std::byteswap(p[wordshift]);
863 wordshift += 1;
864 unsigned long long sumsqMSB = averageword >> 28;
865 sumsqMSB = sumsqMSB << 32;
866
867 m_averagedRawValuesInEvent[nsc].sum[iBC] = averageword & 0xFFFFF;
868 m_averagedRawValuesInEvent[nsc].sumSq[iBC] = sumSq | sumsqMSB;
869 m_averagedRawValuesInEvent[nsc].nTrigValid[iBC] = (averageword >> 20) & 0xFF;
870 m_averagedRawValuesInEvent[nsc].latomeChannel = nsc;
871 }
872
873 ++nsc;
874
875 }
876
878 if(byteshift!=0){
879 increaseWordShift(wordshift);
880 byteshift=0;
881 }
882 ATH_MSG_DEBUG("wordshift before: " << wordshift << ", s: " << s);
883 if ((wordshift - s) % 2)
884 increaseWordShift(wordshift);
885 ATH_MSG_DEBUG("wordshift after : " << wordshift << ", s: " << s);
886 if ((wordshift - s - ((m_iPacket - oldipacket) * (m_monHeaderSize + m_monTrailerSize))) != n64word * 2) {
887 ATH_MSG_WARNING(" ERROR: time slice end is not padded properly " << (wordshift - s - m_iPacket * (m_monHeaderSize + m_monTrailerSize))
888 << "!=" << n64word * 2 << " m_ipacket " << m_iPacket);
889 }
890 s = wordshift;
891 oldipacket = m_iPacket;
892 }
893
894 }
895
896 if (!m_isAveraged && !m_isAutoCorr) {
897 fillRaw(LATOME_Channels);
898 } else {
899 if (onoffmap && clmap) {
900 fillCalib(LATOME_Channels, onoffmap, clmap);
901 } else {
902 ATH_MSG_ERROR("Do not have mapping !!!");
903 }
904 }
905 fillHeader();
906}
907
908void LArLATOMEDecoder::EventProcess::fillCalib(const std::vector<HWIdentifier>* LATOME_Channels, const LArOnOffIdMapping* cablingLeg, const LArCalibLineMapping* clcabling) {
909
911 uint32_t DAC_value=0;
912 uint16_t delay_value=0;
913 uint16_t isPulsed_value=false;
914 std::unique_ptr<LArCalibParams> calibParams1;
915 std::unique_ptr<LArCalibParams> calibParams2;
916
917 int pattype = m_nthLATOME >> 16;
918 const LArOnOffIdMapping* cabling = 0;
919 if (m_caccdigits) {
920 m_caccdigits->setDelayScale(25. / 240.);
921
922 SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_decoder->m_cablingKeySC};
923 cabling = {*cablingHdl};
924 if (!cabling) {
925 ATH_MSG_ERROR("Do not have mapping object " << m_decoder->m_cablingKeySC.key());
926 return;
927 }
928
929 calibParams1=std::make_unique<LArCalibParams>();
930 calibParams2=std::make_unique<LArCalibParams>();
931
932 if (pattype > 0x48) {
933 StatusCode sc1 = calibParams1->initialize();
934 StatusCode sc2 = calibParams2->initialize();
935 if (sc1 != StatusCode::SUCCESS || sc2 != StatusCode::SUCCESS) {
936 ATH_MSG_WARNING("could not initialize LArCalibParams, acc calib will not be filled ");
937 return;
938 }
939 if (pattype == 0x49 || pattype == 0x4a) {
940
942
944 } else {
945
947
949 }
950 } else {
951 StatusCode sc1 = calibParams1->initialize();
952 if (sc1 != StatusCode::SUCCESS) {
953 ATH_MSG_WARNING("could not initialize LArCalibParams, acc calib will not be filled ");
954 return;
955 }
957 }
958 }
959
960 const HWIdentifier hwidEmpty;
961 unsigned nWarnings = 0;
962 for (SuperCell ch = 0; ch < N_LATOME_CHANNELS; ++ch) {
963 LArCalibParams* calibParams = 0;
964 HWIdentifier SCID = ch < (int) LATOME_Channels->size() ? (*LATOME_Channels)[ch] : hwidEmpty;
965 if (SCID == hwidEmpty) {
966 ATH_MSG_DEBUG("No mapping for ch: " << std::dec << ch);
967 continue;
968 }
969 if (m_decoder->m_ignoreBarrelChannels && m_decoder->m_onlineId->barrel_ec(SCID) == 0)
970 continue;
971 if (m_decoder->m_ignoreEndcapChannels && m_decoder->m_onlineId->barrel_ec(SCID) == 1)
972 continue;
973
974 std::vector<uint64_t> sum;
975 std::vector<uint64_t> sum2;
976 unsigned int ntmin = 9999999;
978 for (auto nt : m_averagedRawValuesInEvent[ch].nTrigValid) {
979 if (nt < ntmin) {
980 ntmin = nt;
981 }
982 }
983 sum.resize(m_averagedRawValuesInEvent[ch].sum.size());
984 sum2.resize(m_averagedRawValuesInEvent[ch].sum.size());
985
986 if (ntmin > 0) {
987 for (unsigned int is = 0; is < m_averagedRawValuesInEvent[ch].sum.size(); ++is) {
988 double fsum = (double)m_averagedRawValuesInEvent[ch].sum[is] / m_averagedRawValuesInEvent[ch].nTrigValid[is] * ntmin;
989 double fsum2 = (double)m_averagedRawValuesInEvent[ch].sumSq[is] / m_averagedRawValuesInEvent[ch].nTrigValid[is] * ntmin;
990 sum[is] = round(fsum);
991 sum2[is] = round(fsum2);
992 }
993 } else {
994 std::fill(sum.begin(), sum.end(), 0);
995 std::fill(sum2.begin(), sum2.end(), 0);
996 if (++nWarnings < 64) {
997 ATH_MSG_WARNING("No valid triggers for supercell " << SCID.getString());
998 }
999 }
1000 if (m_accdigits) {
1001 LArAccumulatedDigit* accdigi = new LArAccumulatedDigit(SCID, gain, sum, sum2, ntmin);
1002 m_accdigits->push_back(accdigi);
1003 }
1004 if (m_caccdigits) {
1005 if (pattype == 0x49 || pattype == 0x4a) {
1006 if (m_decoder->m_onlineId->barrel_ec(SCID) == 0) {
1007 calibParams = calibParams1.get();
1008 } else {
1009 calibParams = calibParams2.get();
1010 }
1011 } else if (pattype == 0x4b || pattype == 0x4c) {
1012 if (m_decoder->m_onlineId->isHECchannel(SCID)) {
1013 calibParams = calibParams1.get();
1014 } else {
1015 calibParams = calibParams2.get();
1016 }
1017 } else {
1018 calibParams = calibParams1.get();
1019 }
1020 unsigned int eventNb = 0;
1021 unsigned int numCL = 0;
1022 unsigned int numPulsedLeg = 0;
1023 std::vector<Identifier> ccellIds(0);
1024 Identifier myofflineID = cabling->cnvToIdentifier(SCID);
1025 ccellIds = m_decoder->m_sc2ccMappingTool->superCellToOfflineID(myofflineID);
1026 for (Identifier id : ccellIds) { // loop cells in sc
1027 HWIdentifier cellLegHWID = cablingLeg->createSignalChannelID(id);
1028 const std::vector<HWIdentifier>& calibLineLeg = clcabling->calibSlotLine(cellLegHWID);
1029 numCL += calibLineLeg.size();
1030 for (HWIdentifier calibLineHWID : calibLineLeg) { // loop legacy calib lines
1031 if (calibParams->isPulsed(eventNb, calibLineHWID)) {
1032 numPulsedLeg += 1;
1033 }
1034 }
1035 }
1036
1037 isPulsed_value = true;
1038 if (numPulsedLeg != numCL) {
1039 if (m_decoder->m_keepPulsed)
1040 continue;
1041 isPulsed_value = false;
1042 }
1043 DAC_value = calibParams->DAC(eventNb, SCID) * numPulsedLeg;
1044 // Here we want to change the DAC value to reflect the incorrect factors applied in HEC, where some of the cells are much smaller yet have DAC2MeV factors
1045 // which came from averaging over many cells
1046 int ft = m_decoder->m_onlineId->feedthrough(SCID);
1047 int slot = m_decoder->m_onlineId->slot(SCID);
1048 int channel = m_decoder->m_onlineId->channel(SCID);
1049 if (m_decoder->m_onlineId->barrel_ec(SCID) == 1 && (ft == 3 || ft == 10 || ft == 16 || ft == 22)) {
1050 // if it's HEC
1051 if (slot == 1) {
1052 if (channel >= 16 && channel <= 31) { // eta 1.65 bin
1053 //DAC_value = DAC_value / 1.363; // measured value
1054 DAC_value = DAC_value / 1.2; // computed from geometry
1055 m_decoder->msg(MSG::DEBUG) << "Multiplying DAC for channel " << SCID << "by 1/1.2" << endmsg;
1056 } else if (channel >= 32 && channel <= 47) { // eta 1.75 bin
1057 //DAC_value = DAC_value / 1.206; // measured value
1058 DAC_value = DAC_value * 7. / 8.; // computed from geometry
1059 m_decoder->msg(MSG::DEBUG) << "Multiplying DAC for channel " << SCID << "by 7./8." << endmsg;
1060 }
1061 }
1062 }
1063
1064 delay_value = calibParams->Delay(eventNb, SCID);
1065 LArAccumulatedCalibDigit* accdigi = new LArAccumulatedCalibDigit(SCID, gain, sum, sum2, ntmin, DAC_value, delay_value, isPulsed_value);
1066
1067 m_caccdigits->push_back(accdigi);
1068 }
1069
1070 }
1071 if (nWarnings > 16) {
1072 ATH_MSG_WARNING("Found " << nWarnings << " supercells with no valid triggers");
1073 }
1074}
1075
1076// Pass ADC values from an event
1077void LArLATOMEDecoder::EventProcess::fillRaw(const std::vector<HWIdentifier>* LATOME_Channels) {
1078 // const CaloGain::CaloGain dummyGain = CaloGain::LARHIGHGAIN;
1079 const HWIdentifier hwidEmpty;
1080 for (SuperCell ch = 0; ch < N_LATOME_CHANNELS; ++ch) {
1081 const HWIdentifier SCID = ch < (int) LATOME_Channels->size() ? (*LATOME_Channels)[ch] : hwidEmpty;
1082 if (SCID == hwidEmpty) {
1083 ATH_MSG_DEBUG("No mapping for ch: " << std::dec << ch);
1084 continue;
1085 }
1086 if (m_decoder->m_ignoreBarrelChannels && m_decoder->m_onlineId->barrel_ec(SCID) == 0)
1087 continue;
1088 if (m_decoder->m_ignoreEndcapChannels && m_decoder->m_onlineId->barrel_ec(SCID) == 1)
1089 continue;
1090
1091 std::vector<short> adcValues_inChannel_inEvent;
1092
1093 if (m_hasRawAdc) {
1094 adcValues_inChannel_inEvent = m_rawValuesInEvent[ch].adc;
1095 }
1096
1097 if (m_hasRawAdc && m_adc_coll) {
1100
1101 std::vector<unsigned short> bcid_in_event;
1102 for (short b = m_BC_rawADC; b < m_BC_rawADC + m_nBC_rawADC; ++b) {
1103 bcid_in_event.push_back(m_BCIDsInEvent[b]);
1104 }
1105
1106 LArSCDigit* scDigit = new LArSCDigit(SCID, m_rawValuesInEvent[ch].latomeChannel, m_nthLATOME, adcValues_inChannel_inEvent, bcid_in_event);
1107 m_adc_coll->push_back(scDigit);
1108 }
1109
1110 if (m_hasAdc && m_adc_bas_coll) {
1111 std::vector<unsigned short> bcid_in_event;
1112 if (m_nBC_ADC == (short)m_BCIDsInEvent.size()) {
1113 bcid_in_event = m_BCIDsInEvent;
1114 } else {
1115 for (short b = m_BC_ADC; b < m_BC_ADC + m_nBC_ADC; ++b) {
1116 bcid_in_event.push_back(m_BCIDsInEvent[b]);
1117 }
1118 }
1119 LArSCDigit* scDigit = new LArSCDigit(SCID, m_rawValuesInEvent[ch].latomeChannel, m_nthLATOME, m_rawValuesInEvent[ch].adc_bas, bcid_in_event);
1120 m_adc_bas_coll->push_back(scDigit);
1121 }
1122
1123 if (m_hasE && m_et_coll) {
1124 std::vector<unsigned short> bcid_in_event;
1125 if (m_nBC_E == (unsigned short)m_BCIDsInEvent.size()) {
1126 bcid_in_event = m_BCIDsInEvent;
1127 } else {
1128 for (short b = m_BC_E; b < m_BC_E + m_nBC_E; ++b) {
1129 bcid_in_event.push_back(m_BCIDsInEvent[b]);
1130 }
1131 }
1132 LArRawSC* scDigit =
1133 new LArRawSC(SCID, m_rawValuesInEvent[ch].latomeChannel, m_nthLATOME, m_rawValuesInEvent[ch].et, bcid_in_event, m_rawValuesInEvent[ch].saturation);
1134 m_et_coll->push_back(scDigit);
1135 }
1136
1137 if (m_hasEID && m_et_id_coll) {
1138 std::vector<unsigned short> bcid_in_event;
1139 if (m_nBC_EID == (short)m_BCIDsInEvent.size()) {
1140 bcid_in_event = m_BCIDsInEvent;
1141 } else {
1142 for (short b = m_BC_EID; b < m_BC_EID + m_nBC_EID; ++b) {
1143 bcid_in_event.push_back(m_BCIDsInEvent[b]);
1144 }
1145 }
1146 LArRawSC* scDigit =
1147 new LArRawSC(SCID, m_rawValuesInEvent[ch].latomeChannel, m_nthLATOME, m_rawValuesInEvent[ch].et_id, bcid_in_event, m_rawValuesInEvent[ch].saturation);
1148 m_et_id_coll->push_back(scDigit);
1149 }
1150 }
1151}
1152
const std::regex re(r_e)
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
Tool to get LATOME SC and SCID mapping file and fill std::map variable with it.
static const InterfaceID IID_ILArLATOMEDecoder("LArLATOMEDecoder", 1, 0)
Byte stream converter of LATOME.
MonDataType
#define N_LATOME_CHANNELS
Tool to store LATOME mon header and footer data.
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition RawEvent.h:37
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
void clear()
Erase all the elements in the collection.
std::string getString() const
Provide a string form of the identifier - hexadecimal.
Container class for LArAccumulatedCalibDigit.
Data class for calibration ADC samples preprocessed by the DSP.
Container class for LArAccumulatedDigit.
Data class for ADC samples and autocorr preprocessed by the DSP.
const std::vector< HWIdentifier > & calibSlotLine(const HWIdentifier id) const
unsigned Delay(const unsigned event, const HWIdentifier calibLineID) const
bool isPulsed(const unsigned event, const HWIdentifier calibLineID) const
unsigned DAC(const unsigned event, const HWIdentifier calibLineID) const
Container class for LArDigit.
int signEnergy(unsigned int energy)
static const Word m_monTrailerSize
some cached info to ease processing reading from data header
std::vector< LatomeCalibPatterns > m_latomeCalibPatternsInEvent
void fillRaw(const std::vector< HWIdentifier > *LATOME_Channels)
Pass ADC values from an event.
unsigned int Word
this should be the same as how we get the data, otherwise we will have bugs.
LArLATOMEHeaderContainer * m_header_coll
EventProcess(const LArLATOMEDecoder *decoderInput, LArDigitContainer *adc_coll, LArDigitContainer *adc_bas_coll, LArRawSCContainer *et_coll, LArRawSCContainer *et_id_coll, LArAccumulatedDigitContainer *accdigits, LArAccumulatedCalibDigitContainer *caccdigits, LArLATOMEHeaderContainer *header_coll)
void decodeChannel(unsigned int &wordshift, unsigned int &byteshift, const uint32_t *p, MonDataType at0, MonDataType at1, unsigned int &at0Data, unsigned int &at1Data, unsigned int &satData, bool &at0val, bool &at1val)
void decodeByte(unsigned int &byte, unsigned int wordshift, unsigned int byteshift, const uint32_t *p)
LArAccumulatedDigitContainer * m_accdigits
const LArLATOMEDecoder * m_decoder
unsigned int bytesPerChannel(MonDataType at0, MonDataType at1)
void fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *pROB, const std::vector< HWIdentifier > *LATOME_Channels, const LArOnOffIdMapping *onoffmap=nullptr, const LArCalibLineMapping *clmap=nullptr)
Execute decoding for an event.
LArAccumulatedCalibDigitContainer * m_caccdigits
bool compareOrSet(Word &param, Word value, bool compare)
static const Word s_monHeaderMarker
this is fixed and not read from data
std::vector< LatomeRawData > m_rawValuesInEvent
std::vector< LatomeAveragedRawData > m_averagedRawValuesInEvent
unsigned int decodeHeader(const uint32_t *p, unsigned int offset)
std::vector< unsigned short > m_BCIDsInEvent
void increaseByteShift(unsigned int &wordshift, unsigned int &byteshift)
void decodeWord(unsigned int &word, unsigned int &wordshift, unsigned int &byteshift, const uint32_t *p)
void increaseWordShift(unsigned int &wordshift)
void fillCalib(const std::vector< HWIdentifier > *LATOME_Channels, const LArOnOffIdMapping *onoffmap, const LArCalibLineMapping *clmap)
unsigned int decodeTrailer(const uint32_t *p, unsigned int offset)
std::vector< unsigned int > patterns
static const InterfaceID & interfaceID()
StatusCode convert(const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &robFrags, const LArLATOMEMapping *map, LArDigitContainer *adc_coll, LArDigitContainer *adc_bas_coll, LArRawSCContainer *et_coll, LArRawSCContainer *et_id_coll, LArLATOMEHeaderContainer *header_coll) const
Converter.
LArLATOMEDecoder(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
virtual StatusCode initialize()
Initialize the converter.
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKeySC
const LArOnline_SuperCellID * m_onlineId
static const int s_nBunches
Maximum value of BCID.
ToolHandle< ICaloSuperCellIDTool > m_sc2ccMappingTool
BooleanProperty m_protectSourceId
Container class for LArLATOMEHeader.
Holds information from the LATOME Header.
class to provide SC mapping
HWIdentifier createSignalChannelID(const Identifier &id) const
create a HWIdentifier from an Identifier (not inline)
Container class for LArRawSC.
Liquid Argon SuperCell raw data.
Definition LArRawSC.h:19
Base class for LArDigits taken by LATOME.
Definition LArSCDigit.h:21
STL class.
singleton-like access to IMessageSvc via open function and helper
int ev
Definition globals.cxx:25
std::vector< std::string > patterns
Definition listroot.cxx:187
@ LARHIGHGAIN
Definition CaloGain.h:18
=============================================================================
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
Extra patterns decribing particle interation process.