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