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 }
mps_fire.i
i
Definition: mps_fire.py:428
CombinedTDCQDCDataFormat::qdc_values
unsigned short qdc_values[4]
Definition: HcalLaserUnpacker.cc:13
HcalLaserUnpacker::unpack
void unpack(const FEDRawData &raw, HcalLaserDigi &digi) const
Definition: HcalLaserUnpacker.cc:16
HcalLaserUnpacker.h
CombinedTDCQDCDataFormat::cdfHeader0
unsigned int cdfHeader0
Definition: HcalLaserUnpacker.cc:10
CombinedTDCQDCDataFormat
Definition: HcalLaserUnpacker.cc:9
protons_cff.time
time
Definition: protons_cff.py:39
FEDRawData.h
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
FEDRawData
Definition: FEDRawData.h:19
HcalLaserDigi::addTDCHit
void addTDCHit(int channel, int hittime)
Definition: HcalLaserDigi.cc:16
HcalLaserDigi.h
CombinedTDCQDCDataFormat::n_qdc_hits
unsigned int n_qdc_hits
Definition: HcalLaserUnpacker.cc:11
HcalLaserUnpacker::HcalLaserUnpacker
HcalLaserUnpacker()
Definition: HcalLaserUnpacker.cc:7
CombinedTDCQDCDataFormat::cdfHeader3
unsigned int cdfHeader3
Definition: HcalLaserUnpacker.cc:10
HcalLaserDigi::setQADC
void setQADC(const std::vector< uint16_t > &values)
Definition: HcalLaserDigi.cc:11
CombinedTDCQDCDataFormat::cdfHeader2
unsigned int cdfHeader2
Definition: HcalLaserUnpacker.cc:10
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
CombinedTDCQDCDataFormat::cdfHeader1
unsigned int cdfHeader1
Definition: HcalLaserUnpacker.cc:10
Exception
Definition: hltDiff.cc:245
Exception.h
HcalLaserDigi
Definition: HcalLaserDigi.h:7
CombinedTDCQDCDataFormat::n_tdc_hits
unsigned int n_tdc_hits
Definition: HcalLaserUnpacker.cc:12