16 namespace ZdcUnpacker_impl {
17 template <
class DigiClass>
19 const unsigned short*
limit,
28 digi.setPresamples(presamples);
29 digi.setReadoutIds(eid);
30 int flavor, error_flags, capid0, channelid;
33 bool isCapRotating = !(error_flags & 0x1);
34 bool fiberErr = (error_flags & 0x2);
35 bool dataValid = !(error_flags & 0x2);
36 int fiberchan = channelid & 0x3;
37 int fiber = ((channelid >> 2) & 0x7) + 1;
47 int ncurr = 0, ntaken = 0;
48 const unsigned short* qie_work = startPoint;
52 int capidn = (isCapRotating) ? ((capid0 + ncurr) % 4) : (capid0);
53 int capidn1 = (isCapRotating) ? ((capid0 + ncurr + 1) % 4) : (capid0);
55 HcalQIESample s0((*qie_work) & 0x7F, capidn, fiber, fiberchan, dataValid, fiberErr);
56 HcalQIESample s1(((*qie_work) >> 8) & 0x7F, capidn1, fiber, fiberchan, dataValid, fiberErr);
58 if (ncurr >= startSample && ncurr <= endSample) {
59 digi.setSample(ntaken, s0);
63 if (ncurr >= startSample && ncurr <= endSample) {
64 digi.setSample(ntaken, s1);
70 }
else if (flavor == 6) {
72 if (ncurr >= startSample && ncurr <= endSample) {
74 ((*qie_work) >> 8) & 0x3,
77 ((*qie_work) >> 10) & 0x1,
78 ((*qie_work) >> 11) & 0x1);
79 digi.setSample(ntaken, sample);
95 : sourceIdOffset_(sourceIdOffset), expectedOrbitMessageTime_(-1) {
101 if (end >= 0 && end <= ZDCDataFrame::MAXSAMPLES - 1 && end >= beg) {
113 if (raw.
size() < 16) {
125 const unsigned short *daq_first, *daq_last, *tp_first, *tp_last;
126 std::map<HcalElectronicsId, DetId> myEMap;
210 edm::LogWarning(
"Invalid Data") <<
"Invalid HTR data (data beyond payload size) observed on spigot " << spigot
211 <<
" of DCC with source id " << dccHeader->
getSourceId();
219 edm::LogWarning(
"Invalid Data") <<
"CRC Error on HTR data observed on spigot " << spigot
220 <<
" of DCC with source id " << dccHeader->
getSourceId();
226 edm::LogWarning(
"Invalid Data") <<
"Invalid HTR data observed on spigot " << spigot <<
" of DCC with source id "
233 edm::LogWarning(
"Invalid Data") <<
"Histogram data passed to non-histogram unpacker on spigot " << spigot
234 <<
" of DCC with source id " << dccHeader->
getSourceId();
238 if (colls.
ttp !=
nullptr) {
241 ttpUnpack.
unpack(htr, colls.
ttp->back());
243 LogDebug(
"ZdcUnpackerHcalTechTrigProcessor")
244 <<
"Skipping data on spigot " << spigot <<
" of DCC with source id " << dccHeader->
getSourceId()
245 <<
" which is from the TechTrigProcessor (use separate unpacker!)";
251 edm::LogWarning(
"ZdcUnpacker") <<
"Skipping data on spigot " << spigot <<
" of DCC with source id "
252 << dccHeader->
getSourceId() <<
" which is of unknown flavor "
260 htr.
dataPointers(&daq_first, &daq_last, &tp_first, &tp_last);
262 int htr_tb = smid & 0x1;
263 int htr_slot = (smid >> 1) & 0x1F;
264 int htr_cr = (smid >> 6) & 0x1F;
266 const unsigned short* ptr_header = daq_first;
267 const unsigned short* ptr_end = daq_last + 1;
268 int flavor, error_flags, capid0, channelid;
270 while (ptr_header != ptr_end) {
271 if (*ptr_header == 0xFFFF) {
281 int fiberchan = channelid & 0x3;
282 int fiber = ((channelid >> 2) & 0x7) + 1;
286 eid.
setHTR(htr_cr, htr_slot, htr_tb);
287 auto it = myEMap.find(eid);
289 if (it != myEMap.end()) {
296 ptr_header = ZdcUnpacker_impl::unpack_compact<ZDCDataFrame>(ptr_header,
constexpr void setHTR(int crate, int slot, int tb)
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
constexpr bool null() const
is this a null id ?
int startSample_
first sample from fed raw data to copy
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&Pass ZS?
unsigned int getFibOrbMsgBCN(int fiber) const
Get the BCN of the Fiber Orbit Messages.
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)
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)
static const int MAXSAMPLES
size_t size() const
Lenght of the data buffer in bytes.
void countSpigotFormatError()
std::vector< ZDCDataFrame > * zdcCont
bool isUnsuppressed() const
Is this event an unsuppresed event?
static bool is_channel_header(unsigned short value)
check top bit to see if this is a compact format channel header word
int expectedOrbitMessageTime_
Expected orbit bunch time (needed to evaluate time differences)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
int sourceIdOffset_
number to subtract from the source id to get the dcc id
void unpack(const FEDRawData &raw, const CastorElectronicsMap &emap, CastorRawCollections &conts, HcalUnpackerReport &report, bool silent=false)
For histograms, no begin and end.
static const int SubdetectorId
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.
bool unpack(const HcalHTRData &data, HcalTTPDigi &digi)
int getNPS() const
Get the number of presamples in daq data.
int endSample_
last sample from fed raw data to copy (if present)
int getFirmwareFlavor() const
Get the HTR firmware flavor.
uint32_t zsBunchMask() const
ZS Bunch Mask (if available)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
unsigned int getSubmodule() const
Get the HTR submodule number.
Log< level::Warning, false > LogWarning
Readout chain identification for Hcal.
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
ZdcUnpacker(int sourceIdOffset, int beg, int end)
for normal data
constexpr Detector det() const
get the detector field from this detid
std::vector< HcalTTPDigi > * ttp