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 62 of file SiStripFEDBufferGenerator.h.

Constructor & Destructor Documentation

◆ FEDBufferPayload()

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

Definition at line 50 of file SiStripFEDBufferGenerator.cc.

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

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

Member Function Documentation

◆ appendToBuffer() [1/2]

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

Definition at line 276 of file SiStripFEDBufferGenerator.h.

References sistrip::FEDStripData::data_.

276  {
277  data_[((*pIndexInBuffer)++) ^ 7] = value;
278  }
Definition: value.py:1

◆ appendToBuffer() [2/2]

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 280 of file SiStripFEDBufferGenerator.h.

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

◆ data()

const uint8_t * sistrip::FEDBufferPayload::data ( ) const

Definition at line 82 of file SiStripFEDBufferGenerator.cc.

References sistrip::FEDStripData::data_.

82  {
83  //vectors are guarenteed to be contiguous
84  if (lengthInBytes())
85  return &data_[0];
86  //return NULL if there is no data yet
87  else
88  return nullptr;
89  }

◆ getFELength()

uint16_t sistrip::FEDBufferPayload::getFELength ( const uint8_t  internalFEUnitNum) const

Definition at line 91 of file SiStripFEDBufferGenerator.cc.

References Exception, and contentValuesCheck::ss.

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

◆ lengthInBytes()

size_t sistrip::FEDBufferPayload::lengthInBytes ( ) const
inline

Definition at line 274 of file SiStripFEDBufferGenerator.h.

References sistrip::FEDStripData::data_.

274 { return data_.size(); }

Member Data Documentation

◆ data_

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

Definition at line 77 of file SiStripFEDBufferGenerator.h.

◆ feLengths_

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

Definition at line 78 of file SiStripFEDBufferGenerator.h.