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