16 template <
class DigiClass>
28 digi.setReadoutIds(
eid);
30 int fiber = startPoint->
fiber();
44 int ncurr = 0, ntaken = 0;
47 if (ncurr >= startSample && ncurr <= endSample) {
48 digi.setSample(ntaken, *qie_work);
58 template <
class DigiClass>
60 const unsigned short*
limit,
70 digi.setReadoutIds(
eid);
71 int flavor, error_flags, capid0, channelid;
74 bool isCapRotating = !(error_flags & 0x1);
75 bool fiberErr = (error_flags & 0x2);
76 bool dataValid = !(error_flags & 0x2);
77 int fiberchan = channelid & 0x3;
78 int fiber = ((channelid >> 2) & 0x7) + 1;
91 int ncurr = 0, ntaken = 0;
92 const unsigned short* qie_work = startPoint;
96 int capidn = (isCapRotating) ? ((capid0 + ncurr) % 4) : (capid0);
97 int capidn1 = (isCapRotating) ? ((capid0 + ncurr + 1) % 4) : (capid0);
99 HcalQIESample s0((*qie_work) & 0x7F, capidn, fiber, fiberchan, dataValid, fiberErr);
100 HcalQIESample s1(((*qie_work) >> 8) & 0x7F, capidn1, fiber, fiberchan, dataValid, fiberErr);
102 if (ncurr >= startSample && ncurr <= endSample) {
103 digi.setSample(ntaken, s0);
107 if (ncurr >= startSample && ncurr <= endSample) {
108 digi.setSample(ntaken, s1);
113 digi.setSize(ntaken);
114 }
else if (flavor == 6) {
116 if (ncurr >= startSample && ncurr <= endSample) {
118 ((*qie_work) >> 8) & 0x3,
121 ((*qie_work) >> 10) & 0
x1,
122 ((*qie_work) >> 11) & 0
x1);
123 digi.setSample(ntaken,
sample);
129 digi.setSize(ntaken);
137 template <
class DigiClass>
147 digi.setReadoutIds(
eid);
148 int error_flags =
i.errFlags();
149 int capid0 =
i.capid0();
150 int flavor =
i.flavor();
152 bool isCapRotating = !(error_flags & 0x1);
153 bool fiberErr = (error_flags & 0x2);
154 bool dataValid = !(error_flags & 0x2);
155 int fiberchan =
i.channelid() & 0x3;
156 int fiber = ((
i.channelid() >> 2) & 0x7) + 1;
161 int ncurr = 0, ntaken = 0;
163 for (++
i;
i != iend && !
i.isHeader(); ++
i) {
164 int capidn = (isCapRotating) ? ((capid0 + ncurr) % 4) : (capid0);
166 HcalQIESample s(
i.adc(), capidn, fiber, fiberchan, dataValid, fiberErr);
168 if (ncurr >= startSample && ncurr <= endSample) {
169 digi.setSample(ntaken,
s);
174 digi.setSize(ntaken);
175 }
else if (flavor == 7) {
176 for (++
i;
i != iend && !
i.isHeader(); ++
i) {
177 if (ncurr >= startSample && ncurr <= endSample) {
179 digi.setSample(ntaken,
sample);
184 digi.setSize(ntaken);
213 if (raw.
size() < 16) {
228 static int slb(uint16_t theSample) {
return ((theSample >> 13) & 0x7); }
229 static int slbChan(uint16_t theSample) {
return (theSample >> 11) & 0x3; }
230 static int slbAndChan(uint16_t theSample) {
return (theSample >> 11) & 0x1F; }
249 const unsigned short *daq_first, *daq_last, *tp_first, *tp_last;
261 edm::LogWarning(
"Invalid Data") <<
"Invalid HTR data (data beyond payload size) observed on spigot "
262 << spigot <<
" of DCC with source id " << dccHeader->
getSourceId();
263 report.countSpigotFormatError();
270 edm::LogWarning(
"Invalid Data") <<
"CRC Error on HTR data observed on spigot " << spigot
271 <<
" of DCC with source id " << dccHeader->
getSourceId();
272 report.countSpigotFormatError();
276 int slot = spigot + 1;
287 edm::LogWarning(
"Invalid Data") <<
"Invalid uHTR data (data beyond payload size) observed on slot " << slot
288 <<
" of DTC with source id " << dtcHeader->
getSourceId();
289 report.countSpigotFormatError();
296 edm::LogWarning(
"Invalid Data") <<
"CRC Error on uHTR data observed on slot " << slot
297 <<
" of DTC with source id " << dtcHeader->
getSourceId();
298 report.countSpigotFormatError();
305 report.countEmptyEventSpigot();
315 edm::LogWarning(
"Invalid Data") <<
"Invalid HTR data observed on spigot " << spigot <<
" of DCC with source id "
317 report.countSpigotFormatError();
322 edm::LogWarning(
"Invalid Data") <<
"Histogram data passed to non-histogram unpacker on spigot " << spigot
323 <<
" of DCC with source id " << dccHeader->
getSourceId();
327 if (colls.
ttp !=
nullptr) {
330 ttpUnpack.
unpack(htr, colls.
ttp->back());
333 <<
"Skipping data on spigot " << spigot <<
" of DCC with source id " << dccHeader->
getSourceId()
334 <<
" which is from the TechTrigProcessor (use separate unpacker!)";
340 edm::LogWarning(
"HcalUnpacker") <<
"Skipping data on spigot " << spigot <<
" of DCC with source id "
341 << dccHeader->
getSourceId() <<
" which is of unknown flavor "
350 htr.
dataPointers(&daq_first, &daq_last, &tp_first, &tp_last);
352 int htr_tb = smid & 0x1;
353 int htr_slot = (smid >> 1) & 0x1F;
354 int htr_cr = (smid >> 6) & 0x1F;
360 int currFiberChan = 0x3F;
372 for (tp_work = tp_begin; tp_work != tp_end; tp_work++) {
373 if (tp_work->
raw() == 0xFFFF)
379 for (
int ibit = 0; ibit < 8; ibit++) {
380 int linear = sector * 8 + ibit;
381 if (!unrolled[
linear].checked) {
383 int fiber = (
linear / 3) + 1;
387 eid.setHTR(htr_cr, htr_slot, htr_tb);
403 if (tp_work->
raw() & (1 << ibit))
409 for (
int i = 0;
i < 24;
i++) {
412 unrolled[
i].
ieta, unrolled[
i].
iphi, unrolled[
i].
samples, unrolled[
i].soi, unrolled[
i].databits));
415 for (tp_work = tp_begin; tp_work != tp_end; tp_work++) {
416 if (tp_work->
raw() == 0xFFFF)
428 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No trigger primitive match found for electronics id :" <<
eid;
442 colls.
tpCont->back().setPresamples(nps);
452 colls.
tpCont->back().setSample(colls.
tpCont->back().size(), *tp_work);
453 colls.
tpCont->back().setSize(colls.
tpCont->back().size() + 1);
457 colls.
tpCont->back().setPresamples(ncurr);
471 for (qie_work = qie_begin; qie_work != qie_end;) {
472 if (qie_work->
raw() == 0xFFFF) {
480 eid.setHTR(htr_cr, htr_slot, htr_tb);
486 qie_work = HcalUnpacker_impl::unpack<ZDCDataFrame>(qie_work,
500 qie_work = HcalUnpacker_impl::unpack<HBHEDataFrame>(qie_work,
512 qie_work = HcalUnpacker_impl::unpack<HODataFrame>(qie_work,
524 qie_work = HcalUnpacker_impl::unpack<HFDataFrame>(qie_work,
538 qie_work = HcalUnpacker_impl::unpack<HcalCalibDataFrame>(qie_work,
561 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No match found for electronics id :" <<
eid;
571 const unsigned short* ptr_header = daq_first;
572 const unsigned short* ptr_end = daq_last + 1;
573 int flavor, error_flags, capid0, channelid;
575 while (ptr_header != ptr_end) {
576 if (*ptr_header == 0xFFFF) {
587 int fiberchan = channelid & 0x3;
588 int fiber = ((channelid >> 2) & 0x7) + 1;
592 eid.setHTR(htr_cr, htr_slot, htr_tb);
598 ptr_header = HcalUnpacker_impl::unpack_compact<ZDCDataFrame>(ptr_header,
612 ptr_header = HcalUnpacker_impl::unpack_compact<HBHEDataFrame>(ptr_header,
624 ptr_header = HcalUnpacker_impl::unpack_compact<HODataFrame>(ptr_header,
636 ptr_header = HcalUnpacker_impl::unpack_compact<HFDataFrame>(ptr_header,
650 ptr_header = HcalUnpacker_impl::unpack_compact<HcalCalibDataFrame>(ptr_header,
672 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No match found for electronics id :" <<
eid;
691 int namc =
amc13->NAMC();
692 for (
int iamc = 0; iamc < namc; iamc++) {
694 if (!
amc13->AMCEnabled(iamc))
697 if (!
amc13->AMCDataPresent(iamc)) {
699 edm::LogWarning(
"Invalid Data") <<
"Missing data observed on iamc " << iamc <<
" of AMC13 with source id "
700 <<
amc13->sourceId();
701 report.countSpigotFormatError();
704 if (!
amc13->AMCCRCOk(iamc)) {
706 edm::LogWarning(
"Invalid Data") <<
"CRC Error on uHTR data observed on iamc " << iamc
707 <<
" of AMC13 with source id " <<
amc13->sourceId();
708 report.countSpigotFormatError();
712 if (
amc13->AMCSegmented(iamc)) {
714 edm::LogWarning(
"Invalid Data") <<
"Unpacker cannot handle segmented data observed on iamc " << iamc
715 <<
" of AMC13 with source id " <<
amc13->sourceId();
716 report.countSpigotFormatError();
721 int slot =
amc13->AMCSlot(iamc);
722 int crate =
amc13->AMCId(iamc) & 0xFF;
726 if (uhtr.getFormatVersion() != 1) {
732 int nwords = uhtr.getRawLengthBytes() / 2;
733 for (
int iw = 0; iw < nwords; iw++)
734 printf(
"%04d %04x\n", iw, uhtr.getRawData16()[iw]);
738 int nps = uhtr.presamples();
743 std::cout <<
"This data is flavored:" <<
i.flavor() << std::endl;
749 std::cout <<
"its not a header" << std::endl;
754 if (
i.flavor() == 1 ||
i.flavor() == 0 ||
i.flavor() == 3) {
755 int ifiber = ((
i.channelid() >> 3) & 0x1F);
756 int ichan = (
i.channelid() & 0x7);
760 const uint16_t* head_pos =
i.raw();
762 for (++
i;
i != iend && !
i.isHeader(); ++
i) {
766 if (colls.
qie11 ==
nullptr) {
785 colls.
qie11Addtl[ns]->addDataFrame(did, head_pos);
791 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No match found for electronics id :" <<
eid;
794 std::cout <<
"HcalUnpacker: No match found for electronics id :" <<
eid << std::endl;
798 std::cout <<
"OH NO! detector id is null!" << std::endl;
801 }
else if (
i.flavor() == 2) {
804 int ifiber = ((
i.channelid() >> 3) & 0x1F);
805 int ichan = (
i.channelid() & 0x7);
810 const uint16_t* head_pos =
i.raw();
812 for (++
i;
i != iend && !
i.isHeader(); ++
i) {
826 }
else if (isLasmon) {
833 if (colls.
qie10 ==
nullptr) {
860 colls.
qie10Addtl[ns]->addDataFrame(did, head_pos);
867 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No match found for electronics id :" <<
eid;
870 std::cout <<
"HcalUnpacker: No match found for electronics id :" <<
eid << std::endl;
874 std::cout <<
"OH NO! HcalUnpacker: No match found for electronics id :" <<
eid << std::endl;
877 }
else if (
i.flavor() == 5 || (
i.flavor() == 7 &&
i.technicalDataType() == 15)) {
878 int ifiber = ((
i.channelid() >> 2) & 0x1F);
879 int ichan = (
i.channelid() & 0x3);
886 HcalUnpacker_impl::unpack_compact<ZDCDataFrame>(
893 HcalUnpacker_impl::unpack_compact<HBHEDataFrame>(
898 HcalUnpacker_impl::unpack_compact<HODataFrame>(
903 HcalUnpacker_impl::unpack_compact<HFDataFrame>(
910 HcalUnpacker_impl::unpack_compact<HcalCalibDataFrame>(
916 for (++
i;
i != iend && !
i.isHeader(); ++
i)
925 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No match found for electronics id :" <<
eid;
928 for (++
i;
i != iend && !
i.isHeader(); ++
i)
931 }
else if (
i.flavor() == 0x4) {
932 int ilink = ((
i.channelid() >> 4) & 0xF);
933 int itower = (
i.channelid() & 0xF);
937 std::cout <<
"Unpacking " <<
eid <<
" " <<
i.channelid() << std::endl;
943 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No trigger primitive match found for electronics id :" <<
eid;
947 for (++
i;
i != iend && !
i.isHeader(); ++
i)
950 for (++
i;
i != iend && !
i.isHeader(); ++
i)
955 std::cout <<
"Unpacking " <<
id << std::endl;
959 for (++
i;
i != iend && !
i.isHeader(); ++
i) {
960 colls.
tpCont->back().setSample(
j,
i.value());
962 colls.
tpCont->back().setPresamples(
j);
965 colls.
tpCont->back().setSize(
j);
969 for (++
i;
i != iend && !
i.isHeader(); ++
i)
993 std::vector<HcalHistogramDigi>& histoDigis) {
1008 if (retval || !htr.
check()) {
1009 edm::LogWarning(
"Invalid Data") <<
"Invalid HTR data observed on spigot " << spigot <<
" of DCC with source id "
1014 edm::LogWarning(
"Invalid Data") <<
"Non-histogram data passed to histogram unpacker on spigot " << spigot
1015 <<
" of DCC with source id " << dccHeader->
getSourceId();
1020 int htr_tb = smid & 0x1;
1021 int htr_slot = (smid >> 1) & 0x1F;
1022 int htr_cr = (smid >> 6) & 0x1F;
1028 for (
int nf = 0; nf < 2; nf++) {
1029 if (
f[nf] < 0 || (nf == 1 &&
f[0] ==
f[1]))
1031 for (
fc = 0;
fc <= 2;
fc++) {
1033 eid.setHTR(htr_cr, htr_slot, htr_tb);
1038 edm::LogWarning(
"HCAL") <<
"HcalHistogramUnpacker: No match found for electronics id :" <<
eid;
1047 for (
int capid = 0; capid < 4; capid++)
1056 int namc =
amc13->NAMC();
1058 for (
int iamc = 0; iamc < namc; iamc++) {
1059 if (
amc13->AMCSlot(iamc) == slot)
1062 if (namc ==
amc13->NAMC()) {
1065 const uint16_t*
data = (
const uint16_t*)(
amc13->AMCPayload(namc));
1066 size_t nwords =
amc13->AMCSize(namc) * (
sizeof(
uint64_t) /
sizeof(uint16_t));
1076 constexpr
int limit = 2;
1079 edm::LogInfo(
"Invalid Data") <<
"Suppressing further error messages";
1084 std::stringstream message;
1086 message <<
"The default " << coll_type <<
" Collection has " << default_ns
1087 <<
" samples per digi, while the current data has " << conflict_ns
1088 <<
"! This data cannot be included with the default collection.";
1091 message <<
"\nIn order to store this data in the event, it must have a unique tag. "
1092 <<
"To accomplish this, provide two lists to HcalRawToDigi \n"
1093 <<
"1) that specifies the number of samples and "
1094 <<
"2) that gives tags with which these data are saved.\n"
1095 <<
"For example in this case you might add \n"
1096 <<
"process.hcalDigis.save" << coll_type <<
"DataNSamples = cms.untracked.vint32( " << conflict_ns
1097 <<
") \nprocess.hcalDigis.save" << coll_type <<
"DataTags = cms.untracked.vstring( \"MYDATA\" )";