481 {
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
502 Xgt[irow][icolumn] = 0;
503 XgtF[irow][icolumn] = 0;
504 Xsaturation[irow][icolumn] = 0;
505 }
506 }
507
508 FiberTower.fill(0);
509 FiberTowerSatur.fill(0);
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525 *BCIDptr = (Xfiber[0][
gPos::W280-1]&0x007F0000) >>16;
526
527
528 std::array<int, gPos::AB_TOWERS> etowerData{};
529 std::array<int, gPos::AB_TOWERS> htowerData{};
530 std::array<int, gPos::ABC_ROWS> xetowerData{};
531 std::array<int, gPos::ABC_ROWS> xhtowerData{};
532 std::array<int, gPos::ABC_ROWS> ohtowerData{};
533
534
535 std::array<int, gPos::AB_TOWERS> etowerDataF{};
536 std::array<int, gPos::AB_TOWERS> htowerDataF{};
537 std::array<int, gPos::ABC_ROWS> xetowerDataF{};
538 std::array<int, gPos::ABC_ROWS> xhtowerDataF{};
539 std::array<int, gPos::ABC_ROWS> ohtowerDataF{};
540
541
542
543
544
546 gFields fiberFieldsUndecoded{{}};
547 gSatur fiberSaturation{{}};
548
550
551
552
553 for(
unsigned int i=0;
i<100;
i++){
554
555 if (XMPD_NFI[i] < 0) continue;
556
557 if( ( Xfiber[i][
gPos::W280-1] & 0x000000FF ) == 0x000000BC ) {
558
559 fiberFields[
i][16] = 1;
560 }
561 else {
562 fiberFields[
i][16] = 0;
563 }
564
565
566 fiberFields[
i][18] = ( Xfiber[
i][
gPos::W280-1] & 0x007F0000) >>16 ;
567 fiberFields[
i][19] = ( Xfiber[
i][
gPos::W280-1] & 0xFF800000) >>23 ;
568
569 if (XMPD_DTYP_ARR[ XMPD_NFI[i] ][17] == 8) {
570
571 fiberFields[
i][17] = ( Xfiber[
i][
gPos::W280-1] & 0x0000FF00) >>8 ;
572
573
574
575
576
577
578
579
580
581
582
583
584
585 for(
unsigned int k=0;
k<8;
k++){
586 if( fiberFields[i][17] & (1<<k) ) {
587 fiberSaturation[
i][
k] = 1;
588
589
590 if ( XMPD_DTYP_ARR[XMPD_NFI[i]][2*k] == 0) {
591
592 fiberFieldsSatur[
i][2*
k] = 1;
593 } else if ( XMPD_DTYP_ARR[XMPD_NFI[i]][k] != 1) {
594
595
596 if (!(XFPGA == 1 && XMPD_DTYP_ARR[XMPD_NFI[i]][k] == 11)) {
597 fiberFieldsSatur[
i][
k] = 1;
598 }
599 }
600 }
601 }
602 }
603
604 for (
unsigned int k=0;
k<8; ++
k){
605 int krow = XMPD_GTRN_ARR[
i][
k]/12;
606 int kcolumn = XMPD_GTRN_ARR[
i][
k]%12;
607
608 int korow = XMPD_GTRN_ARR[
i][
k];
609 int kxrow = XMPD_GTRN_ARR[
i][
k];
610
611 int kocolumn = 4;
612 int kxcolumn = 0;
613
614
615 if (XFPGA == 0){
616 kocolumn = 4;
617 kxcolumn = 0;
618 } else if (XFPGA == 1){
619 kocolumn = 7;
620 kxcolumn = 11;
621 }
622
623 if (fiberSaturation[i][k] == 1){
624
625 if ( ( XMPD_DTYP_ARR[XMPD_NFI[i]][2*k] == 0 ) && ( XMPD_GTRN_ARR[i][2*k] > -1 ) ){
626 int krow2 = XMPD_GTRN_ARR[
i][2*
k]/12;
627 int kcolumn2 = XMPD_GTRN_ARR[
i][2*
k]%12;
628 Xsaturation[krow2][kcolumn2] = 1;
629 }
630
631
632
633
634
635
636
637
638 if( (XFPGA != 1) && (XMPD_DTYP_ARR[ XMPD_NFI[i] ][k] == 11 ) && ( XMPD_GTRN_ARR[i][k] > -1 ) ){
639 Xsaturation[ krow][kcolumn] = 1;
640 }
641
642
643
644 if (XFPGA < 2) {
645
646 if( (XMPD_DTYP_ARR[ XMPD_NFI[i] ][k] == 3 ) && ( XMPD_GTRN_ARR[i][k] > -1 ) ){
647 Xsaturation[ kxrow][kxcolumn] = 1;
648 }
649
650 if( (XMPD_DTYP_ARR[ XMPD_NFI[i] ][k] == 2 ) && ( XMPD_GTRN_ARR[i][k] > -1 ) ){
651 Xsaturation[ kxrow][kxcolumn] = 1;
652 }
653
654 if( (XMPD_DTYP_ARR[ XMPD_NFI[i] ][k] == 6 ) && ( XMPD_GTRN_ARR[i][k] > -1 ) ){
655 Xsaturation[ korow][kocolumn] = 1;
656 }
657 } else {
658
659 if( (XMPD_DTYP_ARR[ XMPD_NFI[i] ][k] == 3 ) && ( XMPD_GTRN_ARR[i][k] > -1 ) ){
660 Xsaturation[ krow][kcolumn] = 1;
661 }
662 if( (XMPD_DTYP_ARR[ XMPD_NFI[i] ][k] == 2 ) && ( XMPD_GTRN_ARR[i][k] > -1 ) ){
663 Xsaturation[ krow][kcolumn] = 1;
664 }
665 }
666
667
668
669
670
671
672
673
674
675
676 }
677 }
678 }
679
680
681 for(int iFiber = 0; iFiber < Xin; iFiber++) {
682
683 std::array<uint32_t, 6>
tmp;
684 for(
int i = 0;
i < 6;
i++){
tmp[
i] = Xfiber[iFiber][
i]; };
685
687 int withoutComma = Xfiber[iFiber][6] & 0xFFFFFF00 ;
688 CRC =
crc9d23(withoutComma, CRC, 1 );
689 uint32_t StoredCRC = ( (Xfiber[iFiber][6]>>23) & 0x000001FF);
690 if( (CRC != StoredCRC) && (StoredCRC != 0 ) ) {
691
692 std::stringstream sdetail;
693 sdetail << "[gFexInputByteStreamTool::gtReconstructABC]: Fiber " << iFiber << "of Xin " << Xin << ": BAD New CRC: " << CRC << "Stored CRC "<< StoredCRC ;
694 std::stringstream slocation;
695 slocation << "Fiber " << iFiber << "of Xin " << Xin;
696 std::stringstream stitle;
697 stitle << "Bad CRC" ;
698 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
699
700 }
701
702
703 int fiber_type = XMPD_NFI[iFiber];
704
705 for(int iDatum = 0; iDatum < 16; iDatum++) {
706
707 int dataType = XMPD_DTYP_ARR[fiber_type][iDatum];
708
709 int ntower = XMPD_GTRN_ARR[iFiber][iDatum];
710 if( ntower == -1 ){
711 ATH_MSG_DEBUG(
"[gFexInputByteStreamTool::gtReconstructABC: unused location iFiber "<< iFiber <<
", calo type "<< XCALO_TYPE[iFiber]<<
", data type "<< dataType <<
", iDatum " << iDatum <<
"tower " << ntower);
712 }
713 else if( (ntower < 0) || (ntower >383) ){
714
715 std::stringstream sdetail;
716 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC: bad value of ntower: iFiber "<< iFiber<<
", calo type"<< XCALO_TYPE[iFiber]<<
", data type "<<
dataType<<
", iDatum "<< iDatum<<
"tower "<< ntower ;
717 std::stringstream slocation;
718 slocation << "iFiber "<< iFiber<< ", calo type"<< XCALO_TYPE[iFiber];
719 std::stringstream stitle;
720 stitle << "Bad value of ntower" ;
721 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
722
723 }
724
725
726
727 int ihigh = XMPD_DSTRT_ARR[fiber_type][iDatum];
728 int ihword = ihigh/32;
729 int ihbit = ihigh%32;
730
731 int ilow = 0;
732 int ilword = 0;
733 int ilbit = 0;
734
735 int hTREXval = 0;
736 int lTREXval = 0;
737 int hHECval = 0;
738 int lHECval = 0;
739
740
742 int lmask = 0;
743 int hmask = 0;
744
745 if( XMSK[iFiber] != 1 ) {
747 }
748
749
750 if( (XCALO_TYPE[iFiber] < 3) && (ntower>-1) && (ntower<384) ) {
751 switch(dataType){
752 case 0:
753 ilow = ihigh - 11;
754 ilword = ilow/32;
755 ilbit = ilow%32;
756 if(ilword == ihword){
759 etowerData[ntower] = etowerData[ntower] | ( (Xfiber[iFiber][ihword] &
mask) >> ilbit );
760
761 if( do_lconv){
762 fiberFieldsUndecoded[iFiber][iDatum] = etowerData[ntower];
764 etowerDataF[ntower] = etowerData[ntower];
765 fiberFields[iFiber][iDatum] = etowerData[ntower];
766
767 }
768 else {
769
770 if( etowerData[ntower] & 0x00000800 ){ etowerData[ntower] = (etowerData[ntower] | 0xFFFFF000) ;}
771 etowerData[ntower] = etowerData[ntower]*4;
772 etowerDataF[ntower] = etowerData[ntower];
773 }
774 }
775 else {
776
777 std::stringstream sdetail;
778 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrongly packed data "<< fiber_type<<
", "<<
dataType<<
", "<<ilword<<
", " <<ihword ;
779 std::stringstream slocation;
780 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
781 std::stringstream stitle;
782 stitle << "Wrongly packed data" ;
783 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
784
785 }
786 break;
787
788 case 1:
789 ilow = ihigh - 11;
790 ilword = ilow/32;
791 ilbit = ilow%32;
792
793 hTREXval = Xfiber[iFiber][ihword];
794 lTREXval = Xfiber[iFiber][ilword];
796 lmask =0;
797 hmask =0;
798
799 if(ilword == ihword){
802 htowerData[ntower] = htowerData[ntower] | ( (hTREXval &
mask) >> (ilbit) );
803 }
804 else if ( ihbit == 7 ) {
806 hmask = 0x000000FF;
807 htowerData[ntower] = htowerData[ntower] | ( (hTREXval & hmask) << 4);
808 lmask = 0xF0000000;
809 htowerData[ntower] = htowerData[ntower] | ( ( (lTREXval & lmask) >> 28)&
mask) ;
810 }
811 else if ( ihbit == 3) {
813 hmask = 0x0000000F;
814 htowerData[ntower] = htowerData[ntower] | ( ( hTREXval & hmask) << 8);
815 lmask = 0xFF000000;
816 htowerData[ntower] = htowerData[ntower] | ( ( (lTREXval & lmask) >> 24) &
mask) ;
817 }
818 else {
819
820 std::stringstream sdetail;
821 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrongly packed data "<< fiber_type<<
", "<<
dataType<<
", "<<ilword<<
", " <<ihword ;
822 std::stringstream slocation;
823 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
824 std::stringstream stitle;
825 stitle << "Wrongly packed data" ;
826 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
827
828 }
829
830
831 if( (Xin > 50) ) {
832
833 fiberFieldsUndecoded[iFiber][iDatum] = htowerData[ntower];
834 htowerData[ntower] = 20*htowerData[ntower];
835 htowerDataF[ntower] = htowerData[ntower];
836 fiberFields[iFiber][iDatum] = htowerData[ntower];
837 }
838 else {
839 if( do_lconv){
840 fiberFieldsUndecoded[iFiber][1] = htowerData[ntower];
842 htowerDataF[ntower] = htowerData[ntower];
843 fiberFields[iFiber][1] = htowerData[ntower];
844 }
845 else {
846
847 if( htowerData[ntower] & 0x00000800 ){ htowerData[ntower] = (htowerData[ntower] | 0xFFFFF000) ;}
848 htowerData[ntower] = htowerData[ntower]*4;
849 htowerDataF[ntower] = htowerData[ntower];
850 }
851 }
852 break;
853
854 case 2:
855 ilow = ihigh - 11;
856 ilword = ilow/32;
857 ilbit = ilow%32;
858 if( (ntower > 32) || (ntower < 0) ){
859
860 std::stringstream sdetail;
861 sdetail << "[gFexInputByteStreamTool::gtReconstructABC]: bad value of nTower for extended region 2.4 - 2.5 in eta" ;
862 std::stringstream slocation;
863 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
864 std::stringstream stitle;
865 stitle << "Bad value of nTower in extended eta" ;
866 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
867
868 }
869 if(ilword == ihword){
870 int mask = 0x00000FFF;
872 xetowerData[ntower] = xetowerData[ntower] | ( (Xfiber[iFiber][ihword]&
mask) >> (ilbit) );
873 }
874 else if ( ihbit == 7 ) {
876 hmask = 0x000000FF;
877 xetowerData[ntower] = xetowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 4);
878 lmask = 0xF0000000;
879 xetowerData[ntower] = xetowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 28)&
mask) ;
880 }
881 else if ( ihbit == 3) {
883 hmask = 0x000000F;
884 xetowerData[ntower] = xetowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 8);
885 lmask = 0xFF000000;
886 xetowerData[ntower] = xetowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 24)&
mask) ;
887 }
888 else {
889
890 std::stringstream sdetail;
891 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrongly packed data "<< fiber_type<<
", "<<
dataType<<
", "<<ilword<<
", " <<ihword ;
892 std::stringstream slocation;
893 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
894 std::stringstream stitle;
895 stitle << "Wrongly packed data" ;
896 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
897
898 }
899
900 if( do_lconv){
901 fiberFieldsUndecoded[iFiber][iDatum] = xetowerData[ntower];
902 undoMLE( xetowerData[ntower] );
903 xetowerDataF[ntower] = xetowerData[ntower];
904 fiberFields[iFiber][iDatum] = xetowerData[ntower];
905
906 }
907 else {
908
909 if( xetowerData[ntower] & 0x00000800 ){ xetowerData[ntower] = (xetowerData[ntower] | 0xFFFFF000) ;}
910 xetowerData[ntower] = xetowerData[ntower]*4;
911 xetowerDataF[ntower] = xetowerData[ntower];
912 }
913 break;
914
915 case 3:
916 ilow = ihigh - 11;
917 ilword = ilow/32;
918 ilbit = ilow%32;
919 if(ilword == ihword){
922 xhtowerData[ntower] = xhtowerData[ntower] | ( (Xfiber[iFiber][ihword]&
mask) >> (ilbit) );
923 }
924 else if ( ihbit == 7 ) {
926 hmask = 0x000000FF;
927 xhtowerData[ntower] = xhtowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 4);
928 lmask = 0xF0000000;
929 xhtowerData[ntower] = xhtowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 28)&
mask) ;
930 }
931 else if ( ihbit == 3) {
933 hmask = 0x0000000F;
934 xhtowerData[ntower] = xhtowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 8);
935 lmask = 0xFF000000;
936 xhtowerData[ntower] = xhtowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 24)&
mask) ;
937 }
938 else {
939
940 std::stringstream sdetail;
941 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrongly packed data "<< fiber_type<<
", "<<
dataType<<
", "<<ilword<<
", " <<ihword ;
942 std::stringstream slocation;
943 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
944 std::stringstream stitle;
945 stitle << "Wrongly packed data" ;
946 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
947
948 }
949 if( ntower > 32 ){
950
951 std::stringstream sdetail;
952 sdetail << "[gFexInputByteStreamTool::gtReconstructABC]: bad value of nTower for extended region 2.4 - 2.5 in eta" ;
953 std::stringstream slocation;
954 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
955 std::stringstream stitle;
956 stitle << "Bad value of nTower in extended eta" ;
957 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
958
959 }
960
961 if( do_lconv){
962 fiberFieldsUndecoded[iFiber][iDatum] = xhtowerData[ntower];
963 undoMLE( xhtowerData[ntower] );
964 xhtowerDataF[ntower] = xhtowerData[ntower];
965 fiberFields[iFiber][iDatum] = xhtowerData[ntower];
966 }
967 else {
968
969 if( xhtowerData[ntower] & 0x00000800 ){ xhtowerData[ntower] = (xhtowerData[ntower] | 0xFFFFF000) ;}
970 xhtowerData[ntower] = xhtowerData[ntower]*4;
971 xhtowerDataF[ntower] = xhtowerData[ntower];
972 }
973 break;
974
975 case 6:
976 ilow = ihigh - 11;
977 ilword = ilow/32;
978 ilbit = ilow%32;
979 if(ilword == ihword){
982 ohtowerData[ntower] = ohtowerData[ntower] | ( (Xfiber[iFiber][ihword]&
mask) >> (ilbit) );
983 }
984 else if ( ihbit == 7 ) {
986 hmask = 0x000000FF;
987 ohtowerData[ntower] = ohtowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 4);
988 lmask = 0xF0000000;
989 ohtowerData[ntower] = ohtowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 28)&
mask) ;
990 }
991 else if ( ihbit == 3) {
993 hmask = 0x0000000F;
994 ohtowerData[ntower] = ohtowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 8);
995 lmask = 0xFF000000;
996 ohtowerData[ntower] = ohtowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 24)&
mask) ;
997 }
998 else {
999
1000 std::stringstream sdetail;
1001 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrongly packed data "<< fiber_type<<
", "<<
dataType<<
", "<<ilword<<
", " <<ihword ;
1002 std::stringstream slocation;
1003 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
1004 std::stringstream stitle;
1005 stitle << "Wrongly packed data" ;
1006 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
1007
1008 }
1009 if( ntower > 32 ){
1010
1011 std::stringstream sdetail;
1012 sdetail << "[gFexInputByteStreamTool::gtReconstructABC]: bad value of nTower for extended region 2.4 - 2.5 in eta" ;
1013 std::stringstream slocation;
1014 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
1015 std::stringstream stitle;
1016 stitle << "Bad value of nTower in extended eta" ;
1017 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
1018
1019 }
1020 if( do_lconv){
1021 fiberFieldsUndecoded[iFiber][iDatum] = ohtowerData[ntower];
1022 undoMLE( ohtowerData[ntower] );
1023 ohtowerDataF[ntower] = ohtowerData[ntower];
1024 fiberFields[iFiber][iDatum] = ohtowerData[ntower];
1025 }
1026 else {
1027
1028 if( ohtowerData[ntower] & 0x00000800 ){ ohtowerData[ntower] = (ohtowerData[ntower] | 0xFFFFF000) ;}
1029 ohtowerData[ntower] = ohtowerData[ntower]*4;
1030 ohtowerDataF[ntower] = ohtowerData[ntower];
1031 }
1032 break;
1033
1034 case 11:
1035 ilow = ihigh - 11;
1036 ilword = ilow/32;
1037 ilbit = ilow%32;
1038
1039 hHECval = Xfiber[iFiber][ihword];
1040 lHECval = Xfiber[iFiber][ilword];
1041 if(ilword == ihword){
1044 htowerData[ntower] = htowerData[ntower] | ( (hHECval &
mask) >> (ilbit) );
1045 }
1046 else if ( ihbit == 7 ) {
1048 hmask = 0x000000FF;
1049 htowerData[ntower] = htowerData[ntower] | ( (hHECval & hmask) << 4);
1050 lmask = 0xFF000000;
1051 htowerData[ntower] = htowerData[ntower] | ( ( (lHECval & lmask) >> 28)&
mask) ;
1052 }
1053 else if ( ihbit == 3) {
1055 hmask = 0x0000000F;
1056 htowerData[ntower] = htowerData[ntower] | ( ( hHECval & hmask) << 8);
1057 lmask = 0xFF000000;
1058 htowerData[ntower] = htowerData[ntower] | ( ( (lHECval & lmask) >> 24) &
mask) ;
1059 }
1060 else {
1061
1062 std::stringstream sdetail;
1063 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrongly packed data "<< fiber_type<<
", "<<
dataType<<
", "<<ilword<<
", " <<ihword ;
1064 std::stringstream slocation;
1065 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
1066 std::stringstream stitle;
1067 stitle << "Wrongly packed data" ;
1068 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
1069
1070 }
1071 if( do_lconv){
1072 fiberFieldsUndecoded[iFiber][iDatum] = htowerData[ntower];
1073 undoMLE( htowerData[ntower] );
1074 htowerDataF[ntower] = htowerData[ntower];
1075 fiberFields[iFiber][iDatum] = htowerData[ntower];
1076 }
1077 else {
1078
1079 if( htowerData[ntower] & 0x00000800 ){ htowerData[ntower] = (htowerData[ntower] | 0xFFFFF000) ;}
1080 htowerData[ntower] = htowerData[ntower]*4;
1081 htowerDataF[ntower] = htowerData[ntower];
1082 }
1083 break;
1084 }
1085
1086
1087 }
1088 else if ( (ntower>-1) && (ntower<384) ){
1089
1090
1091
1092 switch(dataType){
1093 case 2:
1094 ilow = ihigh - 11;
1095 ilword = ilow/32;
1096 ilbit = ilow%32;
1097
1098 if( etowerData[ntower] != 0 ) {
1099
1100 std::stringstream sdetail;
1101 sdetail << "[gFexInputByteStreamTool::gtReconstructABC]: etowerData[nTower] is not zero, inconsistent constants! "<< etowerData[ntower] ;
1102 std::stringstream slocation;
1103 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
1104 std::stringstream stitle;
1105 stitle << "etowerData not zero" ;
1106 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
1107
1108 } else {
1109
1110 if(ilword == ihword){
1111 int mask = 0x00000FFF;
1113 etowerData[ntower] = etowerData[ntower] | ( (Xfiber[iFiber][ihword]&
mask) >> (ilbit) );
1114 }
1115 else if ( ihbit == 7 ) {
1117 hmask = 0x000000FF;
1118 etowerData[ntower] = etowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 4);
1119 lmask = 0xF0000000;
1120 etowerData[ntower] = etowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 28)&
mask) ;
1121 }
1122 else if ( ihbit == 3) {
1124 hmask = 0x000000F;
1125 etowerData[ntower] = etowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 8);
1126 lmask = 0xFF000000;
1127 etowerData[ntower] = etowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 24)&
mask) ;
1128 }
1129 else {
1130
1131 std::stringstream sdetail;
1132 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrongly packed data "<< fiber_type<<
", "<<
dataType<<
", "<<ilword<<
", " <<ihword ;
1133 std::stringstream slocation;
1134 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
1135 std::stringstream stitle;
1136 stitle << "Wrongly packed data" ;
1137 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
1138
1139 }
1140
1141 if( do_lconv){
1142 fiberFieldsUndecoded[iFiber][iDatum] = etowerData[ntower];
1143 undoMLE( etowerData[ntower] );
1144 etowerDataF[ntower] = etowerData[ntower];
1145 fiberFields[iFiber][iDatum] = etowerData[ntower];
1146 }
1147 else {
1148
1149 if( etowerData[ntower] & 0x00000800 ){ etowerData[ntower] = (etowerData[ntower] | 0xFFFFF000) ;}
1150 etowerData[ntower] = etowerData[ntower]*4;
1151 etowerDataF[ntower] = etowerData[ntower];
1152 }
1153 }
1154 break;
1155
1156 case 3:
1157 ilow = ihigh - 11;
1158 ilword = ilow/32;
1159 ilbit = ilow%32;
1160
1161 if( htowerData[ntower] != 0 ) {
1162 std::stringstream sdetail;
1163 sdetail << "[gFexInputByteStreamTool::gtReconstructABC]: etowerData[nTower] is not zero, inconsistent constants! "<< etowerData[ntower] ;
1164 std::stringstream slocation;
1165 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
1166 std::stringstream stitle;
1167 stitle << "etowerData not zero" ;
1168 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
1169
1170 } else {
1171
1172 if(ilword == ihword){
1175 htowerData[ntower] = htowerData[ntower] | ( (Xfiber[iFiber][ihword]&
mask) >> (ilbit) );
1176 }
1177 else if ( ihbit == 7 ) {
1179 hmask = 0x000000FF;
1180 htowerData[ntower] = htowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 4);
1181 lmask = 0xF0000000;
1182 htowerData[ntower] = htowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 28)&
mask) ;
1183 }
1184 else if ( ihbit == 3) {
1186 hmask = 0x0000000F;
1187 htowerData[ntower] = htowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 8);
1188 lmask = 0xFF000000;
1189 htowerData[ntower] = htowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 24)&
mask) ;
1190 }
1191 else {
1192
1193 std::stringstream sdetail;
1194 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrongly packed data "<< fiber_type<<
", "<<
dataType<<
", "<<ilword<<
", " <<ihword ;
1195 std::stringstream slocation;
1196 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
1197 std::stringstream stitle;
1198 stitle << "Wrongly packed data" ;
1199 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
1200
1201 }
1202
1203 if( do_lconv){
1204 fiberFieldsUndecoded[iFiber][iDatum] = htowerData[ntower];
1205 undoMLE( htowerData[ntower] );
1206 htowerDataF[ntower] = htowerData[ntower];
1207 fiberFields[iFiber][iDatum] = htowerData[ntower];
1208 }
1209 else {
1210
1211 if( htowerData[ntower] & 0x00000800 ){ htowerData[ntower] = (htowerData[ntower] | 0xFFFFF000) ;}
1212 htowerData[ntower] = htowerData[ntower]*4;
1213 htowerDataF[ntower] = htowerData[ntower];
1214 }
1215 }
1216 break;
1217
1218 case 15:
1219 break;
1220
1221 case 99:
1222 break;
1223
1224 default:
1225
1226 std::stringstream sdetail;
1227 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrong detector type "<<
dataType ;
1228 std::stringstream slocation;
1229 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
1230 std::stringstream stitle;
1231 stitle << "Wrong detector type" ;
1232 printError(slocation.str(),stitle.str(),MSG::DEBUG,sdetail.str());
1233
1234 }
1235 }
1236 }
1237 }
1238
1239
1240
1241 if( XFPGA == 0 ) {
1242 for(int itower=0;itower<384;itower++){
1243 int icolumn = itower%12;
1244 int irow = itower/12;
1245
1246
1247 int xF = etowerDataF[itower] + htowerDataF[itower];
1248
1249 int x = ( (etowerData[itower]>>2) + (htowerData[itower]>>2) );
1250
1253
1254 Xgt[irow][icolumn] =
x;
1255 XgtF[irow][icolumn] = xF;
1256
1257
1258 if ( icolumn == 0) {
1259 int xx = ( (xetowerData[irow]>>2) + (xhtowerData[irow]>>2) );
1261 Xgt[irow][icolumn] = Xgt[irow][icolumn] +
xx;
1262 }
1263 if ( icolumn == 4) {
1264
1265 int ox = (ohtowerData[irow] >> 2 ) ;
1267 Xgt[irow][icolumn] = Xgt[irow][icolumn] + ox ;
1268 }
1269 }
1270 }
1271 else if ( XFPGA == 1 ) {
1272 for(int itower=0;itower<384;itower++){
1273 int icolumn = itower%12;
1274 int irow = itower/12;
1275
1276
1277 int xF = etowerDataF[itower] + htowerDataF[itower] ;
1278
1279 int x = ( (etowerData[itower]>>2) + (htowerData[itower] >> 2) );
1280
1283
1284 Xgt[irow][icolumn] =
x;
1285 XgtF[irow][icolumn] = xF;
1286
1287
1288 if ( icolumn == 11) {
1289
1290
1291
1292 int xx = ( (xetowerData[irow]>>2) + (xhtowerData[irow]>>2) );
1293
1295 Xgt[irow][icolumn] = Xgt[irow][icolumn] +
xx;
1296 }
1297 if ( icolumn == 7 ) {
1298
1299
1300 int xo = ohtowerData[irow]>>2;
1301
1303 Xgt[irow][icolumn] = Xgt[irow][icolumn] + xo;
1304 }
1305 }
1306 }
1307 else if ( XFPGA == 2 ) {
1308 for(int itower=0;itower<384;itower++){
1309 int icolumn = itower%12;
1310 int irow = itower/12;
1311
1312
1313 int xF = etowerDataF[itower] + htowerDataF[itower] ;
1314
1315 int x = ( (etowerData[itower]>>2 ) + (htowerData[itower]>>2));
1318
1319 Xgt[irow][icolumn] =
x;
1320 XgtF[irow][icolumn] = xF;
1321 }
1322 }
1323 else {
1324 ATH_MSG_DEBUG(
"[gFexInputByteStreamTool::gtReconstructABC]: Bad FPGA # "<< XFPGA);
1325 }
1326
1327
1328
1329 for(int iFiber = 0; iFiber < Xin; ++iFiber) {
1330 for(int iDatum = 0; iDatum < 16; ++iDatum) {
1331 int codedData = fiberFieldsUndecoded[iFiber][iDatum];
1332 int saturData = fiberFieldsSatur[iFiber][iDatum];
1333 unsigned int index = (16*iFiber) + iDatum;
1334 FiberTower[
index] = codedData;
1335 FiberTowerSatur[
index] = saturData;
1336 }
1337 }
1338}