CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/EventFilter/HcalRawToDigi/src/HcalTTPUnpacker.cc

Go to the documentation of this file.
00001 #include "EventFilter/HcalRawToDigi/interface/HcalTTPUnpacker.h"
00002 
00003 bool HcalTTPUnpacker::unpack(const HcalHTRData& theData, HcalTTPDigi& theDigi) {
00004 
00005     // Get the base information for the TTP Digi
00006     int theID    = theData.getSubmodule() ;
00007     int nSamples = theData.getNDD() ;
00008     int nPresamples = theData.getNPS() ;
00009     int algorithm = theData.getFirmwareFlavor()&0x1F ;
00010     unsigned int fwVersion = theData.getFirmwareRevision() ;
00011     unsigned int lPipe = theData.getPipelineLength() ; 
00012 
00013     if (nSamples>8) nSamples=8; // protection in case nSamples is too large
00014 
00015     theDigi = HcalTTPDigi(theID,nSamples,nPresamples,fwVersion,algorithm,lPipe) ;
00016 
00017     // Get the data pointers
00018     const unsigned short *daq_first, *daq_last, *tp_first, *tp_last ;
00019     theData.dataPointers(&daq_first,&daq_last,&tp_first,&tp_last) ;
00020 
00021     // Each TTP data sample is 96 bits: 72 (input) + 20 (algo) + output (4)
00022     for (int i=0; i<nSamples; i++) {
00023 
00024         const uint16_t* daq_start = (daq_first+6*i) ;
00025         if ( daq_start > daq_last ) break ;
00026 
00027         const uint16_t* inputContent = daq_start ; 
00028         const uint32_t algoDep = (daq_start[4]>>8)|((uint32_t(daq_start[5])&0xFFF)<<8) ; 
00029         const uint8_t trigOutput = (daq_start[5]>>12)&0xF ;
00030         
00031         int relativeSample = i - nPresamples ;
00032         theDigi.setSample(relativeSample,inputContent,algoDep,trigOutput) ;
00033     }
00034     return true;
00035 }
00036