CMS 3D CMS Logo

Functions
ZdcUnpacker_impl Namespace Reference

Functions

template<class DigiClass >
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)
 

Function Documentation

◆ unpack_compact()

template<class DigiClass >
const unsigned short* ZdcUnpacker_impl::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 at line 18 of file ZdcUnpacker.cc.

References runTauDisplay::eid, HcalHTRData::getFibOrbMsgBCN(), HcalHTRData::is_channel_header(), HcalHTRData::isUnsuppressed(), remoteMonitoring_LASER_era2018_cfg::limit, hcalTTPDigis_cfi::presamples, ecalGpuTask_cfi::sample, HcalHTRData::unpack_per_channel_header(), HcalHTRData::wasMarkAndPassZS(), testProducerWithPsetDescEmpty_cfi::x1, and HcalHTRData::zsBunchMask().

26  {
27  // set parameters
28  digi.setPresamples(presamples);
29  digi.setReadoutIds(eid);
30  int flavor, error_flags, capid0, channelid;
31 
32  HcalHTRData::unpack_per_channel_header(*startPoint, flavor, error_flags, capid0, channelid);
33  bool isCapRotating = !(error_flags & 0x1);
34  bool fiberErr = (error_flags & 0x2);
35  bool dataValid = !(error_flags & 0x2);
36  int fiberchan = channelid & 0x3;
37  int fiber = ((channelid >> 2) & 0x7) + 1;
38 
39  uint32_t zsmask = hhd.zsBunchMask() >> startSample;
40  digi.setZSInfo(hhd.isUnsuppressed(), hhd.wasMarkAndPassZS(fiber, fiberchan), zsmask);
41 
42  if (expectedTime >= 0 && !hhd.isUnsuppressed()) {
43  digi.setFiberIdleOffset(hhd.getFibOrbMsgBCN(fiber) - expectedTime);
44  }
45 
46  // what is my sample number?
47  int ncurr = 0, ntaken = 0;
48  const unsigned short* qie_work = startPoint;
49  // we branch here between normal (flavor=5) and error mode (flavor=6)
50  if (flavor == 5) {
51  for (qie_work++; qie_work != limit && !HcalHTRData::is_channel_header(*qie_work); qie_work++) {
52  int capidn = (isCapRotating) ? ((capid0 + ncurr) % 4) : (capid0);
53  int capidn1 = (isCapRotating) ? ((capid0 + ncurr + 1) % 4) : (capid0);
54  // two samples in one...
55  HcalQIESample s0((*qie_work) & 0x7F, capidn, fiber, fiberchan, dataValid, fiberErr);
56  HcalQIESample s1(((*qie_work) >> 8) & 0x7F, capidn1, fiber, fiberchan, dataValid, fiberErr);
57 
58  if (ncurr >= startSample && ncurr <= endSample) {
59  digi.setSample(ntaken, s0);
60  ++ntaken;
61  }
62  ncurr++;
63  if (ncurr >= startSample && ncurr <= endSample) {
64  digi.setSample(ntaken, s1);
65  ++ntaken;
66  }
67  ncurr++;
68  }
69  digi.setSize(ntaken);
70  } else if (flavor == 6) {
71  for (qie_work++; qie_work != limit && !HcalHTRData::is_channel_header(*qie_work); qie_work++) {
72  if (ncurr >= startSample && ncurr <= endSample) {
73  HcalQIESample sample((*qie_work) & 0x7F,
74  ((*qie_work) >> 8) & 0x3,
75  fiber,
76  fiberchan,
77  ((*qie_work) >> 10) & 0x1,
78  ((*qie_work) >> 11) & 0x1);
79  digi.setSample(ntaken, sample);
80  ++ntaken;
81  }
82  ncurr++;
83  }
84  digi.setSize(ntaken);
85  } else {
86  edm::LogWarning("Bad Data") << "Invalid flavor " << flavor;
87  qie_work = limit;
88  }
89  return qie_work;
90  }
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&Pass ZS?
Definition: HcalHTRData.cc:379
uint32_t zsBunchMask() const
ZS Bunch Mask (if available)
Definition: HcalHTRData.cc:400
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
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
unsigned int getFibOrbMsgBCN(int fiber) const
Get the BCN of the Fiber Orbit Messages.
Definition: HcalHTRData.h:180
Log< level::Warning, false > LogWarning
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:378