CMS 3D CMS Logo

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