15 #include "eformat/SourceIdentifier.h"
37 {0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60,
38 3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63,
39 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61,
40 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62 };
52 return (crate << 24) | (1 << 20) | (
module << 16) | (pin << 8) | asic;
56 return twoBytePedCor > 511? (twoBytePedCor - 1024): twoBytePedCor;
60 std::string noAuxSuffix(
const std::string&
name) {
61 if ((
name.size() > 4) && (
name.substr(
name.size()-4, 4) ==
"Aux.")) {
62 return name.substr(0,
name.size() - 4);
76 m_errorTool(
"ZdcL1CaloErrorByteStreamTool/ZdcL1CaloErrorByteStreamTool"),
78 m_robDataProvider(
"ROBDataProviderSvc",
name) {
79 declareInterface<ZdcByteStreamReadV1V2Tool>(
this);
83 "Get ROB source IDs service");
97 const ZdcID* zdcID =
nullptr;
99 msg(MSG::ERROR) <<
"execute: Could not retrieve ZdcID object from the detector store" <<
endmsg;
100 return StatusCode::FAILURE;
109 return StatusCode::SUCCESS;
117 return StatusCode::SUCCESS;
133 for (; rob != robEnd; ++rob, ++robCounter) {
135 if (!
sc.isSuccess()) {
139 return StatusCode::SUCCESS;
155 ttCollection->setStore(aux);
163 if (
sc != StatusCode::SUCCESS)
173 (*zdcCollection) = (*zc);
176 return StatusCode::SUCCESS;
182 return convert(
"ZdcTriggerTowerContainer", ttCollection);
194 m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID, robFrags,
"ZdcByteStreamxAODReadTool");
195 ATH_MSG_DEBUG(
"Number of ROB fragments:" << robFrags.size());
198 return StatusCode::SUCCESS;
206 auto rob = **robIter;
209 "Treating ROB fragment source id #" << MSG::hex << rob.rob_source_id());
219 if (rob.nstatus() > 0) {
225 return StatusCode::FAILURE;
233 rob.rod_data(payloadBeg);
234 payloadEnd = payloadBeg + rob.rod_ndata();
239 return StatusCode::FAILURE;
244 uint16_t rodVer = rob.rod_version() & 0xffff;
245 state.
m_verCode = ((rodVer & 0xfff) << 4) | 1;
246 uint32_t rodRunNumber = rob.rod_run_no() & 0xffffff;
251 return StatusCode::FAILURE;
254 ATH_MSG_DEBUG(
"Treating crate " << rodCrate <<
" slink " << rodSlink);
259 return StatusCode::FAILURE;
263 "Run number: " << MSG::dec << rodRunNumber <<
endmsg
264 <<
"Version code: 0x" << MSG::hex <<
int(state.
m_verCode) << MSG::dec
265 <<
endmsg <<
"LUT triggered slice offset: "
268 <<
endmsg <<
"FADC baseline lower bound: "
298 }
else if (
blockType == (subBlock | 1)) {
304 case eformat::TDAQ_CALO_PREPROC:
307 case eformat::FORWARD_ZDC:
317 return StatusCode::SUCCESS;
333 return StatusCode::FAILURE;
335 return StatusCode::SUCCESS;
373 <<
"' for rob version '"
375 << MSG::dec <<
"'" );
376 return StatusCode::FAILURE;
378 return StatusCode::SUCCESS;
384 uint8_t totSlice = 3 * numLut + numFadc;
387 for (
int asic = 0 ; asic < 4 ; ++asic ) {
388 for (
int mcm = 0 ; mcm < 16 ; ++mcm ) {
390 std::vector<uint32_t> rotated(totSlice);
393 for (
uint8_t bit = 0 ; bit < 11 ; ++bit ) {
394 if ( state.
m_ppBlock[
slice * 11 + asic * (11 * totSlice) + bit + 1] & (1 << mcm))
395 rotated[
slice] |= (1 << bit);
399 bool nonZeroData =
false;
402 || rotated[
slice + numLut]
403 || rotated[
slice + 2 * numLut + numFadc]) {
409 std::vector<uint8_t> lcpVal;
410 std::vector<uint8_t> lcpBcidVec;
411 std::vector<uint8_t> ljeVal;
412 std::vector<uint8_t> ljeSat80Vec;
413 std::vector<int16_t> pedCor;
414 std::vector<uint8_t> pedEn;
416 std::vector<uint16_t> adcVal;
417 std::vector<uint8_t> adcExt;
421 lcpVal.push_back(rotated[
slice] & 0xff);
422 ljeVal.push_back(rotated[
slice + numLut] & 0xff);
423 pedCor.push_back(::pedCorrection(rotated[
slice + 2 * numLut + numFadc] & 0x3ff));
425 lcpBcidVec.push_back((rotated[
slice] >> 8) & 0x7);
426 ljeSat80Vec.push_back((rotated[
slice + numLut] >> 8) & 0x7);
427 pedEn.push_back((rotated[
slice + 2 * numLut + numFadc] >> 10) & 0x1);
432 if (rotated[
slice + numLut]) {
440 adcVal.push_back(rotated[
slice + 2 * numLut] & 0x3ff);
441 adcExt.push_back((rotated[
slice + 2 * numLut] >> 10 & 0
x1) & 0x3ff);
461 return StatusCode::SUCCESS;
471 present =
br.getField (1);
481 std::vector<uint16_t> adcVal = {0 , 0, 0, 0, 0};
482 std::vector<uint8_t> adcExt = {0 , 0, 0, 0, 0};
485 uint8_t minIndex = minHeader % 5;
486 if (minHeader < 15) {
487 if (minHeader < 10) {
490 fmt = 2 +
br.getField (2);
494 lutVal =
br.getField (3);
500 lutVal =
br.getField (8);
501 lutExt =
br.getField (1);
502 lutSat =
br.getField (1);
503 lutPeak =
br.getField (1);
508 adcExt[
i] =
br.getField (1);
532 std::vector<uint8_t> {lutVal},
533 std::vector<uint8_t> {uint8_t(lutExt | (lutSat << 1) | (lutPeak << 2))},
540 }
catch (
const std::out_of_range& ex) {
544 return StatusCode::SUCCESS;
551 std::vector<uint16_t>
adc = {0, 0, 0, 0, 0};
558 longField =
br.getField (1);
559 numBits = longField == 0? 4: (
format * 2);
561 numBits =
i == 0? 4: (
format + 2);
565 minAdc =
br.getField (numBits);
566 if (longField == 0) {
570 adc[
i] = minAdc +
br.getField (numBits);
578 adc[minIndex] = minAdc;
595 const uint8_t nTotal = numAdc + numLut;
596 const uint8_t wordsPerBlock = 8;
597 const uint8_t iBlk = inData / wordsPerBlock;
602 uint16_t subword = (word >> 16 *
i) & 0x7ff;
603 state.
m_ppLuts[iChan].push_back(subword);
606 }
else if (iBlk < nTotal) {
608 uint16_t subword = (word >> (16 *
i)) & 0x7ff;
609 state.
m_ppFadcs[iChan].push_back(subword);
615 sc = StatusCode::FAILURE;
625 return StatusCode::SUCCESS;
629 return StatusCode::SUCCESS;
631 return StatusCode::FAILURE;
651 std::vector<uint8_t> haveLut(numLut, 0);
652 std::vector<uint8_t> lcpVal(numLut, 0);
654 std::vector<uint8_t> lcpExt(numLut, 0);
655 std::vector<uint8_t> lcpSat(numLut, 0);
656 std::vector<uint8_t> lcpPeak(numLut, 0);
657 std::vector<uint8_t> lcpBcidVec(numLut, 0);
659 std::vector<uint8_t> ljeVal(numLut, 0);
661 std::vector<uint8_t> ljeLow(numLut, 0);
662 std::vector<uint8_t> ljeHigh(numLut, 0);
663 std::vector<uint8_t> ljeRes(numLut, 0);
664 std::vector<uint8_t> ljeSat80Vec(numLut, 0);
666 std::vector<uint16_t> adcVal(numAdc, 0);
667 std::vector<uint8_t> adcExt(numAdc, 0);
668 std::vector<int16_t> pedCor(numLut, 0);
669 std::vector<uint8_t> pedEn(numLut, 0);
672 int8_t minIndex = -1;
675 present =
br.getField (1);
683 for(
uint i=0;
i < numLut; ++
i) {
684 lcpPeak[
i] =
br.getField (1);
689 ljeLow[
i] =
br.getField (1);
696 if (lcpPeak[
i] == 1) {
697 lcpVal[
i] =
br.getField (4);
701 if (lcpPeak[
i] == 1){
702 ljeVal[
i] =
br.getField (3);
709 haveLut[
i] =
br.getField (1);
717 adcExt[
i] =
br.getField (1);
722 if (haveLut[
i] == 1) {
723 lcpVal[
i] =
br.getField (8);
724 lcpExt[
i] =
br.getField (1);
725 lcpSat[
i] =
br.getField (1);
726 lcpPeak[
i] =
br.getField (1);
731 if (haveLut[
i] == 1) {
732 ljeVal[
i] =
br.getField (8);
733 ljeLow[
i] =
br.getField (1);
734 ljeHigh[
i] =
br.getField (1);
735 ljeRes[
i] =
br.getField (1);
744 return StatusCode::FAILURE;
752 pedCor[
i] =
br.getField (6) + pedCorBase;
764 pedCor[
i] = ::pedCorrection(
val);
765 pedEn[
i] =
br.getField (1);
770 lcpBcidVec[
i] =
uint8_t((lcpPeak[
i] << 2) | (lcpSat[
i] << 1) | lcpExt[
i]);
771 ljeSat80Vec[
i] =
uint8_t((ljeRes[
i] << 2) | (ljeHigh[
i] << 1) | ljeLow[
i]);
774 chan, lcpVal, lcpBcidVec, ljeVal, ljeSat80Vec, adcVal, adcExt, pedCor,
777 }
catch (
const std::out_of_range& ex) {
781 return StatusCode::SUCCESS;
787 int8_t&
encoding, int8_t& minIndex)
const {
791 minHeader =
br.getField (4);
793 minIndex = minHeader % 5;
795 if (minHeader < 10) {
807 }
else if (numAdc == 7) {
809 }
else if (numAdc < 16) {
814 uint8_t fieldSize = 1 << numBits;
815 minHeader =
br.getField (numBits);
816 uint8_t encValue = fieldSize - 1;
817 if (minHeader == encValue) {
821 minHeader +=
br.getField (2) << numBits;
822 minIndex = minHeader % fieldSize;
823 encValue = 3 * fieldSize;
825 if (minHeader < encValue) {
842 return std::vector<uint16_t>(numAdc,
val);
844 std::vector<uint16_t>
adc(numAdc, 0);
846 adc[minIndex] = minAdc;
852 std::vector<uint16_t>
adc(numAdc, 0);
858 adc[minIndex] = minAdc;
860 adc[minIndex ==
i? 0:
i] =
br.getField (
871 return StatusCode::SUCCESS;
874 return StatusCode::FAILURE;
876 return StatusCode::FAILURE;
892 std::vector<uint8_t> lcpVal;
893 std::vector<uint8_t> lcpBcidVec;
895 std::vector<uint8_t> ljeVal;
896 std::vector<uint8_t> ljeSat80Vec;
900 std::vector<uint16_t> adcVal;
901 std::vector<uint8_t> adcExt;
902 std::vector<int16_t> pedCor;
903 std::vector<uint8_t> pedEn;
905 for (
int i = 0;
i < numLut; ++
i) {
906 lcpVal.push_back(
br.getField (8));
907 lcpBcidVec.push_back(
br.getField (3));
910 for (
int i = 0;
i < numLut; ++
i) {
911 ljeVal.push_back(
br.getField (8));
912 ljeSat80Vec.push_back(
br.getField (3));
915 for (
int i = 0;
i < numAdc; ++
i) {
916 adcVal.push_back(
br.getField (10));
917 adcExt.push_back(
br.getField (1));
920 for (
int i = 0;
i < numLut; ++
i) {
922 pedCor.push_back(pedCorrection(
pc));
923 pedEn.push_back(
br.getField (1));
925 }
catch (
const std::out_of_range& ex) {
931 ljeVal, ljeSat80Vec, adcVal, adcExt, pedCor, pedEn));
934 return StatusCode::SUCCESS;
947 return StatusCode::SUCCESS;
955 const std::vector<uint8_t>& lcpVal,
956 const std::vector<uint8_t>& lcpBcidVec,
957 const std::vector<uint8_t>& ljeVal,
958 const std::vector<uint8_t>& ljeSat80Vec,
959 const std::vector<uint16_t>& adcVal,
960 const std::vector<uint8_t>& adcExt,
961 const std::vector<int16_t>& pedCor,
962 const std::vector<uint8_t>& pedEn)
const {
969 bool isNotSpare =
false;
982 phi = 4 * pin + asic;
1010 tt->initialize(coolId,
eta,
phi, lcpVal, ljeVal, pedCor, pedEn,
1013 return StatusCode::SUCCESS;
1021 const std::vector<uint8_t>& luts,
1022 const std::vector<uint8_t>& lcpBcidVec,
1023 const std::vector<uint16_t>& fadc,
1024 const std::vector<uint8_t>& bcidExt
1027 std::vector<uint8_t> ljeSat80Vec;
1029 std::vector<int16_t> pedCor;
1030 std::vector<uint8_t> pedEn;
1033 luts , ljeSat80Vec, fadc, bcidExt, pedCor, pedEn)
1036 return StatusCode::SUCCESS;
1044 const std::vector<uint16_t>& luts,
1045 const std::vector<uint16_t>& fadc
1048 std::vector<uint8_t> lcpVal;
1049 std::vector<uint8_t> lcpBcidVec;
1051 std::vector<uint16_t> adcVal;
1052 std::vector<uint8_t> adcExt;
1054 for(
auto lut: luts) {
1055 lcpVal.push_back(BitField::get<uint8_t>(
lut, 0, 8));
1056 lcpBcidVec.push_back(BitField::get<uint8_t>(
lut, 8, 3));
1060 adcExt.push_back(BitField::get<uint8_t>(
f, 0, 1));
1061 adcVal.push_back(BitField::get<uint16_t>(
f, 1, 10));
1067 return StatusCode::SUCCESS;
1072 const int crates = 8;
1077 for (
int crate = 0; crate < crates; ++crate) {
1082 eformat::FORWARD_ZDC);
1086 if (crate > 1 && crate < 6) {
1088 if (crate < 4 && slink == 0) {
1099 const std::string& sgKey)
const
1101 if (sgKey.find(
"Muon") != std::string::npos) {
1104 else if (sgKey.find(
"Spare") != std::string::npos) {
1122 if ((iBit + numBits) <= 31) {
1129 result = field1 | (field2 << nb1);
1135 throw std::out_of_range(
"Requested too much bits from ppm block");
1140 typedef std::map<uint32_t,ZdcDigits*> hashmapType;
1141 hashmapType digits_map;
1149 uint32_t slinkChannel = asic*16 + pin;
1164 if (
iter == digits_map.end())
1167 digits_map.insert(std::pair<uint32_t,ZdcDigits*>(chan_hash,
new ZdcDigits(chan_id)));
1168 iter = digits_map.find(chan_hash);
1170 if (
iter != digits_map.end())
1173 if (
gain==0&&
delay==0) (*iter).second->set_digits_gain0_delay0(
tt->adc() );
1174 if (
gain==1&&
delay==0) (*iter).second->set_digits_gain1_delay0(
tt->adc() );
1175 if (
gain==0&&
delay==1) (*iter).second->set_digits_gain0_delay1(
tt->adc() );
1176 if (
gain==1&&
delay==1) (*iter).second->set_digits_gain1_delay1(
tt->adc() );
1186 while (
iter != iter_end)
1198 zdcCollection->
push_back((*iter).second);
1202 return zdcCollection;