CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
sistrip::FEDBufferPayloadCreator Class Reference

#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 fillClusterDataPreMixMode (std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data) const
 
void fillPreMixRawChannelBuffer (std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data, const bool channelEnabled) 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_
 

Detailed Description

Definition at line 77 of file SiStripFEDBufferGenerator.h.

Constructor & Destructor Documentation

sistrip::FEDBufferPayloadCreator::FEDBufferPayloadCreator ( const std::vector< bool > &  enabledFEUnits,
const std::vector< bool > &  enabledChannels 
)
inline

Definition at line 291 of file SiStripFEDBufferGenerator.h.

292  : feUnitsEnabled_(feUnitsEnabled),
293  channelsEnabled_(channelsEnabled)
294  {}

Member Function Documentation

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()().

104  {
105  std::vector< std::vector<uint8_t> > channelBuffers(FEDCH_PER_FED,std::vector<uint8_t>());
106  for (size_t iCh = 0; iCh < FEDCH_PER_FED; iCh++) {
107  if (!feUnitsEnabled_[iCh/FEDCH_PER_FEUNIT]) continue;
108  fillChannelBuffer(&channelBuffers[iCh],mode,data.channel(iCh),channelsEnabled_[iCh]);
109  }
110  return FEDBufferPayload(channelBuffers);
111  }
static const uint16_t FEDCH_PER_FEUNIT
static const uint16_t FEDCH_PER_FED
void fillChannelBuffer(std::vector< uint8_t > *channelBuffer, const FEDReadoutMode mode, const FEDStripData::ChannelData &data, const bool channelEnabled) const
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 edm::hlt::Exception, alignBH_cfg::mode, sistrip::PACKET_CODE_PROC_RAW, sistrip::PACKET_CODE_SCOPE, sistrip::PACKET_CODE_VIRGIN_RAW, sistrip::READOUT_MODE_PREMIX_RAW, sistrip::READOUT_MODE_PROC_RAW, sistrip::READOUT_MODE_SCOPE, sistrip::READOUT_MODE_VIRGIN_RAW, sistrip::READOUT_MODE_ZERO_SUPPRESSED, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE, and contentValuesCheck::ss.

115  {
116  switch (mode) {
117  case READOUT_MODE_SCOPE:
118  fillRawChannelBuffer(channelBuffer,PACKET_CODE_SCOPE,data,channelEnabled,false);
119  break;
121  fillRawChannelBuffer(channelBuffer,PACKET_CODE_VIRGIN_RAW,data,channelEnabled,true);
122  break;
124  fillRawChannelBuffer(channelBuffer,PACKET_CODE_PROC_RAW,data,channelEnabled,false);
125  break;
127  fillZeroSuppressedChannelBuffer(channelBuffer,data,channelEnabled);
128  break;
130  fillZeroSuppressedLiteChannelBuffer(channelBuffer,data,channelEnabled);
131  break;
133  fillPreMixRawChannelBuffer(channelBuffer,data,channelEnabled);
134  break;
135  default:
136  std::ostringstream ss;
137  ss << "Invalid readout mode " << mode;
138  throw cms::Exception("FEDBufferGenerator") << ss.str();
139  break;
140  }
141  }
void fillZeroSuppressedChannelBuffer(std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data, const bool channelEnabled) const
static const uint8_t PACKET_CODE_SCOPE
void fillRawChannelBuffer(std::vector< uint8_t > *channelBuffer, const uint8_t packetCode, const FEDStripData::ChannelData &data, const bool channelEnabled, const bool reorderData) const
void fillZeroSuppressedLiteChannelBuffer(std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data, const bool channelEnabled) const
static const uint8_t PACKET_CODE_PROC_RAW
void fillPreMixRawChannelBuffer(std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data, const bool channelEnabled) const
static const uint8_t PACKET_CODE_VIRGIN_RAW
void sistrip::FEDBufferPayloadCreator::fillClusterData ( std::vector< uint8_t > *  channelBuffer,
const FEDStripData::ChannelData data 
) const
private

Definition at line 260 of file SiStripFEDBufferGenerator.cc.

References ecalMGPA::adc(), sistrip::FEDStripData::ChannelData::get8BitSample(), sistrip::FEDStripData::ChannelData::size(), and sistrip::STRIPS_PER_APV.

261  {
262  uint16_t clusterSize = 0;
263  const uint16_t nSamples = data.size();
264  for( uint16_t strip = 0; strip < nSamples; ++strip) {
265  const uint8_t adc = data.get8BitSample(strip);
266 
267  if(adc) {
268  if( clusterSize==0 || strip == STRIPS_PER_APV ) {
269  if(clusterSize) {
270  *(channelBuffer->end() - clusterSize - 1) = clusterSize ;
271  clusterSize = 0;
272  }
273  channelBuffer->push_back(strip);
274  channelBuffer->push_back(0); //clustersize
275  }
276  channelBuffer->push_back(adc);
277  ++clusterSize;
278  }
279 
280  else if(clusterSize) {
281  *(channelBuffer->end() - clusterSize - 1) = clusterSize ;
282  clusterSize = 0;
283  }
284  }
285  if(clusterSize) *(channelBuffer->end() - clusterSize - 1) = clusterSize ;
286  }
int adc(sample_type sample)
get the ADC sample (12 bits)
static const uint16_t STRIPS_PER_APV
void sistrip::FEDBufferPayloadCreator::fillClusterDataPreMixMode ( std::vector< uint8_t > *  channelBuffer,
const FEDStripData::ChannelData data 
) const
private

Definition at line 288 of file SiStripFEDBufferGenerator.cc.

References ecalMGPA::adc(), sistrip::FEDStripData::ChannelData::get10BitSample(), sistrip::FEDStripData::ChannelData::size(), and sistrip::STRIPS_PER_APV.

289  {
290  uint16_t clusterSize = 0;
291  const uint16_t nSamples = data.size();
292  for( uint16_t strip = 0; strip < nSamples; ++strip) {
293  const uint16_t adc = data.get10BitSample(strip);
294 
295  if(adc) {
296  if( clusterSize==0 || strip == STRIPS_PER_APV ) {
297  if(clusterSize) {
298  *(channelBuffer->end() - 2*clusterSize - 1) = clusterSize ;
299  clusterSize = 0;
300  }
301  channelBuffer->push_back(strip);
302  channelBuffer->push_back(0); //clustersize
303  }
304  channelBuffer->push_back(adc & 0xFF);
305  channelBuffer->push_back((adc & 0x0300) >> 8);
306 
307  ++clusterSize;
308  }
309 
310  else if(clusterSize) {
311  *(channelBuffer->end() - 2*clusterSize - 1) = clusterSize ;
312  clusterSize = 0;
313  }
314  }
315  if(clusterSize) {
316  *(channelBuffer->end() - 2*clusterSize - 1) = clusterSize ;
317  }
318  }
int adc(sample_type sample)
get the ADC sample (12 bits)
static const uint16_t STRIPS_PER_APV
void sistrip::FEDBufferPayloadCreator::fillPreMixRawChannelBuffer ( std::vector< uint8_t > *  channelBuffer,
const FEDStripData::ChannelData data,
const bool  channelEnabled 
) const
private

Definition at line 225 of file SiStripFEDBufferGenerator.cc.

References sistrip::FEDStripData::ChannelData::getMedians(), and sistrip::PACKET_CODE_ZERO_SUPPRESSED.

228  {
229  channelBuffer->reserve(50);
230  //if channel is disabled then create empty channel header and return
231  if (!channelEnabled) {
232  //min length 7
233  channelBuffer->push_back(7);
234  channelBuffer->push_back(0);
235  //packet code
236  channelBuffer->push_back(PACKET_CODE_ZERO_SUPPRESSED);
237  //4 bytes of medians
238  channelBuffer->insert(channelBuffer->end(),4,0);
239  return;
240  }
241  //if channel is not empty
242  //add space for channel length
243  channelBuffer->push_back(0xFF); channelBuffer->push_back(0xFF);
244  //packet code
245  channelBuffer->push_back(PACKET_CODE_ZERO_SUPPRESSED);
246  //add medians
247  const std::pair<uint16_t,uint16_t> medians = data.getMedians();
248  channelBuffer->push_back(medians.first & 0xFF);
249  channelBuffer->push_back((medians.first & 0x300) >> 8);
250  channelBuffer->push_back(medians.second & 0xFF);
251  channelBuffer->push_back((medians.second & 0x300) >> 8);
252  //clusters
253  fillClusterDataPreMixMode(channelBuffer,data);
254  //set length
255  const uint16_t length = channelBuffer->size();
256  (*channelBuffer)[0] = (length & 0xFF);
257  (*channelBuffer)[1] = ((length & 0x300) >> 8);
258  }
void fillClusterDataPreMixMode(std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data) const
static const uint8_t PACKET_CODE_ZERO_SUPPRESSED
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 143 of file SiStripFEDBufferGenerator.cc.

References sistrip::FEDStripData::ChannelData::getSample(), sistrip::FEDStripOrdering::physicalOrderForStripInChannel(), and sistrip::FEDStripData::ChannelData::size().

148  {
149  const uint16_t nSamples = data.size();
150  //2 bytes per sample + packet code + 2 bytes for length
151  const uint16_t channelLength = nSamples*2 + 3;
152  channelBuffer->reserve(channelLength);
153  //length (max length is 0xFFF)
154  channelBuffer->push_back( channelLength & 0xFF );
155  channelBuffer->push_back( (channelLength & 0xF00) >> 8 );
156  //packet code
157  channelBuffer->push_back(packetCode);
158  //channel samples
159  for (uint16_t sampleNumber = 0; sampleNumber < nSamples; sampleNumber++) {
160  const uint16_t sampleIndex = ( reorderData ? FEDStripOrdering::physicalOrderForStripInChannel(sampleNumber) : sampleNumber );
161  const uint16_t sampleValue = (channelEnabled ? data.getSample(sampleIndex) : 0);
162  channelBuffer->push_back(sampleValue & 0xFF);
163  channelBuffer->push_back((sampleValue & 0x300) >> 8);
164  }
165  }
static uint8_t physicalOrderForStripInChannel(const uint8_t readoutOrderStripIndexInChannel)
void sistrip::FEDBufferPayloadCreator::fillZeroSuppressedChannelBuffer ( std::vector< uint8_t > *  channelBuffer,
const FEDStripData::ChannelData data,
const bool  channelEnabled 
) const
private

Definition at line 167 of file SiStripFEDBufferGenerator.cc.

References sistrip::FEDStripData::ChannelData::getMedians(), and sistrip::PACKET_CODE_ZERO_SUPPRESSED.

170  {
171  channelBuffer->reserve(50);
172  //if channel is disabled then create empty channel header and return
173  if (!channelEnabled) {
174  //min length 7
175  channelBuffer->push_back(7);
176  channelBuffer->push_back(0);
177  //packet code
178  channelBuffer->push_back(PACKET_CODE_ZERO_SUPPRESSED);
179  //4 bytes of medians
180  channelBuffer->insert(channelBuffer->end(),4,0);
181  return;
182  }
183  //if channel is not empty
184  //add space for channel length
185  channelBuffer->push_back(0xFF); channelBuffer->push_back(0xFF);
186  //packet code
187  channelBuffer->push_back(PACKET_CODE_ZERO_SUPPRESSED);
188  //add medians
189  const std::pair<uint16_t,uint16_t> medians = data.getMedians();
190  channelBuffer->push_back(medians.first & 0xFF);
191  channelBuffer->push_back((medians.first & 0x300) >> 8);
192  channelBuffer->push_back(medians.second & 0xFF);
193  channelBuffer->push_back((medians.second & 0x300) >> 8);
194  //clusters
195  fillClusterData(channelBuffer,data);
196  //set length
197  const uint16_t length = channelBuffer->size();
198  (*channelBuffer)[0] = (length & 0xFF);
199  (*channelBuffer)[1] = ((length & 0x300) >> 8);
200  }
void fillClusterData(std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data) const
static const uint8_t PACKET_CODE_ZERO_SUPPRESSED
void sistrip::FEDBufferPayloadCreator::fillZeroSuppressedLiteChannelBuffer ( std::vector< uint8_t > *  channelBuffer,
const FEDStripData::ChannelData data,
const bool  channelEnabled 
) const
private

Definition at line 202 of file SiStripFEDBufferGenerator.cc.

205  {
206  channelBuffer->reserve(50);
207  //if channel is disabled then create empty channel header and return
208  if (!channelEnabled) {
209  //min length 2
210  channelBuffer->push_back(2);
211  channelBuffer->push_back(0);
212  return;
213  }
214  //if channel is not empty
215  //add space for channel length
216  channelBuffer->push_back(0xFF); channelBuffer->push_back(0xFF);
217  //clusters
218  fillClusterData(channelBuffer,data);
219  //set length
220  const uint16_t length = channelBuffer->size();
221  (*channelBuffer)[0] = (length & 0xFF);
222  (*channelBuffer)[1] = ((length & 0x300) >> 8);
223  }
void fillClusterData(std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data) const
FEDBufferPayload sistrip::FEDBufferPayloadCreator::operator() ( const FEDReadoutMode  mode,
const FEDStripData data 
) const
inline

Definition at line 296 of file SiStripFEDBufferGenerator.h.

References createPayload().

297  {
298  return createPayload(mode,data);
299  }
FEDBufferPayload createPayload(const FEDReadoutMode mode, const FEDStripData &data) const

Member Data Documentation

std::vector<bool> sistrip::FEDBufferPayloadCreator::channelsEnabled_
private

Definition at line 102 of file SiStripFEDBufferGenerator.h.

std::vector<bool> sistrip::FEDBufferPayloadCreator::feUnitsEnabled_
private

Definition at line 101 of file SiStripFEDBufferGenerator.h.