CMS 3D CMS Logo

Functions
HcalUnpacker_impl Namespace Reference

Functions

template<class DigiClass >
const HcalQIESampleunpack (const HcalQIESample *startPoint, const HcalQIESample *limit, DigiClass &digi, int presamples, const HcalElectronicsId &eid, int startSample, int endSample, int expectedTime, const HcalHTRData &hhd)
 
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)
 
template<class DigiClass >
void unpack_compact (HcalUHTRData::const_iterator &i, const HcalUHTRData::const_iterator &iend, DigiClass &digi, int presamples, const HcalElectronicsId &eid, int startSample, int endSample)
 

Function Documentation

◆ unpack()

template<class DigiClass >
const HcalQIESample* HcalUnpacker_impl::unpack ( const HcalQIESample startPoint,
const HcalQIESample limit,
DigiClass &  digi,
int  presamples,
const HcalElectronicsId eid,
int  startSample,
int  endSample,
int  expectedTime,
const HcalHTRData hhd 
)

Definition at line 16 of file HcalUnpacker.cc.

References gather_cfg::cout, runTauDisplay::eid, HcalQIESample::fiber(), FCDTask_cfi::fiber, HcalQIESample::fiberAndChan(), HcalQIESample::fiberChan(), HcalHTRData::getFibOrbMsgBCN(), HcalHTRData::isUnsuppressed(), lut2db_cfg::limit, hcalTTPDigis_cfi::presamples, HcalHTRData::wasMarkAndPassZS(), and HcalHTRData::zsBunchMask().

24  {
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  }
bool wasMarkAndPassZS(int fiber, int fiberchan) const
Was this channel passed as part of Mark&Pass ZS?
Definition: HcalHTRData.cc:379
constexpr int fiberChan() const
get the fiber channel number
Definition: HcalQIESample.h:55
constexpr int fiberAndChan() const
get the id channel
Definition: HcalQIESample.h:57
uint32_t zsBunchMask() const
ZS Bunch Mask (if available)
Definition: HcalHTRData.cc:400
constexpr int fiber() const
get the fiber number
Definition: HcalQIESample.h:53
unsigned int getFibOrbMsgBCN(int fiber) const
Get the BCN of the Fiber Orbit Messages.
Definition: HcalHTRData.h:180
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:378

◆ unpack_compact() [1/2]

template<class DigiClass >
const unsigned short* HcalUnpacker_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 58 of file HcalUnpacker.cc.

References gather_cfg::cout, runTauDisplay::eid, FCDTask_cfi::fiber, HcalHTRData::getFibOrbMsgBCN(), HcalHTRData::is_channel_header(), HcalHTRData::isUnsuppressed(), lut2db_cfg::limit, hcalTTPDigis_cfi::presamples, ecalGpuTask_cfi::sample, HcalHTRData::unpack_per_channel_header(), HcalHTRData::wasMarkAndPassZS(), and HcalHTRData::zsBunchMask().

66  {
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  }
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

◆ unpack_compact() [2/2]

template<class DigiClass >
void HcalUnpacker_impl::unpack_compact ( HcalUHTRData::const_iterator i,
const HcalUHTRData::const_iterator iend,
DigiClass &  digi,
int  presamples,
const HcalElectronicsId eid,
int  startSample,
int  endSample 
)

Definition at line 137 of file HcalUnpacker.cc.

References runTauDisplay::eid, FCDTask_cfi::fiber, mps_fire::i, hcalTTPDigis_cfi::presamples, alignCSCRings::s, and ecalGpuTask_cfi::sample.

143  {
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  }