#include <SiStripFEDBufferGenerator.h>
Public Member Functions | |
FEDBufferPayload | createPayload (const FEDReadoutMode mode, const FEDStripData &data) const |
FEDBufferPayloadCreator (const std::vector< bool > &enabledFEUnits, const std::vector< bool > &enabledChannels) | |
FEDBufferPayload | operator() (const FEDReadoutMode mode, const FEDStripData &data) const |
Private Member Functions | |
void | fillChannelBuffer (std::vector< uint8_t > *channelBuffer, const FEDReadoutMode mode, const FEDStripData::ChannelData &data, const bool channelEnabled) const |
void | fillClusterData (std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data) const |
void | fillRawChannelBuffer (std::vector< uint8_t > *channelBuffer, const uint8_t packetCode, const FEDStripData::ChannelData &data, const bool channelEnabled, const bool reorderData) const |
void | fillZeroSuppressedChannelBuffer (std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data, const bool channelEnabled) const |
void | fillZeroSuppressedLiteChannelBuffer (std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data, const bool channelEnabled) const |
Private Attributes | |
std::vector< bool > | channelsEnabled_ |
std::vector< bool > | feUnitsEnabled_ |
Definition at line 76 of file SiStripFEDBufferGenerator.h.
sistrip::FEDBufferPayloadCreator::FEDBufferPayloadCreator | ( | const std::vector< bool > & | enabledFEUnits, |
const std::vector< bool > & | enabledChannels | ||
) | [inline] |
Definition at line 276 of file SiStripFEDBufferGenerator.h.
: feUnitsEnabled_(feUnitsEnabled), channelsEnabled_(channelsEnabled) {}
FEDBufferPayload sistrip::FEDBufferPayloadCreator::createPayload | ( | const FEDReadoutMode | mode, |
const FEDStripData & | data | ||
) | const |
Definition at line 103 of file SiStripFEDBufferGenerator.cc.
References sistrip::FEDStripData::channel(), sistrip::FEDCH_PER_FED, and sistrip::FEDCH_PER_FEUNIT.
Referenced by operator()().
{ std::vector< std::vector<uint8_t> > channelBuffers(FEDCH_PER_FED,std::vector<uint8_t>()); for (size_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) { if (!feUnitsEnabled_[iCh/FEDCH_PER_FEUNIT]) continue; fillChannelBuffer(&channelBuffers[iCh],mode,data.channel(iCh),channelsEnabled_[iCh]); } return FEDBufferPayload(channelBuffers); }
void sistrip::FEDBufferPayloadCreator::fillChannelBuffer | ( | std::vector< uint8_t > * | channelBuffer, |
const FEDReadoutMode | mode, | ||
const FEDStripData::ChannelData & | data, | ||
const bool | channelEnabled | ||
) | const [private] |
Definition at line 113 of file SiStripFEDBufferGenerator.cc.
References Exception, alignBH_cfg::mode, sistrip::PACKET_CODE_PROC_RAW, sistrip::PACKET_CODE_SCOPE, sistrip::PACKET_CODE_VIRGIN_RAW, sistrip::READOUT_MODE_PROC_RAW, sistrip::READOUT_MODE_SCOPE, sistrip::READOUT_MODE_VIRGIN_RAW, sistrip::READOUT_MODE_ZERO_SUPPRESSED, and sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE.
{ switch (mode) { case READOUT_MODE_SCOPE: fillRawChannelBuffer(channelBuffer,PACKET_CODE_SCOPE,data,channelEnabled,false); break; case READOUT_MODE_VIRGIN_RAW: fillRawChannelBuffer(channelBuffer,PACKET_CODE_VIRGIN_RAW,data,channelEnabled,true); break; case READOUT_MODE_PROC_RAW: fillRawChannelBuffer(channelBuffer,PACKET_CODE_PROC_RAW,data,channelEnabled,false); break; case READOUT_MODE_ZERO_SUPPRESSED: fillZeroSuppressedChannelBuffer(channelBuffer,data,channelEnabled); break; case READOUT_MODE_ZERO_SUPPRESSED_LITE: fillZeroSuppressedLiteChannelBuffer(channelBuffer,data,channelEnabled); break; default: std::ostringstream ss; ss << "Invalid readout mode " << mode; throw cms::Exception("FEDBufferGenerator") << ss.str(); break; } }
void sistrip::FEDBufferPayloadCreator::fillClusterData | ( | std::vector< uint8_t > * | channelBuffer, |
const FEDStripData::ChannelData & | data | ||
) | const [private] |
Definition at line 222 of file SiStripFEDBufferGenerator.cc.
References ecalMGPA::adc(), sistrip::FEDStripData::ChannelData::get8BitSample(), sistrip::FEDStripData::ChannelData::size(), and sistrip::STRIPS_PER_APV.
{ uint16_t clusterSize = 0; const uint16_t nSamples = data.size(); for( uint16_t strip = 0; strip < nSamples; ++strip) { const uint8_t adc = data.get8BitSample(strip); if(adc) { if( clusterSize==0 || strip == STRIPS_PER_APV ) { if(clusterSize) { *(channelBuffer->end() - clusterSize - 1) = clusterSize ; clusterSize = 0; } channelBuffer->push_back(strip); channelBuffer->push_back(0); //clustersize } channelBuffer->push_back(adc); ++clusterSize; } else if(clusterSize) { *(channelBuffer->end() - clusterSize - 1) = clusterSize ; clusterSize = 0; } } if(clusterSize) *(channelBuffer->end() - clusterSize - 1) = clusterSize ; }
void sistrip::FEDBufferPayloadCreator::fillRawChannelBuffer | ( | std::vector< uint8_t > * | channelBuffer, |
const uint8_t | packetCode, | ||
const FEDStripData::ChannelData & | data, | ||
const bool | channelEnabled, | ||
const bool | reorderData | ||
) | const [private] |
Definition at line 140 of file SiStripFEDBufferGenerator.cc.
References sistrip::FEDStripData::ChannelData::getSample(), sistrip::FEDStripOrdering::physicalOrderForStripInChannel(), and sistrip::FEDStripData::ChannelData::size().
{ const uint16_t nSamples = data.size(); //2 bytes per sample + packet code + 2 bytes for length const uint16_t channelLength = nSamples*2 + 3; channelBuffer->reserve(channelLength); //length (max length is 0xFFF) channelBuffer->push_back( channelLength & 0xFF ); channelBuffer->push_back( (channelLength & 0xF00) >> 8 ); //packet code channelBuffer->push_back(packetCode); //channel samples for (uint16_t sampleNumber = 0; sampleNumber < nSamples; sampleNumber++) { const uint16_t sampleIndex = ( reorderData ? FEDStripOrdering::physicalOrderForStripInChannel(sampleNumber) : sampleNumber ); const uint16_t sampleValue = (channelEnabled ? data.getSample(sampleIndex) : 0); channelBuffer->push_back(sampleValue & 0xFF); channelBuffer->push_back((sampleValue & 0x300) >> 8); } }
void sistrip::FEDBufferPayloadCreator::fillZeroSuppressedChannelBuffer | ( | std::vector< uint8_t > * | channelBuffer, |
const FEDStripData::ChannelData & | data, | ||
const bool | channelEnabled | ||
) | const [private] |
Definition at line 164 of file SiStripFEDBufferGenerator.cc.
References sistrip::FEDStripData::ChannelData::getMedians(), and sistrip::PACKET_CODE_ZERO_SUPPRESSED.
{ channelBuffer->reserve(50); //if channel is disabled then create empty channel header and return if (!channelEnabled) { //min length 7 channelBuffer->push_back(7); channelBuffer->push_back(0); //packet code channelBuffer->push_back(PACKET_CODE_ZERO_SUPPRESSED); //4 bytes of medians channelBuffer->insert(channelBuffer->end(),4,0); return; } //if channel is not empty //add space for channel length channelBuffer->push_back(0xFF); channelBuffer->push_back(0xFF); //packet code channelBuffer->push_back(PACKET_CODE_ZERO_SUPPRESSED); //add medians const std::pair<uint16_t,uint16_t> medians = data.getMedians(); channelBuffer->push_back(medians.first & 0xFF); channelBuffer->push_back((medians.first & 0x300) >> 8); channelBuffer->push_back(medians.second & 0xFF); channelBuffer->push_back((medians.second & 0x300) >> 8); //clusters fillClusterData(channelBuffer,data); //set length const uint16_t length = channelBuffer->size(); (*channelBuffer)[0] = (length & 0xFF); (*channelBuffer)[1] = ((length & 0x300) >> 8); }
void sistrip::FEDBufferPayloadCreator::fillZeroSuppressedLiteChannelBuffer | ( | std::vector< uint8_t > * | channelBuffer, |
const FEDStripData::ChannelData & | data, | ||
const bool | channelEnabled | ||
) | const [private] |
Definition at line 199 of file SiStripFEDBufferGenerator.cc.
{ channelBuffer->reserve(50); //if channel is disabled then create empty channel header and return if (!channelEnabled) { //min length 2 channelBuffer->push_back(2); channelBuffer->push_back(0); return; } //if channel is not empty //add space for channel length channelBuffer->push_back(0xFF); channelBuffer->push_back(0xFF); //clusters fillClusterData(channelBuffer,data); //set length const uint16_t length = channelBuffer->size(); (*channelBuffer)[0] = (length & 0xFF); (*channelBuffer)[1] = ((length & 0x300) >> 8); }
FEDBufferPayload sistrip::FEDBufferPayloadCreator::operator() | ( | const FEDReadoutMode | mode, |
const FEDStripData & | data | ||
) | const [inline] |
Definition at line 281 of file SiStripFEDBufferGenerator.h.
References createPayload().
{ return createPayload(mode,data); }
std::vector<bool> sistrip::FEDBufferPayloadCreator::channelsEnabled_ [private] |
Definition at line 99 of file SiStripFEDBufferGenerator.h.
std::vector<bool> sistrip::FEDBufferPayloadCreator::feUnitsEnabled_ [private] |
Definition at line 98 of file SiStripFEDBufferGenerator.h.