15 template <
class DigiClass>
27 digi.setReadoutIds(
eid);
29 int fiber = startPoint->
fiber();
43 int ncurr = 0, ntaken = 0;
46 if (ncurr >= startSample && ncurr <= endSample) {
47 digi.setSample(ntaken, *qie_work);
57 template <
class DigiClass>
59 const unsigned short*
limit,
69 digi.setReadoutIds(
eid);
70 int flavor, error_flags, capid0, channelid;
73 bool isCapRotating = !(error_flags & 0x1);
74 bool fiberErr = (error_flags & 0x2);
75 bool dataValid = !(error_flags & 0x2);
76 int fiberchan = channelid & 0x3;
77 int fiber = ((channelid >> 2) & 0x7) + 1;
90 int ncurr = 0, ntaken = 0;
91 const unsigned short* qie_work = startPoint;
95 int capidn = (isCapRotating) ? ((capid0 + ncurr) % 4) : (capid0);
96 int capidn1 = (isCapRotating) ? ((capid0 + ncurr + 1) % 4) : (capid0);
98 HcalQIESample s0((*qie_work) & 0x7F, capidn, fiber, fiberchan, dataValid, fiberErr);
99 HcalQIESample s1(((*qie_work) >> 8) & 0x7F, capidn1, fiber, fiberchan, dataValid, fiberErr);
101 if (ncurr >= startSample && ncurr <= endSample) {
102 digi.setSample(ntaken, s0);
106 if (ncurr >= startSample && ncurr <= endSample) {
107 digi.setSample(ntaken, s1);
112 digi.setSize(ntaken);
113 }
else if (flavor == 6) {
115 if (ncurr >= startSample && ncurr <= endSample) {
117 ((*qie_work) >> 8) & 0x3,
120 ((*qie_work) >> 10) & 0
x1,
121 ((*qie_work) >> 11) & 0
x1);
122 digi.setSample(ntaken,
sample);
128 digi.setSize(ntaken);
136 template <
class DigiClass>
146 digi.setReadoutIds(
eid);
147 int error_flags =
i.errFlags();
148 int capid0 =
i.capid0();
149 int flavor =
i.flavor();
151 bool isCapRotating = !(error_flags & 0x1);
152 bool fiberErr = (error_flags & 0x2);
153 bool dataValid = !(error_flags & 0x2);
154 int fiberchan =
i.channelid() & 0x3;
155 int fiber = ((
i.channelid() >> 2) & 0x7) + 1;
160 int ncurr = 0, ntaken = 0;
162 for (++
i;
i != iend && !
i.isHeader(); ++
i) {
163 int capidn = (isCapRotating) ? ((capid0 + ncurr) % 4) : (capid0);
165 HcalQIESample s(
i.adc(), capidn, fiber, fiberchan, dataValid, fiberErr);
167 if (ncurr >= startSample && ncurr <= endSample) {
168 digi.setSample(ntaken,
s);
173 digi.setSize(ntaken);
174 }
else if (flavor == 7) {
175 for (++
i;
i != iend && !
i.isHeader(); ++
i) {
176 if (ncurr >= startSample && ncurr <= endSample) {
178 digi.setSample(ntaken,
sample);
183 digi.setSize(ntaken);
212 if (raw.
size() < 16) {
227 static int slb(uint16_t theSample) {
return ((theSample >> 13) & 0x7); }
228 static int slbChan(uint16_t theSample) {
return (theSample >> 11) & 0x3; }
229 static int slbAndChan(uint16_t theSample) {
return (theSample >> 11) & 0x1F; }
248 const unsigned short *daq_first, *daq_last, *tp_first, *tp_last;
260 edm::LogWarning(
"Invalid Data") <<
"Invalid HTR data (data beyond payload size) observed on spigot "
261 << spigot <<
" of DCC with source id " << dccHeader->
getSourceId();
262 report.countSpigotFormatError();
269 edm::LogWarning(
"Invalid Data") <<
"CRC Error on HTR data observed on spigot " << spigot
270 <<
" of DCC with source id " << dccHeader->
getSourceId();
271 report.countSpigotFormatError();
275 int slot = spigot + 1;
286 edm::LogWarning(
"Invalid Data") <<
"Invalid uHTR data (data beyond payload size) observed on slot " << slot
287 <<
" of DTC with source id " << dtcHeader->
getSourceId();
288 report.countSpigotFormatError();
295 edm::LogWarning(
"Invalid Data") <<
"CRC Error on uHTR data observed on slot " << slot
296 <<
" of DTC with source id " << dtcHeader->
getSourceId();
297 report.countSpigotFormatError();
304 report.countEmptyEventSpigot();
314 edm::LogWarning(
"Invalid Data") <<
"Invalid HTR data observed on spigot " << spigot <<
" of DCC with source id "
316 report.countSpigotFormatError();
321 edm::LogWarning(
"Invalid Data") <<
"Histogram data passed to non-histogram unpacker on spigot " << spigot
322 <<
" of DCC with source id " << dccHeader->
getSourceId();
326 if (colls.
ttp !=
nullptr) {
329 ttpUnpack.
unpack(htr, colls.
ttp->back());
332 <<
"Skipping data on spigot " << spigot <<
" of DCC with source id " << dccHeader->
getSourceId()
333 <<
" which is from the TechTrigProcessor (use separate unpacker!)";
339 edm::LogWarning(
"HcalUnpacker") <<
"Skipping data on spigot " << spigot <<
" of DCC with source id "
340 << dccHeader->
getSourceId() <<
" which is of unknown flavor "
349 htr.
dataPointers(&daq_first, &daq_last, &tp_first, &tp_last);
351 int htr_tb = smid & 0x1;
352 int htr_slot = (smid >> 1) & 0x1F;
353 int htr_cr = (smid >> 6) & 0x1F;
359 int currFiberChan = 0x3F;
371 for (tp_work = tp_begin; tp_work != tp_end; tp_work++) {
372 if (tp_work->
raw() == 0xFFFF)
378 for (
int ibit = 0; ibit < 8; ibit++) {
379 int linear = sector * 8 + ibit;
380 if (!unrolled[
linear].checked) {
382 int fiber = (
linear / 3) + 1;
386 eid.setHTR(htr_cr, htr_slot, htr_tb);
402 if (tp_work->
raw() & (1 << ibit))
408 for (
int i = 0;
i < 24;
i++) {
411 unrolled[
i].
ieta, unrolled[
i].
iphi, unrolled[
i].
samples, unrolled[
i].soi, unrolled[
i].databits));
414 for (tp_work = tp_begin; tp_work != tp_end; tp_work++) {
415 if (tp_work->
raw() == 0xFFFF)
427 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No trigger primitive match found for electronics id :" <<
eid;
441 colls.
tpCont->back().setPresamples(nps);
451 colls.
tpCont->back().setSample(colls.
tpCont->back().size(), *tp_work);
452 colls.
tpCont->back().setSize(colls.
tpCont->back().size() + 1);
456 colls.
tpCont->back().setPresamples(ncurr);
470 for (qie_work = qie_begin; qie_work != qie_end;) {
471 if (qie_work->
raw() == 0xFFFF) {
479 eid.setHTR(htr_cr, htr_slot, htr_tb);
485 qie_work = HcalUnpacker_impl::unpack<ZDCDataFrame>(qie_work,
499 qie_work = HcalUnpacker_impl::unpack<HBHEDataFrame>(qie_work,
511 qie_work = HcalUnpacker_impl::unpack<HODataFrame>(qie_work,
523 qie_work = HcalUnpacker_impl::unpack<HFDataFrame>(qie_work,
537 qie_work = HcalUnpacker_impl::unpack<HcalCalibDataFrame>(qie_work,
560 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No match found for electronics id :" <<
eid;
570 const unsigned short* ptr_header = daq_first;
571 const unsigned short* ptr_end = daq_last + 1;
572 int flavor, error_flags, capid0, channelid;
574 while (ptr_header != ptr_end) {
575 if (*ptr_header == 0xFFFF) {
586 int fiberchan = channelid & 0x3;
587 int fiber = ((channelid >> 2) & 0x7) + 1;
591 eid.setHTR(htr_cr, htr_slot, htr_tb);
597 ptr_header = HcalUnpacker_impl::unpack_compact<ZDCDataFrame>(ptr_header,
611 ptr_header = HcalUnpacker_impl::unpack_compact<HBHEDataFrame>(ptr_header,
623 ptr_header = HcalUnpacker_impl::unpack_compact<HODataFrame>(ptr_header,
635 ptr_header = HcalUnpacker_impl::unpack_compact<HFDataFrame>(ptr_header,
649 ptr_header = HcalUnpacker_impl::unpack_compact<HcalCalibDataFrame>(ptr_header,
671 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No match found for electronics id :" <<
eid;
690 int namc =
amc13->NAMC();
691 for (
int iamc = 0; iamc < namc; iamc++) {
693 if (!
amc13->AMCEnabled(iamc))
696 if (!
amc13->AMCDataPresent(iamc)) {
698 edm::LogWarning(
"Invalid Data") <<
"Missing data observed on iamc " << iamc <<
" of AMC13 with source id "
699 <<
amc13->sourceId();
700 report.countSpigotFormatError();
703 if (!
amc13->AMCCRCOk(iamc)) {
705 edm::LogWarning(
"Invalid Data") <<
"CRC Error on uHTR data observed on iamc " << iamc
706 <<
" of AMC13 with source id " <<
amc13->sourceId();
707 report.countSpigotFormatError();
711 if (
amc13->AMCSegmented(iamc)) {
713 edm::LogWarning(
"Invalid Data") <<
"Unpacker cannot handle segmented data observed on iamc " << iamc
714 <<
" of AMC13 with source id " <<
amc13->sourceId();
715 report.countSpigotFormatError();
720 int slot =
amc13->AMCSlot(iamc);
721 int crate =
amc13->AMCId(iamc) & 0xFF;
725 if (uhtr.getFormatVersion() != 1) {
731 int nwords = uhtr.getRawLengthBytes() / 2;
732 for (
int iw = 0; iw < nwords; iw++)
733 printf(
"%04d %04x\n", iw, uhtr.getRawData16()[iw]);
737 int nps = uhtr.presamples();
742 std::cout <<
"This data is flavored:" <<
i.flavor() << std::endl;
748 std::cout <<
"its not a header" << std::endl;
753 if (
i.flavor() == 1 ||
i.flavor() == 0 ||
i.flavor() == 3) {
754 int ifiber = ((
i.channelid() >> 3) & 0x1F);
755 int ichan = (
i.channelid() & 0x7);
759 const uint16_t* head_pos =
i.raw();
761 for (++
i;
i != iend && !
i.isHeader(); ++
i) {
765 if (colls.
qie11 ==
nullptr) {
784 colls.
qie11Addtl[ns]->addDataFrame(did, head_pos);
790 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No match found for electronics id :" <<
eid;
793 std::cout <<
"HcalUnpacker: No match found for electronics id :" <<
eid << std::endl;
797 std::cout <<
"OH NO! detector id is null!" << std::endl;
800 }
else if (
i.flavor() == 2) {
803 int ifiber = ((
i.channelid() >> 3) & 0x1F);
804 int ichan = (
i.channelid() & 0x7);
809 const uint16_t* head_pos =
i.raw();
811 for (++
i;
i != iend && !
i.isHeader(); ++
i) {
825 }
else if (isLasmon) {
832 if (colls.
qie10 ==
nullptr) {
859 colls.
qie10Addtl[ns]->addDataFrame(did, head_pos);
866 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No match found for electronics id :" <<
eid;
869 std::cout <<
"HcalUnpacker: No match found for electronics id :" <<
eid << std::endl;
873 std::cout <<
"OH NO! HcalUnpacker: No match found for electronics id :" <<
eid << std::endl;
876 }
else if (
i.flavor() == 5 || (
i.flavor() == 7 &&
i.technicalDataType() == 15)) {
877 int ifiber = ((
i.channelid() >> 2) & 0x1F);
878 int ichan = (
i.channelid() & 0x3);
885 HcalUnpacker_impl::unpack_compact<ZDCDataFrame>(
892 HcalUnpacker_impl::unpack_compact<HBHEDataFrame>(
897 HcalUnpacker_impl::unpack_compact<HODataFrame>(
902 HcalUnpacker_impl::unpack_compact<HFDataFrame>(
909 HcalUnpacker_impl::unpack_compact<HcalCalibDataFrame>(
915 for (++
i;
i != iend && !
i.isHeader(); ++
i)
924 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No match found for electronics id :" <<
eid;
927 for (++
i;
i != iend && !
i.isHeader(); ++
i)
930 }
else if (
i.flavor() == 0x4) {
931 int ilink = ((
i.channelid() >> 4) & 0xF);
932 int itower = (
i.channelid() & 0xF);
936 std::cout <<
"Unpacking " <<
eid <<
" " <<
i.channelid() << std::endl;
942 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No trigger primitive match found for electronics id :" <<
eid;
946 for (++
i;
i != iend && !
i.isHeader(); ++
i)
949 for (++
i;
i != iend && !
i.isHeader(); ++
i)
954 std::cout <<
"Unpacking " <<
id << std::endl;
958 for (++
i;
i != iend && !
i.isHeader(); ++
i) {
959 colls.
tpCont->back().setSample(
j,
i.value());
961 colls.
tpCont->back().setPresamples(
j);
964 colls.
tpCont->back().setSize(
j);
968 for (++
i;
i != iend && !
i.isHeader(); ++
i)
992 std::vector<HcalHistogramDigi>& histoDigis) {
1007 if (retval || !htr.
check()) {
1008 edm::LogWarning(
"Invalid Data") <<
"Invalid HTR data observed on spigot " << spigot <<
" of DCC with source id "
1013 edm::LogWarning(
"Invalid Data") <<
"Non-histogram data passed to histogram unpacker on spigot " << spigot
1014 <<
" of DCC with source id " << dccHeader->
getSourceId();
1019 int htr_tb = smid & 0x1;
1020 int htr_slot = (smid >> 1) & 0x1F;
1021 int htr_cr = (smid >> 6) & 0x1F;
1027 for (
int nf = 0; nf < 2; nf++) {
1028 if (
f[nf] < 0 || (nf == 1 &&
f[0] ==
f[1]))
1030 for (fc = 0; fc <= 2; fc++) {
1032 eid.setHTR(htr_cr, htr_slot, htr_tb);
1037 edm::LogWarning(
"HCAL") <<
"HcalHistogramUnpacker: No match found for electronics id :" <<
eid;
1046 for (
int capid = 0; capid < 4; capid++)
1055 int namc =
amc13->NAMC();
1057 for (
int iamc = 0; iamc < namc; iamc++) {
1058 if (
amc13->AMCSlot(iamc) == slot)
1061 if (namc ==
amc13->NAMC()) {
1064 const uint16_t*
data = (
const uint16_t*)(
amc13->AMCPayload(namc));
1065 size_t nwords =
amc13->AMCSize(namc) * (
sizeof(
uint64_t) /
sizeof(uint16_t));
1075 constexpr
int limit = 2;
1078 edm::LogInfo(
"Invalid Data") <<
"Suppressing further error messages";
1083 std::stringstream message;
1085 message <<
"The default " << coll_type <<
" Collection has " << default_ns
1086 <<
" samples per digi, while the current data has " << conflict_ns
1087 <<
"! This data cannot be included with the default collection.";
1090 message <<
"\nIn order to store this data in the event, it must have a unique tag. "
1091 <<
"To accomplish this, provide two lists to HcalRawToDigi \n"
1092 <<
"1) that specifies the number of samples and "
1093 <<
"2) that gives tags with which these data are saved.\n"
1094 <<
"For example in this case you might add \n"
1095 <<
"process.hcalDigis.save" << coll_type <<
"DataNSamples = cms.untracked.vint32( " << conflict_ns
1096 <<
") \nprocess.hcalDigis.save" << coll_type <<
"DataTags = cms.untracked.vstring( \"MYDATA\" )";