CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
sistrip::FEDBufferPayload Class Reference

#include <SiStripFEDBufferGenerator.h>

Public Member Functions

const uint8_t * data () const
 
 FEDBufferPayload (const std::vector< std::vector< uint8_t > > &channelBuffers)
 
uint16_t getFELength (const uint8_t internalFEUnitNum) const
 
size_t lengthInBytes () const
 

Private Member Functions

void appendToBuffer (size_t *pIndexInBuffer, const uint8_t value)
 
void appendToBuffer (size_t *pIndexInBuffer, std::vector< uint8_t >::const_iterator start, std::vector< uint8_t >::const_iterator finish)
 

Private Attributes

std::vector< uint8_t > data_
 
std::vector< uint16_t > feLengths_
 

Detailed Description

Definition at line 60 of file SiStripFEDBufferGenerator.h.

Constructor & Destructor Documentation

sistrip::FEDBufferPayload::FEDBufferPayload ( const std::vector< std::vector< uint8_t > > &  channelBuffers)

Definition at line 53 of file SiStripFEDBufferGenerator.cc.

References begin, sistrip::FEDStripData::data_, end, sistrip::FEDCH_PER_FEUNIT, and sistrip::FEUNITS_PER_FED.

54  {
55  //calculate size of buffer and allocate enough memory
56  uint32_t totalSize = 0;
57  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
58  for (uint8_t iCh = 0; iCh < FEDCH_PER_FEUNIT; iCh++) {
59  totalSize += channelBuffers[iFE*FEDCH_PER_FEUNIT+iCh].size();
60  }
61  //if it does not finish on a 64Bit word boundary then take into account padding
62  if (totalSize%8) {
63  totalSize = ((totalSize/8) + 1)*8;
64  }
65  }
66  data_.resize(totalSize);
67  size_t indexInBuffer = 0;
68  feLengths_.reserve(FEUNITS_PER_FED);
69  //copy channel data into buffer with padding and update lengths
70  for (uint8_t iFE = 0; iFE < FEUNITS_PER_FED; iFE++) {
71  const size_t lengthAtStartOfFEUnit = indexInBuffer;
72  //insert data for FE unit
73  for (uint8_t iCh = 0; iCh < FEDCH_PER_FEUNIT; iCh++) {
74  appendToBuffer(&indexInBuffer,channelBuffers[iFE*FEDCH_PER_FEUNIT+iCh].begin(),channelBuffers[iFE*FEDCH_PER_FEUNIT+iCh].end());
75  }
76  //store length
77  feLengths_.push_back(indexInBuffer-lengthAtStartOfFEUnit);
78  //add padding
79  while (indexInBuffer % 8) appendToBuffer(&indexInBuffer,0);
80  }
81  }
static const uint16_t FEUNITS_PER_FED
#define end
Definition: vmac.h:37
void appendToBuffer(size_t *pIndexInBuffer, const uint8_t value)
static const uint16_t FEDCH_PER_FEUNIT
#define begin
Definition: vmac.h:30
std::vector< uint16_t > feLengths_

Member Function Documentation

void sistrip::FEDBufferPayload::appendToBuffer ( size_t *  pIndexInBuffer,
const uint8_t  value 
)
inlineprivate

Definition at line 293 of file SiStripFEDBufferGenerator.h.

References sistrip::FEDStripData::ChannelData::data_.

294  {
295  data_[((*pIndexInBuffer)++)^7] = value;
296  }
Definition: value.py:1
void sistrip::FEDBufferPayload::appendToBuffer ( size_t *  pIndexInBuffer,
std::vector< uint8_t >::const_iterator  start,
std::vector< uint8_t >::const_iterator  finish 
)
inlineprivate

Definition at line 298 of file SiStripFEDBufferGenerator.h.

299  {
300  for (std::vector<uint8_t>::const_iterator iVal = start; iVal != finish; iVal++) {
301  appendToBuffer(pIndexInBuffer,*iVal);
302  }
303  }
Definition: start.py:1
void appendToBuffer(size_t *pIndexInBuffer, const uint8_t value)
const uint8_t * sistrip::FEDBufferPayload::data ( ) const

Definition at line 83 of file SiStripFEDBufferGenerator.cc.

References sistrip::FEDStripData::data_, and NULL.

Referenced by sistrip::FEDBufferGenerator::fillBuffer().

84  {
85  //vectors are guarenteed to be contiguous
86  if (lengthInBytes()) return &data_[0];
87  //return NULL if there is no data yet
88  else return NULL;
89  }
#define NULL
Definition: scimark2.h:8
uint16_t sistrip::FEDBufferPayload::getFELength ( const uint8_t  internalFEUnitNum) const

Definition at line 91 of file SiStripFEDBufferGenerator.cc.

References Exception.

Referenced by sistrip::FEDBufferGenerator::generateBuffer().

92  {
93  try{
94  return feLengths_.at(internalFEUnitNum);
95  } catch (const std::out_of_range&) {
96  std::ostringstream ss;
97  ss << "Invalid FE unit number " << internalFEUnitNum << ". "
98  << "Number should be in internal numbering scheme (0-7). ";
99  throw cms::Exception("FEDBufferGenerator") << ss.str();
100  }
101  }
std::vector< uint16_t > feLengths_
size_t sistrip::FEDBufferPayload::lengthInBytes ( ) const
inline

Member Data Documentation

std::vector<uint8_t> sistrip::FEDBufferPayload::data_
private

Definition at line 73 of file SiStripFEDBufferGenerator.h.

std::vector<uint16_t> sistrip::FEDBufferPayload::feLengths_
private

Definition at line 74 of file SiStripFEDBufferGenerator.h.