CMS 3D CMS Logo

List of all members | Public Member Functions
HcalTTPUnpacker Class Reference

#include <HcalTTPUnpacker.h>

Public Member Functions

bool unpack (const HcalHTRData &data, HcalTTPDigi &digi)
 

Detailed Description

Author
J. Mans - Minnesota

Definition at line 11 of file HcalTTPUnpacker.h.

Member Function Documentation

◆ unpack()

bool HcalTTPUnpacker::unpack ( const HcalHTRData data,
HcalTTPDigi digi 
)

Definition at line 3 of file HcalTTPUnpacker.cc.

References qcdUeDQM_cfi::algorithm, HcalHTRData::dataPointers(), amcDumpToRaw_cfi::fwVersion, HcalHTRData::getFirmwareFlavor(), HcalHTRData::getFirmwareRevision(), HcalHTRData::getNDD(), HcalHTRData::getNPS(), HcalHTRData::getPipelineLength(), HcalHTRData::getSubmodule(), mps_fire::i, PresampleTask_cfi::nSamples, and HcalTTPDigi::setSample().

Referenced by CastorUnpacker::unpack(), ZdcUnpacker::unpack(), and HcalUnpacker::unpackVME().

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