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;
370 for (tp_work = tp_begin; tp_work != tp_end; tp_work++) {
371 if (tp_work->
raw() == 0xFFFF)
377 for (
int ibit = 0; ibit < 8; ibit++) {
379 if (!unrolled[
linear].checked) {
381 int fiber = (
linear / 3) + 1;
385 eid.setHTR(htr_cr, htr_slot, htr_tb);
401 if (tp_work->
raw() & (1 << ibit))
407 for (
int i = 0;
i < 24;
i++) {
410 unrolled[
i].
ieta, unrolled[
i].
iphi, unrolled[
i].
samples, unrolled[
i].soi, unrolled[
i].databits));
413 for (tp_work = tp_begin; tp_work != tp_end; tp_work++) {
414 if (tp_work->
raw() == 0xFFFF)
425 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No trigger primitive match found for electronics id :" <<
eid;
439 colls.
tpCont->back().setPresamples(nps);
449 colls.
tpCont->back().setSample(colls.
tpCont->back().size(), *tp_work);
450 colls.
tpCont->back().setSize(colls.
tpCont->back().size() + 1);
454 colls.
tpCont->back().setPresamples(ncurr);
467 for (qie_work = qie_begin; qie_work != qie_end;) {
468 if (qie_work->
raw() == 0xFFFF) {
476 eid.setHTR(htr_cr, htr_slot, htr_tb);
482 qie_work = HcalUnpacker_impl::unpack<ZDCDataFrame>(qie_work,
496 qie_work = HcalUnpacker_impl::unpack<HBHEDataFrame>(qie_work,
508 qie_work = HcalUnpacker_impl::unpack<HODataFrame>(qie_work,
520 qie_work = HcalUnpacker_impl::unpack<HFDataFrame>(qie_work,
534 qie_work = HcalUnpacker_impl::unpack<HcalCalibDataFrame>(qie_work,
557 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No match found for electronics id :" <<
eid;
567 const unsigned short* ptr_header = daq_first;
568 const unsigned short* ptr_end = daq_last + 1;
569 int flavor, error_flags, capid0, channelid;
571 while (ptr_header != ptr_end) {
572 if (*ptr_header == 0xFFFF) {
583 int fiberchan = channelid & 0x3;
584 int fiber = ((channelid >> 2) & 0x7) + 1;
588 eid.setHTR(htr_cr, htr_slot, htr_tb);
594 ptr_header = HcalUnpacker_impl::unpack_compact<ZDCDataFrame>(ptr_header,
608 ptr_header = HcalUnpacker_impl::unpack_compact<HBHEDataFrame>(ptr_header,
620 ptr_header = HcalUnpacker_impl::unpack_compact<HODataFrame>(ptr_header,
632 ptr_header = HcalUnpacker_impl::unpack_compact<HFDataFrame>(ptr_header,
646 ptr_header = HcalUnpacker_impl::unpack_compact<HcalCalibDataFrame>(ptr_header,
668 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No match found for electronics id :" <<
eid;
687 int namc =
amc13->NAMC();
688 for (
int iamc = 0; iamc < namc; iamc++) {
690 if (!
amc13->AMCEnabled(iamc))
693 if (!
amc13->AMCDataPresent(iamc)) {
695 edm::LogWarning(
"Invalid Data") <<
"Missing data observed on iamc " << iamc <<
" of AMC13 with source id " 696 <<
amc13->sourceId();
697 report.countSpigotFormatError();
700 if (!
amc13->AMCCRCOk(iamc)) {
702 edm::LogWarning(
"Invalid Data") <<
"CRC Error on uHTR data observed on iamc " << iamc
703 <<
" of AMC13 with source id " <<
amc13->sourceId();
704 report.countSpigotFormatError();
708 if (
amc13->AMCSegmented(iamc)) {
710 edm::LogWarning(
"Invalid Data") <<
"Unpacker cannot handle segmented data observed on iamc " << iamc
711 <<
" of AMC13 with source id " <<
amc13->sourceId();
712 report.countSpigotFormatError();
716 if (!
amc13->AMCLengthOk(iamc)) {
718 edm::LogWarning(
"Invalid Data") <<
"Length mismatch between uHTR and AMC13 observed on iamc " << iamc
719 <<
" of AMC13 with source id " <<
amc13->sourceId();
720 report.countSpigotFormatError();
725 int slot =
amc13->AMCSlot(iamc);
726 int crate =
amc13->AMCId(iamc) & 0xFF;
730 if (uhtr.getFormatVersion() != 1) {
736 int nwords = uhtr.getRawLengthBytes() / 2;
737 for (
int iw = 0; iw < nwords; iw++)
738 printf(
"%04d %04x\n", iw, uhtr.getRawData16()[iw]);
742 int nps = uhtr.presamples();
747 std::cout <<
"This data is flavored:" <<
i.flavor() << std::endl;
753 std::cout <<
"its not a header" << std::endl;
758 if (
i.flavor() == 1 ||
i.flavor() == 0 ||
i.flavor() == 3) {
759 int ifiber = ((
i.channelid() >> 3) & 0x1F);
760 int ichan = (
i.channelid() & 0x7);
764 const uint16_t* head_pos =
i.raw();
766 for (++
i;
i != iend && !
i.isHeader(); ++
i) {
770 if (colls.
qie11 ==
nullptr) {
789 colls.
qie11Addtl[ns]->addDataFrame(did, head_pos);
795 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No match found for electronics id :" <<
eid;
798 std::cout <<
"HcalUnpacker: No match found for electronics id :" <<
eid << std::endl;
802 std::cout <<
"OH NO! detector id is null!" << std::endl;
805 }
else if (
i.flavor() == 2) {
808 int ifiber = ((
i.channelid() >> 3) & 0x1F);
809 int ichan = (
i.channelid() & 0x7);
814 const uint16_t* head_pos =
i.raw();
816 for (++
i;
i != iend && !
i.isHeader(); ++
i) {
830 }
else if (isLasmon) {
837 if (colls.
qie10 ==
nullptr) {
864 colls.
qie10Addtl[ns]->addDataFrame(did, head_pos);
871 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No match found for electronics id :" <<
eid;
874 std::cout <<
"HcalUnpacker: No match found for electronics id :" <<
eid << std::endl;
878 std::cout <<
"OH NO! HcalUnpacker: No match found for electronics id :" <<
eid << std::endl;
881 }
else if (
i.flavor() == 5 || (
i.flavor() == 7 &&
i.technicalDataType() == 15)) {
882 int ifiber = ((
i.channelid() >> 2) & 0x1F);
883 int ichan = (
i.channelid() & 0x3);
890 HcalUnpacker_impl::unpack_compact<ZDCDataFrame>(
897 HcalUnpacker_impl::unpack_compact<HBHEDataFrame>(
902 HcalUnpacker_impl::unpack_compact<HODataFrame>(
907 HcalUnpacker_impl::unpack_compact<HFDataFrame>(
914 HcalUnpacker_impl::unpack_compact<HcalCalibDataFrame>(
920 for (++
i;
i != iend && !
i.isHeader(); ++
i)
929 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No match found for electronics id :" <<
eid;
932 for (++
i;
i != iend && !
i.isHeader(); ++
i)
935 }
else if (
i.flavor() == 0x4) {
936 int ilink = ((
i.channelid() >> 4) & 0xF);
937 int itower = (
i.channelid() & 0xF);
941 std::cout <<
"Unpacking " <<
eid <<
" " <<
i.channelid() << std::endl;
947 edm::LogWarning(
"HCAL") <<
"HcalUnpacker: No trigger primitive match found for electronics id :" <<
eid;
951 for (++
i;
i != iend && !
i.isHeader(); ++
i)
954 for (++
i;
i != iend && !
i.isHeader(); ++
i)
959 std::cout <<
"Unpacking " <<
id << std::endl;
963 for (++
i;
i != iend && !
i.isHeader(); ++
i) {
964 colls.
tpCont->back().setSample(
j,
i.value());
966 colls.
tpCont->back().setPresamples(
j);
969 colls.
tpCont->back().setSize(
j);
973 for (++
i;
i != iend && !
i.isHeader(); ++
i)
997 std::vector<HcalHistogramDigi>& histoDigis) {
1012 if (retval || !htr.
check()) {
1013 edm::LogWarning(
"Invalid Data") <<
"Invalid HTR data observed on spigot " << spigot <<
" of DCC with source id " 1018 edm::LogWarning(
"Invalid Data") <<
"Non-histogram data passed to histogram unpacker on spigot " << spigot
1019 <<
" of DCC with source id " << dccHeader->
getSourceId();
1024 int htr_tb = smid & 0x1;
1025 int htr_slot = (smid >> 1) & 0x1F;
1026 int htr_cr = (smid >> 6) & 0x1F;
1032 for (
int nf = 0; nf < 2; nf++) {
1033 if (
f[nf] < 0 || (nf == 1 &&
f[0] ==
f[1]))
1035 for (fc = 0; fc <= 2; fc++) {
1037 eid.setHTR(htr_cr, htr_slot, htr_tb);
1042 edm::LogWarning(
"HCAL") <<
"HcalHistogramUnpacker: No match found for electronics id :" <<
eid;
1051 for (
int capid = 0; capid < 4; capid++)
1060 int namc =
amc13->NAMC();
1062 for (
int iamc = 0; iamc < namc; iamc++) {
1063 if (
amc13->AMCSlot(iamc) == slot)
1066 if (namc ==
amc13->NAMC()) {
1069 const uint16_t*
data = (
const uint16_t*)(
amc13->AMCPayload(namc));
1070 size_t nwords =
amc13->AMCSize(namc) * (
sizeof(
uint64_t) /
sizeof(uint16_t));
1080 constexpr
int limit = 2;
1083 edm::LogInfo(
"Invalid Data") <<
"Suppressing further error messages";
1088 std::stringstream message;
1090 message <<
"The default " << coll_type <<
" Collection has " << default_ns
1091 <<
" samples per digi, while the current data has " << conflict_ns
1092 <<
"! This data cannot be included with the default collection.";
1095 message <<
"\nIn order to store this data in the event, it must have a unique tag. " 1096 <<
"To accomplish this, provide two lists to HcalRawToDigi \n" 1097 <<
"1) that specifies the number of samples and " 1098 <<
"2) that gives tags with which these data are saved.\n" 1099 <<
"For example in this case you might add \n" 1100 <<
"process.hcalDigis.save" << coll_type <<
"DataNSamples = cms.untracked.vint32( " << conflict_ns
1101 <<
") \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)
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.
static constexpr int32_t SubdetectorId
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?