Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:15:05

0001 #include "EventFilter/HcalRawToDigi/interface/HcalTTPUnpacker.h"
0002 
0003 bool HcalTTPUnpacker::unpack(const HcalHTRData& theData, HcalTTPDigi& theDigi) {
0004   // Get the base information for the TTP Digi
0005   int theID = theData.getSubmodule();
0006   int nSamples = theData.getNDD();
0007   int nPresamples = theData.getNPS();
0008   int algorithm = theData.getFirmwareFlavor() & 0x1F;
0009   unsigned int fwVersion = theData.getFirmwareRevision();
0010   unsigned int lPipe = theData.getPipelineLength();
0011 
0012   if (nSamples > 8)
0013     nSamples = 8;  // protection in case nSamples is too large
0014 
0015   theDigi = HcalTTPDigi(theID, nSamples, nPresamples, fwVersion, algorithm, lPipe);
0016 
0017   // Get the data pointers
0018   const unsigned short *daq_first, *daq_last, *tp_first, *tp_last;
0019   theData.dataPointers(&daq_first, &daq_last, &tp_first, &tp_last);
0020 
0021   // Each TTP data sample is 96 bits: 72 (input) + 20 (algo) + output (4)
0022   for (int i = 0; i < nSamples; i++) {
0023     const uint16_t* daq_start = (daq_first + 6 * i);
0024     if (daq_start > daq_last)
0025       break;
0026 
0027     const uint16_t* inputContent = daq_start;
0028     const uint32_t algoDep = (daq_start[4] >> 8) | ((uint32_t(daq_start[5]) & 0xFFF) << 8);
0029     const uint8_t trigOutput = (daq_start[5] >> 12) & 0xF;
0030 
0031     int relativeSample = i - nPresamples;
0032     theDigi.setSample(relativeSample, inputContent, algoDep, trigOutput);
0033   }
0034   return true;
0035 }