ATLAS Offline Software
Loading...
Searching...
No Matches
CscROD_Decoder.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#include "CscROD_Decoder.h"
6
7#include <algorithm>
8
9#include "GaudiKernel/TypeNameString.h"
12#include "eformat/Issue.h"
13
14using eformat::helper::SourceIdentifier;
17
19Muon::CscROD_Decoder::CscROD_Decoder(const std::string& type, const std::string& name, const IInterface* parent) :
20 base_class(type, name, parent), m_cabling("CSCcablingSvc", name) {
21 declareProperty("IsCosmics", m_isCosmic = false);
22 declareProperty("IsOldCosmics", m_isOldCosmic = false);
23}
24
26 // get the cabling service
27 ATH_CHECK(m_cabling.retrieve());
28 ATH_CHECK(m_idHelperSvc.retrieve());
29 m_hid2re.set(&(*m_cabling), &m_idHelperSvc->cscIdHelper());
30 if (m_isCosmic) {
31 m_hid2re.set_isCosmic();
32 if (m_isOldCosmic) m_hid2re.set_isOldCosmic();
33 }
34 return StatusCode::SUCCESS;
35}
36
37void Muon::CscROD_Decoder::fillCollection(const xAOD::EventInfo& eventInfo, const ROBFragment& robFrag, CscRawDataContainer& rdoIDC) const {
38 ATH_MSG_DEBUG("in CscROD_Decode::fillCollection()");
39
40 // Check the ROB and ROD fragment . E.P.
41 try {
42 robFrag.check();
43 } catch (eformat::Issue& ex) {
44 ATH_MSG_DEBUG(ex.what());
45 return; // error in fragment - we search for no collection
46 }
47
48 uint32_t nstat = robFrag.nstatus();
49 if (nstat) {
50 const uint32_t* it;
51 robFrag.status(it);
52 if (*it) {
53 ATH_MSG_DEBUG("Error in ROB status word: 0x" << std::hex << *it << std::dec);
54 return;
55 }
56 }
57
58 eformat::helper::Version ver(robFrag.rod_version());
59 const uint16_t& rodMinorVersion = ver.minor_version();
60
61 ATH_MSG_DEBUG("in CscROD_Decoder::fillCollection :ROD version " << MSG::hex << rodMinorVersion << MSG::dec);
62
63 if (rodMinorVersion == 0x0200)
64 this->rodVersion2(robFrag, rdoIDC);
65 else if ((rodMinorVersion >> 8) == 4) { // minor ver. 0400 Oct. 2014
66 this->rodVersion2(robFrag, rdoIDC);
67 } else if (rodMinorVersion == 0x1 || // ROD version for CTB and DC3 - for backward compatibility
69 this->rodVersion1(robFrag, rdoIDC);
70 else if (rodMinorVersion == 0x0)
71 ATH_MSG_DEBUG("Empty ROB - doing nothing ");
72 else // ROD version for DC2 - old and obselete; for backward compatibility
73 this->rodVersion0(robFrag, rdoIDC);
74}
75
79uint32_t Muon::CscROD_Decoder::getHashId(const uint32_t word, std::string /*detdescr*/) const {
80 CscRODReadOut rodReadOut;
82 rodReadOut.set(&m_idHelperSvc->cscIdHelper());
83 rodReadOut.setChamberBitVaue(1);
84
85 uint32_t address = rodReadOut.fragmentToAddress(word);
86 Identifier moduleId = rodReadOut.decodeAddress(address);
87 // Identifier channelId = rodReadOut.decodeAddress(moduleId);
88 return rodReadOut.hashIdentifier(address, moduleId);
89}
90
92Identifier Muon::CscROD_Decoder::getChannelId(const uint32_t word, std::string /*detdescr*/) const {
93 CscRODReadOut rodReadOut;
95 rodReadOut.set(&m_idHelperSvc->cscIdHelper());
96 rodReadOut.setChamberBitVaue(1);
97
98 uint32_t address = rodReadOut.fragmentToAddress(word);
99 Identifier moduleId = rodReadOut.decodeAddress(address);
100 return rodReadOut.decodeAddress(address, moduleId);
101}
102
104void Muon::CscROD_Decoder::getSamples(const std::vector<uint32_t>& words, std::vector<uint16_t>& samples) const {
105 CscRODReadOut rodReadOut;
107 rodReadOut.set(&m_idHelperSvc->cscIdHelper());
108 rodReadOut.setChamberBitVaue(1);
109
110 for (unsigned int j = 0; j < words.size(); ++j) {
111 uint16_t amp1, amp2;
112 rodReadOut.decodeAmplitude(words[j], amp1, amp2);
113 samples.push_back(amp1);
114 samples.push_back(amp2);
115 }
116}
117
119 ATH_MSG_DEBUG(" ");
120 ATH_MSG_DEBUG("===================================================");
121 ATH_MSG_DEBUG("in CscROD_Decode::fillCollection() - ROD version 2");
122
123 const uint32_t& detev_type = robFrag.rod_detev_type();
124
125 CscRODReadOut rodReadOut;
126
127 rodReadOut.set(&m_idHelperSvc->cscIdHelper());
128 rodReadOut.setChamberBitVaue(1);
129
131 SourceIdentifier sid(robFrag.rod_source_id());
132 uint16_t subDetectorId = sid.subdetector_id();
133 uint32_t onlineRodId = sid.module_id();
134 ATH_MSG_DEBUG("Online ROD id is 0x" << MSG::hex << onlineRodId << MSG::dec);
135
136 uint16_t rodId = 0xFFFF;
137 bool check = m_cabling->offlineId(onlineRodId, rodId);
138 if (!check)
139 ATH_MSG_ERROR("enable to convert online ROD Id to offline ROD Id - "
140 << "check the cabling service ");
141 uint16_t idColl = m_cabling->collectionId(subDetectorId, rodId);
142
143 ATH_MSG_DEBUG("Online ROD / ROD / collection / subDetector IDs are 0x" << MSG::hex << onlineRodId << MSG::dec << " " << rodId << " "
144 << idColl << " " << subDetectorId);
145
146 // assert (subDetectorId == 0x6A || subDetectorId == 0x69); // 50 or 51
147
148 // Create the Csc container and use the cache to get it
149 std::unique_ptr<CscRawDataCollection> rawCollection(nullptr);
151 if (lock.alreadyPresent()) {
152 ATH_MSG_DEBUG("CSC RDO collection already exist with collection hash = " << idColl << " collection filling is skipped!");
153 return;
154 } else {
155 ATH_MSG_DEBUG("CSC RDO collection does not exist - creating a new one with hash = " << idColl);
156 rawCollection = std::make_unique<CscRawDataCollection>(idColl);
157 }
158
160 rawCollection->setSubDetectorId(subDetectorId);
161 rawCollection->setRodId(onlineRodId);
162 rawCollection->setOnlineId(idColl);
163
165 rawCollection->set_eventType(detev_type);
166
168 bool isSparsified = rawCollection->sparsified();
169
171 bool ne = rawCollection->neutron();
172
174 bool cal = rawCollection->calEnabled();
175
177 uint16_t latency = rawCollection->latency();
178
180 uint16_t calLayer = rawCollection->calLayer();
181
183 uint16_t calAmplitude = rawCollection->calAmplitude();
184
186 uint16_t samplingTime = rawCollection->rate();
187
189 uint16_t numSamples = detev_type & 0xFF;
190
191 ATH_MSG_DEBUG("Event Type: " << MSG::hex << detev_type << MSG::dec);
192 ATH_MSG_DEBUG("Sampling Time: " << samplingTime << " Number of Samples: " << numSamples);
193 ATH_MSG_DEBUG("Is Calibration Enabled?: " << cal << " Calibration Amplitude: " << calAmplitude);
194 ATH_MSG_DEBUG("Calibration Layer: " << calLayer << " Latency: " << latency);
195 ATH_MSG_DEBUG("Is neutron rejection ON?: " << ne << " Is sparsified data?: " << isSparsified);
196
197
199 uint32_t counter = 0;
200 uint32_t rpuSize = 0;
201
202 const unsigned int size = robFrag.rod_ndata();
203 ATH_MSG_DEBUG("CscROD_Decoder Total words received = " << size);
204
205 // uint32_t wordPos = 0;
206 PointerType vint; // OFFLINE_FRAGMENTS_NAMESPACE::
207 robFrag.rod_data(vint);
208
209 bool isHeaderWordNull = false; // header is 0 so couldn't retrieve rpuID and size.
210 bool isClusterWordsUnrealistic = false; // too many cluster words causes unrealistic strip position
211 while (counter < size) {
213 uint32_t header = vint[counter];
214 ATH_MSG_DEBUG("RPU Header word 0x" << MSG::hex << header << MSG::dec);
215 if (!header) { // rpu size and rpu id couldn't be figured out...
216 isHeaderWordNull = true;
217 break;
218 }
219 counter += 1;
220
222 uint16_t rpuID_raw = (header >> 24) & 0xFF;
223 ATH_MSG_DEBUG("RPU ID original = " << rpuID_raw);
224 // ROD version 3 (SLAC made) return 13 instead of 11 as of March 2010
225 uint16_t rpuID;
226 if (rpuID_raw == 13) {
227 rpuID = uint16_t(rpuID_raw - 2); // make 13 to 11...
228 } else {
229 rpuID = rpuID_raw;
230 }
231
232 ATH_MSG_DEBUG("RPU ID Updated = " << rpuID);
233
234 rawCollection->addRPU(rpuID);
235
237 uint16_t dataType = (header >> 16) & 0xFF;
238 rawCollection->addDataType(dataType);
239
241 uint32_t rSize = header & 0xFFFF;
242 rpuSize += rSize;
243 ATH_MSG_DEBUG("RPU size = " << rSize);
244
245
253 if (dataType == 1)
254 continue;
255 else if (dataType == 2) {
256 counter += rSize - 1;
257 ATH_MSG_DEBUG("Error condition encounted on RPU ID = " << rpuID << " continuing ...");
258 continue;
259 } else {
261
262 if (rSize == 1) {
263 ATH_MSG_DEBUG("TTTT Type = " << dataType << " with no data and no errors. "
264 << " Continue to next RPU ...");
265 continue;
266 }
267
269 uint32_t scaAddress = vint[counter];
270 ATH_MSG_DEBUG("SCA Address = " << scaAddress);
271 rawCollection->set_scaAddress(scaAddress);
272 counter += 1;
273
275 uint32_t precisionClusters = vint[counter];
276 ATH_MSG_DEBUG("Number of Precision Cluster word 0x" << MSG::hex << precisionClusters << MSG::dec);
277 uint32_t precisionClusterCounts = 0;
278 for (uint16_t k = 0; k < 4; k++) {
279 uint16_t counts = (precisionClusters >> (24 - k * 8)) & 0xFF;
280 precisionClusterCounts += counts;
281 ATH_MSG_DEBUG("Number of precision Cluster Counts - "
282 << "Layer Index = " << k << " Cluster Counts = " << counts);
283 unsigned int index = 0;
284 if (rpuID == 5)
285 index = k;
286 else if (rpuID == 11)
287 index = k + 5;
288 else
289 ATH_MSG_ERROR("RPU ID out of range " << rpuID);
290 rawCollection->set_spuCount(index, counts);
291 }
292 counter += 1;
293
295 uint32_t secondClusterWord = vint[counter];
296 ATH_MSG_DEBUG("Second cluster word 0x" << MSG::hex << secondClusterWord << MSG::dec);
297 counter += 1;
298
300 uint16_t nonPrecisionClusterCounts = (secondClusterWord >> 24) & 0xFF;
301 ATH_MSG_DEBUG("Summed Number of Clusters for non-precision layers " << nonPrecisionClusterCounts);
302 if (rpuID == 5) rawCollection->set_spuCount(4, nonPrecisionClusterCounts);
303 if (rpuID == 11)
304 rawCollection->set_spuCount(9, nonPrecisionClusterCounts); // all the counts are in position 5/10 for non-precision strips
305
307 bool triggerType = (secondClusterWord >> 21) & 0x1;
308 if (triggerType) rawCollection->set_triggerType();
309
311 bool samplingPhase = (secondClusterWord >> 20) & 0x1;
312 if (samplingPhase) rawCollection->set_samplingPhase();
313
315 uint8_t firstBitSummary = (secondClusterWord >> 16) & 0xF;
316 rawCollection->set_firstBitSummary(firstBitSummary);
317
319 uint16_t clusterDataWords = secondClusterWord & 0xFFFF;
320 ATH_MSG_DEBUG("Cluster Data Words = " << clusterDataWords);
321
323 uint32_t totalClusterCounts = nonPrecisionClusterCounts + precisionClusterCounts;
324 ATH_MSG_DEBUG("Total summed Cluster Count for precision and non-precision layers = " << totalClusterCounts);
325
326 if (totalClusterCounts == 0) {
327 ATH_MSG_DEBUG("No Cluster found - skipping to next RPU ");
328 counter += rSize - 4;
329 continue;
330 }
331
333 uint16_t clusterCount = 0;
334
335 while (clusterCount < totalClusterCounts) {
337 uint32_t address = vint[counter];
338
339 ATH_MSG_DEBUG("cluster location word 0x" << MSG::hex << address << MSG::dec);
340
341 uint32_t addr = rodReadOut.fragmentToAddress(address);
342 Identifier moduleId = rodReadOut.decodeAddress(addr);
343 Identifier channelId = rodReadOut.decodeAddress(addr, moduleId);
344 int stationId = m_idHelperSvc->cscIdHelper().stationName(channelId);
345 int currentLayer = m_idHelperSvc->cscIdHelper().wireLayer(channelId);
346 int orientation = m_idHelperSvc->cscIdHelper().measuresPhi(channelId);
347 int stripId = m_idHelperSvc->cscIdHelper().strip(channelId);
348
349 counter += 1;
350
352 uint32_t time_width = vint[counter];
353 ATH_MSG_DEBUG(" cluster time size word : stripId (CscIdHelper) 0x" << MSG::hex << time_width << MSG::dec << " " << stripId);
354 counter += 1;
355 uint16_t time = (time_width >> 16) & 0xFFF;
356 uint16_t width = time_width & 0xFFFF;
357 if (width > 192) {
358 isClusterWordsUnrealistic = true;
359 break;
360 }
361 bool isTimeComputed = (time_width >> 28) & 0x1;
362
363 uint16_t totalSampleWords = width * numSamples / 2 + (width * numSamples) % 2;
364
366 std::vector<uint16_t> amplitude;
367 for (int j = 0; j < totalSampleWords; ++j) {
368 uint16_t amp1, amp2;
369 rodReadOut.decodeAmplitude(vint[counter], amp1, amp2);
370 amplitude.push_back(amp1);
371 amplitude.push_back(amp2);
372 counter += 1;
373 }
374 clusterCount += 1;
375
377 uint16_t spuID = 0x0;
378 if (orientation == 0)
379 spuID = static_cast<uint16_t>((stationId - 50) * 5 + currentLayer - 1);
380 else
381 spuID = static_cast<uint16_t>(((stationId - 50) + 1) * 5 - 1);
382
383 uint32_t hashId = rodReadOut.hashIdentifier(addr, moduleId);
384
385 // To get rid of unhealthy word Careful!! It should be located after all the counter to look at the next words...
386 if (address == 0) {
387 ATH_MSG_INFO("Location word is not available and CscRawData is discarded!!");
388 continue;
389 }
390
391 CscRawData* rawData = new CscRawData(amplitude, address, idColl, time, spuID, width, hashId);
392 if (isTimeComputed) rawData->set_isTimeComputed();
393
394 rawCollection->push_back(rawData);
395 ATH_MSG_DEBUG(" idColl clusHashid spuID stationId :: "
396 << idColl << " " << hashId << " " << spuID << " " << stationId << " :: measphi" << orientation << " L"
397 << currentLayer << " strId " << stripId << " nStr " << width << " T" << time << " nSampWords "
398 << totalSampleWords << " " << m_idHelperSvc->cscIdHelper().show_to_string(channelId));
399 }
400
401 ATH_MSG_DEBUG("****Total Cluster count = " << clusterCount << " for RPU ID " << rpuID);
403 // If any of two RPU has problem, delete both.....likely have a problem
404
405 if (counter > rpuSize) {
406 ATH_MSG_INFO("ROB Fragment with ID 0x" << std::hex << robFrag.rod_source_id() << std::dec << " has word Counter ="
407 << counter << " must not exceed summed RPU sizes =" << rpuSize << " Discarded!!");
408
409 rawCollection->erase(rawCollection->begin(), rawCollection->end());
410 return;
411 }
412
414 if (counter < rpuSize) {
415 ATH_MSG_DEBUG("" << (rpuSize - counter) << " ghost words at the end of this RPU - skipping ...");
416 counter = rpuSize;
417 }
418 } // if (dataType == 1) else
419 } // while (counter<size)
420
421 // To reject unhealthy rob
422 if (isHeaderWordNull) {
423 ATH_MSG_INFO(" ROB Fragment with ID " << std::hex << robFrag.rod_source_id() << std::dec << " has null rpuID. Discarded!!");
424 rawCollection->erase(rawCollection->begin(), rawCollection->end());
425 }
426 if (isClusterWordsUnrealistic) {
427 ATH_MSG_INFO(" ROB Fragment with ID 0x" << std::hex << robFrag.rod_source_id() << std::dec
428 << " has too many cluster words. Discarded!!");
429 rawCollection->erase(rawCollection->begin(), rawCollection->end());
430 }
431
432
433 StatusCode status_lock = lock.addOrDelete(std::move(rawCollection));
434 if (status_lock.isFailure()) {
435 ATH_MSG_ERROR("Could not insert CscRawDataCollection into CscRawDataContainer...");
436 return;
437 }
438
439
440 ATH_MSG_DEBUG("end of CscROD_Decode::fillCollection()");
441}
442
444 ATH_MSG_DEBUG("in CscROD_Decode::fillCollection() - ROD version 1");
445
446 CscRODReadOutV1 rodReadOut;
447
448 // Csc Id Helper not needed :: initialize pointer to 0!
449 rodReadOut.set(nullptr);
450
451 // get some information
452 SourceIdentifier sid(robFrag.rod_source_id());
453
454 uint16_t subDetectorId = sid.subdetector_id();
455 uint16_t rodId = sid.module_id();
456
457 uint16_t idColl = m_cabling->collectionId(subDetectorId, rodId);
458
459 // assert (subDetectorId <= 1);
460
461 // Create the Csc container and use the cache to get it
462 std::unique_ptr<CscRawDataCollection> rawCollection(nullptr);
464 if (lock.alreadyPresent()) {
465 ATH_MSG_DEBUG("CSC RDO collection already exist with collection hash = " << idColl << " converting is skipped!");
466 return;
467 } else {
468 ATH_MSG_DEBUG("CSC RDO collection does not exist - creating a new one with hash = " << idColl);
469 rawCollection = std::make_unique<CscRawDataCollection>(idColl);
470 }
471
472 // set the ROD id and the subDector id
473 rawCollection->setSubDetectorId(subDetectorId);
474 rawCollection->setRodId(rodId);
475 rawCollection->setOnlineId(idColl);
476
477 const unsigned int size = robFrag.rod_ndata();
478 ATH_MSG_DEBUG("CscROD_Decoder Total words received = " << size);
479
480 PointerType p;
481 robFrag.rod_data(p);
482
483 // expected number of samples
484 // this is the first word in the ROD data block
485 uint32_t numSamples = p[0];
486 rawCollection->setNumSamples((uint16_t)numSamples);
487
488 // latency - the second word
489 uint16_t latency = (uint16_t)p[1];
490 rawCollection->setLatency(latency);
491
492 // the sampling rate
493 uint16_t samplingRate = (uint16_t)p[2];
494 rawCollection->setSamplingRate(samplingRate);
495 // rodReadOut.setSamplingTime(1000.0/samplingRate);
496
497 // the number of DPU is the fourth word
498 uint32_t numDPU = p[3];
499 rawCollection->setNumDPU((uint16_t)numDPU);
500
501 // size of the ROD data block
502 // expected size of the ROD header and footer
503 uint32_t rodHeader = rodReadOut.getHeaderSize();
504 uint32_t rodFooter = rodReadOut.getFooterSize();
505
506 // loop over data fragments and decode them to fill the collection v
507 // move the DPU header
508 bool dpuFragment = rodReadOut.isDPU(p[rodHeader]);
509 if (!dpuFragment) {
510 ATH_MSG_ERROR("expecting a DPU fragment, Aborting...");
511 return;
512 }
513
514 uint32_t i = rodHeader;
515
516 while (dpuFragment && i < (size - rodFooter)) {
517 // the DPU id follows the DPU header marker
518 i += 1;
519 uint32_t dpuID = p[i];
520
521 // number of channel blocks to follow
522 i += 1;
523 uint32_t numChannel = p[i];
524
525 // the satus word
526 i += 1;
527 // uint32_t status[6];
528 // for (int j=0; j < 6; j++) status[j] = p[i+j];
529
530 // miscellaneous debugging word
531 i += 6;
532 // uint32_t misc[2];
533 // for (int j=0; j < 2; j++) misc[j] = p[i+j];
534
535 // increase counter appropriately
536 i += 2;
537
538 // now check that there is a valid number of channel blocks to read
539 if (!rodReadOut.discard(numChannel)) {
540 for (unsigned int j = 0; j < numChannel; j++) {
541 // decode the channel block data
542 if (rodReadOut.isAddress(p[i])) {
543 rodReadOut.decodeAddress(p[i]);
544 // std::cout << "Found a CSC strip address = " << rodReadOut.address() << std::endl;
545 i += 1;
546 } else
547 ATH_MSG_ERROR("expecting an address fragment");
548 std::vector<uint16_t> amplitude;
549 for (unsigned int j = 1; j <= numSamples; j++) {
550 if ((j % 2) == 1) {
551 rodReadOut.decodeAmplitude(p[i]);
552 amplitude.push_back(rodReadOut.getAmp1());
553 if (amplitude.size() < numSamples) amplitude.push_back(rodReadOut.getAmp2());
554 i += 1;
555 }
556 }
557 uint32_t address = rodReadOut.address();
558 CscRawData* rawData = new CscRawData(amplitude, address, idColl, dpuID);
559 rawCollection->push_back(rawData);
560 }
561 } else { // this is a discard
562 ATH_MSG_INFO("this is a discard::numChannel = " << MSG::hex << numChannel);
563 }
564 // check that the new fragment is a DPU header block
565 if (i < (size - rodFooter)) dpuFragment = rodReadOut.isDPU(p[i]);
566 }
567
568
569 StatusCode status_lock = lock.addOrDelete(std::move(rawCollection));
570 if (status_lock.isFailure()) {
571 ATH_MSG_ERROR("Could not insert CscRawDataCollection into CscRawDataContainer...");
572 return;
573 }
574
575
576 }
577
579 ATH_MSG_DEBUG("in CscROD_Decode::fillCollection() - ROD version 0");
580
581 CscRODReadOutV0 rodReadOut;
582
583 // Csc Id Helper not needed :: initialize pointer to 0!
584 rodReadOut.set(nullptr);
585
586 const unsigned int size = robFrag.rod_ndata();
587 ATH_MSG_DEBUG("CscROD_Decoder Total words received = " << size);
588
589 PointerType p;
590 robFrag.rod_data(p);
591
592 // get some information
593 rodReadOut.decodeSourceID(p[3]);
594 uint16_t subDetectorId = rodReadOut.subDetectorId();
595 uint16_t rodId = rodReadOut.rodId();
596
597 // assert (subDetectorId <= 1);
598
599 uint16_t subId = (subDetectorId == 0x0) ? 0x6A : 0x69;
600
601 uint16_t idColl = m_cabling->collectionId(subId, rodId);
602
603 // Create the Csc container and use the cache to get it
604 std::unique_ptr<CscRawDataCollection> rawCollection(nullptr);
606 if (lock.alreadyPresent()) {
607 ATH_MSG_DEBUG("CSC RDO collection already exist with collection hash = " << idColl << " converting is skipped!");
608 return;
609 } else {
610 ATH_MSG_DEBUG("CSC RDO collection does not exist - creating a new one with hash = " << idColl);
611 rawCollection = std::make_unique<CscRawDataCollection>(idColl);
612 }
613
614 // set the ROD id and the subDector id
615 rawCollection->setSubDetectorId(subDetectorId);
616 rawCollection->setRodId(rodId);
617 rawCollection->setOnlineId(idColl);
618
619 uint32_t rodHeader = rodReadOut.getHeaderSize();
620 uint32_t rodFooter = rodReadOut.getFooterSize();
621
622 // loop over data fragments and decode them to fill the collection v
623 bool bodyFragment = rodReadOut.isBody(p[rodHeader]);
624 if (!bodyFragment) {
625 ATH_MSG_ERROR("expecting a body fragment, Aborting...");
626 return;
627 }
628 uint32_t i = rodHeader;
629 while (bodyFragment && i < (size - rodFooter)) {
630 if (rodReadOut.isAmplitude(p[i])) {
631 rodReadOut.decodeAmplitude(p[i], 1);
632 i += 1;
633 } else {
634 ATH_MSG_ERROR("expecting an amplitude fragment");
635 }
636 if (rodReadOut.isAmplitude(p[i])) {
637 rodReadOut.decodeAmplitude(p[i], 2);
638 i += 1;
639 } else
640 ATH_MSG_ERROR("expecting an amplitude fragment");
641 if (rodReadOut.isAddress(p[i])) {
642 rodReadOut.decodeAddress(p[i]);
643 i += 1;
644 } else
645 ATH_MSG_ERROR("expecting an address fragment");
646
647 std::vector<uint16_t> amplitudes;
648 amplitudes.push_back(rodReadOut.getAmp1());
649 amplitudes.push_back(rodReadOut.getAmp2());
650 amplitudes.push_back(rodReadOut.getAmp3());
651 amplitudes.push_back(rodReadOut.getAmp4());
652 CscRawData* rawData = new CscRawData(amplitudes, rodReadOut.address(), idColl);
653
654 rawCollection->push_back(rawData);
655
656 // check that the new fragment is body
657 bodyFragment = rodReadOut.isBody(p[i]);
658 }
659
660
661 StatusCode status_lock = lock.addOrDelete(std::move(rawCollection));
662 if (status_lock.isFailure()) {
663 ATH_MSG_ERROR("Could not insert CscRawDataCollection into CscRawDataContainer...");
664 return;
665 }
666
667
668 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
const double width
void decodeAmplitude(const uint32_t fragment, int index)
uint16_t subDetectorId() const
uint16_t rodId() const
uint16_t getAmp1() const
uint16_t getAmp2() const
uint32_t getHeaderSize()
bool isBody(const uint32_t fragment) const
bool isAddress(const uint32_t fragment) const
uint16_t getAmp4() const
uint32_t address(const Identifier &channelId, int &eta, int &phi) const
void set(const CscIdHelper *cscHelper)
uint32_t getFooterSize()
void decodeSourceID(uint32_t sourceId)
void decodeAddress(const uint32_t fragment)
uint16_t getAmp3() const
bool isAmplitude(const uint16_t fragment) const
uint32_t getHeaderSize()
bool discard(const uint32_t fragment) const
void decodeAmplitude(const uint32_t fragment)
uint32_t getFooterSize()
void set(const CscIdHelper *cscHelper)
uint32_t address(const Identifier &channelId, int &eta, int &phi) const
bool isAddress(const uint32_t fragment) const
bool isDPU(const uint32_t fragment) const
uint16_t getAmp1() const
void decodeAddress(const uint32_t fragment)
uint16_t getAmp2() const
Identifier decodeAddress(const uint32_t address) const
uint32_t hashIdentifier(const uint32_t address, const Identifier &moduleId) const
void set(const CscIdHelper *cscIdHelper)
void decodeAmplitude(const uint32_t fragment, uint16_t &amp1, uint16_t &amp2) const
void setChamberBitVaue(uint32_t value)
uint32_t fragmentToAddress(const uint32_t fragment) const
This container provides access to collections of CSC RDOs and a mechanism for recording them.
Class to hold the electronic output for a single CSC readout channel: n sampling ADC data + the addre...
Definition CscRawData.h:21
void set_isTimeComputed()
Definition CscRawData.h:122
StatusCode addOrDelete(std::unique_ptr< T > ptr)
IDC_WriteHandle getWriteHandle(IdentifierHash hash)
virtual Identifier getChannelId(const uint32_t word, std::string detdesription) const override
void rodVersion2(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, CscRawDataContainer &rdoIDC) const
CSC_Hid2RESrcID m_hid2re
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual StatusCode initialize() override
virtual void fillCollection(const xAOD::EventInfo &eventInfo, const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, CscRawDataContainer &rdoIDC) const override
virtual uint32_t getHashId(const uint32_t word, std::string detdesription) const override
void rodVersion0(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, CscRawDataContainer &rdoIDC) const
the ROD version
ServiceHandle< CSCcablingSvc > m_cabling
virtual void getSamples(const std::vector< uint32_t > &words, std::vector< uint16_t > &samples) const override
CscROD_Decoder(const std::string &type, const std::string &name, const IInterface *parent)
constructor
void rodVersion1(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, CscRawDataContainer &rdoIDC) const
bool eventType(EventType type) const
Check for one particular bitmask value.
@ IS_TESTBEAM
true: testbeam, false: full detector
const DataType * PointerType
Definition RawEvent.h:25
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27
Definition index.py:1
EventInfo_v1 EventInfo
Definition of the latest event info version.