test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
17  HcalLaserDigi& digi) const {
18 
19  if (raw.size()<3*8) {
20  throw cms::Exception("Missing Data") << "No data in the block";
21  }
22 
23  const CombinedTDCQDCDataFormat* qdctdc=(const CombinedTDCQDCDataFormat*)raw.data();
24 
25  // first, we do the QADC
26  std::vector<uint16_t> qadcvals;
27  for (unsigned int i=0;i<qdctdc->n_qdc_hits;i++) {
28  qadcvals.push_back(qdctdc->qdc_values[i]&0xFFF);
29  }
30  digi.setQADC(qadcvals);
31 
32  // next, we do the TDC
33  const unsigned int* hitbase=(&(qdctdc->n_tdc_hits))+1; // base is one beyond
34  unsigned int totalhits=0;
35 
36  hitbase+=qdctdc->n_qdc_hits/2; // two unsigned short per unsigned long
37  totalhits=qdctdc->n_tdc_hits&0xFFFF; // mask off high bits
38 
39  for (unsigned int i=0; i<totalhits; i++) {
40  int channel=(hitbase[i]&0x7FC00000)>>22; // hardcode channel assignment
41  int time=(hitbase[i]&0xFFFFF);
42  if (channel==0 && time==0 && i==(totalhits-1)) continue; // ignore "filler" hit
43  digi.addTDCHit(channel,time);
44  }
45 }
int i
Definition: DBlmapReader.cc:9
void addTDCHit(int channel, int hittime)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
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:28
void unpack(const FEDRawData &raw, HcalLaserDigi &digi) const