419 Xgt[irow][icolumn] = 0;
420 XgtF[irow][icolumn] = 0;
421 Xsaturation[irow][icolumn] = 0;
439 *BCIDptr = (Xfiber[0][
gPos::W280-1]&0x007F0000) >>16;
442 std::array<int, gPos::AB_TOWERS> etowerData{};
443 std::array<int, gPos::AB_TOWERS> htowerData{};
444 std::array<int, gPos::ABC_ROWS> xetowerData{};
445 std::array<int, gPos::ABC_ROWS> xhtowerData{};
446 std::array<int, gPos::ABC_ROWS> ohtowerData{};
449 std::array<int, gPos::AB_TOWERS> etowerDataF{};
450 std::array<int, gPos::AB_TOWERS> htowerDataF{};
451 std::array<int, gPos::ABC_ROWS> xetowerDataF{};
452 std::array<int, gPos::ABC_ROWS> xhtowerDataF{};
453 std::array<int, gPos::ABC_ROWS> ohtowerDataF{};
460 gFields fiberFieldsUndecoded{{}};
461 gSatur fiberSaturation{{}};
464 for(
unsigned int i=0;
i<100;
i++){
466 if (XMPD_NFI[
i] < 0)
continue;
468 if( ( Xfiber[
i][
gPos::W280-1] & 0x000000FF ) == 0x000000BC ) {
470 fiberFields[
i][16] = 1;
473 fiberFields[
i][16] = 0;
477 fiberFields[
i][18] = ( Xfiber[
i][
gPos::W280-1] & 0x007F0000) >>16 ;
478 fiberFields[
i][19] = ( Xfiber[
i][
gPos::W280-1] & 0xFF800000) >>23 ;
480 if (XMPD_DTYP_ARR[ XMPD_NFI[
i] ][17] == 8) {
482 fiberFields[
i][17] = ( Xfiber[
i][
gPos::W280-1] & 0x0000FF00) >>8 ;
484 for(
unsigned int k=0;
k<8;
k++){
485 if( fiberFields[
i][17] & (1<<
k) ) {
486 fiberSaturation[
i][
k] = 1;
492 for(
unsigned int k=0;
k<16;
k++){
493 if( (XMPD_DTYP_ARR[ XMPD_NFI[
i] ][
k] != 4 ) && ( XMPD_GTRN_ARR[
i][
k] > -1 ) ) {
494 int krow = XMPD_GTRN_ARR[
i][
k]/12;
495 int kcolumn = XMPD_GTRN_ARR[
i][
k]%12;
497 if( fiberSaturation[
i][kFilled] == 1 ) {
498 Xsaturation[ krow][kcolumn] = 1;
501 kFilled = kFilled + 1;
507 for(
int iFiber = 0; iFiber < Xin; iFiber++) {
509 std::array<uint32_t, 6>
tmp;
510 for(
int i = 0;
i < 6;
i++){
tmp[
i] = Xfiber[iFiber][
i]; };
513 int withoutComma = Xfiber[iFiber][6] & 0xFFFFFF00 ;
514 CRC =
crc9d23(withoutComma, CRC, 1 );
515 uint32_t StoredCRC = ( (Xfiber[iFiber][6]>>23) & 0x000001FF);
516 if( (CRC != StoredCRC) && (StoredCRC != 0 ) ) {
518 std::stringstream sdetail;
519 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: Fiber " << iFiber <<
"of Xin " << Xin <<
": BAD New CRC: " << CRC <<
"Stored CRC "<< StoredCRC ;
520 std::stringstream slocation;
521 slocation <<
"Fiber " << iFiber <<
"of Xin " << Xin;
522 std::stringstream stitle;
523 stitle <<
"Bad CRC" ;
529 int fiber_type = XMPD_NFI[iFiber];
531 for(
int iDatum = 0; iDatum < 16; iDatum++) {
533 int dataType = XMPD_DTYP_ARR[fiber_type][iDatum];
535 int ntower = XMPD_GTRN_ARR[iFiber][iDatum];
537 ATH_MSG_DEBUG(
"[gFexInputByteStreamTool::gtReconstructABC: unused location iFiber "<< iFiber <<
", calo type "<< XCALO_TYPE[iFiber]<<
", data type "<<
dataType <<
", iDatum " << iDatum <<
"tower " << ntower);
539 else if( (ntower < 0) || (ntower >383) ){
541 std::stringstream sdetail;
542 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC: bad value of ntower: iFiber "<< iFiber<<
", calo type"<< XCALO_TYPE[iFiber]<<
", data type "<<
dataType<<
", iDatum "<< iDatum<<
"tower "<< ntower ;
543 std::stringstream slocation;
544 slocation <<
"iFiber "<< iFiber<<
", calo type"<< XCALO_TYPE[iFiber];
545 std::stringstream stitle;
546 stitle <<
"Bad value of ntower" ;
553 int ihigh = XMPD_DSTRT_ARR[fiber_type][iDatum];
554 int ihword = ihigh/32;
555 int ihbit = ihigh%32;
571 if( XMSK[iFiber] != 1 ) {
576 if( (XCALO_TYPE[iFiber] < 3) && (ntower>-1) && (ntower<384) ) {
582 if(ilword == ihword){
585 etowerData[ntower] = etowerData[ntower] | ( (Xfiber[iFiber][ihword] &
mask) >> ilbit );
588 fiberFieldsUndecoded[iFiber][iDatum] = etowerData[ntower];
590 etowerDataF[ntower] = etowerData[ntower];
591 fiberFields[iFiber][iDatum] = etowerData[ntower];
596 if( etowerData[ntower] & 0x00000800 ){ etowerData[ntower] = (etowerData[ntower] | 0xFFFFF000) ;}
597 etowerData[ntower] = etowerData[ntower]*4;
598 etowerDataF[ntower] = etowerData[ntower];
603 std::stringstream sdetail;
604 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrongly packed data "<< fiber_type<<
", "<<
dataType<<
", "<<ilword<<
", " <<ihword ;
605 std::stringstream slocation;
606 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
607 std::stringstream stitle;
608 stitle <<
"Wrongly packed data" ;
619 hTREXval = Xfiber[iFiber][ihword];
620 lTREXval = Xfiber[iFiber][ilword];
625 if(ilword == ihword){
628 htowerData[ntower] = htowerData[ntower] | ( (hTREXval &
mask) >> (ilbit) );
630 else if ( ihbit == 7 ) {
633 htowerData[ntower] = htowerData[ntower] | ( (hTREXval & hmask) << 4);
635 htowerData[ntower] = htowerData[ntower] | ( ( (lTREXval & lmask) >> 28)&
mask) ;
637 else if ( ihbit == 3) {
640 htowerData[ntower] = htowerData[ntower] | ( ( hTREXval & hmask) << 8);
642 htowerData[ntower] = htowerData[ntower] | ( ( (lTREXval & lmask) >> 24) &
mask) ;
646 std::stringstream sdetail;
647 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrongly packed data "<< fiber_type<<
", "<<
dataType<<
", "<<ilword<<
", " <<ihword ;
648 std::stringstream slocation;
649 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
650 std::stringstream stitle;
651 stitle <<
"Wrongly packed data" ;
659 fiberFieldsUndecoded[iFiber][iDatum] = htowerData[ntower];
660 htowerData[ntower] = 20*htowerData[ntower];
661 htowerDataF[ntower] = htowerData[ntower];
662 fiberFields[iFiber][iDatum] = htowerData[ntower];
666 fiberFieldsUndecoded[iFiber][1] = htowerData[ntower];
668 htowerDataF[ntower] = htowerData[ntower];
669 fiberFields[iFiber][1] = htowerData[ntower];
673 if( htowerData[ntower] & 0x00000800 ){ htowerData[ntower] = (htowerData[ntower] | 0xFFFFF000) ;}
674 htowerData[ntower] = htowerData[ntower]*4;
675 htowerDataF[ntower] = htowerData[ntower];
684 if( (ntower > 32) || (ntower < 0) ){
686 std::stringstream sdetail;
687 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: bad value of nTower for extended region 2.4 - 2.5 in eta" ;
688 std::stringstream slocation;
689 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
690 std::stringstream stitle;
691 stitle <<
"Bad value of nTower in extended eta" ;
695 if(ilword == ihword){
696 int mask = 0x00000FFF;
698 xetowerData[ntower] = xetowerData[ntower] | ( (Xfiber[iFiber][ihword]&
mask) >> (ilbit) );
700 else if ( ihbit == 7 ) {
703 xetowerData[ntower] = xetowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 4);
705 xetowerData[ntower] = xetowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 28)&
mask) ;
707 else if ( ihbit == 3) {
710 xetowerData[ntower] = xetowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 8);
712 xetowerData[ntower] = xetowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 24)&
mask) ;
716 std::stringstream sdetail;
717 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrongly packed data "<< fiber_type<<
", "<<
dataType<<
", "<<ilword<<
", " <<ihword ;
718 std::stringstream slocation;
719 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
720 std::stringstream stitle;
721 stitle <<
"Wrongly packed data" ;
727 fiberFieldsUndecoded[iFiber][iDatum] = xetowerData[ntower];
728 undoMLE( xetowerData[ntower] );
729 xetowerDataF[ntower] = xetowerData[ntower];
730 fiberFields[iFiber][iDatum] = xetowerData[ntower];
735 if( xetowerData[ntower] & 0x00000800 ){ xetowerData[ntower] = (xetowerData[ntower] | 0xFFFFF000) ;}
736 xetowerData[ntower] = xetowerData[ntower]*4;
737 xetowerDataF[ntower] = xetowerData[ntower];
745 if(ilword == ihword){
748 xhtowerData[ntower] = xhtowerData[ntower] | ( (Xfiber[iFiber][ihword]&
mask) >> (ilbit) );
750 else if ( ihbit == 7 ) {
753 xhtowerData[ntower] = xhtowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 4);
755 xhtowerData[ntower] = xhtowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 28)&
mask) ;
757 else if ( ihbit == 3) {
760 xhtowerData[ntower] = xhtowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 8);
762 xhtowerData[ntower] = xhtowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 24)&
mask) ;
766 std::stringstream sdetail;
767 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrongly packed data "<< fiber_type<<
", "<<
dataType<<
", "<<ilword<<
", " <<ihword ;
768 std::stringstream slocation;
769 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
770 std::stringstream stitle;
771 stitle <<
"Wrongly packed data" ;
777 std::stringstream sdetail;
778 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: bad value of nTower for extended region 2.4 - 2.5 in eta" ;
779 std::stringstream slocation;
780 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
781 std::stringstream stitle;
782 stitle <<
"Bad value of nTower in extended eta" ;
788 fiberFieldsUndecoded[iFiber][iDatum] = xhtowerData[ntower];
789 undoMLE( xhtowerData[ntower] );
790 xhtowerDataF[ntower] = xhtowerData[ntower];
791 fiberFields[iFiber][iDatum] = xhtowerData[ntower];
795 if( xhtowerData[ntower] & 0x00000800 ){ xhtowerData[ntower] = (xhtowerData[ntower] | 0xFFFFF000) ;}
796 xhtowerData[ntower] = xhtowerData[ntower]*4;
797 xhtowerDataF[ntower] = xhtowerData[ntower];
805 if(ilword == ihword){
808 ohtowerData[ntower] = ohtowerData[ntower] | ( (Xfiber[iFiber][ihword]&
mask) >> (ilbit) );
810 else if ( ihbit == 7 ) {
813 ohtowerData[ntower] = ohtowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 4);
815 ohtowerData[ntower] = ohtowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 28)&
mask) ;
817 else if ( ihbit == 3) {
820 ohtowerData[ntower] = ohtowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 8);
822 ohtowerData[ntower] = ohtowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 24)&
mask) ;
826 std::stringstream sdetail;
827 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrongly packed data "<< fiber_type<<
", "<<
dataType<<
", "<<ilword<<
", " <<ihword ;
828 std::stringstream slocation;
829 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
830 std::stringstream stitle;
831 stitle <<
"Wrongly packed data" ;
837 std::stringstream sdetail;
838 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: bad value of nTower for extended region 2.4 - 2.5 in eta" ;
839 std::stringstream slocation;
840 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
841 std::stringstream stitle;
842 stitle <<
"Bad value of nTower in extended eta" ;
847 fiberFieldsUndecoded[iFiber][iDatum] = ohtowerData[ntower];
848 undoMLE( ohtowerData[ntower] );
849 ohtowerDataF[ntower] = ohtowerData[ntower];
850 fiberFields[iFiber][iDatum] = ohtowerData[ntower];
854 if( ohtowerData[ntower] & 0x00000800 ){ ohtowerData[ntower] = (ohtowerData[ntower] | 0xFFFFF000) ;}
855 ohtowerData[ntower] = ohtowerData[ntower]*4;
856 ohtowerDataF[ntower] = ohtowerData[ntower];
865 hHECval = Xfiber[iFiber][ihword];
866 lHECval = Xfiber[iFiber][ilword];
867 if(ilword == ihword){
870 htowerData[ntower] = htowerData[ntower] | ( (hHECval &
mask) >> (ilbit) );
872 else if ( ihbit == 7 ) {
875 htowerData[ntower] = htowerData[ntower] | ( (hHECval & hmask) << 4);
877 htowerData[ntower] = htowerData[ntower] | ( ( (lHECval & lmask) >> 28)&
mask) ;
879 else if ( ihbit == 3) {
882 htowerData[ntower] = htowerData[ntower] | ( ( hHECval & hmask) << 8);
884 htowerData[ntower] = htowerData[ntower] | ( ( (lHECval & lmask) >> 24) &
mask) ;
888 std::stringstream sdetail;
889 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrongly packed data "<< fiber_type<<
", "<<
dataType<<
", "<<ilword<<
", " <<ihword ;
890 std::stringstream slocation;
891 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
892 std::stringstream stitle;
893 stitle <<
"Wrongly packed data" ;
898 fiberFieldsUndecoded[iFiber][iDatum] = htowerData[ntower];
900 htowerDataF[ntower] = htowerData[ntower];
901 fiberFields[iFiber][iDatum] = htowerData[ntower];
905 if( htowerData[ntower] & 0x00000800 ){ htowerData[ntower] = (htowerData[ntower] | 0xFFFFF000) ;}
906 htowerData[ntower] = htowerData[ntower]*4;
907 htowerDataF[ntower] = htowerData[ntower];
914 else if ( (ntower>-1) && (ntower<384) ){
924 if( etowerData[ntower] != 0 ) {
926 std::stringstream sdetail;
927 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: etowerData[nTower] is not zero, inconsistent constants! "<< etowerData[ntower] ;
928 std::stringstream slocation;
929 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
930 std::stringstream stitle;
931 stitle <<
"etowerData not zero" ;
936 if(ilword == ihword){
937 int mask = 0x00000FFF;
939 etowerData[ntower] = etowerData[ntower] | ( (Xfiber[iFiber][ihword]&
mask) >> (ilbit) );
941 else if ( ihbit == 7 ) {
944 etowerData[ntower] = etowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 4);
946 etowerData[ntower] = etowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 28)&
mask) ;
948 else if ( ihbit == 3) {
951 etowerData[ntower] = etowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 8);
953 etowerData[ntower] = etowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 24)&
mask) ;
957 std::stringstream sdetail;
958 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrongly packed data "<< fiber_type<<
", "<<
dataType<<
", "<<ilword<<
", " <<ihword ;
959 std::stringstream slocation;
960 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
961 std::stringstream stitle;
962 stitle <<
"Wrongly packed data" ;
968 fiberFieldsUndecoded[iFiber][iDatum] = etowerData[ntower];
970 etowerDataF[ntower] = etowerData[ntower];
971 fiberFields[iFiber][iDatum] = etowerData[ntower];
975 if( etowerData[ntower] & 0x00000800 ){ etowerData[ntower] = (etowerData[ntower] | 0xFFFFF000) ;}
976 etowerData[ntower] = etowerData[ntower]*4;
977 etowerDataF[ntower] = etowerData[ntower];
987 if( htowerData[ntower] != 0 ) {
988 std::stringstream sdetail;
989 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: etowerData[nTower] is not zero, inconsistent constants! "<< etowerData[ntower] ;
990 std::stringstream slocation;
991 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
992 std::stringstream stitle;
993 stitle <<
"etowerData not zero" ;
998 if(ilword == ihword){
1001 htowerData[ntower] = htowerData[ntower] | ( (Xfiber[iFiber][ihword]&
mask) >> (ilbit) );
1003 else if ( ihbit == 7 ) {
1006 htowerData[ntower] = htowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 4);
1008 htowerData[ntower] = htowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 28)&
mask) ;
1010 else if ( ihbit == 3) {
1013 htowerData[ntower] = htowerData[ntower] | ( (Xfiber[iFiber][ihword]&hmask) << 8);
1015 htowerData[ntower] = htowerData[ntower] | ( ( (Xfiber[iFiber][ilword]&lmask) >> 24)&
mask) ;
1019 std::stringstream sdetail;
1020 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrongly packed data "<< fiber_type<<
", "<<
dataType<<
", "<<ilword<<
", " <<ihword ;
1021 std::stringstream slocation;
1022 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
1023 std::stringstream stitle;
1024 stitle <<
"Wrongly packed data" ;
1030 fiberFieldsUndecoded[iFiber][iDatum] = htowerData[ntower];
1031 undoMLE( htowerData[ntower] );
1032 htowerDataF[ntower] = htowerData[ntower];
1033 fiberFields[iFiber][iDatum] = htowerData[ntower];
1037 if( htowerData[ntower] & 0x00000800 ){ htowerData[ntower] = (htowerData[ntower] | 0xFFFFF000) ;}
1038 htowerData[ntower] = htowerData[ntower]*4;
1039 htowerDataF[ntower] = htowerData[ntower];
1052 std::stringstream sdetail;
1053 sdetail <<
"[gFexInputByteStreamTool::gtReconstructABC]: wrong detector type "<<
dataType ;
1054 std::stringstream slocation;
1055 slocation <<
"Fiber type "<< fiber_type<<
" and data type"<<
dataType;
1056 std::stringstream stitle;
1057 stitle <<
"Wrong detector type" ;
1068 for(
int itower=0;itower<384;itower++){
1069 int icolumn = itower%12;
1070 int irow = itower/12;
1073 int xF = etowerDataF[itower] + htowerDataF[itower];
1075 int x = ( (etowerData[itower]>>2) + (htowerData[itower]>>2) );
1080 Xgt[irow][icolumn] =
x;
1081 XgtF[irow][icolumn] = xF;
1084 if ( icolumn == 0) {
1085 int xx = ( (xetowerData[irow]>>2) + (xhtowerData[irow]>>2) );
1087 Xgt[irow][icolumn] = Xgt[irow][icolumn] + xx;
1089 if ( icolumn == 4) {
1091 int ox = (ohtowerData[irow] >> 2 ) ;
1093 Xgt[irow][icolumn] = Xgt[irow][icolumn] + ox ;
1097 else if ( XFPGA == 1 ) {
1098 for(
int itower=0;itower<384;itower++){
1099 int icolumn = itower%12;
1100 int irow = itower/12;
1103 int xF = etowerDataF[itower] + htowerDataF[itower] ;
1105 int x = ( (etowerData[itower]>>2) + (htowerData[itower] >> 2) );
1110 Xgt[irow][icolumn] =
x;
1111 XgtF[irow][icolumn] = xF;
1114 if ( icolumn == 11) {
1118 int xx = ( (xetowerData[irow]>>2) + (xhtowerData[irow]>>2) );
1121 Xgt[irow][icolumn] = Xgt[irow][icolumn] + xx;
1123 if ( icolumn == 7 ) {
1126 int xo = ohtowerData[irow]>>2;
1129 Xgt[irow][icolumn] = Xgt[irow][icolumn] + xo;
1133 else if ( XFPGA == 2 ) {
1134 for(
int itower=0;itower<384;itower++){
1135 int icolumn = itower%12;
1136 int irow = itower/12;
1139 int xF = etowerDataF[itower] + htowerDataF[itower] ;
1141 int x = ( (etowerData[itower]>>2 ) + (htowerData[itower]>>2));
1145 Xgt[irow][icolumn] =
x;
1146 XgtF[irow][icolumn] = xF;
1150 ATH_MSG_DEBUG(
"[gFexInputByteStreamTool::gtReconstructABC]: Bad FPGA # "<< XFPGA);