311 uint32_t sizeRawData = 0;
312 uint32_t sizeReadOutFormatHit = 0;
313 uint32_t sizeReadOutFormatTracklet = 0;
314 uint32_t sizeHipTWord = 0;
315 uint32_t sizeSectorLogicWord = 0;
318 bool isHeaderOK =
true;
320 unsigned int vDataIndex = 0;
321 for (; isHeaderOK; ++vDataIndex) {
326 if (rawdata_flag == 0xFF) {
333 switch (flagmentId) {
335 sizeRawData = counter;
338 sizeReadOutFormatHit = counter;
341 sizeReadOutFormatTracklet = counter;
350 sizeHipTWord = counter;
353 sizeSectorLogicWord = counter;
361 bool t_debug = (log.level() <= MSG::DEBUG);
363 if (!isHeaderOK || sizeRawData == 0 || sizeRawData >= 0x10000) {
364 unsigned int tmpRodId = rodId + (subDetectorId ==
CSIDE ?
NROD / 2 : 0);
365 if (tmpRodId >
NROD) {
369 if ((t_debug || !m_failedHeaderSizeRawData[tmpRodId])) {
370 log << (!m_failedHeaderSizeRawData[tmpRodId] ? MSG::WARNING
372 <<
"Corrupted data, Skip decoding of this ROD data"
373 <<
" TgcRODReadout : ROD ID= " << rodId
374 <<
" RawData Size= " << sizeRawData <<
endmsg;
375 log << (!m_failedHeaderSizeRawData[tmpRodId] ? MSG::WARNING
377 <<
"ReadOut Hit Size= " << sizeReadOutFormatHit
378 <<
" ReadOut Tracklet= " << sizeReadOutFormatTracklet
379 <<
" ReadOut SL= " << sizeSectorLogicWord
380 <<
" vDataIndex = " << vDataIndex <<
" HipT = " << sizeHipTWord
383 ++m_failedHeaderSizeRawData[tmpRodId];
385 return StatusCode::SUCCESS;
389 log << MSG::DEBUG <<
"TgcRODReadout : ROD ID=" << rodId
390 <<
" RawData Size=" << sizeRawData
391 <<
" ReadOut Hit Size= " << sizeReadOutFormatHit
392 <<
" ReadOut Tracklet= " << sizeReadOutFormatTracklet
393 <<
" ReadOut SL= " << sizeSectorLogicWord <<
endmsg;
396 uint32_t firstRawDataIndex = vDataIndex;
399 std::vector<TgcRawData*> vCh;
402 uint16_t fe_bcId = 0;
403 uint32_t fe_l1Id = 0;
404 uint16_t sswId = 999;
405 uint16_t slbId = 999;
408 uint16_t b_error = 0;
409 uint16_t rec_type = 999;
411 std::unique_ptr<TgcSlbData> slb{};
413 for (; vDataIndex < firstRawDataIndex + sizeRawData; ++vDataIndex) {
415 log << MSG::DEBUG <<
"Tgc BS Raw:" << vDataIndex <<
": "
416 << std::hex << vData[vDataIndex] <<
endmsg;
423 if ((rawdata_flag == 0xff) || (rawdata_flag == 0xfc)) {
430 rec_type = (vData[vDataIndex] & 0x18000000) >> 27;
432 log << MSG::WARNING <<
"Rec Type " << rec_type
433 <<
" is not supproted "
434 <<
" Skip decoding of remaining hits of this event..."
436 return StatusCode::SUCCESS;
442 sswId = (vData[vDataIndex] & 0x0F0000) >> 16;
443 }
else if (rec_type == 1) {
445 sswId = (vData[vDataIndex] & 0x07800000) >> 23;
451 if (slb !=
nullptr) {
455 subDetectorId, rodId, slb.get(), vCh);
458 fe_l1Id = (vData[vDataIndex] & 0x0000F000) >> 12;
459 fe_bcId = vData[vDataIndex] & 0x00000FFF;
460 slbId = (vData[vDataIndex] & 0x1F000000) >> 24;
464 mod = (vData[vDataIndex] & 0x00070000) >> 16;
465 rxId = (vData[vDataIndex] & 0x00F80000) >> 19;
466 }
else if (rec_type == 1) {
468 mod = (vData[vDataIndex] & 0x000E0000) >> 17;
471 if (fe_l1Id != l1Id) {
474 <<
"l1Id in SLB Header is different from l1Id in "
476 <<
" for rodId:" << rodId <<
" slbId:" << slbId
477 <<
" l1Id, bcId (SLB):" << fe_l1Id <<
", "
478 << fe_bcId <<
" l1Id, bcId (ROD):" << l1Id <<
", "
486 if (vData[vDataIndex] & 0x10000000) {
489 b_error = vData[vDataIndex] & 0x0FFF;
494 rxId = (vData[vDataIndex] & 0x7C00000) >> 22;
507 std::make_unique<TgcSlbData>(
bcId, l1Id, sswId, slbId);
509 if (!
setSbLoc(subDetectorId, rodId, slb.get(), rxId,
511 unsigned int tmpRodId =
512 rodId + (subDetectorId ==
CSIDE ?
NROD / 2 : 0);
513 if (tmpRodId >
NROD) {
517 if ((t_debug || !m_failedSetSbLoc[tmpRodId])) {
518 log << (!m_failedSetSbLoc[tmpRodId] ? MSG::WARNING
520 <<
" Fail to set sbLoc"
521 <<
" :rodId=" << rodId <<
" :sswId=" << sswId
522 <<
" :slbAddress= " << slbId
523 <<
" : rxId= " << rxId <<
endmsg;
524 log << (!m_failedSetSbLoc[tmpRodId] ? MSG::WARNING
526 <<
"Corrupted data, Skip decoding of remaining "
527 "hits of this event..."
530 ++m_failedSetSbLoc[tmpRodId];
531 return StatusCode::SUCCESS;
535 unsigned int tmpRodId =
536 rodId + (subDetectorId ==
CSIDE ?
NROD / 2 : 0);
537 if (tmpRodId >
NROD) {
541 if ((t_debug || !m_failedSetType[tmpRodId])) {
542 log << (!m_failedSetType[tmpRodId] ? MSG::WARNING
544 <<
" Fail to set Module Type"
545 <<
" :rodId=" << rodId <<
" :sswId=" << sswId
546 <<
" :slbAddress= " << slbId <<
endmsg;
547 log << (!m_failedSetType[tmpRodId] ? MSG::WARNING
549 <<
"Corrupted data, Skip decoding of remaining "
550 "hits of this event..."
553 ++m_failedSetType[tmpRodId];
554 return StatusCode::SUCCESS;
557 slb->setError(b_error);
560 log << MSG::DEBUG <<
"TgcRODReadout : slb =" << slb
561 <<
" : rodId=" << rodId <<
" : sswId=" << sswId
562 <<
" : slbAddress= " << slbId <<
" : rxId= " << rxId
568 for (
int iHL = 0; iHL < 32;
570 uint32_t vd = vData[vDataIndex] << iHL;
581 slb->setError(vData[vDataIndex] & 0x0FFF);
587 unsigned long cellAddr = (vd & 0x1F000000) >> 24;
588 unsigned long cellBitMap = (vd & 0x00FF0000) >> 16;
592 slb->setBitmap(
bcTag, cellAddr, cellBitMap);
601 uint32_t error_context = (vData[vDataIndex] & 0x00FFFFFF);
602 uint16_t error_id = (vData[vDataIndex] & 0x01F000000) >> 24;
603 if ((t_debug && (error_context != 0))) {
604 log << MSG::DEBUG <<
"TgcRODReadout : Error Report "
605 <<
" : error id =" << error_id
606 <<
" : context =" << error_context <<
endmsg;
614 if (slb !=
nullptr) {
621 uint32_t firstROHitIndex = vDataIndex;
622 for (; vDataIndex < firstROHitIndex + sizeReadOutFormatHit;
624 log << MSG::DEBUG <<
"Tgc BS Readout HIT:" << vDataIndex <<
": "
625 << std::hex << vData[vDataIndex] <<
endmsg;
627 uint32_t firstROTrackletIndex = vDataIndex;
628 for (; vDataIndex < firstROTrackletIndex + sizeReadOutFormatTracklet;
630 log << MSG::DEBUG <<
"Tgc BS Readout HIT:" << vDataIndex <<
": "
631 << std::hex << vData[vDataIndex] <<
endmsg;
639 std::vector<TgcRawData*>::iterator ith = vCh.begin();
640 std::vector<TgcRawData*>::iterator ith_e = vCh.end();
643 for (; ith != ith_e; ++ith) {
650 log << MSG::DEBUG << n_vCh
651 <<
"words of were recorded in TgcRdo container" <<
endmsg;
654 return StatusCode::SUCCESS;
661 MsgStream& log)
const {
663 bool t_debug = (log.level() <= MSG::DEBUG);
667 bool isAside =
false;
668 bool isEndcap =
false;
671 int dummy_subDetectorId = 0;
675 int slbaddress_ret = 0;
679 if (!cabling.getSLBIDfromRxID(
phi, isAside, isEndcap, moduleType, slbId,
680 subDetectorId, rodId, sswId, rxId)) {
681 unsigned int tmpRodId = rodId + (subDetectorId ==
CSIDE ?
NROD / 2 : 0);
682 if (tmpRodId >
NROD) {
686 if (t_debug || !m_failedGetSLBIDfromRxID[tmpRodId]) {
687 log << (!m_failedGetSLBIDfromRxID[tmpRodId] ? MSG::WARNING
689 <<
" Fail to getSLBIDfromRxID "
690 <<
" :rodId=" << rodId <<
" :sswId=" << sswId
691 <<
" :rxId= " << rxId <<
endmsg;
693 m_failedGetSLBIDfromRxID[tmpRodId]++;
698 if (!cabling.getReadoutIDfromSLBID(
phi, isAside, isEndcap, moduleType,
699 slbId, dummy_subDetectorId, dummy_rodId,
700 dummy_sswId, sbLoc)) {
701 unsigned int tmpRodId = rodId + (subDetectorId ==
CSIDE ?
NROD / 2 : 0);
702 if (tmpRodId >
NROD) {
706 if ((t_debug || !m_failedGetReadoutIDfromSLBID[tmpRodId])) {
707 log << (!m_failedGetReadoutIDfromSLBID[tmpRodId] ? MSG::WARNING
709 <<
" Fail to getReadoutIDfromSLBID "
710 <<
" :rodId=" << rodId <<
" :sswId=" << sswId
711 <<
" :rxId= " << rxId <<
endmsg;
713 m_failedGetReadoutIDfromSLBID[tmpRodId]++;
718 if (cabling.getSLBAddressfromReadoutID(slbaddress_ret, subDetectorId, rodId,
721 if (slbaddress_ret != slb->
getSlbId()) {
723 log << MSG::DEBUG <<
" wrong getSLBAddress :"
724 <<
" :sswId = " << sswId <<
" :rxId = " << rxId
725 <<
":sbLoc = " << sbLoc <<
endmsg;
726 log << MSG::DEBUG <<
" :slbAddress = " << slb->
getSlbId()
727 <<
" expected value = " << slbaddress_ret <<
endmsg;