375 {
376
377
378 const EventContext& ctx = Gaudi::Hive::currentContext();
379
381
383 if ( eventInfo.isValid() ) {
386 m_evtNum = eventInfo->eventNumber();
390 } else {
397 }
398
399 std::ostringstream evState;
400 evState <<
"Run "<< std::setw(6) <<
m_runNum
402 <<
" Evt "<< std::setw(9) <<
m_evtNum
404 <<
" Flags 0x" << std::hex <<
m_tileFlag << std::dec;
405
406 std::ostringstream evtnum;
407 evtnum <<
"Run "<< std::setw(6) <<
m_runNum
409 <<
" Evt "<< std::setw(9) <<
m_evtNum
411
412 std::ostringstream nevtnum;
413 nevtnum << evtnum.str()
415
416 bool emptyBad = true;
417 bool badFromCell = false;
428
429 IdContext chan_context =
m_tileHWID->channel_context();
433 HWIdentifier ch_id =
m_tileHWID->channel_id(drawer_id,0);
434 m_tileHWID->get_hash(ch_id, hash, &chan_context);
436 std::fill(itr,itr+48,true);
437 }
438
441 if (statusOk) {
443
444 using namespace boost::local_time;
445 using namespace boost::posix_time;
446 static const time_zone_ptr gva_tz(new posix_time_zone((std::string)"CET+01CEST01:00:00,M3.5.0/02:00:00,M10.5.0/03:00:00"));
447 local_date_time gva_time(from_time_t(eventInfo->timeStamp()),gva_tz);
448 evState << " " << gva_time << " ";
449
450
451 const char *
part[5] = {
"UNK",
"LBA",
"LBC",
"EBA",
"EBC" };
455 int n2 = (n1 +
dn - 1) % 64;
457 evState <<
" " <<
part[
rr] <<std::setw(2)<<std::setfill(
'0')<<n1+1
458 <<
" - " <<
part[
rr] <<std::setw(2)<<std::setfill(
'0')<<n2+1
459 <<
" " <<
dn <<
" consec bad ";
460 }
466 int pp = 1;
467 for (
int rr = 1;
rr < 5; ++
rr) {
468 if ((p2 & pp) || (p1 & pp)) {
469 evState <<
" " <<
part[
rr];
470 if (p2 & pp) {
471 if (p0 & pp) evState << " off";
472 else evState << " OFF";
473 }
474 if (p1 & pp) {
475 if (p0 & pp) evState << " mask";
476 else evState << " MASK";
477 }
478 }
479 pp <<= 1;
480 }
481 evState <<
" " <<
dn <<
" consec bad ";
482 }
483
485 int n1 = -1;
486 int n2 = -1;
493 std::vector<int> consec;
494 for (
int ros = 1;
ros < 5; ++
ros) {
495 int drmax = 65;
496 for (
int dr = 0;
dr < drmax; ++
dr) {
501 if (dr < 64)
allmod.push_back((ros << 8) + dr);
502 } else if (m1 >= 0) {
504 if (m1 == 0) drmax +=
dm;
505 if (dm > dn) {
510 consec.clear();
511 consec.push_back((ros << 8) + m1);
512 } else if (dm == dn) {
513 if (m1 < 64) consec.push_back((ros << 8) + m1);
514 }
516 }
517 }
518 }
519 evState <<
" DCS " <<
allmod.size() <<
" off ";
520 if (dn > 1) {
522 if (consec.size() > 1) evState << "*" << (consec.size());
523 evState << " consec "
524 <<
part[
rr] << std::setw(2) << std::setfill(
'0') << (n1 % 64) + 1 <<
" - "
525 << part[
rr] << std::setw(2) << std::setfill(
'0') << (n2 % 64) + 1 <<
" ";
528 for (
size_t n = 1;
n < consec.size(); ++
n) {
531 evState << part[m1 >> 8] << std::setw(2) << std::setfill(
'0') << (
m1 % 64) + 1 <<
" - "
532 << part[m2 >> 8] << std::setw(2) << std::setfill(
'0') << (
m2 % 64) + 1 <<
" ";
533 for (
size_t m = 0;
m <
allmod.size(); ++
m) {
535 if (mm >= m1 && mm <= m2) {
537 }
538 }
539 }
540 } else {
542 }
543 if (
allmod.size() > (
size_t) dn) {
544 for (
size_t m = 0;
m <
allmod.size(); ++
m) {
546 if (!(mm >= n1 && mm <= n2)) {
547 evState << part[mm >> 8] << std::setw(2) << std::setfill(
'0') << (
mm % 64) + 1 <<
" ";
548 }
549 }
550 }
551 }
552
554 }
555
556 int rawdata = -1;
557 const TileCell* cellminCh = 0;
558 const TileCell* cellmaxCh = 0;
559 const TileCell* tcellminCh = 0;
560 const TileCell* tcellmaxCh = 0;
561
563
564
566
567 if (!cellContainer.isValid()) {
568
569 ATH_MSG_WARNING(
"Unable to read CaloCellContainer from EventStore, disable reading of this container");
571
572 } else {
573
574 float emin = 0.;
575 float emax = 0.;
576 float tmin = 0.;
577 float tmax = 0.;
580 float tcmin = 0.;
581 float tcmax = 0.;
584 const TileCell* tcellmin = 0;
585 const TileCell* tcellmax = 0;
586
587
588
589
590
591
593
594 for (const CaloCell* cell : *cellContainer) {
595
596 Identifier
id =
cell->ID();
598 const TileCell* tile_cell =
dynamic_cast<const TileCell*
> (
cell);
599 if (tile_cell==0) continue;
600 const CaloDetDescrElement * caloDDE =
cell->caloDDE();
601 IdentifierHash hash1 = caloDDE->
onl1();
602 IdentifierHash hash2 = caloDDE->
onl2();
605 if (rawdata < 0) {
607 }
608
609 bool bad1 = tile_cell->
badch1();
610 bool bad2 = tile_cell->
badch2();
611 float ene1 = tile_cell->
ene1();
612 float ene2 = tile_cell->
ene2();
613 float time1 = tile_cell->
time1();
614 float time2 = tile_cell->
time2();
623
624 float ene = tile_cell->
energy();
625 bool eneOk = false;
630 } else {
632 }
633
634 if (eneOk) {
635 if (bad1 && bad2) {
637 } else {
639 }
640 }
641
643 bool timeOk = false;
648 } else {
650 }
651
652 if (timeOk) {
653 if (time != 0.) {
655 } else {
657 }
658 }
659
660 if (timeOk && eneOk) {
661
663 <<
" cell " << std::left << std::setw(14) <<
m_tileID->to_string(
id,-2)
664 << " ene = " << ene << " time = " << time);
665
668
669 if (ene < emin) {
670 emin = ene;
672 } else if (ene > emax) {
673 emax = ene;
675 }
676
677 if (time<tmin) {
679 tcellmin = tile_cell;
680 }
681 else if (time>tmax) {
683 tcellmax = tile_cell;
684 }
685 }
686
687 if ( !(bad1 && bad2) ) {
688
689 bool ene1Ok = false;
690 bool time1Ok = false;
691
697 } else {
699 }
700
705 } else {
707 }
708
709 if (ene1Ok) {
711 }
712
713 if (time1Ok) {
714 if (time1 != 0.) {
716 } else {
718 }
719 }
720 }
721
722 bool ene2Ok = false;
723 bool time2Ok = false;
724
730 } else {
732 }
733
738 } else {
740 }
741
742 if (ene2Ok) {
744 }
745
746 if (time2Ok) {
747 if (time2 != 0.) {
749 } else {
751 }
752 }
753 }
754
755 bool over1=false;
756 bool over2=false;
757 if (checkOver) {
760 }
761
762 if ((ene1Ok && time1Ok) || over1) {
763
765 <<
" cell " << std::left << std::setw(14) <<
m_tileID->to_string(
id,-2)
766 << " ch_ene1 = " << ene1 << " ch_t1 = " << time1
767 << ((over1)?" overflow":""));
768
771
772 if (ene1 < chmin) {
774 cellminCh = tile_cell;
775 } else if (ene1 > chmax) {
777 cellmaxCh = tile_cell;
778 }
779
780 if (time1 < tcmin) {
781 tcmin = time1;
782 tcellminCh = tile_cell;
783 } else if (time1 > tcmax) {
784 tcmax = time1;
785 tcellmaxCh = tile_cell;
786 }
787 }
788
789 if ((ene2Ok && time2Ok) || over2) {
790
792 <<
" cell " << std::left << std::setw(14) <<
m_tileID->to_string(
id,-2)
793 << " ch_ene2 = " << ene2 << " ch_t2 = " << time2
794 << ((over2)?" overflow":""));
795
798
799 if (ene2 < chmin) {
801 cellminCh = tile_cell;
802 } else if (ene2 > chmax) {
804 cellmaxCh = tile_cell;
805 }
806
807 if (time2 < tcmin) {
808 tcmin = time2;
809 tcellminCh = tile_cell;
810 } else if (time2 > tcmax) {
811 tcmax = time2;
812 tcellmaxCh = tile_cell;
813 }
814 }
815
816 }
817 }
818 }
819
820 if (tcellmin && tcellmin != cellmin && tcellmin != cellmax) {
822 <<
" cell " << std::left << std::setw(14) <<
m_tileID->to_string(tcellmin->
ID(),-2)
823 <<
" ene = " << tcellmin->
energy()
824 <<
" tmin = " << tcellmin->
time());
825 }
826 if (tcellmax && tcellmax != cellmin && tcellmax != cellmax) {
828 <<
" cell " << std::left << std::setw(14) <<
m_tileID->to_string(tcellmax->
ID(),-2)
829 <<
" ene = " << tcellmax->
energy()
830 <<
" tmax = " << tcellmax->
energy());
831 }
832
833 if (tcellminCh && tcellminCh != cellminCh && tcellminCh != cellmaxCh) {
835 <<
" cell " << std::left << std::setw(14) <<
m_tileID->to_string(tcellminCh->
ID(),-2)
836 <<
" ch_ene = " << tcellminCh->
ene1() <<
" " << tcellminCh->
ene2()
837 <<
" ch_tmin = " << tcellminCh->
time1() <<
" " << tcellminCh->
time2());
838 }
839 if (tcellmaxCh && tcellmaxCh != cellminCh && tcellmaxCh != cellmaxCh) {
841 <<
" cell " << std::left << std::setw(14) <<
m_tileID->to_string(tcellmaxCh->
ID(),-2)
842 <<
" ch_ene = " << tcellmaxCh->
ene1() <<
" " << tcellmaxCh->
ene2()
843 <<
" ch_tmax = " << tcellmaxCh->
time1() <<
" " << tcellmaxCh->
time2());
844 }
845
846 if (cellmin) {
848 statusOk = true;
849 const char *
tit = (tcellmin ==
cellmin) ?
" tmin = ": ((tcellmax ==
cellmin) ?
" tmax = ":
" t = ");
850 if (cellminCh!=cellmin) {
852 <<
" cell " << std::left << std::setw(14) <<
m_tileID->to_string(
cellmin->ID(),-2)
853 << " emin = " << emin
855 << " accepted");
856
857 } else {
859 <<
" cell " << std::left << std::setw(14) <<
m_tileID->to_string(
cellmin->ID(),-2)
860 << " emin = " << emin
861 << " ch_emin = " << chmin
863 << " accepted");
864 }
865 }
866
867 if (cellminCh) {
869 statusOk = true;
870 const char *
tit = (tcellminCh == cellminCh) ?
" tmin = ": ((tcellmaxCh == cellminCh) ?
" tmax = ":
" t = ");
871 if (cellminCh!=cellmin) {
873 <<
" cell " << std::left << std::setw(14) <<
m_tileID->to_string(cellminCh->
ID(),-2)
874 << " ch_emin = " << chmin
875 << tit << cellminCh->
time()
876 << " accepted");
877 }
878 }
879
880 if (cellmax) {
882 statusOk = true;
883 const char *
tit = (tcellmin ==
cellmax) ?
" tmin = ": ((tcellmax ==
cellmax) ?
" tmax = ":
" t = ");
884 if (cellmaxCh!=cellmax) {
886 <<
" cell " << std::left << std::setw(14) <<
m_tileID->to_string(
cellmax->ID(),-2)
887 << " emax = " << emax
889 << " accepted");
890
891 } else {
893 <<
" cell " << std::left << std::setw(14) <<
m_tileID->to_string(
cellmax->ID(),-2)
894 << " emax = " << emax
895 << " ch_emax = " << chmax
897 << " accepted");
898 }
899 }
900
901 if (cellmaxCh) {
903 statusOk = true;
904 const char *
tit = (tcellminCh == cellmaxCh) ?
" tmin = ": ((tcellmaxCh == cellmaxCh) ?
" tmax = ":
" t = ");
905 if (cellmaxCh!=cellmax) {
907 <<
" cell " << std::left << std::setw(14) <<
m_tileID->to_string(cellmaxCh->
ID(),-2)
908 << " ch_emax = " << chmax
909 << tit << cellmaxCh->
time()
910 << " accepted");
911 }
912 }
913
914 emptyBad = false;
915 badFromCell = true;
916 }
917 }
918
919 const TileDQstatus* DQstatus(0);
920
922
923
925
927 ATH_MSG_WARNING(
"Unable to read TileRawChannelContainer from EventStore, disable reading of this container");
929
930 } else {
931
934 float tcmin = 0.;
935 float tcmax = 0.;
936 const TileRawChannel* minCh = 0;
937 const TileRawChannel* maxCh = 0;
938 const TileRawChannel* tminCh = 0;
939 const TileRawChannel* tmaxCh = 0;
943 bool fillChanEne = ( !
m_readCells && allowAmpCheck );
944 if (!fillChanEne) {
949 }
950
953 else
954 rawdata = 0;
955
956 IdContext chan_context =
m_tileHWID->channel_context();
959
960 int nbadMax = 0;
961 int nbadMBMax = 0;
962 const TileRawChannelCollection * collMax = 0;
963 const TileRawChannelCollection * collMBMax = 0;
964
965 bool someDQerrors = false;
966
967 for (const TileRawChannelCollection* rawChannelCollection : *rawChannelContainer) {
968
969 int frag = rawChannelCollection->identify();
970 bool eb = (frag > 0x2ff);
971 bool ebsp = (frag == 0x30e || frag == 0x411);
972
977
978 int chMBTS = -1;
979 if (eb) {
980 for (int ch: {12,4,0}) {
981 m_cabling->h2s_cell_id_index(ros,drawer,ch,index,pmt);
982 if (index == -2) {
984 break;
985 }
986 }
987 }
988
989 HWIdentifier ch_id =
m_tileHWID->channel_id(ros,drawer,0);
990 m_tileHWID->get_hash(ch_id, hash, &chan_context);
991 int hashNext =
index = (
int)hash + 48;
992
993
994
995 uint32_t RODBCID = rawChannelCollection->getRODBCID();
996 uint32_t DSPBCID = rawChannelCollection->getFragDSPBCID();
997 uint32_t GlobalCRCErr = rawChannelCollection->getFragGlobalCRC() & 0x1;
998 uint32_t FE_DMUmask = rawChannelCollection->getFragFEChipMask();
999 uint32_t ROD_DMUmask = rawChannelCollection->getFragRODChipMask();
1000 uint32_t BCIDErr = rawChannelCollection->getFragBCID();
1001 uint32_t MemoryParityErr = rawChannelCollection->getFragMemoryPar();
1002 uint32_t HeaderFormatErr = rawChannelCollection->getFragHeaderBit();
1003 uint32_t HeaderParityErr = rawChannelCollection->getFragHeaderPar();
1004 uint32_t SampleFormatErr = rawChannelCollection->getFragSampleBit();
1005 uint32_t SampleParityErr = rawChannelCollection->getFragSamplePar();
1006 uint32_t SingleStrobeErr = rawChannelCollection->getFragSstrobe();
1007 uint32_t DoubleStrobeErr = rawChannelCollection->getFragDstrobe();
1008
1009 if (RODBCID!=0 && RODBCID !=
m_evtBCID ) {
1012 <<
" drw " <<
drwname(rawChannelCollection->identify())
1013 << " ROD BCID " << RODBCID << " is wrong - skipping");
1014
1017 << " suppressing further messages about drawer 0x" << std::hex << rawChannelCollection->identify()
1018 << std::dec << " being bad");
1019 }
1020 someDQerrors = true;
1021 continue;
1022 }
1023
1024 if (DSPBCID >= 0x7FFF
1025 && GlobalCRCErr
1026 && FE_DMUmask == 0xFFFF
1027 && ROD_DMUmask == 0xFFFF
1028 && BCIDErr == 0xFFFF
1029 && MemoryParityErr == 0xFFFF
1030 && HeaderFormatErr == 0xFFFF
1031 && HeaderParityErr == 0xFFFF
1032 && SampleFormatErr == 0xFFFF
1033 && SampleParityErr == 0xFFFF
1034 && SingleStrobeErr == 0xFFFF
1035 && DoubleStrobeErr == 0xFFFF) {
1036
1039 <<
" drw " <<
drwname(rawChannelCollection->identify())
1040 << " is OFF - skipping");
1041
1044 << " suppressing further messages about drawer 0x" << std::hex
1045 << rawChannelCollection->identify()
1046 << std::dec << " being bad");
1047 }
1048 continue;
1049 }
1050
1051 if (DSPBCID == 0
1052 && GlobalCRCErr == 0
1053 && FE_DMUmask == 0
1054 && ROD_DMUmask == 0
1055 && BCIDErr == 0
1056 && MemoryParityErr == 0
1057 && HeaderFormatErr == 0
1058 && HeaderParityErr == 0
1059 && SampleFormatErr == 0
1060 && SampleParityErr == 0
1061 && SingleStrobeErr == 0
1062 && DoubleStrobeErr == 0) {
1063
1066 <<
" drw " <<
drwname(rawChannelCollection->identify())
1067 << " is MISSING - skipping");
1068
1071 << " suppressing further messages about drawer 0x" << std::hex
1072 << rawChannelCollection->identify() << std::dec << " being bad");
1073 }
1074 continue;
1075 }
1076
1077 if (GlobalCRCErr) {
1078 GlobalCRCErr = 0xFFFF;
1082 <<
" drw " <<
drwname(rawChannelCollection->identify())
1083 << " global CRC error - skipping");
1084
1087 << " suppressing further messages about drawer 0x" << std::hex
1088 << rawChannelCollection->identify() << std::dec << " being bad");
1089 }
1090 someDQerrors = true;
1091 continue;
1092 }
1093 }
1094
1095 if (HeaderFormatErr || HeaderParityErr || SampleFormatErr || SampleParityErr ) {
1096 FE_DMUmask = 0xFFFF;
1097 } else {
1098 if (eb) {
1099 if (ebsp) FE_DMUmask<<=1;
1100 FE_DMUmask = (FE_DMUmask & 0xFF) | ((FE_DMUmask & 0xF00)<<2);
1101 }
1102 }
1103
1104 FE_DMUmask = ~FE_DMUmask & 0xFFFF;
1105 ROD_DMUmask = ~ROD_DMUmask & 0xFFFF;
1106
1107 if (BCIDErr & 0x2) {
1108 BCIDErr = 0xFFFF;
1112 <<
" drw " <<
drwname(rawChannelCollection->identify())
1113 << " BCID in DMU1 is bad - skipping");
1114
1117 << " suppressing further messages about drawer 0x"
1118 << std::hex << rawChannelCollection->identify() << std::dec << " being bad");
1119 }
1120 someDQerrors = true;
1121 continue;
1122 }
1123
1124 } else {
1125
1126 if ( DSPBCID!=0xDEAD && DSPBCID!=
m_evtBCID ) {
1127 BCIDErr = 0xFFFF;
1131 <<
" drw " <<
drwname(rawChannelCollection->identify())
1132 << " DSP BCID is wrong - skipping");
1133
1136 << " suppressing further messages about drawer 0x"
1137 << std::hex << rawChannelCollection->identify() << std::dec << " being bad");
1138 }
1139 someDQerrors = true;
1140 continue;
1141 }
1142 }
1143 }
1144
1145 uint32_t error = GlobalCRCErr | FE_DMUmask | ROD_DMUmask | BCIDErr | MemoryParityErr |
1146 HeaderFormatErr | HeaderParityErr | SampleFormatErr | SampleParityErr;
1147
1151 <<
" drw " <<
drwname(rawChannelCollection->identify())
1152 << " whole drawer is bad - skipping");
1153
1156 << " suppressing further messages about drawer 0x"
1157 << std::hex << rawChannelCollection->identify() << std::dec << " being bad");
1158 }
1159 someDQerrors = true;
1160 continue;
1161 }
1162
1163
1168 << " enabling messages about drawer 0x" << std::hex
1169 << rawChannelCollection->identify()
1170 << std::dec <<
" being bad after " <<
m_maxVerboseCnt <<
" good events");
1171 }
1172 }
1173
1175 if (eb) {
1176 if (ebsp) {
1177 errMB &= 0x3cfe;
1178 } else {
1179 errMB &= 0x3cff;
1180 }
1181 }
1182 int nbadMB = 0;
1183 while (errMB) {
1184 if (errMB & 0xF) ++nbadMB;
1185 errMB >>= 4;
1186 }
1188 if (nbadMB > nbadMBMax) {
1189 nbadMBMax = nbadMB;
1190 collMBMax = rawChannelCollection;
1191 }
1192
1193 int nerr = 0;
1194 for (uint32_t i = 0x8000;
i != 0;
i >>= 1) {
1195 if (error&i) {
1196 ++nerr;
1198 } else {
1199 if (emptyBad && nbadMB < 4) {
1203 } else {
1205 }
1206 }
1207 }
1208
1209 int nbad = ((ebsp) ? nerr-5 : ((eb) ? nerr-4 : nerr));
1210
1212 someDQerrors = true;
1213 if (nbad > nbadMax) {
1214 nbadMax = nbad;
1215 collMax = rawChannelCollection;
1216 }
1217 }
1218 if (someDQerrors) {
1221 }
1222 }
1223
1224 if (allowAmpCheck || emptyBad) {
1225
1226 for (const TileRawChannel* rawChannel : *rawChannelCollection) {
1227
1228 HWIdentifier adcId = rawChannel->adc_HWID();
1229 HWIdentifier chId =
m_tileHWID->channel_id(adcId);
1230 m_tileHWID->get_hash(chId, hash, &chan_context);
1234 int ch_type = 0;
1235 if (channel == chMBTS) {
1236 ch_type = 2;
1237 } else if ( (ebsp && (channel == 18 || channel == 19 || channel == 12 || channel == 13) )
1238 || (eb && (channel == 0 || channel == 1 || channel == 12 || channel == 13) ) ) {
1239 ch_type = 1;
1240 }
1243 (DQstatus && !DQstatus->isAdcDQgood(ros,drawer,channel,adc)) ||
1245 }
1246
1247 if (allowAmpCheck) {
1248
1249 float amp = rawChannel->amplitude();
1250 float time = rawChannel->time();
1251 if (fillChanEne) {
1255 } else {
1258 }
1259
1264 continue;
1265
1266 bool ampOk = false;
1271 } else {
1273 }
1274
1275 bool timeOk = false;
1280 } else {
1282 }
1283
1284 if (ampOk && timeOk) {
1285
1287 <<
" chan " << std::left << std::setw(14) <<
m_tileHWID->to_string(adcId)
1288 << " ch_ene = " << amp << " ch_t = " << time);
1289
1291
1292 if (amp < chmin) {
1294 minCh = rawChannel;
1295 } else if (amp > chmax) {
1297 maxCh = rawChannel;
1298 }
1299
1300 if (time<tcmin) {
1302 tminCh = rawChannel;
1303 }
1304 else if (time>tcmax) {
1306 tmaxCh = rawChannel;
1307 }
1308 }
1309 }
1310 }
1311 }
1312
1313 for (index = hashNext - 48;
index < hashNext; ++
index) {
1314 if ((
m_chanSel[index] && rawdata) || someDQerrors) {
1316 <<
" drw " <<
drwname(rawChannelCollection->identify())
1317 << " nBadMB = " << nbadMB
1318 << " nBadDMU = " << nbad
1320 << " DSPBCID = " << rawChannelCollection->getFragDSPBCID()
1321 << " GlobCRC = " << rawChannelCollection->getFragGlobalCRC() << " " << GlobalCRCErr
1322 << " error = 0x" << std::hex << error
1323 << " FE_CRC = 0x" << rawChannelCollection->getFragFEChipMask() << " 0x" << FE_DMUmask
1324 << " ROD_CRC = 0x" << rawChannelCollection->getFragRODChipMask() << " 0x" << ROD_DMUmask
1325 << " BCIDErr = 0x" << rawChannelCollection->getFragBCID() << " 0x" << BCIDErr
1326 << " MemPar = 0x" << rawChannelCollection->getFragMemoryPar()
1327 << " HeadForm = 0x"<< rawChannelCollection->getFragHeaderBit()
1328 << " HeadPar = 0x" << rawChannelCollection->getFragHeaderPar()
1329 << " SampForm = 0x"<< rawChannelCollection->getFragSampleBit()
1330 << " SampPar = 0x" << rawChannelCollection->getFragSamplePar()
1331 << std::dec);
1332 break;
1333 }
1334 }
1335 }
1336
1339 statusOk = true;
1342 << " nBadMB = " << nbadMBMax
1343 << " accepted");
1344
1347 statusOk = true;
1350 << " nBadDMU = " << nbadMax
1351 << " accepted");
1352 }
1353
1354 if (tminCh && tminCh != minCh && tminCh != maxCh) {
1356 <<
" chan " << std::left << std::setw(14) <<
m_tileHWID->to_string(tminCh->
adc_HWID())
1358 <<
" tmin =" << tminCh->
time());
1359 }
1360
1361 if (tmaxCh && tmaxCh != minCh && tmaxCh != maxCh) {
1363 <<
" chan " << std::left << std::setw(14) <<
m_tileHWID->to_string(tmaxCh->
adc_HWID())
1365 <<
" tmax = " << tmaxCh->
time());
1366 }
1367
1368 if (minCh) {
1370 statusOk = true;
1371 const char *
tit = (tminCh == minCh) ?
" tmin = ": ((tmaxCh == minCh) ?
" tmax = ":
" t = ");
1373 <<
" chan " << std::left << std::setw(14) <<
m_tileHWID->to_string(minCh->
adc_HWID())
1374 << " ch_emin = " << chmin
1375 << tit << minCh->
time()
1376 << " accepted");
1377 }
1378 if (maxCh) {
1380 statusOk = true;
1381 const char *
tit = (tminCh == maxCh) ?
" tmin = ": ((tmaxCh == maxCh) ?
" tmax = ":
" t = ");
1383 <<
" chan " << std::left << std::setw(14) <<
m_tileHWID->to_string(maxCh->
adc_HWID())
1384 << " ch_emax = " << chmax
1385 << tit << maxCh->
time()
1386 << " accepted");
1387 }
1388 emptyBad = false;
1389 }
1390 }
1391
1392
1394
1395
1397
1398 if (!digitsContainer.isValid()) {
1399 ATH_MSG_WARNING(
"Unable to read TileDigitsContainer from EventStore, disable reading of this container");
1401
1402 } else {
1403
1404 IdContext chan_context =
m_tileHWID->channel_context();
1405 IdentifierHash
hash;
1407 int nConst = 0;
1408 int nJump = 0;
1409 int nDmuErr = 0;
1410 int nOverLG = 0;
1411 int nOverHG = 0;
1412 int nUnderLG = 0;
1413 int nUnderHG = 0;
1414
1415 for (const TileDigitsCollection * digitsCollection : *digitsContainer) {
1416
1417 int frag = digitsCollection->identify();
1418 bool eb = (frag > 0x2ff);
1419 bool ebsp = (frag == 0x30e || frag == 0x411);
1420
1421 int ros = frag >> 8;
1422 int drawer = frag & 0x3F;
1425
1426 int chMBTS = -1;
1427 if (eb) {
1428 for (int ch: {12,4,0}) {
1429 m_cabling->h2s_cell_id_index(ros,drawer,ch,index,pmt);
1430 if (index == -2) {
1432 break;
1433 }
1434 }
1435 }
1436
1437 int nChBadDB = 0;
1438 int nChBadNC = 0;
1439 int nChBad = 0;
1440 int nChTot = 0;
1441 int nChDmu[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1442 int nChBadDmu[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1443
1444 for (const TileDigits* tile_digits : *digitsCollection) {
1445
1446 ++nChTot;
1447
1448 HWIdentifier adcId = tile_digits->adc_HWID();
1449 HWIdentifier chId =
m_tileHWID->channel_id(adcId);
1450 m_tileHWID->get_hash(chId, hash, &chan_context);
1454 ++nChDmu[dmu];
1456 bool isConnected = (chEmpty < 2);
1457 if (!isConnected) ++nChBadNC;
1459 const char *cellname = "";
1460 int ch_type = 0;
1461 if (channel == chMBTS) {
1462 cellname = " MBTS";
1463 ch_type = 2;
1464 } else if ( (ebsp && (channel == 18 || channel == 19 || channel == 12 || channel == 13) )
1465 || (eb && (channel == 0 || channel == 1 || channel == 12 || channel == 13) ) ) {
1466 cellname = " GAP";
1467 ch_type = 1;
1468 } else if (chEmpty > 0) {
1469 cellname = " EMPTY";
1470 }
1471
1472 const char *badname = "";
1473 if (DQstatus && !DQstatus->isAdcDQgood(ros,drawer,channel,adc)) {
1474 badname = " BADDQ";
1475 if (isConnected) {
1476 ++nChBad;
1477 ++nChBadDmu[dmu];
1478 }
1480 badname = " BADDCS";
1482 badname = " BADDB";
1483 if (isConnected) {
1484 ++nChBadDB;
1485 }
1487 if (badFromCell) {
1488 if (ch_type != 2) badname = " BADQUAL";
1490 if (isConnected && ch_type!=2) {
1491 ++nChBad;
1492 ++nChBadDmu[dmu];
1493 }
1494 } else {
1495 badname = " BADUNKN";
1496 }
1497 }
else if (badFromCell &&
m_chanEne[hash] == 0.0) {
1498 badname = " BADDIGI";
1499 if (isConnected) {
1500 ++nChBad;
1501 ++nChBadDmu[dmu];
1502 }
1503 }
1504 const char *enename = " ene = ";
1505 const char *timename = " time = ";
1506 const char *qualname = " qual = ";
1507 if (badFromCell && badname[0] != 0) {
1508 enename = " BAD = ";
1510 qualname = " eDSP = ";
1512 }
1514 timename = " tDSP = ";
1516 }
1517 }
1518
1519 char badnm[30];
1520 sprintf(badnm," BADDIGIEX%s",badname);
1521 float dmin,dmax;
1522
1523 std::vector<float> samples = tile_digits->samples();
1524 int nSamp = samples.size();
1525 if (nSamp > 6) {
1526
1530
1532
1533 if (badname[0]==0) {
1534 if (err && err>-3) {
1535 if (isConnected || err != -2) {
1537 badname = badnm;
1538 ++nChBad;
1539 ++nChBadDmu[dmu];
1540 if (!isConnected) --nChBadNC;
1541 }
1542 if (err > 0) {
1543 if (err < 10) {
1545 } else if (err < 36) {
1547 }
1548 } else {
1549 badnm[9] = 48;
1550 }
1551 } else {
1552
1553
1555 if (warn) {
1557 sprintf(badnm," warningE%d%s",warn,badname);
1558 badname = badnm;
1559 }
1560 }
1561 }
1562
1563 if ((!err)
1564 && (useCh)
1565 && (badname[0] == 0 || badname[1] == 'w'
1567
1568 if (adc) {
1569
1573 ++nOverHG;
1574 }
1575 }
1579 ++nUnderHG;
1580 }
1581 }
1582
1583 } else {
1584
1588 ++nOverLG;
1589 }
1590 }
1594 ++nUnderLG;
1595 }
1596 }
1597 }
1598 }
1599
1600 bool someSampErrors = false;
1601
1603
1606
1607 float ped = samples[0];
1610 int nped = 1;
1611 int npedmax = 1;
1612 bool cnstPed = true;
1613 bool cnstPedmax = true;
1614 for (
int i = 1;
i < nSamp; ++
i) {
1615 float smp = samples[
i];
1616 float dped = smp -
ped;
1617 if (fabs(dped) < pedDelta) {
1618 ++nped;
1619 if (dped != 0.0) {
1620 cnstPed = false;
1622 }
1623 } else {
1624 if (nped>npedmax) {
1625 npedmax=nped;
1626 cnstPedmax = cnstPed;
1627 }
1628 cnstPed = true;
1630 nped = 1;
1631 }
1632 if (smp<dmin) {
1633 dmin = smp;
1634 } else if (smp>dmax) {
1635 dmax = smp;
1636 }
1637 }
1638 if (nped>npedmax) {
1639 npedmax=nped;
1640 cnstPedmax = cnstPed;
1641 }
1642
1643 if (dmax - dmin >= jumpDelta) {
1646 bool accCnst = false;
1647 bool accJump = false;
1648 bool cnstMin = true;
1649 bool cnstMax = true;
1650 bool jumpNeg = false;
1651 bool jumpPos = false;
1652 bool jumpEnd = false;
1653 bool jumpZer = false;
1654 bool jumpOve = false;
1655 bool narrowUp = false;
1656 bool narrowDown = false;
1657 if (npedmax >=
m_constLength && ((dmax-ped) >= jumpDelta || (ped-dmin) >= jumpDelta) ) {
1658 ++nConst;
1659 accCnst = true;
1660 }
1661 int nmin = 0;
1663 int pmin = -1;
1664 int pmax = -1;
1665 float abovemin = dmax;
1666 float belowmax = dmin;
1667 for (
int i = 0;
i < nSamp; ++
i) {
1668 float smp = samples[
i];
1669 if (smp - dmin < pedDelta) {
1670 ++nmin;
1672 if (smp != dmin) cnstMin = false;
1673 }
1674 if (dmax - smp < pedDelta) {
1677 if (smp != dmax) cnstMax = false;
1678 }
1679 if (smp < abovemin && smp > dmin) {
1680 abovemin = smp;
1681 }
1682 if (smp > belowmax && smp < dmax) {
1683 belowmax = smp;
1684 }
1685 }
1686 if (
nmax + nmin == nSamp) {
1687 if (
nmax > 1 && nmin > 1) {
1688 ++nJump;
1689 accJump = true;
1690 }
else if (
nmax == 1) {
1691 if (pmax < nSamp - 1) {
1692 ++nJump;
1693 accJump = true;
1694 jumpPos = true;
1695 cnstMax = false;
1696 }
1697 if (pmax == 0 || pmax == nSamp - 1) {
1698 jumpEnd = true;
1699 }
1700 } else if (nmin == 1) {
1701 ++nJump;
1702 accJump = true;
1703 jumpNeg = true;
1704 cnstMin = false;
1705 if (pmin == 0 || pmin == nSamp - 1) {
1706 jumpEnd = true;
1707 }
1708 }
1709 }
1710 if (dmin == 0.0) {
1711 if (!accJump) {
1712 ++nJump;
1713 accJump = true;
1714 cnstMin = false;
1715 cnstMax = false;
1716 }
1717 jumpZer = true;
1718 }
1720 if (!accJump) {
1721 ++nJump;
1722 accJump = true;
1723 cnstMin = false;
1724 cnstMax = false;
1725 }
1726 jumpOve = true;
1727 }
1729 if (pmax > 0 && pmax < nSamp-1 && std::max(samples[pmax-1], samples[pmax+1]) < dmin+secondMax) {
1730 if (!accJump) {
1731 ++nJump;
1732 accJump = true;
1733 cnstMax = false;
1734 if (nmin +
nmax != nSamp) {
1735 cnstMin = false;
1736 }
1737 }
1738 narrowUp = true;
1739 }
1740 if (pmin > 0 && pmin < nSamp - 1 && std::min(samples[pmin - 1], samples[pmin + 1]) > dmax - secondMax) {
1741 if (!accJump) {
1742 ++nJump;
1743 accJump = true;
1744 cnstMin = false;
1745 if (nmin +
nmax != nSamp) {
1746 cnstMax = false;
1747 }
1748 }
1749 narrowDown = true;
1750 }
1751
1752 if (accEmin || accEmax || accCnst || accJump) {
1753 someSampErrors = true;
1755 <<
" chan " << std::left << std::setw(14) <<
m_tileHWID->to_string(adcId)
1756 << enename <<
m_chanEne[hash] <<
" samp = " << samples[0]
1757 << " " << samples[1] << " " << samples[2] << " " << samples[3]
1758 << " " << samples[4] << " " << samples[5] << " " << samples[6]
1761 << cellname << badname
1762 << ((accEmin) ? " neg_e" : "")
1763 << ((accEmax) ? " pos_e" : "")
1764 << ((accCnst) ? " const" : "")
1765 << ((accCnst&&cnstPedmax) ? "Const" : "")
1766 << ((accJump) ? " jump" : "")
1767 << ((accJump&&jumpZer) ? "Zero" : "")
1768 << ((accJump&&jumpOve) ? "Over" : "")
1769 << ((accJump&&jumpPos) ? "SingleUp" : ((narrowUp) ? "NarrowUp" : "") )
1770 << ((accJump&&jumpNeg) ? "SingleDown" : ((narrowDown) ? "NarrowDown" : "") )
1771 << ((accJump&&jumpEnd) ? "AtEdge" : "")
1772 << ((accJump&&cnstMin) ? "ConstMin" : "")
1773 << ((accJump&&cnstMax) ? "ConstMax" : "")
1774 << " " << dmax-dmin);
1775 }
1776 }
1777 }
1778
1779 if (someSampErrors) {
1785 bool jumpZer = (dmin < 0.01);
1787 <<
" chan " << std::left << std::setw(14) <<
m_tileHWID->to_string(adcId)
1788 << enename <<
m_chanEne[hash] <<
" samp = " << samples[0]
1789 << " " << samples[1] << " " << samples[2] << " " << samples[3]
1790 << " " << samples[4] << " " << samples[5] << " " << samples[6]
1793 << cellname << badname
1794 << ((accEmin) ? " neg_e" : "")
1795 << ((accEmax) ? " pos_e" : "")
1796 <<((jumpZer) ? " underflow" : "")
1797 <<((jumpOve) ? " overflow" : "") );
1798 }
1799
1800 }
1801 }
1802 if (
m_checkDMUs && nChBad > 1 && nChBad + nChBadDB + nChBadNC < nChTot) {
1803 int nChBad1 = 0;
1804 int nChBad2 = 0;
1805 int nDmuBad1 = 0;
1806 int nDmuBad2 = 0;
1807 int nDmuBad = 0;
1808 int nDmuTot = 0;
1809 bool has23 = false;
1810 for (int dmu = 0; dmu < 16; ++dmu) {
1811 if (nChDmu[dmu] > 0) {
1812 ++nDmuTot;
1813 if (nChBadDmu[dmu] > 0) {
1814 ++nDmuBad;
1815 if (dmu < 8) {
1816 nChBad1 += nChBadDmu[dmu];
1817 ++nDmuBad1;
1818 } else {
1819 nChBad2 += nChBadDmu[dmu];
1820 ++nDmuBad2;
1821 }
1822 if (nChBadDmu[dmu] == 2 && nChDmu[dmu] == 3) has23 = true;
1823 }
1824 }
1825 }
1826 if (nDmuBad == 1 ) continue;
1827 if (nDmuBad == 2 && nChBad < 3) continue;
1828
1829 if (nDmuBad>2 || nChBad > 9 || nChTot > 19 || has23) {
1830
1831 ++nDmuErr;
1832
1833 for (const TileDigits* tile_digits : *digitsCollection) {
1834
1835 HWIdentifier adcId = tile_digits->adc_HWID();
1836 HWIdentifier chId =
m_tileHWID->channel_id(adcId);
1837 m_tileHWID->get_hash(chId, hash, &chan_context);
1839 std::vector<float> samples = tile_digits->samples();
1840
1841 if (!
m_chanSel[hash] && samples.size()>6) {
1845 const char *cellname = "";
1846 int ch_type = 0;
1847 if (channel == chMBTS) {
1848 cellname = " MBTS";
1849 ch_type = 2;
1850 } else if ( (ebsp && (channel == 18 || channel == 19 || channel == 12 || channel == 13) )
1851 || (eb && (channel == 0 || channel == 1 || channel == 12 || channel == 13) ) ) {
1852 cellname = " GAP";
1853 ch_type = 1;
1854 } else if (chEmpty > 0) {
1855 cellname = " EMPTY";
1856 }
1857 const char *badname = "";
1859 badname = " BADDB";
1860 } else if (DQstatus && !DQstatus->isAdcDQgood(ros, drawer, channel, adc)) {
1861 badname = " BADDQ";
1863 badname = " BADDCS";
1865 if (badFromCell) {
1866 if (ch_type != 2) badname = " BADQUAL";
1868 } else {
1869 badname = " BADUNKN";
1870 }
1871 }
else if (badFromCell &&
m_chanEne[hash] == 0.0) {
1872 badname = " BADDIGI";
1873 }
1874
1875 char badnm[30];
1876 sprintf(badnm, " BADDIGIEX%s", badname);
1877 float dmin, dmax;
1878
1881 if (err) {
1882 bool isConnected = (chEmpty < 2);
1883 if (isConnected || err != -2) {
1884 badname = badnm;
1885 }
1886 if (err > 0) {
1887 if (err < 10) {
1888 badnm[9] = 48 +
err;
1889 } else if (err < 36) {
1890 badnm[9] = 55 +
err;
1891 }
1892 } else {
1893 badnm[9] = 48;
1894 }
1895 }
1896
1897 const char *enename = " ene = ";
1898 const char *timename = " time = ";
1899 const char *qualname = " qual = ";
1900 if (badFromCell && badname[0] != 0) {
1901 enename = " BAD = ";
1903 qualname = " eDSP = ";
1905 }
1907 timename = " tDSP = ";
1909 }
1910 }
1911
1915 bool jumpZer = (dmin < 0.01);
1916
1918 <<
" chan " << std::left << std::setw(14) <<
m_tileHWID->to_string(adcId)
1919 << enename <<
m_chanEne[hash] <<
" samp = " << samples[0]
1920 << " " << samples[1] << " " << samples[2] << " " << samples[3]
1921 << " " << samples[4] << " " << samples[5] << " " << samples[6]
1924 << cellname << badname
1925 << ((accEmin) ? " neg_e" : "")
1926 << ((accEmax) ? " pos_e" : "")
1927 << ((jumpZer) ? " underflow" : "")
1928 << ((jumpOve) ? " overflow" : "") );
1929
1930 }
1931 }
1932 }
1933
1934 std::ostringstream badstr;
1935 badstr << " ch: " << nChBad1 << " + " << nChBad2 << " = " << nChBad << " / " << nChTot << " = " << 100*nChBad/nChTot
1936 << " % dmu: " << nDmuBad1 << " + " << nDmuBad2 << " = " << nDmuBad << " / " << nDmuTot << " ";
1937 for (int dmu=0; dmu<16; ++dmu) {
1938 if (nChDmu[dmu]>0) {
1939 badstr << " " << std::hex << dmu << "=" << nChBadDmu[dmu] << "/" << nChDmu[dmu];
1940 }
1941 }
1943 <<
" drw " <<
drwname(digitsCollection->identify()) << badstr.str());
1944 }
1945 }
1946
1947 if (nConst) {
1949 statusOk = true;
1951 << " n_const_sample_errors = " << nConst
1952 << " accepted");
1953 }
1954 if (nJump) {
1956 statusOk = true;
1958 << " n_jump_sample_errors = " << nJump
1959 << " accepted");
1960 }
1961 if (nOverLG) {
1963 statusOk = true;
1965 << " n_overflow_LG = " << nOverLG
1966 << " accepted");
1967 }
1968 if (nOverHG) {
1970 statusOk = true;
1972 << " n_overflow_HG = " << nOverHG
1973 << " accepted");
1974 }
1975 if (nUnderLG) {
1977 statusOk = true;
1979 << " n_underflow_LG = " << nUnderLG
1980 << " accepted");
1981 }
1982 if (nUnderHG) {
1984 statusOk = true;
1986 << " n_underflow_HG = " << nUnderHG
1987 << " accepted");
1988 }
1989 if (nDmuErr) {
1991 statusOk = true;
1993 << " n_DMU_errors = " << nDmuErr
1994 << " accepted");
1995 }
1996 }
1997 }
1998
2000 this->setFilterPassed (false);
2001 else
2002 this->setFilterPassed (statusOk);
2003
2004 if (statusOk) {
2006
2007 } else {
2008
2009 }
2010
2011 return StatusCode::SUCCESS;
2012}
const boost::regex rr(r_r)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
static std::string drwname(int id)
static const Attributes_t empty
float time() const
get time (data member)
double energy() const
get energy (data member)
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
IdentifierHash onl2() const
cell online identifier 2
IdentifierHash onl1() const
cell online identifier 1
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
std::vector< float > m_chanEne
bool m_bitTimeCell[ptnlength]
int Are3FF(std::vector< float > &OptFilterDigits, int OptFilterGain, int ch_type)
std::vector< float > m_chanDsp
bool m_bitEneChan[3][ptnlength]
ToolHandle< ITileBadChanTool > m_tileBadChanTool
SG::ReadHandleKey< TileDQstatus > m_dqStatusKey
std::vector< bool > m_chanSel
std::vector< bool > m_chanToSkip
ToolHandle< ITileDCSTool > m_tileDCS
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
std::vector< bool > m_chanBad
bool m_bitTimeChan[3][ptnlength]
SG::ReadHandleKey< TileDigitsContainer > m_digitsContainerKey
SG::ReadHandleKey< CaloCellContainer > m_cellContainerKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
std::vector< int > m_nDrawerOff
std::vector< float > m_chanTime
std::vector< bool > m_drawerToSkip
std::vector< float > m_chanTDsp
std::vector< float > m_chanQua
float m_ADCmaskValueMinusEps
bool m_bitEneCell[ptnlength]
uint8_t qual1(void) const
get quality of first PMT (data member)
float time1(void) const
get time of first PMT
int gain2(void) const
get gain of second PMT
bool badch1(void) const
check if first PMT is in bad channel list and masked
uint8_t qbit2(void) const
get quality bits of second PMT (data member)
int gain1(void) const
get gain of first PMT
uint8_t qual2(void) const
get quality of second PMT (data member)
float ene1(void) const
get energy of first PMT
bool badch2(void) const
check if second PMT is in bad channel list and masked
float time2(void) const
get time of second PMT
uint8_t qbit1(void) const
get quality bits of first PMT (data member)
float ene2(void) const
get energy of second PMT
static int isChEmpty(int partition, int drawer, int ch)
True if channel is not fully implemented.
static int CorruptedData(int ros, int drawer, int channel, int gain, const std::vector< float > &digits, float &dmin, float &dmax, float ADCmaxMinusEps, float ADCmaskValueMinusEps)
@ OnlineMegaElectronVolts
float time(int ind=0) const
float amplitude(int ind=0) const
HWIdentifier adc_HWID(void) const
@ Tile
The Tile calorimeter.
@ Warning
The sub-detector issued a warning.
@ Error
The sub-detector issued an error.
time(flags, cells_name, *args, **kw)
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())