CMS 3D CMS Logo

HcalLaserUnpacker.cc
Go to the documentation of this file.
5 #include <ostream>
6 
8 
11  unsigned int n_qdc_hits; // Count of QDC channels
12  unsigned int n_tdc_hits; // upper/lower TDC counts
13  unsigned short qdc_values[4];
14 };
15 
16 void HcalLaserUnpacker::unpack(const FEDRawData& raw, HcalLaserDigi& digi) const {
17  if (raw.size() < 3 * 8) {
18  throw cms::Exception("Missing Data") << "No data in the block";
19  }
20 
21  const CombinedTDCQDCDataFormat* qdctdc = (const CombinedTDCQDCDataFormat*)raw.data();
22 
23  // first, we do the QADC
24  std::vector<uint16_t> qadcvals;
25  for (unsigned int i = 0; i < qdctdc->n_qdc_hits; i++) {
26  qadcvals.push_back(qdctdc->qdc_values[i] & 0xFFF);
27  }
28  digi.setQADC(qadcvals);
29 
30  // next, we do the TDC
31  const unsigned int* hitbase = (&(qdctdc->n_tdc_hits)) + 1; // base is one beyond
32  unsigned int totalhits = 0;
33 
34  hitbase += qdctdc->n_qdc_hits / 2; // two unsigned short per unsigned long
35  totalhits = qdctdc->n_tdc_hits & 0xFFFF; // mask off high bits
36 
37  for (unsigned int i = 0; i < totalhits; i++) {
38  int channel = (hitbase[i] & 0x7FC00000) >> 22; // hardcode channel assignment
39  int time = (hitbase[i] & 0xFFFFF);
40  if (channel == 0 && time == 0 && i == (totalhits - 1))
41  continue; // ignore "filler" hit
42  digi.addTDCHit(channel, time);
43  }
44 }
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:48
void addTDCHit(int channel, int hittime)
unsigned short qdc_values[4]
void setQADC(const std::vector< uint16_t > &values)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
void unpack(const FEDRawData &raw, HcalLaserDigi &digi) const