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 54 of file SiStripFEDBufferGenerator.cc.

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

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

Member Function Documentation

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

Definition at line 277 of file SiStripFEDBufferGenerator.h.

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

278  {
279  data_[((*pIndexInBuffer)++)^7] = value;
280  }
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 282 of file SiStripFEDBufferGenerator.h.

283  {
284  for (std::vector<uint8_t>::const_iterator iVal = start; iVal != finish; iVal++) {
285  appendToBuffer(pIndexInBuffer,*iVal);
286  }
287  }
Definition: start.py:1
void appendToBuffer(size_t *pIndexInBuffer, const uint8_t value)
const uint8_t * sistrip::FEDBufferPayload::data ( ) const

Definition at line 84 of file SiStripFEDBufferGenerator.cc.

References sistrip::FEDStripData::data_.

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

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

Definition at line 92 of file SiStripFEDBufferGenerator.cc.

References Exception.

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

93  {
94  try{
95  return feLengths_.at(internalFEUnitNum);
96  } catch (const std::out_of_range&) {
97  std::ostringstream ss;
98  ss << "Invalid FE unit number " << internalFEUnitNum << ". "
99  << "Number should be in internal numbering scheme (0-7). ";
100  throw cms::Exception("FEDBufferGenerator") << ss.str();
101  }
102  }
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.