CMS 3D CMS Logo

HcalTTPUnpacker.cc
Go to the documentation of this file.
2 
3 bool HcalTTPUnpacker::unpack(const HcalHTRData& theData, HcalTTPDigi& theDigi) {
4  // Get the base information for the TTP Digi
5  int theID = theData.getSubmodule();
6  int nSamples = theData.getNDD();
7  int nPresamples = theData.getNPS();
8  int algorithm = theData.getFirmwareFlavor() & 0x1F;
9  unsigned int fwVersion = theData.getFirmwareRevision();
10  unsigned int lPipe = theData.getPipelineLength();
11 
12  if (nSamples > 8)
13  nSamples = 8; // protection in case nSamples is too large
14 
15  theDigi = HcalTTPDigi(theID, nSamples, nPresamples, fwVersion, algorithm, lPipe);
16 
17  // Get the data pointers
18  const unsigned short *daq_first, *daq_last, *tp_first, *tp_last;
19  theData.dataPointers(&daq_first, &daq_last, &tp_first, &tp_last);
20 
21  // Each TTP data sample is 96 bits: 72 (input) + 20 (algo) + output (4)
22  for (int i = 0; i < nSamples; i++) {
23  const uint16_t* daq_start = (daq_first + 6 * i);
24  if (daq_start > daq_last)
25  break;
26 
27  const uint16_t* inputContent = daq_start;
28  const uint32_t algoDep = (daq_start[4] >> 8) | ((uint32_t(daq_start[5]) & 0xFFF) << 8);
29  const uint8_t trigOutput = (daq_start[5] >> 12) & 0xF;
30 
31  int relativeSample = i - nPresamples;
32  theDigi.setSample(relativeSample, inputContent, algoDep, trigOutput);
33  }
34  return true;
35 }
unsigned int getFirmwareRevision() const
Get the HTR firmware version.
Definition: HcalHTRData.cc:430
int getNPS() const
Get the number of presamples in daq data.
Definition: HcalHTRData.cc:426
int getFirmwareFlavor() const
Get the HTR firmware flavor.
Definition: HcalHTRData.cc:433
void dataPointers(const unsigned short **daq_first, const unsigned short **daq_last, const unsigned short **tp_first, const unsigned short **tp_last) const
Obtain the starting and ending pointers for external unpacking of the data.
Definition: HcalHTRData.cc:161
unsigned int getPipelineLength() const
Get the pipeline length used for this event.
Definition: HcalHTRData.cc:427
void setSample(int relativeSample, const uint16_t *triggerInputs, const uint32_t algodep, const uint8_t outputTrigger)
Definition: HcalTTPDigi.cc:28
bool unpack(const HcalHTRData &data, HcalTTPDigi &digi)
int getNDD() const
Get the number of daq data samples per channel when not zero-suppressed.
Definition: HcalHTRData.cc:412
unsigned int getSubmodule() const
Get the HTR submodule number.
Definition: HcalHTRData.cc:355