309 uint32_t sizeRawData = 0;
310 uint32_t sizeReadOutFormatHit = 0;
311 uint32_t sizeReadOutFormatTracklet = 0;
312 uint32_t sizeHipTWord = 0;
313 uint32_t sizeSectorLogicWord = 0;
316 bool isHeaderOK =
true;
318 unsigned int vDataIndex = 0;
319 for (; isHeaderOK; ++vDataIndex) {
324 if (rawdata_flag == 0xFF) {
331 switch (flagmentId) {
333 sizeRawData = counter;
336 sizeReadOutFormatHit = counter;
339 sizeReadOutFormatTracklet = counter;
348 sizeHipTWord = counter;
351 sizeSectorLogicWord = counter;
359 bool t_debug = (log.level() <= MSG::DEBUG);
361 if (!isHeaderOK || sizeRawData == 0 || sizeRawData >= 0x10000) {
362 unsigned int tmpRodId = rodId + (subDetectorId ==
CSIDE ?
NROD / 2 : 0);
363 if (tmpRodId >
NROD) {
367 if ((t_debug || !m_failedHeaderSizeRawData[tmpRodId])) {
368 log << (!m_failedHeaderSizeRawData[tmpRodId] ? MSG::WARNING
370 <<
"Corrupted data, Skip decoding of this ROD data"
371 <<
" TgcRODReadout : ROD ID= " << rodId
372 <<
" RawData Size= " << sizeRawData <<
endmsg;
373 log << (!m_failedHeaderSizeRawData[tmpRodId] ? MSG::WARNING
375 <<
"ReadOut Hit Size= " << sizeReadOutFormatHit
376 <<
" ReadOut Tracklet= " << sizeReadOutFormatTracklet
377 <<
" ReadOut SL= " << sizeSectorLogicWord
378 <<
" vDataIndex = " << vDataIndex <<
" HipT = " << sizeHipTWord
381 ++m_failedHeaderSizeRawData[tmpRodId];
383 return StatusCode::SUCCESS;
387 log << MSG::DEBUG <<
"TgcRODReadout : ROD ID=" << rodId
388 <<
" RawData Size=" << sizeRawData
389 <<
" ReadOut Hit Size= " << sizeReadOutFormatHit
390 <<
" ReadOut Tracklet= " << sizeReadOutFormatTracklet
391 <<
" ReadOut SL= " << sizeSectorLogicWord <<
endmsg;
394 uint32_t firstRawDataIndex = vDataIndex;
397 std::vector<TgcRawData*> vCh;
400 uint16_t fe_bcId = 0;
401 uint32_t fe_l1Id = 0;
402 uint16_t sswId = 999;
403 uint16_t slbId = 999;
406 uint16_t b_error = 0;
407 uint16_t rec_type = 999;
409 std::unique_ptr<TgcSlbData> slb{};
411 for (; vDataIndex < firstRawDataIndex + sizeRawData; ++vDataIndex) {
413 log << MSG::DEBUG <<
"Tgc BS Raw:" << vDataIndex <<
": "
414 << std::hex << vData[vDataIndex] << std::dec<<
endmsg;
421 if ((rawdata_flag == 0xff) || (rawdata_flag == 0xfc)) {
428 rec_type = (vData[vDataIndex] & 0x18000000) >> 27;
430 log << MSG::WARNING <<
"Rec Type " << rec_type
431 <<
" is not supproted "
432 <<
" Skip decoding of remaining hits of this event..."
434 return StatusCode::SUCCESS;
440 sswId = (vData[vDataIndex] & 0x0F0000) >> 16;
441 }
else if (rec_type == 1) {
443 sswId = (vData[vDataIndex] & 0x07800000) >> 23;
449 if (slb !=
nullptr) {
453 subDetectorId, rodId, slb.get(), vCh);
456 fe_l1Id = (vData[vDataIndex] & 0x0000F000) >> 12;
457 fe_bcId = vData[vDataIndex] & 0x00000FFF;
458 slbId = (vData[vDataIndex] & 0x1F000000) >> 24;
462 mod = (vData[vDataIndex] & 0x00070000) >> 16;
463 rxId = (vData[vDataIndex] & 0x00F80000) >> 19;
464 }
else if (rec_type == 1) {
466 mod = (vData[vDataIndex] & 0x000E0000) >> 17;
469 if (fe_l1Id != l1Id) {
472 <<
"l1Id in SLB Header is different from l1Id in "
474 <<
" for rodId:" << rodId <<
" slbId:" << slbId
475 <<
" l1Id, bcId (SLB):" << fe_l1Id <<
", "
476 << fe_bcId <<
" l1Id, bcId (ROD):" << l1Id <<
", "
484 if (vData[vDataIndex] & 0x10000000) {
487 b_error = vData[vDataIndex] & 0x0FFF;
492 rxId = (vData[vDataIndex] & 0x7C00000) >> 22;
505 std::make_unique<TgcSlbData>(
bcId, l1Id, sswId, slbId);
507 if (!
setSbLoc(subDetectorId, rodId, slb.get(), rxId,
509 unsigned int tmpRodId =
510 rodId + (subDetectorId ==
CSIDE ?
NROD / 2 : 0);
511 if (tmpRodId >
NROD) {
515 if ((t_debug || !m_failedSetSbLoc[tmpRodId])) {
516 log << (!m_failedSetSbLoc[tmpRodId] ? MSG::WARNING
518 <<
" Fail to set sbLoc"
519 <<
" :rodId=" << rodId <<
" :sswId=" << sswId
520 <<
" :slbAddress= " << slbId
521 <<
" : rxId= " << rxId <<
endmsg;
522 log << (!m_failedSetSbLoc[tmpRodId] ? MSG::WARNING
524 <<
"Corrupted data, Skip decoding of remaining "
525 "hits of this event..."
528 ++m_failedSetSbLoc[tmpRodId];
529 return StatusCode::SUCCESS;
533 unsigned int tmpRodId =
534 rodId + (subDetectorId ==
CSIDE ?
NROD / 2 : 0);
535 if (tmpRodId >
NROD) {
539 if ((t_debug || !m_failedSetType[tmpRodId])) {
540 log << (!m_failedSetType[tmpRodId] ? MSG::WARNING
542 <<
" Fail to set Module Type"
543 <<
" :rodId=" << rodId <<
" :sswId=" << sswId
544 <<
" :slbAddress= " << slbId <<
endmsg;
545 log << (!m_failedSetType[tmpRodId] ? MSG::WARNING
547 <<
"Corrupted data, Skip decoding of remaining "
548 "hits of this event..."
551 ++m_failedSetType[tmpRodId];
552 return StatusCode::SUCCESS;
555 slb->setError(b_error);
558 log << MSG::DEBUG <<
"TgcRODReadout : slb =" << slb
559 <<
" : rodId=" << rodId <<
" : sswId=" << sswId
560 <<
" : slbAddress= " << slbId <<
" : rxId= " << rxId
566 for (
int iHL = 0; iHL < 32;
568 uint32_t vd = vData[vDataIndex] << iHL;
579 slb->setError(vData[vDataIndex] & 0x0FFF);
585 unsigned long cellAddr = (vd & 0x1F000000) >> 24;
586 unsigned long cellBitMap = (vd & 0x00FF0000) >> 16;
590 slb->setBitmap(
bcTag, cellAddr, cellBitMap);
599 uint32_t error_context = (vData[vDataIndex] & 0x00FFFFFF);
600 uint16_t error_id = (vData[vDataIndex] & 0x01F000000) >> 24;
601 if ((t_debug && (error_context != 0))) {
602 log << MSG::DEBUG <<
"TgcRODReadout : Error Report "
603 <<
" : error id =" << error_id
604 <<
" : context =" << error_context <<
endmsg;
612 if (slb !=
nullptr) {
619 uint32_t firstROHitIndex = vDataIndex;
620 for (; vDataIndex < firstROHitIndex + sizeReadOutFormatHit;
622 log << MSG::DEBUG <<
"Tgc BS Readout HIT:" << vDataIndex <<
": "
623 << std::hex << vData[vDataIndex] <<
endmsg;
625 uint32_t firstROTrackletIndex = vDataIndex;
626 for (; vDataIndex < firstROTrackletIndex + sizeReadOutFormatTracklet;
628 log << MSG::DEBUG <<
"Tgc BS Readout HIT:" << vDataIndex <<
": "
629 << std::hex << vData[vDataIndex] <<
endmsg;
637 std::vector<TgcRawData*>::iterator ith = vCh.begin();
638 std::vector<TgcRawData*>::iterator ith_e = vCh.end();
641 for (; ith != ith_e; ++ith) {
648 log << MSG::DEBUG << n_vCh
649 <<
"words of were recorded in TgcRdo container" <<
endmsg;
652 return StatusCode::SUCCESS;
659 MsgStream& log)
const {
661 bool t_debug = (log.level() <= MSG::DEBUG);
665 bool isAside =
false;
666 bool isEndcap =
false;
669 int dummy_subDetectorId = 0;
673 int slbaddress_ret = 0;
677 if (!cabling.getSLBIDfromRxID(
phi, isAside, isEndcap, moduleType, slbId,
678 subDetectorId, rodId, sswId, rxId)) {
679 unsigned int tmpRodId = rodId + (subDetectorId ==
CSIDE ?
NROD / 2 : 0);
680 if (tmpRodId >
NROD) {
684 if (t_debug || !m_failedGetSLBIDfromRxID[tmpRodId]) {
685 log << (!m_failedGetSLBIDfromRxID[tmpRodId] ? MSG::WARNING
687 <<
" Fail to getSLBIDfromRxID "
688 <<
" :rodId=" << rodId <<
" :sswId=" << sswId
689 <<
" :rxId= " << rxId <<
endmsg;
691 m_failedGetSLBIDfromRxID[tmpRodId]++;
696 if (!cabling.getReadoutIDfromSLBID(
phi, isAside, isEndcap, moduleType,
697 slbId, dummy_subDetectorId, dummy_rodId,
698 dummy_sswId, sbLoc)) {
699 unsigned int tmpRodId = rodId + (subDetectorId ==
CSIDE ?
NROD / 2 : 0);
700 if (tmpRodId >
NROD) {
704 if ((t_debug || !m_failedGetReadoutIDfromSLBID[tmpRodId])) {
705 log << (!m_failedGetReadoutIDfromSLBID[tmpRodId] ? MSG::WARNING
707 <<
" Fail to getReadoutIDfromSLBID "
708 <<
" :rodId=" << rodId <<
" :sswId=" << sswId
709 <<
" :rxId= " << rxId <<
endmsg;
711 m_failedGetReadoutIDfromSLBID[tmpRodId]++;
716 if (cabling.getSLBAddressfromReadoutID(slbaddress_ret, subDetectorId, rodId,
719 if (slbaddress_ret != slb->
getSlbId()) {
721 log << MSG::DEBUG <<
" wrong getSLBAddress :"
722 <<
" :sswId = " << sswId <<
" :rxId = " << rxId
723 <<
":sbLoc = " << sbLoc <<
endmsg;
724 log << MSG::DEBUG <<
" :slbAddress = " << slb->
getSlbId()
725 <<
" expected value = " << slbaddress_ret <<
endmsg;