15 #include "eformat/SourceIdentifier.h"
42 {0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60,
43 3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63,
44 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61,
45 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62 };
57 return (crate << 24) | (1 << 20) | (
module << 16) | (pin << 8) | asic;
61 return twoBytePedCor > 511? (twoBytePedCor - 1024): twoBytePedCor;
65 std::string noAuxSuffix(
const std::string&
name) {
66 if ((
name.size() > 4) && (
name.substr(
name.size()-4, 4) ==
"Aux.")) {
67 return name.substr(0,
name.size() - 4);
81 m_errorTool(
"ZdcL1CaloErrorByteStreamTool/ZdcL1CaloErrorByteStreamTool"),
83 m_robDataProvider(
"ROBDataProviderSvc",
name) {
84 declareInterface<ZdcByteStreamReadV1V2Tool>(
this);
88 "Get ROB source IDs service");
102 const ZdcID* zdcID =
nullptr;
104 msg(MSG::ERROR) <<
"execute: Could not retrieve ZdcID object from the detector store" <<
endmsg;
105 return StatusCode::FAILURE;
114 return StatusCode::SUCCESS;
122 return StatusCode::SUCCESS;
138 for (; rob != robEnd; ++rob, ++robCounter) {
140 if (!
sc.isSuccess()) {
144 return StatusCode::SUCCESS;
160 ttCollection->setStore(aux);
168 if (
sc != StatusCode::SUCCESS)
178 (*zdcCollection) = (*zc);
181 return StatusCode::SUCCESS;
187 return convert(
"ZdcTriggerTowerContainer", ttCollection);
200 ATH_MSG_DEBUG(
"Number of ROB fragments:" << robFrags.size());
203 return StatusCode::SUCCESS;
211 auto rob = **robIter;
214 "Treating ROB fragment source id #" << MSG::hex << rob.rob_source_id());
224 if (rob.nstatus() > 0) {
230 return StatusCode::FAILURE;
238 rob.rod_data(payloadBeg);
239 payloadEnd = payloadBeg + rob.rod_ndata();
244 return StatusCode::FAILURE;
249 uint16_t rodVer = rob.rod_version() & 0xffff;
250 state.
m_verCode = ((rodVer & 0xfff) << 4) | 1;
251 uint32_t rodRunNumber = rob.rod_run_no() & 0xffffff;
256 return StatusCode::FAILURE;
259 ATH_MSG_DEBUG(
"Treating crate " << rodCrate <<
" slink " << rodSlink);
264 return StatusCode::FAILURE;
268 "Run number: " << MSG::dec << rodRunNumber <<
endmsg
269 <<
"Version code: 0x" << MSG::hex <<
int(state.
m_verCode) << MSG::dec
270 <<
endmsg <<
"LUT triggered slice offset: "
273 <<
endmsg <<
"FADC baseline lower bound: "
303 }
else if (
blockType == (subBlock | 1)) {
309 case eformat::TDAQ_CALO_PREPROC:
312 case eformat::FORWARD_ZDC:
322 return StatusCode::SUCCESS;
338 return StatusCode::FAILURE;
340 return StatusCode::SUCCESS;
378 <<
"' for rob version '"
380 << MSG::dec <<
"'" );
381 return StatusCode::FAILURE;
383 return StatusCode::SUCCESS;
389 uint8_t totSlice = 3 * numLut + numFadc;
392 for (
int asic = 0 ; asic < 4 ; ++asic ) {
393 for (
int mcm = 0 ; mcm < 16 ; ++mcm ) {
395 std::vector<uint32_t> rotated(totSlice);
398 for (
uint8_t bit = 0 ; bit < 11 ; ++bit ) {
399 if ( state.
m_ppBlock[
slice * 11 + asic * (11 * totSlice) + bit + 1] & (1 << mcm))
400 rotated[
slice] |= (1 << bit);
404 bool nonZeroData =
false;
407 || rotated[
slice + numLut]
408 || rotated[
slice + 2 * numLut + numFadc]) {
414 std::vector<uint8_t> lcpVal;
415 std::vector<uint8_t> lcpBcidVec;
416 std::vector<uint8_t> ljeVal;
417 std::vector<uint8_t> ljeSat80Vec;
418 std::vector<int16_t> pedCor;
419 std::vector<uint8_t> pedEn;
421 std::vector<uint16_t> adcVal;
422 std::vector<uint8_t> adcExt;
426 lcpVal.push_back(rotated[
slice] & 0xff);
427 ljeVal.push_back(rotated[
slice + numLut] & 0xff);
428 pedCor.push_back(::pedCorrection(rotated[
slice + 2 * numLut + numFadc] & 0x3ff));
430 lcpBcidVec.push_back((rotated[
slice] >> 8) & 0x7);
431 ljeSat80Vec.push_back((rotated[
slice + numLut] >> 8) & 0x7);
432 pedEn.push_back((rotated[
slice + 2 * numLut + numFadc] >> 10) & 0x1);
437 if (rotated[
slice + numLut]) {
445 adcVal.push_back(rotated[
slice + 2 * numLut] & 0x3ff);
446 adcExt.push_back((rotated[
slice + 2 * numLut] >> 10 & 0
x1) & 0x3ff);
466 return StatusCode::SUCCESS;
476 present =
br.getField (1);
486 std::vector<uint16_t> adcVal = {0 , 0, 0, 0, 0};
487 std::vector<uint8_t> adcExt = {0 , 0, 0, 0, 0};
490 uint8_t minIndex = minHeader % 5;
491 if (minHeader < 15) {
492 if (minHeader < 10) {
495 fmt = 2 +
br.getField (2);
499 lutVal =
br.getField (3);
505 lutVal =
br.getField (8);
506 lutExt =
br.getField (1);
507 lutSat =
br.getField (1);
508 lutPeak =
br.getField (1);
513 adcExt[
i] =
br.getField (1);
537 std::vector<uint8_t> {lutVal},
538 std::vector<uint8_t> {uint8_t(lutExt | (lutSat << 1) | (lutPeak << 2))},
545 }
catch (
const std::out_of_range& ex) {
549 return StatusCode::SUCCESS;
556 std::vector<uint16_t>
adc = {0, 0, 0, 0, 0};
563 longField =
br.getField (1);
564 numBits = longField == 0? 4: (
format * 2);
566 numBits =
i == 0? 4: (
format + 2);
570 minAdc =
br.getField (numBits);
571 if (longField == 0) {
575 adc[
i] = minAdc +
br.getField (numBits);
583 adc[minIndex] = minAdc;
600 const uint8_t nTotal = numAdc + numLut;
601 const uint8_t wordsPerBlock = 8;
602 const uint8_t iBlk = inData / wordsPerBlock;
607 uint16_t subword = (word >> 16 *
i) & 0x7ff;
608 state.
m_ppLuts[iChan].push_back(subword);
611 }
else if (iBlk < nTotal) {
613 uint16_t subword = (word >> (16 *
i)) & 0x7ff;
614 state.
m_ppFadcs[iChan].push_back(subword);
620 sc = StatusCode::FAILURE;
630 return StatusCode::SUCCESS;
634 return StatusCode::SUCCESS;
636 return StatusCode::FAILURE;
656 std::vector<uint8_t> haveLut(numLut, 0);
657 std::vector<uint8_t> lcpVal(numLut, 0);
659 std::vector<uint8_t> lcpExt(numLut, 0);
660 std::vector<uint8_t> lcpSat(numLut, 0);
661 std::vector<uint8_t> lcpPeak(numLut, 0);
662 std::vector<uint8_t> lcpBcidVec(numLut, 0);
664 std::vector<uint8_t> ljeVal(numLut, 0);
666 std::vector<uint8_t> ljeLow(numLut, 0);
667 std::vector<uint8_t> ljeHigh(numLut, 0);
668 std::vector<uint8_t> ljeRes(numLut, 0);
669 std::vector<uint8_t> ljeSat80Vec(numLut, 0);
671 std::vector<uint16_t> adcVal(numAdc, 0);
672 std::vector<uint8_t> adcExt(numAdc, 0);
673 std::vector<int16_t> pedCor(numLut, 0);
674 std::vector<uint8_t> pedEn(numLut, 0);
677 int8_t minIndex = -1;
680 present =
br.getField (1);
688 for(
uint i=0;
i < numLut; ++
i) {
689 lcpPeak[
i] =
br.getField (1);
694 ljeLow[
i] =
br.getField (1);
701 if (lcpPeak[
i] == 1) {
702 lcpVal[
i] =
br.getField (4);
706 if (lcpPeak[
i] == 1){
707 ljeVal[
i] =
br.getField (3);
714 haveLut[
i] =
br.getField (1);
722 adcExt[
i] =
br.getField (1);
727 if (haveLut[
i] == 1) {
728 lcpVal[
i] =
br.getField (8);
729 lcpExt[
i] =
br.getField (1);
730 lcpSat[
i] =
br.getField (1);
731 lcpPeak[
i] =
br.getField (1);
736 if (haveLut[
i] == 1) {
737 ljeVal[
i] =
br.getField (8);
738 ljeLow[
i] =
br.getField (1);
739 ljeHigh[
i] =
br.getField (1);
740 ljeRes[
i] =
br.getField (1);
749 return StatusCode::FAILURE;
757 pedCor[
i] =
br.getField (6) + pedCorBase;
769 pedCor[
i] = ::pedCorrection(
val);
770 pedEn[
i] =
br.getField (1);
775 lcpBcidVec[
i] =
uint8_t((lcpPeak[
i] << 2) | (lcpSat[
i] << 1) | lcpExt[
i]);
776 ljeSat80Vec[
i] =
uint8_t((ljeRes[
i] << 2) | (ljeHigh[
i] << 1) | ljeLow[
i]);
779 chan, lcpVal, lcpBcidVec, ljeVal, ljeSat80Vec, adcVal, adcExt, pedCor,
782 }
catch (
const std::out_of_range& ex) {
786 return StatusCode::SUCCESS;
792 int8_t&
encoding, int8_t& minIndex)
const {
796 minHeader =
br.getField (4);
798 minIndex = minHeader % 5;
800 if (minHeader < 10) {
812 }
else if (numAdc == 7) {
814 }
else if (numAdc < 16) {
819 uint8_t fieldSize = 1 << numBits;
820 minHeader =
br.getField (numBits);
821 uint8_t encValue = fieldSize - 1;
822 if (minHeader == encValue) {
826 minHeader +=
br.getField (2) << numBits;
827 minIndex = minHeader % fieldSize;
828 encValue = 3 * fieldSize;
830 if (minHeader < encValue) {
847 return std::vector<uint16_t>(numAdc,
val);
849 std::vector<uint16_t>
adc(numAdc, 0);
851 adc[minIndex] = minAdc;
857 std::vector<uint16_t>
adc(numAdc, 0);
863 adc[minIndex] = minAdc;
865 adc[minIndex ==
i? 0:
i] =
br.getField (
876 return StatusCode::SUCCESS;
879 return StatusCode::FAILURE;
881 return StatusCode::FAILURE;
897 std::vector<uint8_t> lcpVal;
898 std::vector<uint8_t> lcpBcidVec;
900 std::vector<uint8_t> ljeVal;
901 std::vector<uint8_t> ljeSat80Vec;
905 std::vector<uint16_t> adcVal;
906 std::vector<uint8_t> adcExt;
907 std::vector<int16_t> pedCor;
908 std::vector<uint8_t> pedEn;
910 for (
int i = 0;
i < numLut; ++
i) {
911 lcpVal.push_back(
br.getField (8));
912 lcpBcidVec.push_back(
br.getField (3));
915 for (
int i = 0;
i < numLut; ++
i) {
916 ljeVal.push_back(
br.getField (8));
917 ljeSat80Vec.push_back(
br.getField (3));
920 for (
int i = 0;
i < numAdc; ++
i) {
921 adcVal.push_back(
br.getField (10));
922 adcExt.push_back(
br.getField (1));
925 for (
int i = 0;
i < numLut; ++
i) {
927 pedCor.push_back(pedCorrection(
pc));
928 pedEn.push_back(
br.getField (1));
930 }
catch (
const std::out_of_range& ex) {
936 ljeVal, ljeSat80Vec, adcVal, adcExt, pedCor, pedEn));
939 return StatusCode::SUCCESS;
943 for(
const auto& lut : state.
m_ppLuts) {
952 return StatusCode::SUCCESS;
960 const std::vector<uint8_t>& lcpVal,
961 const std::vector<uint8_t>& lcpBcidVec,
962 const std::vector<uint8_t>& ljeVal,
963 const std::vector<uint8_t>& ljeSat80Vec,
964 const std::vector<uint16_t>& adcVal,
965 const std::vector<uint8_t>& adcExt,
966 const std::vector<int16_t>& pedCor,
967 const std::vector<uint8_t>& pedEn)
const {
974 bool isNotSpare =
false;
987 phi = 4 * pin + asic;
1015 tt->initialize(coolId,
eta,
phi, lcpVal, ljeVal, pedCor, pedEn,
1018 return StatusCode::SUCCESS;
1026 const std::vector<uint8_t>& luts,
1027 const std::vector<uint8_t>& lcpBcidVec,
1028 const std::vector<uint16_t>& fadc,
1029 const std::vector<uint8_t>& bcidExt
1032 std::vector<uint8_t> ljeSat80Vec;
1034 std::vector<int16_t> pedCor;
1035 std::vector<uint8_t> pedEn;
1038 luts , ljeSat80Vec, fadc, bcidExt, pedCor, pedEn)
1041 return StatusCode::SUCCESS;
1049 const std::vector<uint16_t>& luts,
1050 const std::vector<uint16_t>& fadc
1053 std::vector<uint8_t> lcpVal;
1054 std::vector<uint8_t> lcpBcidVec;
1056 std::vector<uint16_t> adcVal;
1057 std::vector<uint8_t> adcExt;
1059 for(
auto lut: luts) {
1060 lcpVal.push_back(BitField::get<uint8_t>(lut, 0, 8));
1061 lcpBcidVec.push_back(BitField::get<uint8_t>(lut, 8, 3));
1065 adcExt.push_back(BitField::get<uint8_t>(
f, 0, 1));
1066 adcVal.push_back(BitField::get<uint16_t>(
f, 1, 10));
1072 return StatusCode::SUCCESS;
1077 const int crates = 8;
1082 for (
int crate = 0; crate < crates; ++crate) {
1087 eformat::FORWARD_ZDC);
1091 if (crate > 1 && crate < 6) {
1093 if (crate < 4 && slink == 0) {
1104 const std::string& sgKey)
const
1106 if (sgKey.find(
"Muon") != std::string::npos) {
1109 else if (sgKey.find(
"Spare") != std::string::npos) {
1127 if ((iBit + numBits) <= 31) {
1134 result = field1 | (field2 << nb1);
1140 throw std::out_of_range(
"Requested too much bits from ppm block");
1145 typedef std::map<uint32_t,ZdcDigits*> hashmapType;
1146 hashmapType digits_map;
1159 uint32_t slinkChannel = asic*16 + pin;
1174 if (iter == digits_map.end())
1177 digits_map.insert(std::pair<uint32_t,ZdcDigits*>(chan_hash,
new ZdcDigits(chan_id)));
1178 iter = digits_map.find(chan_hash);
1180 if (iter != digits_map.end())
1183 if (
gain==0&&
delay==0) (*iter).second->set_digits_gain0_delay0(
tt->adc() );
1184 if (
gain==1&&
delay==0) (*iter).second->set_digits_gain1_delay0(
tt->adc() );
1185 if (
gain==0&&
delay==1) (*iter).second->set_digits_gain0_delay1(
tt->adc() );
1186 if (
gain==1&&
delay==1) (*iter).second->set_digits_gain1_delay1(
tt->adc() );
1196 while (iter != iter_end)
1208 zdcCollection->
push_back((*iter).second);
1212 return zdcCollection;