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) & 0x1,
121 ((*qie_work) >> 11) & 0x1);
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++) {
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\" )";
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
std::set< HcalElectronicsId > unknownIds_
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&Pass ZS?
int sourceIdOffset_
number to subtract from the source id to get the dcc id
int endSample_
last sample from fed raw data to copy (if present)
int startSample_
first sample from fed raw data to copy
static int slbAndChan(uint16_t theSample)
void unpackUTCA(const FEDRawData &raw, const HcalElectronicsMap &emap, Collections &conts, HcalUnpackerReport &report, bool silent=false)
std::vector< HcalTTPDigi > * ttp
constexpr int fiberChan() const
get the fiber channel number
std::vector< HFDataFrame > * hfCont
constexpr int fiberAndChan() const
get the id channel
void addDataFrame(DetId detid, const uint16_t *data)
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
static bool isTPGSOI(const HcalTriggerPrimitiveSample &s)
int getNPS() const
Get the number of presamples in daq data.
QIE10DigiCollection * qie10Lasermon
size_t size() const
Lenght of the data buffer in bytes.
const unsigned short * unpack_compact(const unsigned short *startPoint, const unsigned short *limit, DigiClass &digi, int presamples, const HcalElectronicsId &eid, int startSample, int endSample, int expectedTime, const HcalHTRData &hhd)
bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned short *histogram) const
Unpack special histogramming mode data.
std::vector< HBHEDataFrame > * hbheCont
std::vector< HOTriggerPrimitiveDigi > * tphoCont
uint32_t zsBunchMask() const
ZS Bunch Mask (if available)
static bool unpack_per_channel_header(unsigned short, int &flav, int &error_flags, int &capid0, int &channelid)
Unpack a per-channel header word (compact format)
std::unordered_map< int, QIE11DigiCollection * > qie11Addtl
constexpr Detector det() const
get the detector field from this detid
int getFirmwareFlavor() const
Get the HTR firmware flavor.
bool isOverflowWarning() const
void printInvalidDataMessage(const std::string &coll_type, int default_ns, int conflict_ns, bool extended=false)
HcalDataFrameContainer< QIE10DataFrame > QIE10DigiCollection
void dataPointers(const unsigned short **daq_first, const unsigned short **daq_last, const unsigned short **tp_first, const unsigned short **tp_last) const
Obtain the starting and ending pointers for external unpacking of the data.
constexpr bool null() const
is this a null id ?
uint16_t raw() const
get the raw word
static bool is_channel_header(unsigned short value)
check top bit to see if this is a compact format channel header word
std::unordered_map< int, QIE10DigiCollection * > qie10Addtl
QIE10DigiCollection * qie10ZDC
constexpr int ieta() const
get the cell ieta
int expectedOrbitMessageTime_
Expected orbit bunch time (needed to evaluate time differences)
int getFormatVersion() const
Get the version number of this event.
bool wasMarkAndPassZSTP(int slb, int slbchan) const
Was this channel passed as part of Mark&Pass ZS?
void unpackVME(const FEDRawData &raw, const HcalElectronicsMap &emap, Collections &conts, HcalUnpackerReport &report, bool silent=false)
std::vector< HcalTriggerPrimitiveDigi > * tpCont
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
void getHistogramFibers(int &a, int &b) const
Get the fiber numbers for the data present in this event (only in histogram mode!) ...
std::set< HcalElectronicsId > unknownIdsTrig_
Recorded to limit number of times a log message is generated.
HcalDataFrameContainer< QIE11DataFrame > QIE11DigiCollection
Log< level::Info, false > LogInfo
void unpack(const FEDRawData &raw, const HcalElectronicsMap &emap, std::vector< HcalHistogramDigi > &histoDigis)
static const int SubdetectorId
std::vector< HcalCalibDataFrame > * calibCont
constexpr uint16_t raw() const
get the raw word
static int slb(uint16_t theSample)
unsigned long long uint64_t
constexpr int fiber() const
get the fiber number
bool unpack(const HcalHTRData &data, HcalTTPDigi &digi)
std::vector< HODataFrame > * hoCont
QIE11DigiCollection * qie11
CalibDetType calibFlavor() const
get the flavor of this calibration detid
static const HcalTrigTowerDetId Undefined
static const int FORMAT_VERSION_COMPACT_DATA
char data[epos_bytes_allocation]
uint16_t * getArray(int capid)
get the array for the specified capid
QIE10DigiCollection * qie10
std::vector< ZDCDataFrame > * zdcCont
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
unsigned int getFibOrbMsgBCN(int fiber) const
Get the BCN of the Fiber Orbit Messages.
unsigned int getSubmodule() const
Get the HTR submodule number.
bool isEmptyEvent() const
void unpackUMNio(const FEDRawData &raw, int slot, Collections &colls)
const DetId lookupTrigger(HcalElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
Log< level::Warning, false > LogWarning
Readout chain identification for Hcal.
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
constexpr int iphi() const
get the cell iphi
HcalOtherSubdetector subdet() const
get the category
const HcalQIESample * unpack(const HcalQIESample *startPoint, const HcalQIESample *limit, DigiClass &digi, int presamples, const HcalElectronicsId &eid, int startSample, int endSample, int expectedTime, const HcalHTRData &hhd)
static int slbChan(uint16_t theSample)
bool isUnsuppressed() const
Is this event an unsuppresed event?