fill RpcPads from a block of integers New version for data format 3.1 (ATLAS cosmics - NEW RPC READOUT)
468 {
469 bool skipSectorLogicDecoding = (sectorLogicContainer == nullptr);
470 if (skipSectorLogicDecoding)
ATH_MSG_DEBUG(
"Skip SectorLogic decoding, so SLROC.decodeFragment is not being processed");
471
472
473
474
475
476
477
478
479
481
482 const int size =
p.size();
483
486
487
488
489
490 if (size > 0 && msgLvl(MSG::VERBOSE)) {
491 msg(MSG::VERBOSE) <<
"The size of this ROD-read is " <<
size <<
endmsg;
492 int decoded;
493 char decoded_char[1000];
494 for (
int i = 0;
i <
size;
i++) {
495 decoded = (
p[
i] & 0xf000) >> 12;
496 if (decoded < 0x4) sprintf(decoded_char, "Hit data");
497 if (decoded == 0x4) sprintf(decoded_char, "CM Footer");
498 if (decoded == 0x5) sprintf(decoded_char, "PAD Header");
499 if (decoded == 0x6) sprintf(decoded_char, "PAD/SL Subheader");
500 if (decoded == 0x7) sprintf(decoded_char, "PAD Footer");
501 if (decoded == 0x8) sprintf(decoded_char, "CM Subheader");
502 if (decoded == 0x9) sprintf(decoded_char, "RX Header");
503 if (decoded == 0xa) sprintf(decoded_char, "PAD Prefooter");
504 if (decoded == 0xb) sprintf(decoded_char, "RX Footer");
505 if (decoded == 0xc) sprintf(decoded_char, "CM Header");
506 if (decoded == 0xd) sprintf(decoded_char, "SL Header");
507 if (decoded == 0xe) sprintf(decoded_char, "RX Subheader");
508 if (decoded == 0xf) sprintf(decoded_char, "SL Footer");
509
510 msg(MSG::VERBOSE) <<
"word " <<
i <<
" = " << MSG::hex <<
p[
i] << MSG::dec <<
" " << MSG::hex << decoded << MSG::dec <<
" "
511 << decoded_char <<
endmsg;
512 }
513 }
514
515 if (size == 0) {
517 return StatusCode::FAILURE;
518 }
519
520 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"The source ID is: " << MSG::hex << sourceId <<
endmsg;
521
524
525
527
528
529 Identifier thisPadOfflineId =
v.identify();
530
531
532 Identifier padOfflineId;
533 bool foundPad = false;
534
535 if (msgLvl(MSG::VERBOSE))
536 msg(MSG::VERBOSE) <<
"The offline ID request for conversion is "
538
539 bool isSLHeader = false;
540 bool isSLSubHeader = false;
541 bool isSLFooter = false;
542 bool isSLFragment = false;
543 bool isRXHeader = false;
544 bool isRXFooter = false;
545 bool isPADFragment = false;
546 bool isPadHeader = false;
547 bool isPadSubHeader = false;
548 bool isPadPreFooter = false;
549 bool isPadFooter = false;
550
551
552
553 RPCRXRODDecode myRPC;
554 RXReadOutStructure RXROS;
555 PadReadOutStructure PDROS;
556 SectorLogicRXReadOutStructure SLROS;
557 MatrixReadOutStructure matrixROS;
558 RPCRODStructure rodReadout;
559
560 char recField;
561 unsigned short int PadID = 99;
567 unsigned int SLBodyWords = 0;
568 unsigned int SL_data_sise = 500;
569 unsigned short int SLBuff[500];
570
571
573 uint16_t subDetectorID = (sourceId & 0xff0000) >> 16;
574
575 uint16_t side = (subDetectorID == eformat::MUON_RPC_BARREL_A_SIDE) ? 1 : 0;
577 if (msgLvl(MSG::VERBOSE)) {
578 msg(MSG::VERBOSE) <<
"subDetectorID = 0x" << MSG::hex << subDetectorID << MSG::dec <<
endmsg;
579
580 msg(MSG::VERBOSE) <<
"rodID = 0x" << MSG::hex << rodId << MSG::dec <<
endmsg;
582 }
583
584
585
586 for (uint16_t i = 0;
i <
size; ++
i) {
587
588
589 isRXHeader = false;
590 isRXFooter = false;
591 isPadHeader = false;
592 isPadSubHeader = false;
593 isPadPreFooter = false;
594 isPadFooter = false;
595 isSLHeader = false;
596 isSLSubHeader = false;
597 isSLFooter = false;
599
602 if (!skipSectorLogicDecoding) { SLROS.
decodeFragment(currentWord, recField); }
603
605 isRXHeader = true;
606 isSLFragment = false;
607 isPADFragment = false;
609 isPadSubHeader = true;
611 isRXFooter = true;
613 isPadHeader = true;
614 isSLFragment = false;
616 isPadPreFooter = true;
618 isPadFooter = true;
620 isSLHeader = true;
621 isSLFragment = true;
622 isPADFragment = false;
624 isSLFooter = true;
625 isSLFragment = false;
627 isSLSubHeader = true;
628 }
629
630
631 if (skipSectorLogicDecoding) {
632 isSLHeader = false;
633 isSLSubHeader = false;
634 isSLFragment = false;
635 isSLFooter = false;
636 }
637
638 SG::ReadCondHandle<RpcCablingCondData> cablingCondData{
m_rpcReadKey, Gaudi::Hive::currentContext()};
639 const RpcCablingCondData* rpcCabling{*cablingCondData};
640
641 if (msgLvl(MSG::VERBOSE)) {
642 char decoded_char[256];
643 if (isRXHeader) {
644 sprintf(decoded_char, " RX Header");
645 } else if (isRXFooter) {
646 sprintf(decoded_char, " RX Footer");
647 } else if (isSLHeader) {
648 sprintf(decoded_char, " SL Header");
649 } else if (isSLSubHeader) {
650 sprintf(decoded_char, " SL SubHeader");
651 } else if (isSLFooter) {
652 sprintf(decoded_char, " SL Footer");
653 } else if (isPadHeader) {
654 sprintf(decoded_char, " Pad Header");
655 } else if (isPadSubHeader) {
656 sprintf(decoded_char, " Pad SubHeader");
657 } else if (isPadPreFooter) {
658 sprintf(decoded_char, " Pad PreFooter");
659 } else if (isPadFooter) {
660 sprintf(decoded_char, " Pad Footer");
661 } else if (isSLFragment) {
662 sprintf(decoded_char, " SL Fragment");
663 } else if (isPADFragment) {
664 sprintf(decoded_char, " Pad Fragment");
665 } else {
666 sprintf(decoded_char, " Undecoded");
667 }
668
669 msg(MSG::VERBOSE) <<
i <<
" -->current data word is " << MSG::hex << currentWord << MSG::dec << decoded_char <<
endmsg;
670 }
671 if (isRXHeader) {
672 if (msgLvl(MSG::VERBOSE)) {
673 msg(MSG::VERBOSE) <<
" this is a RX Header " <<
endmsg;
674 msg(MSG::VERBOSE) <<
" Sector ID=" << RXROS.
RXid() <<
endmsg;
675 }
676
677
678
679
680
681
683 sectorForCabling = 2 * rodId + rxid;
684 sector =
side * 32 + sectorForCabling;
685
686
688 sector = 39;
689 sectorForCabling = 7;
690
692 sector = 40;
693 sectorForCabling = 8;
694 }
696 sector = 40;
697 sectorForCabling = 8;
698 }
699
700 } else if (isRXFooter) {
702 } else if (isSLHeader || isSLFragment || isSLSubHeader || isSLFooter) {
703
705
706 if (isSLHeader) {
707 SLBodyWords = 0;
708 slfel1id = SLROS.
fel1id();
710
711 ATH_MSG_VERBOSE(
" SL Header: slfel1id " << slfel1id <<
" slid: " << slid);
712 } else if (isSLSubHeader) {
714
716
717 }
718
719 else if (isSLFooter) {
720 if (SLindex > 1) {
ATH_MSG_VERBOSE(
"More than 2 SL fragments in sector " << sector); }
721
722 if (msgLvl(MSG::VERBOSE)) {
723 msg(MSG::VERBOSE) <<
" Number of data words in SectorLogicReadOut= " << SLBodyWords <<
endmsg;
724 msg(MSG::VERBOSE) <<
" TEST SL: " << foundSL <<
endmsg;
725
726
727 for (unsigned short j = 0; j < SLBodyWords; j++) {
728 msg(MSG::VERBOSE) <<
" SL data word " << j <<
" : " << MSG::hex << SLBuff[j] << MSG::dec <<
endmsg;
729 }
730 }
731
732
733
734
735 SectorLogicRXReadOut* sectorLogic = myRPC.
SLFragment();
736
737 if (sectorLogicContainer && !sectorLogicContainer->
findSector(sector, side)) {
738 slstatus = SLROS.
status();
740
741 RpcSectorLogic* sl = new RpcSectorLogic(sector, slfel1id, slbcid, slstatus, slcrc);
742 bool inputHeaderFound = false;
743 bool outputHeaderFound = false;
744 ATH_MSG_VERBOSE(
"New RpcSectorLogic: sector=" << sector <<
" fel1id=" << slfel1id <<
" BCID=" << slbcid);
745
748
755
757
760
762
766 inputHeaderFound = true;
768 if (!inputHeaderFound) {
770 } else {
777
778 RpcSLTriggerHit* slHit =
779 new RpcSLTriggerHit(rowinBcid, slPadId, ptid, roi, outerPlane, overlapPhi, overlapEta, triggerBcid);
782 ATH_MSG_VERBOSE(
"New input RpcSLTriggerHit: ptid, roi= " << ptid <<
" " << roi);
783 }
786 outputHeaderFound = true;
788 if (!outputHeaderFound) {
789 rowinBcid = 999;
790 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"ERROR: outputSLHeader missing !!" <<
endmsg;
791 } else {
793 outerPlane = 0;
794 overlapPhi = 0;
795
796 for (
int icand = 0; icand < SLROS.
nTriggerCand(); ++icand) {
801 RpcSLTriggerHit* slHit = new RpcSLTriggerHit(rowinBcid, 0, ptid, roi, outerPlane, overlapPhi,
802 overlapEta, triggerBcid);
804
806 ATH_MSG_VERBOSE(
"New output RpcSLTriggerHit: ptid, roi= " << ptid <<
" " << roi);
807 }
808
810 }
811 }
812 }
813 }
814
815 if (sectorLogicContainer) sectorLogicContainer->
push_back(sl);
816
817 if (sectorLogicContainer && !sectorLogicContainer->
setSector(sector, side)) {
818 ATH_MSG_VERBOSE(
"Sector " << sector <<
" decoded more than once in SL");
819 }
820 }
821
822 } else {
823 if (SLBodyWords >= SL_data_sise) {
825 return StatusCode::FAILURE;
826 }
827 SLBuff[SLBodyWords] = currentWord;
828 SLBodyWords++;
829 }
830
831 } else if (isPadHeader || isPADFragment) {
832
834
836
837 if (recField == 'H') {
838 PadID = PDROS.
padid();
839
840
842 if (PadID < 3) {
843 sector = 56;
844 } else {
845 sector = 55;
846
847 PadID -= 3;
848 }
849 }
850
851 side = (sector < 32) ? 0 : 1;
853
854
855 if (!rpcCabling->
giveOfflineId(side, sectorLogic, PadID, padOfflineId)) {
856 if (msgLvl(MSG::VERBOSE))
857 msg(MSG::VERBOSE) <<
"Cannot retrieve the OfflineID for the PAD n. " << PadID <<
" at side " <<
side
858 <<
" and sector " << sectorLogic <<
endmsg;
859 } else {
860 if (msgLvl(MSG::VERBOSE))
861 msg(MSG::VERBOSE) <<
"ID " <<
m_idHelperSvc->rpcIdHelper().show_to_string(padOfflineId)
862 <<
" associated to PAD n. " << PadID <<
" at side " <<
side <<
" and sector " << sectorLogic
864 }
865
866
867 if (thisPadOfflineId == padOfflineId) {
868 if (msgLvl(MSG::VERBOSE))
869 msg(MSG::VERBOSE) <<
" match found with ID " <<
m_idHelperSvc->rpcIdHelper().show_to_string(thisPadOfflineId)
870 <<
" requested for the conversion; return this collection" <<
endmsg;
871
872 foundPad = true;
873
874 v.setOnlineId(PadID);
876
877
878 v.setLvl1Id(PDROS.
l1id());
879
880 } else {
881 if (msgLvl(MSG::VERBOSE))
882 msg(MSG::VERBOSE) <<
" match NOT found with ID "
883 <<
m_idHelperSvc->rpcIdHelper().show_to_string(thisPadOfflineId)
884 <<
" requested for the conversion" <<
endmsg;
885 }
886 }
887
888
889 if (recField == 'S') {
890 if (foundPad) {
891 v.setBcId(PDROS.
bcid());
892 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"Found the subheader, setting bcid to: " << PDROS.
bcid() <<
endmsg;
893 }
894 }
895
896 if (recField == 'P') {
897 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"Found the prefooter" <<
endmsg;
898
900
901 if (currentWord & 0x0fff) {
902 if (msgLvl(MSG::VERBOSE))
903 msg(MSG::VERBOSE) <<
"Pad Busy status not zero ! value: " << MSG::hex << (currentWord & 0x0fff) << MSG::dec
905 }
906 }
907
908 if (recField == 'F') {
909 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
" Pad Footer " <<
endmsg;
911 if (msgLvl(MSG::VERBOSE) && PDROS.
errorCode() != 0) {
912 msg(MSG::VERBOSE) <<
"Pad Error flag not zero ! value: " << MSG::hex << PDROS.
errorCode() << MSG::dec <<
endmsg;
913 }
914
915
916 if (foundPad) {
917 foundPad = false;
918
919
920 if (!(PadID > 3 && sector % 2 > 0)) { return StatusCode::SUCCESS; }
921 }
922 }
923
924 isPadFooter ? isPADFragment = false : isPADFragment = true;
925
926 if (msgLvl(MSG::VERBOSE)) {
927 msg(MSG::VERBOSE) <<
" current word " << MSG::hex << currentWord << MSG::dec <<
endmsg;
928
929 msg(MSG::VERBOSE) <<
" ==isPADFragment= " << isPADFragment <<
endmsg;
930 msg(MSG::VERBOSE) <<
" calling pushword: " << MSG::hex << currentWord << MSG::dec <<
endmsg;
931 }
932
933 int foundCM = 0;
935
936 if (foundCM == 1) {
938
939
940 if (foundPad) {
942
943
944
945 matrixROS =
matrix->getHeader();
948
949 matrixROS =
matrix->getSubHeader();
951
952 if (msgLvl(MSG::VERBOSE))
953 msg(MSG::VERBOSE) <<
"Creating a new CM, cmaId=" << cmaId <<
" fel1id=" << fel1id <<
" febcid=" << febcid
955
956
958
959 matrixROS =
matrix->getFooter();
961
962
963
964
965 for (
int i = 0;
i <
matrix->numberOfBodyWords(); ++
i) {
966 matrixROS =
matrix->getCMAHit(i);
967
971
972 RpcFiredChannel* firedChan = 0;
973
974 if (ijk < 7) {
976 firedChan = new RpcFiredChannel(bcid, time, ijk, channel);
977
979 << " ijk=" << ijk << " channel=" << channel);
980
981
983 } else if (ijk == 7) {
986 firedChan = new RpcFiredChannel(bcid, time, ijk, threshold, overlap);
987
989 << " ijk=" << ijk << " overlap=" << overlap
990 << " threshold=" << threshold);
991
992
994 }
995 }
996
997 v.push_back(coinMatrix);
998
999 }
1000
1002
1003 }
1004 }
1005 }
1007
1008 return StatusCode::SUCCESS;
1009 }
std::vector< uint16_t > get16bits_v301(BS data, const int size, const int nHeader, const int nFooter) const
int pushWord(const ubit16 inword, uint NOBXS)
MatrixReadOut * CMFragment()
SectorLogicRXReadOut * SLFragment()
void setIsInput(bool isInput)
bool setSector(uint16_t sectorId, const uint16_t side=0)
Flag the sector as already decoded.
void setHasMoreThan2TriggerCand(const bool a)
ubit16 outputOverlap(int nCand) const
ubit16 decodeFragment(ubit16 inputWord, char &field)
ubit16 outputTriggerBcid(int) const
ubit16 outputThreshold(int nCand) const
ubit16 inputTriggerBcid() const
ubit16 outputRowinBcid() const
ubit16 nTriggerCand() const
ubit16 hasMoreThan2TriggerCand() const
ubit16 outputRoi(int nCand) const
ubit16 inputPadId() const
ubit16 inputOverlapPhi() const
ubit16 inputOverlapEta() const
ubit16 inputThreshold() const
ubit16 inputRowinBcid() const
ubit16 inputOuterPlane() const
uint16_t numberOfInputWords()
uint16_t readSLHitCurrent()