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.

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  }

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

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.

276  {
277  data_[((*pIndexInBuffer)++) ^ 7] = value;
278  }

References sistrip::FEDStripData::data_.

◆ 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  }

◆ data()

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

Definition at line 82 of file SiStripFEDBufferGenerator.cc.

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  }

References sistrip::FEDStripData::data_.

◆ getFELength()

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

Definition at line 91 of file SiStripFEDBufferGenerator.cc.

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  }

References Exception, and contentValuesCheck::ss.

◆ lengthInBytes()

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

Definition at line 274 of file SiStripFEDBufferGenerator.h.

274 { return data_.size(); }

References sistrip::FEDStripData::data_.

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.

start
Definition: start.py:1
sistrip::FEDBufferPayload::data_
std::vector< uint8_t > data_
Definition: SiStripFEDBufferGenerator.h:77
sistrip::FEDBufferPayload::appendToBuffer
void appendToBuffer(size_t *pIndexInBuffer, const uint8_t value)
Definition: SiStripFEDBufferGenerator.h:276
sistrip::FEDBufferPayload::feLengths_
std::vector< uint16_t > feLengths_
Definition: SiStripFEDBufferGenerator.h:78
end
#define end
Definition: vmac.h:39
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
sistrip::FEUNITS_PER_FED
static const uint16_t FEUNITS_PER_FED
Definition: ConstantsForHardwareSystems.h:29
sistrip::FEDBufferPayload::lengthInBytes
size_t lengthInBytes() const
Definition: SiStripFEDBufferGenerator.h:274
value
Definition: value.py:1
Exception
Definition: hltDiff.cc:246
sistrip::FEDCH_PER_FEUNIT
static const uint16_t FEDCH_PER_FEUNIT
Definition: ConstantsForHardwareSystems.h:28
begin
#define begin
Definition: vmac.h:32