fill RpcPads from a block of integers New version for data format 3.1 (ATLAS cosmics - NEW RPC READOUT)
474 {
475 bool skipSectorLogicDecoding = (sectorLogicContainer == nullptr);
476 if (skipSectorLogicDecoding)
ATH_MSG_DEBUG(
"Skip SectorLogic decoding, so SLROC.decodeFragment is not being processed");
477
478
479
480
481
482
483
484
485
487
488 const int size =
p.size();
489
492
493
494
495
496 if (
size > 0 && msgLvl(MSG::VERBOSE)) {
497 msg(MSG::VERBOSE) <<
"The size of this ROD-read is " <<
size <<
endmsg;
498 int decoded;
499 char decoded_char[1000];
500 for (
int i = 0;
i <
size;
i++) {
501 decoded = (
p[
i] & 0xf000) >> 12;
502 if (decoded < 0x4) sprintf(decoded_char, "Hit data");
503 if (decoded == 0x4) sprintf(decoded_char, "CM Footer");
504 if (decoded == 0x5) sprintf(decoded_char, "PAD Header");
505 if (decoded == 0x6) sprintf(decoded_char, "PAD/SL Subheader");
506 if (decoded == 0x7) sprintf(decoded_char, "PAD Footer");
507 if (decoded == 0x8) sprintf(decoded_char, "CM Subheader");
508 if (decoded == 0x9) sprintf(decoded_char, "RX Header");
509 if (decoded == 0xa) sprintf(decoded_char, "PAD Prefooter");
510 if (decoded == 0xb) sprintf(decoded_char, "RX Footer");
511 if (decoded == 0xc) sprintf(decoded_char, "CM Header");
512 if (decoded == 0xd) sprintf(decoded_char, "SL Header");
513 if (decoded == 0xe) sprintf(decoded_char, "RX Subheader");
514 if (decoded == 0xf) sprintf(decoded_char, "SL Footer");
515
516 msg(MSG::VERBOSE) <<
"word " <<
i <<
" = " << MSG::hex <<
p[
i] << MSG::dec <<
" " << MSG::hex << decoded << MSG::dec <<
" "
517 << decoded_char <<
endmsg;
518 }
519 }
520
523 return StatusCode::FAILURE;
524 }
525
526 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"The source ID is: " << MSG::hex << sourceId <<
endmsg;
527
530
531
533
534
535 Identifier thisPadOfflineId =
v.identify();
536
537
538 Identifier padOfflineId;
539 bool foundPad = false;
540
541 if (msgLvl(MSG::VERBOSE))
542 msg(MSG::VERBOSE) <<
"The offline ID request for conversion is "
544
545 bool isSLHeader = false;
546 bool isSLSubHeader = false;
547 bool isSLFooter = false;
548 bool isSLFragment = false;
549 bool isRXHeader = false;
550 bool isRXFooter = false;
551 bool isPADFragment = false;
552 bool isPadHeader = false;
553 bool isPadSubHeader = false;
554 bool isPadPreFooter = false;
555 bool isPadFooter = false;
556
557
558
559 RPCRXRODDecode myRPC;
560 RXReadOutStructure RXROS;
561 PadReadOutStructure PDROS;
562 SectorLogicRXReadOutStructure SLROS;
563 MatrixReadOutStructure matrixROS;
564 RPCRODStructure rodReadout;
565
566 char recField;
567 unsigned short int PadID = 99;
573 unsigned int SLBodyWords = 0;
574 unsigned int SL_data_sise = 500;
575 unsigned short int SLBuff[500];
576
577
579 uint16_t subDetectorID = (sourceId & 0xff0000) >> 16;
580
581 uint16_t side = (subDetectorID == eformat::MUON_RPC_BARREL_A_SIDE) ? 1 : 0;
583 if (msgLvl(MSG::VERBOSE)) {
584 msg(MSG::VERBOSE) <<
"subDetectorID = 0x" << MSG::hex << subDetectorID << MSG::dec <<
endmsg;
585
586 msg(MSG::VERBOSE) <<
"rodID = 0x" << MSG::hex << rodId << MSG::dec <<
endmsg;
588 }
589
590
591
592 for (uint16_t i = 0;
i <
size; ++
i) {
593
594
595 isRXHeader = false;
596 isRXFooter = false;
597 isPadHeader = false;
598 isPadSubHeader = false;
599 isPadPreFooter = false;
600 isPadFooter = false;
601 isSLHeader = false;
602 isSLSubHeader = false;
603 isSLFooter = false;
605
608 if (!skipSectorLogicDecoding) { SLROS.
decodeFragment(currentWord, recField); }
609
611 isRXHeader = true;
612 isSLFragment = false;
613 isPADFragment = false;
615 isPadSubHeader = true;
617 isRXFooter = true;
619 isPadHeader = true;
620 isSLFragment = false;
622 isPadPreFooter = true;
624 isPadFooter = true;
626 isSLHeader = true;
627 isSLFragment = true;
628 isPADFragment = false;
630 isSLFooter = true;
631 isSLFragment = false;
633 isSLSubHeader = true;
634 }
635
636
637 if (skipSectorLogicDecoding) {
638 isSLHeader = false;
639 isSLSubHeader = false;
640 isSLFragment = false;
641 isSLFooter = false;
642 }
643
644 SG::ReadCondHandle<RpcCablingCondData> cablingCondData{
m_rpcReadKey, ctx};
645 const RpcCablingCondData* rpcCabling{*cablingCondData};
646
647 if (msgLvl(MSG::VERBOSE)) {
648 char decoded_char[256];
649 if (isRXHeader) {
650 sprintf(decoded_char, " RX Header");
651 } else if (isRXFooter) {
652 sprintf(decoded_char, " RX Footer");
653 } else if (isSLHeader) {
654 sprintf(decoded_char, " SL Header");
655 } else if (isSLSubHeader) {
656 sprintf(decoded_char, " SL SubHeader");
657 } else if (isSLFooter) {
658 sprintf(decoded_char, " SL Footer");
659 } else if (isPadHeader) {
660 sprintf(decoded_char, " Pad Header");
661 } else if (isPadSubHeader) {
662 sprintf(decoded_char, " Pad SubHeader");
663 } else if (isPadPreFooter) {
664 sprintf(decoded_char, " Pad PreFooter");
665 } else if (isPadFooter) {
666 sprintf(decoded_char, " Pad Footer");
667 } else if (isSLFragment) {
668 sprintf(decoded_char, " SL Fragment");
669 } else if (isPADFragment) {
670 sprintf(decoded_char, " Pad Fragment");
671 } else {
672 sprintf(decoded_char, " Undecoded");
673 }
674
675 msg(MSG::VERBOSE) <<
i <<
" -->current data word is " << MSG::hex << currentWord << MSG::dec << decoded_char <<
endmsg;
676 }
677 if (isRXHeader) {
678 if (msgLvl(MSG::VERBOSE)) {
679 msg(MSG::VERBOSE) <<
" this is a RX Header " <<
endmsg;
680 msg(MSG::VERBOSE) <<
" Sector ID=" << RXROS.
RXid() <<
endmsg;
681 }
682
683
684
685
686
687
689 sectorForCabling = 2 * rodId + rxid;
690 sector =
side * 32 + sectorForCabling;
691
692
694 sector = 39;
695
696
698 sector = 40;
699
700 }
702 sector = 40;
703
704 }
705
706 } else if (isRXFooter) {
708 } else if (isSLHeader || isSLFragment || isSLSubHeader || isSLFooter) {
709
711
712 if (isSLHeader) {
713 SLBodyWords = 0;
714 slfel1id = SLROS.
fel1id();
716
717 ATH_MSG_VERBOSE(
" SL Header: slfel1id " << slfel1id <<
" slid: " << slid);
718 } else if (isSLSubHeader) {
720
722
723 }
724
725 else if (isSLFooter) {
726 if (SLindex > 1) {
ATH_MSG_VERBOSE(
"More than 2 SL fragments in sector " << sector); }
727
728 if (msgLvl(MSG::VERBOSE)) {
729 msg(MSG::VERBOSE) <<
" Number of data words in SectorLogicReadOut= " << SLBodyWords <<
endmsg;
730 msg(MSG::VERBOSE) <<
" TEST SL: " << foundSL <<
endmsg;
731
732
733 for (
unsigned short j = 0;
j < SLBodyWords;
j++) {
734 msg(MSG::VERBOSE) <<
" SL data word " <<
j <<
" : " << MSG::hex << SLBuff[
j] << MSG::dec <<
endmsg;
735 }
736 }
737
738
739
740
741 SectorLogicRXReadOut* sectorLogic = myRPC.
SLFragment();
742
743 if (sectorLogicContainer && !sectorLogicContainer->
findSector(sector, side)) {
744 slstatus = SLROS.
status();
746
747 RpcSectorLogic* sl = new RpcSectorLogic(sector, slfel1id, slbcid, slstatus, slcrc);
748 bool inputHeaderFound = false;
749 bool outputHeaderFound = false;
750 ATH_MSG_VERBOSE(
"New RpcSectorLogic: sector=" << sector <<
" fel1id=" << slfel1id <<
" BCID=" << slbcid);
751
754
761
763
766
768
772 inputHeaderFound = true;
774 if (!inputHeaderFound) {
776 } else {
783
784 RpcSLTriggerHit* slHit =
785 new RpcSLTriggerHit(rowinBcid, slPadId, ptid, roi, outerPlane, overlapPhi, overlapEta, triggerBcid);
788 ATH_MSG_VERBOSE(
"New input RpcSLTriggerHit: ptid, roi= " << ptid <<
" " << roi);
789 }
792 outputHeaderFound = true;
794 if (!outputHeaderFound) {
795 rowinBcid = 999;
796 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"ERROR: outputSLHeader missing !!" <<
endmsg;
797 } else {
799 outerPlane = 0;
800 overlapPhi = 0;
801
802 for (
int icand = 0; icand < SLROS.
nTriggerCand(); ++icand) {
807 RpcSLTriggerHit* slHit = new RpcSLTriggerHit(rowinBcid, 0, ptid, roi, outerPlane, overlapPhi,
808 overlapEta, triggerBcid);
810
812 ATH_MSG_VERBOSE(
"New output RpcSLTriggerHit: ptid, roi= " << ptid <<
" " << roi);
813 }
814
816 }
817 }
818 }
819 }
820
821 if (sectorLogicContainer) sectorLogicContainer->
push_back(sl);
822
823 if (sectorLogicContainer && !sectorLogicContainer->
setSector(sector, side)) {
824 ATH_MSG_VERBOSE(
"Sector " << sector <<
" decoded more than once in SL");
825 }
826 }
827
828 } else {
829 if (SLBodyWords >= SL_data_sise) {
831 return StatusCode::FAILURE;
832 }
833 SLBuff[SLBodyWords] = currentWord;
834 SLBodyWords++;
835 }
836
837 } else if (isPadHeader || isPADFragment) {
838
840
842
843 if (recField == 'H') {
844 PadID = PDROS.
padid();
845
846
848 if (PadID < 3) {
849 sector = 56;
850 } else {
851 sector = 55;
852
853 PadID -= 3;
854 }
855 }
856
857 side = (sector < 32) ? 0 : 1;
859
860
861 if (!rpcCabling->
giveOfflineId(side, sectorLogic, PadID, padOfflineId)) {
862 if (msgLvl(MSG::VERBOSE))
863 msg(MSG::VERBOSE) <<
"Cannot retrieve the OfflineID for the PAD n. " << PadID <<
" at side " <<
side
864 <<
" and sector " << sectorLogic <<
endmsg;
865 } else {
866 if (msgLvl(MSG::VERBOSE))
867 msg(MSG::VERBOSE) <<
"ID " <<
m_idHelperSvc->rpcIdHelper().show_to_string(padOfflineId)
868 <<
" associated to PAD n. " << PadID <<
" at side " <<
side <<
" and sector " << sectorLogic
870 }
871
872
873 if (thisPadOfflineId == padOfflineId) {
874 if (msgLvl(MSG::VERBOSE))
875 msg(MSG::VERBOSE) <<
" match found with ID " <<
m_idHelperSvc->rpcIdHelper().show_to_string(thisPadOfflineId)
876 <<
" requested for the conversion; return this collection" <<
endmsg;
877
878 foundPad = true;
879
880 v.setOnlineId(PadID);
882
883
884 v.setLvl1Id(PDROS.
l1id());
885
886 } else {
887 if (msgLvl(MSG::VERBOSE))
888 msg(MSG::VERBOSE) <<
" match NOT found with ID "
889 <<
m_idHelperSvc->rpcIdHelper().show_to_string(thisPadOfflineId)
890 <<
" requested for the conversion" <<
endmsg;
891 }
892 }
893
894
895 if (recField == 'S') {
896 if (foundPad) {
897 v.setBcId(PDROS.
bcid());
898 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"Found the subheader, setting bcid to: " << PDROS.
bcid() <<
endmsg;
899 }
900 }
901
902 if (recField == 'P') {
903 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"Found the prefooter" <<
endmsg;
904
906
907 if (currentWord & 0x0fff) {
908 if (msgLvl(MSG::VERBOSE))
909 msg(MSG::VERBOSE) <<
"Pad Busy status not zero ! value: " << MSG::hex << (currentWord & 0x0fff) << MSG::dec
911 }
912 }
913
914 if (recField == 'F') {
915 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
" Pad Footer " <<
endmsg;
917 if (msgLvl(MSG::VERBOSE) && PDROS.
errorCode() != 0) {
918 msg(MSG::VERBOSE) <<
"Pad Error flag not zero ! value: " << MSG::hex << PDROS.
errorCode() << MSG::dec <<
endmsg;
919 }
920
921
922 if (foundPad) {
923 foundPad = false;
924
925
926 if (!(PadID > 3 && sector % 2 > 0)) { return StatusCode::SUCCESS; }
927 }
928 }
929
930 isPadFooter ? isPADFragment = false : isPADFragment = true;
931
932 if (msgLvl(MSG::VERBOSE)) {
933 msg(MSG::VERBOSE) <<
" current word " << MSG::hex << currentWord << MSG::dec <<
endmsg;
934
935 msg(MSG::VERBOSE) <<
" ==isPADFragment= " << isPADFragment <<
endmsg;
936 msg(MSG::VERBOSE) <<
" calling pushword: " << MSG::hex << currentWord << MSG::dec <<
endmsg;
937 }
938
939 int foundCM = 0;
941
942 if (foundCM == 1) {
944
945
946 if (foundPad) {
948
949
950
951 matrixROS =
matrix->getHeader();
954
955 matrixROS =
matrix->getSubHeader();
957
958 if (msgLvl(MSG::VERBOSE))
959 msg(MSG::VERBOSE) <<
"Creating a new CM, cmaId=" << cmaId <<
" fel1id=" << fel1id <<
" febcid=" << febcid
961
962
964
965 matrixROS =
matrix->getFooter();
967
968
969
970
971 for (
int i = 0;
i <
matrix->numberOfBodyWords(); ++
i) {
972 matrixROS =
matrix->getCMAHit(i);
973
977
978 RpcFiredChannel* firedChan = 0;
979
980 if (ijk < 7) {
982 firedChan = new RpcFiredChannel(bcid, time, ijk, channel);
983
985 << " ijk=" << ijk << " channel=" << channel);
986
987
989 } else if (ijk == 7) {
992 firedChan = new RpcFiredChannel(bcid, time, ijk, threshold, overlap);
993
995 << " ijk=" << ijk << " overlap=" << overlap
996 << " threshold=" << threshold);
997
998
1000 }
1001 }
1002
1003 v.push_back(coinMatrix);
1004
1005 }
1006
1008
1009 }
1010 }
1011 }
1013
1014 return StatusCode::SUCCESS;
1015 }
size_t size() const
Number of registered mappings.
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()