17 namespace ZdcUnpacker_impl {
18 template <
class DigiClass>
19 const unsigned short*
unpack_compact(
const unsigned short* startPoint,
const unsigned short*
limit, DigiClass& digi,
23 digi.setPresamples(presamples);
24 digi.setReadoutIds(eid);
25 int flavor, error_flags, capid0, channelid;
28 bool isCapRotating=!(error_flags&0x1);
29 bool fiberErr=(error_flags&0x2);
30 bool dataValid=!(error_flags&0x2);
31 int fiberchan=channelid&0x3;
32 int fiber=((channelid>>2)&0x7)+1;
43 const unsigned short* qie_work=startPoint;
47 int capidn=(isCapRotating)?((capid0+ncurr)%4):(capid0);
48 int capidn1=(isCapRotating)?((capid0+ncurr+1)%4):(capid0);
50 HcalQIESample s0((*qie_work)&0x7F,capidn,fiber,fiberchan,dataValid,fiberErr);
51 HcalQIESample s1(((*qie_work)>>8)&0x7F,capidn1,fiber,fiberchan,dataValid,fiberErr);
53 if (ncurr>=startSample && ncurr<=endSample) {
54 digi.setSample(ntaken,s0);
58 if (ncurr>=startSample && ncurr<=endSample) {
59 digi.setSample(ntaken,s1);
65 }
else if (flavor==6) {
67 if (ncurr>=startSample && ncurr<=endSample) {
68 HcalQIESample sample((*qie_work)&0x7F,((*qie_work)>>8)&0x3,fiber,fiberchan,((*qie_work)>>10)&0x1,((*qie_work)>>11)&0x1);
69 digi.setSample(ntaken,sample);
91 if ( end >= 0 && end <= ZDCDataFrame::MAXSAMPLES -1 && end >= beg ) {
102 if (!silent)
edm::LogWarning(
"Invalid Data") <<
"Empty/invalid DCC data, size = " << raw.
size();
112 const unsigned short* daq_first, *daq_last, *tp_first, *tp_last;
113 std::map<HcalElectronicsId,DetId> myEMap;
197 if (!silent)
edm::LogWarning(
"Invalid Data") <<
"Invalid HTR data (data beyond payload size) observed on spigot " << spigot <<
" of DCC with source id " << dccHeader->
getSourceId();
205 edm::LogWarning(
"Invalid Data") <<
"CRC Error on HTR data observed on spigot " << spigot <<
" of DCC with source id " << dccHeader->
getSourceId();
211 edm::LogWarning(
"Invalid Data") <<
"Invalid HTR data observed on spigot " << spigot <<
" of DCC with source id " << dccHeader->
getSourceId();
217 edm::LogWarning(
"Invalid Data") <<
"Histogram data passed to non-histogram unpacker on spigot " << spigot <<
" of DCC with source id " << dccHeader->
getSourceId();
227 LogDebug(
"ZdcUnpackerHcalTechTrigProcessor") <<
"Skipping data on spigot " << spigot <<
" of DCC with source id " << dccHeader->
getSourceId() <<
" which is from the TechTrigProcessor (use separate unpacker!)";
239 htr.
dataPointers(&daq_first,&daq_last,&tp_first,&tp_last);
242 int htr_slot=(smid>>1)&0x1F;
243 int htr_cr=(smid>>6)&0x1F;
246 const unsigned short* ptr_header=daq_first;
247 const unsigned short* ptr_end=daq_last+1;
248 int flavor, error_flags, capid0, channelid;
250 while (ptr_header!=ptr_end) {
251 if (*ptr_header==0xFFFF) {
261 int fiberchan=channelid&0x3;
262 int fiber=((channelid>>2)&0x7)+1;
266 eid.
setHTR(htr_cr,htr_slot,htr_tb);
267 auto it = myEMap.find(eid);
269 if (it != myEMap.end())
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
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)
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.
void setHTR(int crate, int slot, int tb)
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)
bool null() const
is this a null id ?
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.
Detector det() const
get the detector field from this detid
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
std::vector< HcalTTPDigi > * ttp