CMS 3D CMS Logo

Functions
sistrip::fedchannelunpacker::detail Namespace Reference

Functions

template<uint16_t mask>
uint16_t getADC_B1 (const uint8_t *data, uint_fast16_t wOffset, uint_fast8_t bOffset)
 
template<uint16_t mask>
uint16_t getADC_B2 (const uint8_t *data, uint_fast16_t wOffset, uint_fast8_t bOffset)
 
template<uint8_t num_words>
uint16_t getADC_W (const uint8_t *data, uint_fast16_t offset, uint8_t bits_shift)
 
uint16_t readoutOrder (uint16_t physical_order)
 
template<uint_fast8_t num_bits, typename OUT >
StatusCode unpackRawB (const FEDChannel &channel, OUT &&out)
 
template<uint8_t num_bits, typename OUT >
StatusCode unpackRawW (const FEDChannel &channel, OUT &&out, uint8_t bits_shift=0)
 
template<uint_fast8_t num_bits, typename OUT >
StatusCode unpackZSB (const FEDChannel &channel, OUT &&out, uint8_t headerLength, uint16_t stripStart)
 
template<uint8_t num_bits, typename OUT >
StatusCode unpackZSW (const FEDChannel &channel, OUT &&out, uint8_t headerLength, uint16_t stripStart, uint8_t bits_shift=0)
 

Function Documentation

◆ getADC_B1()

template<uint16_t mask>
uint16_t sistrip::fedchannelunpacker::detail::getADC_B1 ( const uint8_t *  data,
uint_fast16_t  wOffset,
uint_fast8_t  bOffset 
)

Definition at line 208 of file SiStripFEDBuffer.h.

References sistrip::BITS_PER_BYTE, data, and ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask.

208  {
209  // get ADC from one byte, until bOffset into the byte at wOffset (maximum decided by mask)
210  return (data[wOffset ^ 7] >> (BITS_PER_BYTE - bOffset)) & mask;
211  }
constexpr uint16_t BITS_PER_BYTE
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ getADC_B2()

template<uint16_t mask>
uint16_t sistrip::fedchannelunpacker::detail::getADC_B2 ( const uint8_t *  data,
uint_fast16_t  wOffset,
uint_fast8_t  bOffset 
)

Definition at line 203 of file SiStripFEDBuffer.h.

References sistrip::BITS_PER_BYTE, data, and ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask.

203  {
204  // get ADC from two bytes, from wOffset until bOffset bits from the next byte (maximum decided by mask)
205  return (((data[wOffset ^ 7]) << bOffset) + (data[(wOffset + 1) ^ 7] >> (BITS_PER_BYTE - bOffset))) & mask;
206  }
constexpr uint16_t BITS_PER_BYTE
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ getADC_W()

template<uint8_t num_words>
uint16_t sistrip::fedchannelunpacker::detail::getADC_W ( const uint8_t *  data,
uint_fast16_t  offset,
uint8_t  bits_shift 
)

Definition at line 197 of file SiStripFEDBuffer.h.

References data, and hltrates_dqm_sourceclient-live_cfg::offset.

197  {
198  // get ADC from one or two bytes (at most 10 bits), and shift if needed
199  return (data[offset ^ 7] + (num_words == 2 ? ((data[(offset + 1) ^ 7] & 0x03) << 8) : 0)) << bits_shift;
200  }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ readoutOrder()

uint16_t sistrip::fedchannelunpacker::detail::readoutOrder ( uint16_t  physical_order)
inline

Definition at line 351 of file SiStripFEDBuffer.h.

Referenced by sistrip::fedchannelunpacker::unpackVirginRaw().

351  {
352  return (4 * ((static_cast<uint16_t>((static_cast<float>(physical_order) / 8.0))) % 4) +
353  static_cast<uint16_t>(static_cast<float>(physical_order) / 32.0) + 16 * (physical_order % 8));
354  }

◆ unpackRawB()

template<uint_fast8_t num_bits, typename OUT >
StatusCode sistrip::fedchannelunpacker::detail::unpackRawB ( const FEDChannel channel,
OUT &&  out 
)

Definition at line 234 of file SiStripFEDBuffer.h.

References sistrip::fedchannelunpacker::BAD_CHANNEL_LENGTH, sistrip::BITS_PER_BYTE, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), data, sistrip::FEDChannel::data(), sistrip::FEDChannel::length(), LogDebug, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, sistrip::FEDChannel::offset(), MillePedeFileConverter_cfg::out, and sistrip::fedchannelunpacker::SUCCESS.

234  {
235  static_assert(num_bits <= 16, "Word length must be between 0 and 16.");
236  if (channel.length() & 0xF000) {
237  LogDebug("FEDBuffer") << "Channel length is invalid. Channel length is " << uint16_t(channel.length()) << ".";
238  return StatusCode::BAD_CHANNEL_LENGTH;
239  }
240  constexpr uint16_t mask = (1 << num_bits) - 1;
241  const uint8_t* const data = channel.data();
242  const uint_fast16_t chEnd = channel.offset() + channel.length();
243  uint_fast16_t wOffset = channel.offset() + 3;
244  uint_fast8_t bOffset = 0;
245  while (((wOffset + 1) < chEnd) || ((chEnd - wOffset) * BITS_PER_BYTE - bOffset >= num_bits)) {
246  bOffset += num_bits;
247  if ((num_bits > BITS_PER_BYTE) || (bOffset > BITS_PER_BYTE)) {
248  bOffset -= BITS_PER_BYTE;
249  **out++ = SiStripRawDigi(getADC_B2<mask>(data, wOffset, bOffset));
250  ++wOffset;
251  } else {
252  **out++ = SiStripRawDigi(getADC_B1<mask>(data, wOffset, bOffset));
253  }
254  if (bOffset == BITS_PER_BYTE) {
255  bOffset = 0;
256  ++wOffset;
257  }
258  }
259  return StatusCode::SUCCESS;
260  }
successful classification
constexpr uint16_t BITS_PER_BYTE
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
#define LogDebug(id)

◆ unpackRawW()

template<uint8_t num_bits, typename OUT >
StatusCode sistrip::fedchannelunpacker::detail::unpackRawW ( const FEDChannel channel,
OUT &&  out,
uint8_t  bits_shift = 0 
)

Definition at line 215 of file SiStripFEDBuffer.h.

References sistrip::fedchannelunpacker::BAD_CHANNEL_LENGTH, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), data, sistrip::FEDChannel::data(), sistrip::FEDChannel::length(), LogDebug, hltrates_dqm_sourceclient-live_cfg::offset, sistrip::FEDChannel::offset(), MillePedeFileConverter_cfg::out, and sistrip::fedchannelunpacker::SUCCESS.

215  {
216  constexpr auto num_words = num_bits / 8;
217  static_assert(((num_bits % 8) == 0) && (num_words > 0) && (num_words < 3));
218  if ((num_words > 1) && ((channel.length() - 3) % num_words)) {
219  LogDebug("FEDBuffer") << "Channel length is invalid. Raw channels have 3 header bytes and " << num_words
220  << " bytes per sample. "
221  << "Channel length is " << uint16_t(channel.length()) << ".";
222  return StatusCode::BAD_CHANNEL_LENGTH;
223  }
224  const uint8_t* const data = channel.data();
225  const uint_fast16_t end = channel.offset() + channel.length();
226  for (uint_fast16_t offset = channel.offset() + 3; offset != end; offset += num_words) {
227  *out++ = SiStripRawDigi(getADC_W<num_words>(data, offset, bits_shift));
228  }
229  return StatusCode::SUCCESS;
230  }
successful classification
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
#define LogDebug(id)

◆ unpackZSB()

template<uint_fast8_t num_bits, typename OUT >
StatusCode sistrip::fedchannelunpacker::detail::unpackZSB ( const FEDChannel channel,
OUT &&  out,
uint8_t  headerLength,
uint16_t  stripStart 
)

Definition at line 301 of file SiStripFEDBuffer.h.

References sistrip::fedchannelunpacker::BAD_CHANNEL_LENGTH, sistrip::BITS_PER_BYTE, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), data, sistrip::FEDChannel::data(), sistrip::FEDChannel::length(), LogDebug, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, sistrip::FEDChannel::offset(), MillePedeFileConverter_cfg::out, sistrip::fedchannelunpacker::SUCCESS, and sistrip::fedchannelunpacker::UNORDERED_DATA.

301  {
302  constexpr uint16_t mask = (1 << num_bits) - 1;
303  if (channel.length() & 0xF000) {
304  LogDebug("FEDBuffer") << "Channel length is invalid. Channel length is " << uint16_t(channel.length()) << ".";
305  return StatusCode::BAD_CHANNEL_LENGTH;
306  }
307  const uint8_t* const data = channel.data();
308  uint_fast16_t wOffset = channel.offset() + headerLength; // header is 2 (lite) or 7
309  uint_fast8_t bOffset{0}, firstStrip{0}, nInCluster{0}, inCluster{0};
310  const uint_fast16_t chEnd = channel.offset() + channel.length();
311  while (((wOffset + 1) < chEnd) ||
312  ((inCluster != nInCluster) && ((chEnd - wOffset) * BITS_PER_BYTE - bOffset >= num_bits))) {
313  if (inCluster == nInCluster) {
314  if (wOffset + 2 >= chEnd) {
315  // offset should already be at end then (empty cluster)
316  break;
317  }
318  if (bOffset) {
319  ++wOffset;
320  bOffset = 0;
321  }
322  const uint_fast8_t newFirstStrip = data[(wOffset++) ^ 7];
323  if (newFirstStrip < (firstStrip + inCluster)) {
324  LogDebug("FEDBuffer") << "First strip of new cluster is not greater than last strip of previous cluster. "
325  << "Last strip of previous cluster is " << uint16_t(firstStrip + inCluster) << ". "
326  << "First strip of new cluster is " << uint16_t(newFirstStrip) << ".";
327  return StatusCode::UNORDERED_DATA;
328  }
329  firstStrip = newFirstStrip;
330  nInCluster = data[(wOffset++) ^ 7];
331  inCluster = 0;
332  bOffset = 0;
333  }
334  bOffset += num_bits;
335  if ((num_bits > BITS_PER_BYTE) || (bOffset > BITS_PER_BYTE)) {
336  bOffset -= BITS_PER_BYTE;
337  *out++ = SiStripDigi(stripStart + firstStrip + inCluster, getADC_B2<mask>(data, wOffset, bOffset));
338  ++wOffset;
339  } else {
340  *out++ = SiStripDigi(stripStart + firstStrip + inCluster, getADC_B1<mask>(data, wOffset, bOffset));
341  }
342  ++inCluster;
343  if (bOffset == BITS_PER_BYTE) {
344  bOffset = 0;
345  ++wOffset;
346  }
347  }
348  return StatusCode::SUCCESS;
349  }
successful classification
constexpr uint16_t BITS_PER_BYTE
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
#define LogDebug(id)

◆ unpackZSW()

template<uint8_t num_bits, typename OUT >
StatusCode sistrip::fedchannelunpacker::detail::unpackZSW ( const FEDChannel channel,
OUT &&  out,
uint8_t  headerLength,
uint16_t  stripStart,
uint8_t  bits_shift = 0 
)

Definition at line 263 of file SiStripFEDBuffer.h.

References sistrip::fedchannelunpacker::BAD_CHANNEL_LENGTH, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), data, sistrip::FEDChannel::data(), sistrip::FEDChannel::length(), LogDebug, hltrates_dqm_sourceclient-live_cfg::offset, sistrip::FEDChannel::offset(), MillePedeFileConverter_cfg::out, sistrip::fedchannelunpacker::SUCCESS, and sistrip::fedchannelunpacker::UNORDERED_DATA.

264  {
265  constexpr auto num_words = num_bits / 8;
266  static_assert(((num_bits % 8) == 0) && (num_words > 0) && (num_words < 3));
267  if (channel.length() & 0xF000) {
268  LogDebug("FEDBuffer") << "Channel length is invalid. Channel length is " << uint16_t(channel.length()) << ".";
269  return StatusCode::BAD_CHANNEL_LENGTH;
270  }
271  const uint8_t* const data = channel.data();
272  uint_fast16_t offset = channel.offset() + headerLength; // header is 2 (lite) or 7
273  uint_fast8_t firstStrip{0}, nInCluster{0}, inCluster{0};
274  const uint_fast16_t end = channel.offset() + channel.length();
275  while (offset != end) {
276  if (inCluster == nInCluster) {
277  if (offset + 2 >= end) {
278  // offset should already be at end then (empty cluster)
279  break;
280  }
281  const uint_fast8_t newFirstStrip = data[(offset++) ^ 7];
282  if (newFirstStrip < (firstStrip + inCluster)) {
283  LogDebug("FEDBuffer") << "First strip of new cluster is not greater than last strip of previous cluster. "
284  << "Last strip of previous cluster is " << uint16_t(firstStrip + inCluster) << ". "
285  << "First strip of new cluster is " << uint16_t(newFirstStrip) << ".";
286  return StatusCode::UNORDERED_DATA;
287  }
288  firstStrip = newFirstStrip;
289  nInCluster = data[(offset++) ^ 7];
290  inCluster = 0;
291  }
292  *out++ = SiStripDigi(stripStart + firstStrip + inCluster, getADC_W<num_words>(data, offset, bits_shift));
293  offset += num_words;
294  ++inCluster;
295  }
296  return StatusCode::SUCCESS;
297  }
successful classification
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
#define LogDebug(id)