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 FEDReadoutMode mode) 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 FEDReadoutMode mode) 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 307 of file SiStripFEDBufferGenerator.h.

308  : feUnitsEnabled_(feUnitsEnabled),
309  channelsEnabled_(channelsEnabled)
310  {}

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
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
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 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_LITE10, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE10_CMOVERRIDE, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_BOTBOT, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_BOTBOT_CMOVERRIDE, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_CMOVERRIDE, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_TOPBOT, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE8_TOPBOT_CMOVERRIDE, 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  //case READOUT_MODE_ZERO_SUPPRESSED_CMOVERRIDE:
128  fillZeroSuppressedChannelBuffer(channelBuffer,data,channelEnabled);
129  break;
138  fillZeroSuppressedLiteChannelBuffer(channelBuffer,data,channelEnabled,mode);
139  break;
141  fillPreMixRawChannelBuffer(channelBuffer,data,channelEnabled);
142  break;
143  default:
144  std::ostringstream ss;
145  ss << "Invalid readout mode " << mode;
146  throw cms::Exception("FEDBufferGenerator") << ss.str();
147  break;
148  }
149  }
void fillZeroSuppressedChannelBuffer(std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data, const bool channelEnabled) const
static const uint8_t PACKET_CODE_SCOPE
void fillZeroSuppressedLiteChannelBuffer(std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data, const bool channelEnabled, const FEDReadoutMode mode) const
void fillRawChannelBuffer(std::vector< uint8_t > *channelBuffer, const uint8_t packetCode, const FEDStripData::ChannelData &data, const bool channelEnabled, const bool reorderData) const
static const uint8_t PACKET_CODE_PROC_RAW
void fillPreMixRawChannelBuffer(std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data, const bool channelEnabled) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static const uint8_t PACKET_CODE_VIRGIN_RAW
void sistrip::FEDBufferPayloadCreator::fillClusterData ( std::vector< uint8_t > *  channelBuffer,
const FEDStripData::ChannelData data,
const FEDReadoutMode  mode 
) const
private

Definition at line 271 of file SiStripFEDBufferGenerator.cc.

References ecalMGPA::adc(), sistrip::FEDStripData::ChannelData::get10BitSample(), sistrip::FEDStripData::ChannelData::get8BitSample(), hgc_digi::nSamples, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE10, sistrip::READOUT_MODE_ZERO_SUPPRESSED_LITE10_CMOVERRIDE, sistrip::FEDStripData::ChannelData::size(), findQualityFiles::size, and sistrip::STRIPS_PER_APV.

272  {
273  uint16_t clusterSize = 0;
274  const uint16_t nSamples = data.size();
275  uint16_t size;
276  switch (mode) {
279  size = 2; break;
280  default:
281  size = 1; break;
282  }
283  for( uint16_t strip = 0; strip < nSamples; ++strip) {
284  uint16_t adc;
285  switch (mode) {
288  adc = data.get10BitSample(strip); break;
289  default:
290  adc = data.get8BitSample(strip,mode); break;
291  }
292 
293  if(adc) {
294  if( clusterSize==0 || strip == STRIPS_PER_APV ) {
295  if(clusterSize) {
296  *(channelBuffer->end() - size*clusterSize - 1) = clusterSize ;
297  clusterSize = 0;
298  }
299  channelBuffer->push_back(strip);
300  channelBuffer->push_back(0); //clustersize
301  }
302  switch (mode) {
305  channelBuffer->push_back(adc & 0xFF);
306  channelBuffer->push_back((adc & 0x0300) >> 8);
307  break;
308  default:
309  channelBuffer->push_back(adc & 0xFF);
310  break;
311  }
312  ++clusterSize;
313  }
314 
315  else if(clusterSize) {
316  *(channelBuffer->end() - size*clusterSize - 1) = clusterSize ;
317  clusterSize = 0;
318  }
319  }
320  if(clusterSize) *(channelBuffer->end() - size*clusterSize - 1) = clusterSize ;
321  }
int adc(sample_type sample)
get the ADC sample (12 bits)
constexpr size_t nSamples
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static const uint16_t STRIPS_PER_APV
tuple size
Write out results.
void sistrip::FEDBufferPayloadCreator::fillClusterDataPreMixMode ( std::vector< uint8_t > *  channelBuffer,
const FEDStripData::ChannelData data 
) const
private

Definition at line 323 of file SiStripFEDBufferGenerator.cc.

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

324  {
325  uint16_t clusterSize = 0;
326  const uint16_t nSamples = data.size();
327  for( uint16_t strip = 0; strip < nSamples; ++strip) {
328  const uint16_t adc = data.get10BitSample(strip);
329 
330  if(adc) {
331  if( clusterSize==0 || strip == STRIPS_PER_APV ) {
332  if(clusterSize) {
333  *(channelBuffer->end() - 2*clusterSize - 1) = clusterSize ;
334  clusterSize = 0;
335  }
336  channelBuffer->push_back(strip);
337  channelBuffer->push_back(0); //clustersize
338  }
339  channelBuffer->push_back(adc & 0xFF);
340  channelBuffer->push_back((adc & 0x0300) >> 8);
341 
342  ++clusterSize;
343  }
344 
345  else if(clusterSize) {
346  *(channelBuffer->end() - 2*clusterSize - 1) = clusterSize ;
347  clusterSize = 0;
348  }
349  }
350  if(clusterSize) {
351  *(channelBuffer->end() - 2*clusterSize - 1) = clusterSize ;
352  }
353  }
int adc(sample_type sample)
get the ADC sample (12 bits)
constexpr size_t nSamples
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
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 236 of file SiStripFEDBufferGenerator.cc.

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

239  {
240  channelBuffer->reserve(50);
241  //if channel is disabled then create empty channel header and return
242  if (!channelEnabled) {
243  //min length 7
244  channelBuffer->push_back(7);
245  channelBuffer->push_back(0);
246  //packet code
247  channelBuffer->push_back(PACKET_CODE_ZERO_SUPPRESSED);
248  //4 bytes of medians
249  channelBuffer->insert(channelBuffer->end(),4,0);
250  return;
251  }
252  //if channel is not empty
253  //add space for channel length
254  channelBuffer->push_back(0xFF); channelBuffer->push_back(0xFF);
255  //packet code
256  channelBuffer->push_back(PACKET_CODE_ZERO_SUPPRESSED);
257  //add medians
258  const std::pair<uint16_t,uint16_t> medians = data.getMedians();
259  channelBuffer->push_back(medians.first & 0xFF);
260  channelBuffer->push_back((medians.first & 0x300) >> 8);
261  channelBuffer->push_back(medians.second & 0xFF);
262  channelBuffer->push_back((medians.second & 0x300) >> 8);
263  //clusters
264  fillClusterDataPreMixMode(channelBuffer,data);
265  //set length
266  const uint16_t length = channelBuffer->size();
267  (*channelBuffer)[0] = (length & 0xFF);
268  (*channelBuffer)[1] = ((length & 0x300) >> 8);
269  }
void fillClusterDataPreMixMode(std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data) const
static const uint8_t PACKET_CODE_ZERO_SUPPRESSED
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
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 151 of file SiStripFEDBufferGenerator.cc.

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

156  {
157  const uint16_t nSamples = data.size();
158  //2 bytes per sample + packet code + 2 bytes for length
159  const uint16_t channelLength = nSamples*2 + 3;
160  channelBuffer->reserve(channelLength);
161  //length (max length is 0xFFF)
162  channelBuffer->push_back( channelLength & 0xFF );
163  channelBuffer->push_back( (channelLength & 0xF00) >> 8 );
164  //packet code
165  channelBuffer->push_back(packetCode);
166  //channel samples
167  for (uint16_t sampleNumber = 0; sampleNumber < nSamples; sampleNumber++) {
168  const uint16_t sampleIndex = ( reorderData ? FEDStripOrdering::physicalOrderForStripInChannel(sampleNumber) : sampleNumber );
169  const uint16_t sampleValue = (channelEnabled ? data.getSample(sampleIndex) : 0);
170  channelBuffer->push_back(sampleValue & 0xFF);
171  channelBuffer->push_back((sampleValue & 0x300) >> 8);
172  }
173  }
static uint8_t physicalOrderForStripInChannel(const uint8_t readoutOrderStripIndexInChannel)
constexpr size_t nSamples
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void sistrip::FEDBufferPayloadCreator::fillZeroSuppressedChannelBuffer ( std::vector< uint8_t > *  channelBuffer,
const FEDStripData::ChannelData data,
const bool  channelEnabled 
) const
private

Definition at line 175 of file SiStripFEDBufferGenerator.cc.

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

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

Definition at line 211 of file SiStripFEDBufferGenerator.cc.

215  {
216  channelBuffer->reserve(50);
217  //if channel is disabled then create empty channel header and return
218  if (!channelEnabled) {
219  //min length 2
220  channelBuffer->push_back(2);
221  channelBuffer->push_back(0);
222  return;
223  }
224  //if channel is not empty
225  //add space for channel length
226  channelBuffer->push_back(0xFF);
227  channelBuffer->push_back(0xFF);
228  //clusters
229  fillClusterData(channelBuffer,data,mode);
230  //set fibre length
231  const uint16_t length = channelBuffer->size();
232  (*channelBuffer)[0] = (length & 0xFF);
233  (*channelBuffer)[1] = ((length & 0x300) >> 8);
234  }
void fillClusterData(std::vector< uint8_t > *channelBuffer, const FEDStripData::ChannelData &data, const FEDReadoutMode mode) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
FEDBufferPayload sistrip::FEDBufferPayloadCreator::operator() ( const FEDReadoutMode  mode,
const FEDStripData data 
) const
inline

Definition at line 312 of file SiStripFEDBufferGenerator.h.

References createPayload().

313  {
314  return createPayload(mode,data);
315  }
FEDBufferPayload createPayload(const FEDReadoutMode mode, const FEDStripData &data) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82

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.