CMS 3D CMS Logo

HcalUnpacker.cc
Go to the documentation of this file.
12 
13 //#define DebugLog
14 
15 namespace HcalUnpacker_impl {
16  template <class DigiClass>
17  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) {
18  // set parameters
19  digi.setPresamples(presamples);
20  digi.setReadoutIds(eid);
21 
22  int fiber=startPoint->fiber();
23  int fiberchan=startPoint->fiberChan();
24  uint32_t zsmask=hhd.zsBunchMask()>>startSample;
25  digi.setZSInfo(hhd.isUnsuppressed(),hhd.wasMarkAndPassZS(fiber,fiberchan),zsmask);
26 
27  if (expectedTime>=0 && !hhd.isUnsuppressed()) {
28 #ifdef DebugLog
29  std::cout << hhd.getFibOrbMsgBCN(fiber) << " " << expectedTime << std::endl;
30 #endif
31  digi.setFiberIdleOffset(hhd.getFibOrbMsgBCN(fiber)-expectedTime);
32  }
33 
34  // what is my sample number?
35  int myFiberChan=startPoint->fiberAndChan();
36  int ncurr=0,ntaken=0;
37  const HcalQIESample* qie_work=startPoint;
38  while (qie_work!=limit && qie_work->fiberAndChan()==myFiberChan) {
39  if (ncurr>=startSample && ncurr<=endSample) {
40  digi.setSample(ntaken,*qie_work);
41  ++ntaken;
42  }
43  ncurr++;
44  qie_work++;
45  }
46  digi.setSize(ntaken);
47  return qie_work;
48  }
49 
50 
51  template <class DigiClass>
52  const unsigned short* unpack_compact(const unsigned short* startPoint, const unsigned short* limit, DigiClass& digi,
53  int presamples, const HcalElectronicsId& eid, int startSample, int endSample,
54  int expectedTime, const HcalHTRData& hhd) {
55  // set parameters
56  digi.setPresamples(presamples);
57  digi.setReadoutIds(eid);
58  int flavor, error_flags, capid0, channelid;
59 
60  HcalHTRData::unpack_per_channel_header(*startPoint,flavor,error_flags,capid0,channelid);
61  bool isCapRotating=!(error_flags&0x1);
62  bool fiberErr=(error_flags&0x2);
63  bool dataValid=!(error_flags&0x2);
64  int fiberchan=channelid&0x3;
65  int fiber=((channelid>>2)&0x7)+1;
66 
67  uint32_t zsmask=hhd.zsBunchMask()>>startSample;
68  digi.setZSInfo(hhd.isUnsuppressed(),hhd.wasMarkAndPassZS(fiber,fiberchan),zsmask);
69 
70  if (expectedTime>=0 && !hhd.isUnsuppressed()) {
71 #ifdef DebugLog
72  std::cout << hhd.getFibOrbMsgBCN(fiber) << " " << expectedTime << std::endl;
73 #endif
74  digi.setFiberIdleOffset(hhd.getFibOrbMsgBCN(fiber)-expectedTime);
75  }
76 
77  // what is my sample number?
78  int ncurr=0,ntaken=0;
79  const unsigned short* qie_work=startPoint;
80  // we branch here between normal (flavor=5) and error mode (flavor=6)
81  if (flavor==5) {
82  for (qie_work++; qie_work!=limit && !HcalHTRData::is_channel_header(*qie_work); qie_work++) {
83  int capidn=(isCapRotating)?((capid0+ncurr)%4):(capid0);
84  int capidn1=(isCapRotating)?((capid0+ncurr+1)%4):(capid0);
85  // two samples in one...
86  HcalQIESample s0((*qie_work)&0x7F,capidn,fiber,fiberchan,dataValid,fiberErr);
87  HcalQIESample s1(((*qie_work)>>8)&0x7F,capidn1,fiber,fiberchan,dataValid,fiberErr);
88 
89  if (ncurr>=startSample && ncurr<=endSample) {
90  digi.setSample(ntaken,s0);
91  ++ntaken;
92  }
93  ncurr++;
94  if (ncurr>=startSample && ncurr<=endSample) {
95  digi.setSample(ntaken,s1);
96  ++ntaken;
97  }
98  ncurr++;
99  }
100  digi.setSize(ntaken);
101  } else if (flavor==6) {
102  for (qie_work++; qie_work!=limit && !HcalHTRData::is_channel_header(*qie_work); qie_work++) {
103  if (ncurr>=startSample && ncurr<=endSample) {
104  HcalQIESample sample((*qie_work)&0x7F,((*qie_work)>>8)&0x3,fiber,fiberchan,((*qie_work)>>10)&0x1,((*qie_work)>>11)&0x1);
105  digi.setSample(ntaken,sample);
106  ++ntaken;
107  }
108 
109  ncurr++;
110  }
111  digi.setSize(ntaken);
112  } else {
113  edm::LogWarning("Bad Data") << "Invalid flavor " << flavor;
114  qie_work=limit;
115  }
116  return qie_work;
117  }
118 
119  template <class DigiClass>
121  int presamples, const HcalElectronicsId& eid, int startSample, int endSample) {
122  // set parameters
123  digi.setPresamples(presamples-startSample);
124  digi.setReadoutIds(eid);
125  int error_flags=i.errFlags();
126  int capid0=i.capid0();
127  int flavor = i.flavor();
128 
129  bool isCapRotating=!(error_flags&0x1);
130  bool fiberErr=(error_flags&0x2);
131  bool dataValid=!(error_flags&0x2);
132  int fiberchan=i.channelid()&0x3;
133  int fiber=((i.channelid()>>2)&0x7)+1;
134 
135  // digi.setZSInfo(hhd.isUnsuppressed(),hhd.wasMarkAndPassZS(fiber,fiberchan),zsmask);
136 
137  // what is my sample number?
138  int ncurr=0,ntaken=0;
139  if(flavor==5){
140  for (++i; i!=iend && !i.isHeader(); ++i) {
141  int capidn=(isCapRotating)?((capid0+ncurr)%4):(capid0);
142 
143  HcalQIESample s(i.adc(),capidn,fiber,fiberchan,dataValid,fiberErr);
144 
145  if (ncurr>=startSample && ncurr<=endSample) {
146  digi.setSample(ntaken,s);
147  ++ntaken;
148  }
149  ncurr++;
150  }
151  digi.setSize(ntaken);
152  }
153  else if(flavor==7){ //similar to VME flavor 6, used for premix in MC
154  for (++i; i!=iend && !i.isHeader(); ++i) {
155  if (ncurr>=startSample && ncurr<=endSample) {
156  HcalQIESample sample(i.adc(),i.capid(),fiber,fiberchan,i.dataValid(),i.errFlags());
157  digi.setSample(ntaken,sample);
158  ++ntaken;
159  }
160  ncurr++;
161  }
162  digi.setSize(ntaken);
163  }
164  }
165 
166 }
167 
168 
169 static inline bool isTPGSOI(const HcalTriggerPrimitiveSample& s) {
170  return (s.raw()&0x200)!=0;
171 }
172 
173 
174 struct HOUnrolledTP { // parts of an HO trigger primitive, unpacked
175  bool valid, checked;
176  int ieta, iphi, samples, soi;
177  unsigned int databits;
179  valid=false;
180  checked=false;
181  ieta=0;
182  iphi=0;
183  samples=0;
184  soi=0;
185  databits=0;
186  }
187  void setbit(int i) { databits|=(1<<i); }
188 };
189 
191  Collections& colls, HcalUnpackerReport& report, bool silent) {
192 
193  if (raw.size()<16) {
194  if (!silent) edm::LogWarning("Invalid Data") << "Empty/invalid data, size = " << raw.size();
195  return;
196  }
197 
198  // get the DCC header
199  const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(raw.data());
200 
201  if (dccHeader->BOEshouldBeZeroAlways()==0) // also includes uTCA before the common AMC13XG firmware
202  unpackVME(raw,emap,colls,report,silent);
203  else unpackUTCA(raw,emap,colls,report,silent);
204 }
205 
206 static int slb(uint16_t theSample) { return ((theSample>>13)&0x7); }
207 static int slbChan(uint16_t theSample) { return (theSample>>11)&0x3; }
208 static int slbAndChan(uint16_t theSample) { return (theSample>>11)&0x1F; }
209 
210 
212  Collections& colls, HcalUnpackerReport& report, bool silent) {
213 
214  // get the DCC header
215  const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(raw.data());
216  const HcalDTCHeader* dtcHeader=(const HcalDTCHeader*)(raw.data());
217  bool is_VME_DCC=(dccHeader->getDCCDataFormatVersion()<0x10) || ((mode_&0x1)==0);
218 
219  int dccid=(is_VME_DCC)?(dccHeader->getSourceId()-sourceIdOffset_):(dtcHeader->getSourceId()-sourceIdOffset_);
220 
221  // check the summary status
222 
223  // walk through the HTR data. For the uTCA, use spigot=slot+1
224  HcalHTRData htr;
225  const unsigned short* daq_first, *daq_last, *tp_first, *tp_last;
226  const HcalQIESample* qie_begin, *qie_end, *qie_work;
227  const HcalTriggerPrimitiveSample *tp_begin, *tp_end, *tp_work;
228  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {
229 
230  if (is_VME_DCC) {
231  if (!dccHeader->getSpigotPresent(spigot)) continue;
232 
233  int retval=dccHeader->getSpigotData(spigot,htr,raw.size());
234  if (retval!=0) {
235  if (retval==-1) {
236  if (!silent) edm::LogWarning("Invalid Data") << "Invalid HTR data (data beyond payload size) observed on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId();
237  report.countSpigotFormatError();
238  }
239  continue;
240  }
241  // check
242  if (dccHeader->getSpigotCRCError(spigot)) {
243  if (!silent)
244  edm::LogWarning("Invalid Data") << "CRC Error on HTR data observed on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId();
245  report.countSpigotFormatError();
246  continue;
247  }
248  } else { // is_uTCA (!is_VME_DCC)
249  int slot=spigot+1;
250  if (slot>HcalDTCHeader::MAXIMUM_SLOT) continue;
251 
252  if (!dtcHeader->getSlotPresent(slot)) continue;
253 
254  int retval=dtcHeader->getSlotData(slot,htr,raw.size());
255  if (retval!=0) {
256  if (retval==-1) {
257  if (!silent) edm::LogWarning("Invalid Data") << "Invalid uHTR data (data beyond payload size) observed on slot " << slot << " of DTC with source id " << dtcHeader->getSourceId();
258  report.countSpigotFormatError();
259  }
260  continue;
261  }
262  // check
263  if (dtcHeader->getSlotCRCError(slot)) {
264  if (!silent)
265  edm::LogWarning("Invalid Data") << "CRC Error on uHTR data observed on slot " << slot << " of DTC with source id " << dtcHeader->getSourceId();
266  report.countSpigotFormatError();
267  continue;
268  }
269  }
270 
271 
272  // check for EE
273  if (htr.isEmptyEvent()) {
274  report.countEmptyEventSpigot();
275  }
276  if (htr.isOverflowWarning()) {
277  report.countOFWSpigot();
278  }
279  if (htr.isBusy()) {
280  report.countBusySpigot();
281  }
282  if (!htr.check()) {
283  if (!silent)
284  edm::LogWarning("Invalid Data") << "Invalid HTR data observed on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId();
285  report.countSpigotFormatError();
286  continue;
287  }
288  if (htr.isHistogramEvent()) {
289  if (!silent) edm::LogWarning("Invalid Data") << "Histogram data passed to non-histogram unpacker on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId();
290  continue;
291  }
292  if ((htr.getFirmwareFlavor()&0xE0)==0x80) { // some kind of TTP data
293  if (colls.ttp!=nullptr) {
294  HcalTTPUnpacker ttpUnpack;
295  colls.ttp->push_back(HcalTTPDigi());
296  ttpUnpack.unpack(htr,colls.ttp->back());
297  } else {
298  LogDebug("HcalTechTrigProcessor") << "Skipping data on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId() << " which is from the TechTrigProcessor (use separate unpacker!)";
299  }
300  continue;
301  }
302  if (htr.getFirmwareFlavor()>=0x80) {
303  if (!silent) edm::LogWarning("HcalUnpacker") << "Skipping data on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId() << " which is of unknown flavor " << htr.getFirmwareFlavor();
304  continue;
305  }
306 
307  // calculate "real" number of presamples
308  int nps=htr.getNPS()-startSample_;
309 
310  // get pointers
311  htr.dataPointers(&daq_first,&daq_last,&tp_first,&tp_last);
312  unsigned int smid=htr.getSubmodule();
313  int htr_tb=smid&0x1;
314  int htr_slot=(smid>>1)&0x1F;
315  int htr_cr=(smid>>6)&0x1F;
316 
317  tp_begin=(const HcalTriggerPrimitiveSample*)tp_first;
318  tp_end=(const HcalTriggerPrimitiveSample*)(tp_last+1); // one beyond last..
319 
321  int currFiberChan=0x3F; // invalid fiber+channel...
322  int ncurr=0;
323  bool valid=false;
324 
325  bool tpgSOIbitInUse=htr.getFormatVersion()>=3; // version 3 and later
326  bool isHOtpg=htr.getFormatVersion()>=3 && htr.getFirmwareFlavor()==0; // HO is flavor zero
327  int npre=0;
328  /*
329  Unpack the trigger primitives
330  */
331  if (isHOtpg) {
332  HOUnrolledTP unrolled[24];
333  for (tp_work=tp_begin; tp_work!=tp_end; tp_work++) {
334  if (tp_work->raw()==0xFFFF) continue; // filler word
335  int sector=slbChan(tp_work->raw());
336  if (sector>2) continue;
337 
338  for (int ibit=0; ibit<8; ibit++) {
339  int linear=sector*8+ibit;
340  if (!unrolled[linear].checked) {
341  unrolled[linear].checked=true;
342  int fiber=(linear/3)+1;
343  int fc=(linear%3);
344  // electronics id (use precision match for HO TP)
345  HcalElectronicsId eid(fc,fiber,spigot,dccid);
346  eid.setHTR(htr_cr,htr_slot,htr_tb);
347  DetId did=emap.lookup(eid);
348  if (!did.null()) {
349  if (did.det()==DetId::Hcal && ((HcalSubdetector)did.subdetId())==HcalOuter ) {
350  HcalDetId hid(did);
351  unrolled[linear].valid=true;
352  unrolled[linear].ieta=hid.ieta();
353  unrolled[linear].iphi=hid.iphi();
354  }
355  } else {
356  report.countUnmappedTPDigi(eid);
357  }
358  }
359  if (unrolled[linear].valid) {
360  if (isTPGSOI(*tp_work)) unrolled[linear].soi=unrolled[linear].samples;
361  if (tp_work->raw()&(1<<ibit)) unrolled[linear].setbit(unrolled[linear].samples);
362  unrolled[linear].samples++;
363  }
364  }
365  }
366  for (int i=0; i<24; i++) {
367  if (unrolled[i].valid)
368  colls.tphoCont->push_back(HOTriggerPrimitiveDigi(
369  unrolled[i].ieta,
370  unrolled[i].iphi,
371  unrolled[i].samples,
372  unrolled[i].soi,
373  unrolled[i].databits));
374  }
375  } else { // regular TPs (not HO)
376  for (tp_work=tp_begin; tp_work!=tp_end; tp_work++) {
377  if (tp_work->raw()==0xFFFF) continue; // filler word
378  if (slbAndChan(tp_work->raw())!=currFiberChan) { // start new set
379  npre=0;
380  currFiberChan=slbAndChan(tp_work->raw());
381  // lookup the right channel
382  HcalElectronicsId eid(slbChan(tp_work->raw()),slb(tp_work->raw()),spigot,dccid,htr_cr,htr_slot,htr_tb);
383  DetId did=emap.lookupTrigger(eid);
384  if (did.null()) {
385  report.countUnmappedTPDigi(eid);
386  if (unknownIdsTrig_.find(eid)==unknownIdsTrig_.end()) {
387  if (!silent) edm::LogWarning("HCAL") << "HcalUnpacker: No trigger primitive match found for electronics id :" << eid;
388  unknownIdsTrig_.insert(eid);
389  }
390  valid=false;
391  continue;
392  } else if (did==HcalTrigTowerDetId::Undefined ||
393  (did.det()==DetId::Hcal && did.subdetId()==0)) {
394  // known to be unmapped
395  valid=false;
396  continue;
397  }
398  HcalTrigTowerDetId id(did);
399  colls.tpCont->push_back(HcalTriggerPrimitiveDigi(id));
400  // set the various bits
401  if (!tpgSOIbitInUse) colls.tpCont->back().setPresamples(nps);
402  colls.tpCont->back().setZSInfo(htr.isUnsuppressed(),htr.wasMarkAndPassZSTP(slb(tp_work->raw()),slbChan(tp_work->raw())));
403 
404  // no hits recorded for current
405  ncurr=0;
406  valid=true;
407  }
408  // add the word (if within settings or recent firmware [recent firmware ignores startSample/endSample])
409  if (valid && ((tpgSOIbitInUse && ncurr<10) || (ncurr>=startSample_ && ncurr<=endSample_))) {
410  colls.tpCont->back().setSample(colls.tpCont->back().size(),*tp_work);
411  colls.tpCont->back().setSize(colls.tpCont->back().size()+1);
412  }
413  // set presamples,if SOI
414  if (valid && tpgSOIbitInUse && isTPGSOI(*tp_work)) {
415  colls.tpCont->back().setPresamples(ncurr);
416  }
417  ncurr++;
418  npre++;
419  }
420  }
421 
424 
425  qie_begin=(const HcalQIESample*)daq_first;
426  qie_end=(const HcalQIESample*)(daq_last+1); // one beyond last..
427 
429 
430 
431  for (qie_work=qie_begin; qie_work!=qie_end; ) {
432  if (qie_work->raw()==0xFFFF) {
433  qie_work++;
434  continue; // filler word
435  }
436  // always at the beginning ...
437 
438  // lookup the right channel
439  HcalElectronicsId eid(qie_work->fiberChan(),qie_work->fiber(),spigot,dccid);
440  eid.setHTR(htr_cr,htr_slot,htr_tb);
441  DetId did=emap.lookup(eid);
442 
443  if (!did.null()) {
444  if (did.det()==DetId::Calo && did.subdetId()==HcalZDCDetId::SubdetectorId) {
445  colls.zdcCont->push_back(ZDCDataFrame(HcalZDCDetId(did)));
446  qie_work=HcalUnpacker_impl::unpack<ZDCDataFrame>(qie_work, qie_end, colls.zdcCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
447  } else if (did.det()==DetId::Hcal) {
448  switch (((HcalSubdetector)did.subdetId())) {
449  case (HcalBarrel):
450  case (HcalEndcap): {
451  colls.hbheCont->push_back(HBHEDataFrame(HcalDetId(did)));
452  qie_work=HcalUnpacker_impl::unpack<HBHEDataFrame>(qie_work, qie_end, colls.hbheCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
453  } break;
454  case (HcalOuter): {
455  colls.hoCont->push_back(HODataFrame(HcalDetId(did)));
456  qie_work=HcalUnpacker_impl::unpack<HODataFrame>(qie_work, qie_end, colls.hoCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
457  } break;
458  case (HcalForward): {
459  colls.hfCont->push_back(HFDataFrame(HcalDetId(did)));
460  qie_work=HcalUnpacker_impl::unpack<HFDataFrame>(qie_work, qie_end, colls.hfCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
461  } break;
462  case (HcalOther) : {
463  HcalOtherDetId odid(did);
464  if (odid.subdet()==HcalCalibration) {
465  colls.calibCont->push_back(HcalCalibDataFrame(HcalCalibDetId(did)));
466  qie_work=HcalUnpacker_impl::unpack<HcalCalibDataFrame>(qie_work, qie_end, colls.calibCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
467  }
468  } break;
469  case (HcalEmpty):
470  default: {
471  for (int fiberC=qie_work->fiberAndChan();
472  qie_work!=qie_end && qie_work->fiberAndChan()==fiberC;
473  qie_work++);
474  }
475  break;
476  }
477  }
478  } else {
479  report.countUnmappedDigi(eid);
480  if (unknownIds_.find(eid)==unknownIds_.end()) {
481  if (!silent) edm::LogWarning("HCAL") << "HcalUnpacker: No match found for electronics id :" << eid;
482  unknownIds_.insert(eid);
483  }
484  for (int fiberC=qie_work->fiberAndChan();
485  qie_work!=qie_end && qie_work->fiberAndChan()==fiberC;
486  qie_work++);
487  }
488  }
489  } else {
490  // this is the branch for unpacking the compact data format with per-channel headers
491  const unsigned short* ptr_header=daq_first;
492  const unsigned short* ptr_end=daq_last+1;
493  int flavor, error_flags, capid0, channelid;
494 
495  while (ptr_header!=ptr_end) {
496  if (*ptr_header==0xFFFF) { // impossible filler word
497  ptr_header++;
498  continue;
499  }
500  // unpack the header word
501  bool isheader=HcalHTRData::unpack_per_channel_header(*ptr_header,flavor,error_flags,capid0,channelid);
502  if (!isheader) {
503  ptr_header++;
504  continue;
505  }
506 
507  int fiberchan=channelid&0x3;
508  int fiber=((channelid>>2)&0x7)+1;
509 
510  // lookup the right channel
511  HcalElectronicsId eid(fiberchan,fiber,spigot,dccid);
512  eid.setHTR(htr_cr,htr_slot,htr_tb);
513  DetId did=emap.lookup(eid);
514 
515  if (!did.null()) {
516  if (did.det()==DetId::Calo && did.subdetId()==HcalZDCDetId::SubdetectorId) {
517  colls.zdcCont->push_back(ZDCDataFrame(HcalZDCDetId(did)));
518  ptr_header=HcalUnpacker_impl::unpack_compact<ZDCDataFrame>(ptr_header, ptr_end, colls.zdcCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
519  } else if (did.det()==DetId::Hcal) {
520  switch (((HcalSubdetector)did.subdetId())) {
521  case (HcalBarrel):
522  case (HcalEndcap): {
523  colls.hbheCont->push_back(HBHEDataFrame(HcalDetId(did)));
524  ptr_header=HcalUnpacker_impl::unpack_compact<HBHEDataFrame>(ptr_header, ptr_end, colls.hbheCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
525  } break;
526  case (HcalOuter): {
527  colls.hoCont->push_back(HODataFrame(HcalDetId(did)));
528  ptr_header=HcalUnpacker_impl::unpack_compact<HODataFrame>(ptr_header, ptr_end, colls.hoCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
529  } break;
530  case (HcalForward): {
531  colls.hfCont->push_back(HFDataFrame(HcalDetId(did)));
532  ptr_header=HcalUnpacker_impl::unpack_compact<HFDataFrame>(ptr_header, ptr_end, colls.hfCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
533  } break;
534  case (HcalOther) : {
535  HcalOtherDetId odid(did);
536  if (odid.subdet()==HcalCalibration) {
537  colls.calibCont->push_back(HcalCalibDataFrame(HcalCalibDetId(did)));
538  ptr_header=HcalUnpacker_impl::unpack_compact<HcalCalibDataFrame>(ptr_header, ptr_end, colls.calibCont->back(), nps, eid, startSample_, endSample_, expectedOrbitMessageTime_, htr);
539  }
540  } break;
541  case (HcalEmpty):
542  default: {
543  for (ptr_header++;
544  ptr_header!=ptr_end && !HcalHTRData::is_channel_header(*ptr_header);
545  ptr_header++);
546  }
547  break;
548  }
549  }
550  } else {
551  report.countUnmappedDigi(eid);
552  if (unknownIds_.find(eid)==unknownIds_.end()) {
553  if (!silent) edm::LogWarning("HCAL") << "HcalUnpacker: No match found for electronics id :" << eid;
554  unknownIds_.insert(eid);
555  }
556  for (ptr_header++;
557  ptr_header!=ptr_end && !HcalHTRData::is_channel_header(*ptr_header);
558  ptr_header++);
559  }
560  }
561 
562  }
563  }
564 }
565 
567  Collections& colls, HcalUnpackerReport& report, bool silent) {
568 
569  const hcal::AMC13Header* amc13=(const hcal::AMC13Header*)(raw.data());
570 
571  // how many AMC in this packet
572  int namc=amc13->NAMC();
573  for (int iamc=0; iamc<namc; iamc++) {
574  // if not enabled, ignore
575  if (!amc13->AMCEnabled(iamc)) continue;
576 
577  if (!amc13->AMCDataPresent(iamc)) {
578  if (!silent)
579  edm::LogWarning("Invalid Data") << "Missing data observed on iamc " << iamc << " of AMC13 with source id " << amc13->sourceId();
580  report.countSpigotFormatError();
581  continue;
582  }
583  if (!amc13->AMCCRCOk(iamc)) {
584  if (!silent)
585  edm::LogWarning("Invalid Data") << "CRC Error on uHTR data observed on iamc " << iamc << " of AMC13 with source id " << amc13->sourceId();
586  report.countSpigotFormatError();
587  // continue;
588  }
589  // this unpacker cannot handle segmented data!
590  if (amc13->AMCSegmented(iamc)) {
591  if (!silent)
592  edm::LogWarning("Invalid Data") << "Unpacker cannot handle segmented data observed on iamc " << iamc << " of AMC13 with source id " << amc13->sourceId();
593  report.countSpigotFormatError();
594  continue;
595  }
596 
597  // ok, now we're work-able
598  int slot=amc13->AMCSlot(iamc);
599  int crate=amc13->AMCId(iamc)&0xFF;
600 
601  HcalUHTRData uhtr(amc13->AMCPayload(iamc),amc13->AMCSize(iamc));
602  //Check to make sure uMNio is not unpacked here
603  if(uhtr.getFormatVersion() != 1) {
604  unpackUMNio(raw, slot, colls);
605  continue;
606  }
607 #ifdef DebugLog
608  //debug printouts
609  int nwords=uhtr.getRawLengthBytes()/2;
610  for (int iw=0; iw<nwords; iw++)
611  printf("%04d %04x\n",iw,uhtr.getRawData16()[iw]);
612 #endif
613 
614  //use uhtr presamples since amc header not properly packed in simulation
615  int nps = uhtr.presamples();
616 
617  HcalUHTRData::const_iterator i=uhtr.begin(), iend=uhtr.end();
618  while (i!=iend) {
619 #ifdef DebugLog
620  std::cout << "This data is flavored:" << i.flavor() << std::endl;
621 #endif
622 
623  if (!i.isHeader()) {
624  ++i;
625 #ifdef DebugLog
626  std::cout << "its not a header" << std::endl;
627 #endif
628  continue;
629  }
631  if (i.flavor() == 1 || i.flavor() == 0) {
632  int ifiber=((i.channelid()>>3)&0x1F);
633  int ichan=(i.channelid()&0x7);
634  HcalElectronicsId eid(crate,slot,ifiber,ichan, false);
635  DetId did=emap.lookup(eid);
636  // Count from current position to next header, or equal to end
637  const uint16_t* head_pos = i.raw();
638  int ns = 0;
639  for (++i; i != iend && !i.isHeader(); ++i) {
640  ns++;
641  }
642  // Check QEI11 container exists
643  if (colls.qie11 == nullptr) {
644  colls.qie11 = new QIE11DigiCollection(ns);
645  }
646  else if (colls.qie11->samples() != ns) {
647  // if this sample type hasn't been requested to be saved
648  // warn the user to provide a configuration that prompts it to be saved
649  if( colls.qie11Addtl.find( ns ) == colls.qie11Addtl.end() ) {
650  printInvalidDataMessage( "QIE11", colls.qie11->samples(), ns, true );
651  }
652  }
653 
654  // Insert data
656  if (!did.null()) { // unpack and store...
657  // only fill the default collection if we have the correct number of samples
658  if (colls.qie11->samples() == ns) {
659  colls.qie11->addDataFrame(did, head_pos);
660  }
661  // fill the additional qie11 collections
662  if( colls.qie11Addtl.find( ns ) != colls.qie11Addtl.end() ) {
663  colls.qie11Addtl[ns]->addDataFrame( did, head_pos );
664  }
665  } else {
666  report.countUnmappedDigi(eid);
667  if (unknownIds_.find(eid)==unknownIds_.end()) {
668  if (!silent) edm::LogWarning("HCAL") << "HcalUnpacker: No match found for electronics id :" << eid;
669  unknownIds_.insert(eid);
670 #ifdef DebugLog
671  std::cout << "HcalUnpacker: No match found for electronics id :" << eid << std::endl;
672 #endif
673  }
674 #ifdef DebugLog
675  std::cout << "OH NO! detector id is null!" << std::endl;
676 #endif
677  }
678  } else if (i.flavor() == 2){
680 
681  int ifiber=((i.channelid()>>3)&0x1F);
682  int ichan=(i.channelid()&0x7);
683  HcalElectronicsId eid(crate,slot,ifiber,ichan, false);
684  DetId did=emap.lookup(eid);
685 
686  // Count from current position to next header, or equal to end
687  const uint16_t* head_pos = i.raw();
688  int ns = 0;
689  for (++i; i != iend && !i.isHeader(); ++i) {
690  ns++;
691  }
692 
693  bool isZDC = (did.det()==DetId::Calo && did.subdetId()==HcalZDCDetId::SubdetectorId);
694  bool isLasmon = (did.det()==DetId::Hcal && (HcalSubdetector)did.subdetId() == HcalOther && HcalCalibDetId( did ).calibFlavor() == 5);
695 
696  if( isZDC ) {
697  if( colls.qie10ZDC == nullptr ) {
698  colls.qie10ZDC = new QIE10DigiCollection(ns);
699  } else if (colls.qie10ZDC->samples() != ns) {
700  printInvalidDataMessage( "QIE10ZDC", colls.qie10ZDC->samples(), ns, false );
701  }
702  }
703  else if( isLasmon ) {
704  if (colls.qie10Lasermon == nullptr ) {
705  colls.qie10Lasermon = new QIE10DigiCollection(ns);
706  } else if (colls.qie10Lasermon->samples() != ns) {
707  printInvalidDataMessage( "QIE10LASMON", colls.qie10Lasermon->samples(), ns, false );
708  }
709  } else { // these are the default qie10 channels
710  if (colls.qie10 == nullptr) {
711  colls.qie10 = new QIE10DigiCollection(ns);
712  }
713  else if (colls.qie10->samples() != ns) {
714  // if this sample type hasn't been requested to be saved
715  // warn the user to provide a configuration that prompts it to be saved
716  if( colls.qie10Addtl.find( ns ) == colls.qie10Addtl.end() ) {
717  printInvalidDataMessage( "QIE10", colls.qie10->samples(), ns, true );
718  }
719  }
720  }
721 
722  // Insert data
724  if (!did.null()) { // unpack and store...
725  // fill the additional qie10 collections
726  if( isZDC ) colls.qie10ZDC->addDataFrame( did, head_pos );
727  else if( isLasmon) colls.qie10Lasermon->addDataFrame( did, head_pos );
728  else {
729 
730  // only fill the default collection if we have the correct number of samples
731  if (colls.qie10->samples() == ns) {
732  colls.qie10->addDataFrame(did, head_pos);
733  }
734 
735  // fill the additional qie10 collections
736  if( colls.qie10Addtl.find( ns ) != colls.qie10Addtl.end() ) {
737  colls.qie10Addtl[ns]->addDataFrame( did, head_pos );
738  }
739  }
740  } else {
741  report.countUnmappedDigi(eid);
742  if (unknownIds_.find(eid)==unknownIds_.end()) {
743  if (!silent) edm::LogWarning("HCAL") << "HcalUnpacker: No match found for electronics id :" << eid;
744  unknownIds_.insert(eid);
745 #ifdef DebugLog
746  std::cout << "HcalUnpacker: No match found for electronics id :" << eid << std::endl;
747 #endif
748  }
749 #ifdef DebugLog
750  std::cout << "OH NO! HcalUnpacker: No match found for electronics id :" << eid << std::endl;
751 #endif
752  }
753  }
754  else if (i.flavor()==5 || (i.flavor()==7 && i.technicalDataType()==15)) { // Old-style digis
755  int ifiber=((i.channelid()>>2)&0x1F);
756  int ichan=(i.channelid()&0x3);
757  HcalElectronicsId eid(crate,slot,ifiber,ichan, false);
758  DetId did=emap.lookup(eid);
759 
760  if (!did.null()) { // unpack and store...
761  if (did.det()==DetId::Calo && did.subdetId()==HcalZDCDetId::SubdetectorId) {
762  colls.zdcCont->push_back(ZDCDataFrame(HcalZDCDetId(did)));
763  HcalUnpacker_impl::unpack_compact<ZDCDataFrame>(i,iend, colls.zdcCont->back(), nps, eid, startSample_, endSample_);
764  } else if (did.det()==DetId::Hcal) {
765  switch (((HcalSubdetector)did.subdetId())) {
766  case (HcalBarrel):
767  case (HcalEndcap): {
768  colls.hbheCont->push_back(HBHEDataFrame(HcalDetId(did)));
769  HcalUnpacker_impl::unpack_compact<HBHEDataFrame>(i, iend, colls.hbheCont->back(), nps, eid, startSample_, endSample_);
770  } break;
771  case (HcalOuter): {
772  colls.hoCont->push_back(HODataFrame(HcalDetId(did)));
773  HcalUnpacker_impl::unpack_compact<HODataFrame>(i, iend, colls.hoCont->back(), nps, eid, startSample_, endSample_);
774  } break;
775  case (HcalForward): {
776  colls.hfCont->push_back(HFDataFrame(HcalDetId(did)));
777  HcalUnpacker_impl::unpack_compact<HFDataFrame>(i, iend, colls.hfCont->back(), nps, eid, startSample_, endSample_);
778  } break;
779  case (HcalOther) : {
780  HcalOtherDetId odid(did);
781  if (odid.subdet()==HcalCalibration) {
782  colls.calibCont->push_back(HcalCalibDataFrame(HcalCalibDetId(did)));
783  HcalUnpacker_impl::unpack_compact<HcalCalibDataFrame>(i, iend, colls.calibCont->back(), nps, eid, startSample_, endSample_);
784  }
785  } break;
786  case (HcalEmpty):
787  default: {
788  for (++i;
789  i!=iend && !i.isHeader();
790  ++i);
791  }
792  break;
793  }
794  }
795  } else {
796  report.countUnmappedDigi(eid);
797  if (unknownIds_.find(eid)==unknownIds_.end()) {
798  if (!silent) edm::LogWarning("HCAL") << "HcalUnpacker: No match found for electronics id :" << eid;
799  unknownIds_.insert(eid);
800  }
801  for (++i;
802  i!=iend && !i.isHeader();
803  ++i);
804  }
805  } else if (i.flavor()==0x4) { // TP digis
806  int ilink=((i.channelid()>>4)&0xF);
807  int itower=(i.channelid()&0xF);
808  HcalElectronicsId eid(crate,slot,ilink,itower,true);
809  DetId did=emap.lookupTrigger(eid);
810 #ifdef DebugLog
811  std::cout << "Unpacking " << eid << " " << i.channelid() << std::endl;
812 #endif
813  if (did.null()) {
814  report.countUnmappedTPDigi(eid);
815  if (unknownIdsTrig_.find(eid)==unknownIdsTrig_.end()) {
816  if (!silent) edm::LogWarning("HCAL") << "HcalUnpacker: No trigger primitive match found for electronics id :" << eid;
817  unknownIdsTrig_.insert(eid);
818  }
819  // Skip it
820  for (++i; i!=iend && !i.isHeader(); ++i);
821  } else if (did==HcalTrigTowerDetId::Undefined ||
822  (did.det()==DetId::Hcal && did.subdetId()==0)) {
823  for (++i; i!=iend && !i.isHeader(); ++i);
824  } else {
825  HcalTrigTowerDetId id(did);
826 #ifdef DebugLog
827  std::cout << "Unpacking " << id << std::endl;
828 #endif
829  colls.tpCont->push_back(HcalTriggerPrimitiveDigi(id));
830  int j=0;
831  for (++i; i!=iend && !i.isHeader(); ++i) {
832  colls.tpCont->back().setSample(j,i.value());
833  if (i.soi()) colls.tpCont->back().setPresamples(j);
834  j++;
835  }
836  colls.tpCont->back().setSize(j);
837  }
838  } else {
839  // consume any not-understood channel data
840  for (++i;
841  i!=iend && !i.isHeader();
842  ++i);
843  }
844  }
845  }
846 }
847 
849  hbheCont=nullptr;
850  hoCont=nullptr;
851  hfCont=nullptr;
852  tpCont=nullptr;
853  zdcCont=nullptr;
854  calibCont=nullptr;
855  ttp=nullptr;
856  qie10=nullptr;
857  qie10ZDC=nullptr;
858  qie10Lasermon=nullptr;
859  qie11=nullptr;
860  umnio=nullptr;
861 }
862 
863 void HcalUnpacker::unpack(const FEDRawData& raw, const HcalElectronicsMap& emap, std::vector<HcalHistogramDigi>& histoDigis) {
864 
865  // get the DCC header
866  const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(raw.data());
867  int dccid=dccHeader->getSourceId()-sourceIdOffset_;
868 
869  // check the summary status
870 
871  // walk through the HTR data...
872  HcalHTRData htr;
873  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {
874  if (!dccHeader->getSpigotPresent(spigot)) continue;
875 
876  int retval=dccHeader->getSpigotData(spigot,htr,raw.size());
877  // check
878  if (retval || !htr.check()) {
879  edm::LogWarning("Invalid Data") << "Invalid HTR data observed on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId();
880  continue;
881  }
882  if (!htr.isHistogramEvent()) {
883  edm::LogWarning("Invalid Data") << "Non-histogram data passed to histogram unpacker on spigot " << spigot << " of DCC with source id " << dccHeader->getSourceId();
884  continue;
885  }
886 
887  unsigned int smid=htr.getSubmodule();
888  int htr_tb=smid&0x1;
889  int htr_slot=(smid>>1)&0x1F;
890  int htr_cr=(smid>>6)&0x1F;
891 
892  // find out the fibers
893  int f[2],fc;
894  htr.getHistogramFibers(f[0],f[1]);
895 
896  for (int nf=0; nf<2; nf++) {
897  if (f[nf]<0 || (nf==1 && f[0]==f[1])) continue; // skip if invalid or the same
898  for (fc=0; fc<=2; fc++) {
899  HcalElectronicsId eid(fc,f[nf],spigot,dccid);
900  eid.setHTR(htr_cr,htr_slot,htr_tb);
901  DetId did=emap.lookup(eid);
902 
903  if (did.null() || did.det()!=DetId::Hcal || did.subdetId()==0) {
904  if (unknownIds_.find(eid)==unknownIds_.end()) {
905  edm::LogWarning("HCAL") << "HcalHistogramUnpacker: No match found for electronics id :" << eid;
906  unknownIds_.insert(eid);
907  }
908  continue;
909  }
910  histoDigis.push_back(HcalHistogramDigi(HcalDetId(did))); // add it!
911  HcalHistogramDigi& digi=histoDigis.back();
912 
913  // unpack the four capids
914  for (int capid=0; capid<4; capid++)
915  htr.unpackHistogram(f[nf],fc,capid,digi.getArray(capid));
916 
917  }
918  }
919  }
920 }
921 // Method to unpack uMNio data
922 void HcalUnpacker::unpackUMNio(const FEDRawData& raw, int slot, Collections& colls) {
923  const hcal::AMC13Header* amc13=(const hcal::AMC13Header*)(raw.data());
924  int namc=amc13->NAMC();
925  //Find AMC corresponding to uMNio slot
926  for (int iamc=0; iamc<namc; iamc++) {
927  if (amc13->AMCSlot(iamc) == slot) namc = iamc;
928  }
929  if (namc==amc13->NAMC()) {
930  return;
931  }
932  const uint16_t* data = (const uint16_t*)(amc13->AMCPayload(namc));
933  size_t nwords = amc13->AMCSize(namc) * ( sizeof(uint64_t) / sizeof(uint16_t) );
934  *(colls.umnio) = HcalUMNioDigi(data, nwords);
935 
936 }
937 
938 void HcalUnpacker::printInvalidDataMessage( const std::string &coll_type, int default_ns, int conflict_ns, bool extended ) {
939 
940  nPrinted_++;
941 
942  constexpr int limit = 2;//print up to limit-1 messages
943  if( nPrinted_ >= limit ) {
944 
945  if( nPrinted_ == limit ) edm::LogInfo("Invalid Data") << "Suppressing further error messages";
946 
947  return;
948  }
949 
950  std::stringstream message;
951 
952  message << "The default " << coll_type << " Collection has "
953  << default_ns << " samples per digi, while the current data has "
954  << conflict_ns << "! This data cannot be included with the default collection.";
955 
956  if( extended ) {
957  message << "\nIn order to store this data in the event, it must have a unique tag. "
958  << "To accomplish this, provide two lists to HcalRawToDigi \n"
959  << "1) that specifies the number of samples and "
960  << "2) that gives tags with which these data are saved.\n"
961  << "For example in this case you might add \n"
962  << "process.hcalDigis.save" << coll_type << "DataNSamples = cms.untracked.vint32( "
963  << conflict_ns << ") \nprocess.hcalDigis.save" << coll_type << "DataTags = cms.untracked.vstring( \"MYDATA\" )" ;
964  }
965 
966  edm::LogWarning("Invalid Data") << message.str();
967 }
968 
#define LogDebug(id)
int getSourceId() const
Definition: HcalDTCHeader.h:35
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...
Definition: HcalHTRData.cc:62
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
Definition: HcalUnpacker.h:33
CalibDetType calibFlavor() const
get the flavor of this calibration detid
std::vector< HFDataFrame > * hfCont
Definition: HcalUnpacker.h:28
HcalUMNioDigi * umnio
Definition: HcalUnpacker.h:41
constexpr bool null() const
is this a null id ?
Definition: DetId.h:52
bool getSpigotCRCError(unsigned int nspigot) const
Read the "CRC-Mismatch" bit for this spigot.
void addDataFrame(DetId detid, const uint16_t *data)
uint16_t value() const
Definition: HcalUHTRData.h:52
static bool isTPGSOI(const HcalTriggerPrimitiveSample &s)
QIE10DigiCollection * qie10Lasermon
Definition: HcalUnpacker.h:36
constexpr int fiberChan() const
get the fiber channel number
Definition: HcalQIESample.h:73
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)
Definition: HcalUnpacker.cc:52
std::vector< HBHEDataFrame > * hbheCont
Definition: HcalUnpacker.h:26
std::vector< HOTriggerPrimitiveDigi > * tphoCont
Definition: HcalUnpacker.h:32
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&Pass ZS?
Definition: HcalHTRData.cc:357
unsigned int getFibOrbMsgBCN(int fiber) const
Get the BCN of the Fiber Orbit Messages.
Definition: HcalHTRData.h:178
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)
Definition: HcalHTRData.cc:434
void getHistogramFibers(int &a, int &b) const
Get the fiber numbers for the data present in this event (only in histogram mode!) ...
Definition: HcalHTRData.cc:414
int getSpigotData(int nspigot, HcalHTRData &decodeTool, int validSize) const
std::unordered_map< int, QIE11DigiCollection * > qie11Addtl
Definition: HcalUnpacker.h:40
int getFormatVersion() const
Get the version number of this event.
Definition: HcalHTRData.h:33
#define constexpr
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
void printInvalidDataMessage(const std::string &coll_type, int default_ns, int conflict_ns, bool extended=false)
int AMCSize(int i) const
Definition: AMC13Header.h:37
HcalDataFrameContainer< QIE10DataFrame > QIE10DigiCollection
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:354
bool isOverflowWarning() const
Definition: HcalHTRData.cc:109
bool unpackHistogram(int fiber, int fiberchan, int capid, unsigned short *histogram) const
Unpack special histogramming mode data.
Definition: HcalHTRData.cc:442
static bool is_channel_header(unsigned short value)
check top bit to see if this is a compact format channel header word
Definition: HcalHTRData.h:90
std::unordered_map< int, QIE10DigiCollection * > qie10Addtl
Definition: HcalUnpacker.h:39
QIE10DigiCollection * qie10ZDC
Definition: HcalUnpacker.h:35
bool isEmptyEvent() const
Definition: HcalHTRData.cc:100
bool AMCDataPresent(int i) const
Definition: AMC13Header.h:47
int ieta() const
get the cell ieta
Definition: HcalDetId.h:159
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
HcalSubdetector
Definition: HcalAssistant.h:31
uint16_t raw() const
get the raw word
void unpackVME(const FEDRawData &raw, const HcalElectronicsMap &emap, Collections &conts, HcalUnpackerReport &report, bool silent=false)
double f[11][100]
std::vector< HcalTriggerPrimitiveDigi > * tpCont
Definition: HcalUnpacker.h:31
bool getSpigotPresent(unsigned int nspigot) const
Read the "PRESENT" bit for this spigot.
bool getSlotPresent(unsigned int nslot) const
Read the "PRESENT" bit for this slot.
Definition: HcalDTCHeader.h:80
HcalDataFrameContainer< QIE11DataFrame > QIE11DigiCollection
int getSourceId() const
Definition: HcalDCCHeader.h:32
int iphi() const
get the cell iphi
Definition: HcalDetId.h:161
unsigned int databits
Definition: DetId.h:18
void unpack(const FEDRawData &raw, const HcalElectronicsMap &emap, std::vector< HcalHistogramDigi > &histoDigis)
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
std::vector< HcalCalibDataFrame > * calibCont
Definition: HcalUnpacker.h:29
static int slb(uint16_t theSample)
unsigned long long uint64_t
Definition: Time.h:15
HcalOtherSubdetector subdet() const
get the category
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.
Definition: HcalHTRData.cc:154
bool unpack(const HcalHTRData &data, HcalTTPDigi &digi)
int sourceId() const
Definition: AMC13Header.h:15
std::vector< HODataFrame > * hoCont
Definition: HcalUnpacker.h:27
QIE11DigiCollection * qie11
Definition: HcalUnpacker.h:37
void setbit(int i)
short BOEshouldBeZeroAlways() const
Definition: HcalDCCHeader.h:50
int getNPS() const
Get the number of presamples in daq data.
Definition: HcalHTRData.cc:401
static const HcalTrigTowerDetId Undefined
bool AMCSegmented(int i) const
Definition: AMC13Header.h:41
static const int FORMAT_VERSION_COMPACT_DATA
Definition: HcalHTRData.h:20
int getFirmwareFlavor() const
Get the HTR firmware flavor.
Definition: HcalHTRData.cc:410
int NAMC() const
Definition: AMC13Header.h:25
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:19
int AMCSlot(int i) const
Definition: AMC13Header.h:33
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const uint64_t * AMCPayload(int i) const
Definition: AMC13Header.cc:4
int getSlotData(int nslot, HcalHTRData &decodeTool, int validSize) const
bool wasMarkAndPassZSTP(int slb, int slbchan) const
Was this channel passed as part of Mark&Pass ZS?
Definition: HcalHTRData.cc:365
uint16_t * getArray(int capid)
get the array for the specified capid
uint32_t zsBunchMask() const
ZS Bunch Mask (if available)
Definition: HcalHTRData.cc:374
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
constexpr uint16_t raw() const
get the raw word
Definition: HcalQIESample.h:57
QIE10DigiCollection * qie10
Definition: HcalUnpacker.h:34
std::vector< ZDCDataFrame > * zdcCont
Definition: HcalUnpacker.h:30
bool AMCCRCOk(int i) const
Definition: AMC13Header.h:45
const DetId lookupTrigger(HcalElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
short getDCCDataFormatVersion() const
Definition: HcalDCCHeader.h:57
unsigned int getSubmodule() const
Get the HTR submodule number.
Definition: HcalHTRData.cc:332
bool AMCEnabled(int i) const
Definition: AMC13Header.h:51
bool isBusy() const
Definition: HcalHTRData.cc:117
float linear(float x)
void unpackUMNio(const FEDRawData &raw, int slot, Collections &colls)
uint16_t AMCId(int i) const
Definition: AMC13Header.h:31
const uint16_t * raw() const
Definition: HcalUHTRData.h:68
Readout chain identification for Hcal.
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
Definition: HcalHTRData.cc:386
static const int MAXIMUM_SLOT
Definition: HcalDTCHeader.h:22
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)
Definition: HcalUnpacker.cc:17
bool getSlotCRCError(unsigned int nslot) const
Read the "CRC-Mismatch" bit for this slot.
Definition: HcalDTCHeader.h:84
static int slbChan(uint16_t theSample)
constexpr int fiber() const
get the fiber number
Definition: HcalQIESample.h:71
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39
constexpr int fiberAndChan() const
get the id channel
Definition: HcalQIESample.h:75