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 192 of file SiStripFEDBuffer.h.

192  {
193  // get ADC from one byte, until bOffset into the byte at wOffset (maximum decided by mask)
194  return (data[wOffset ^ 7] >> (BITS_PER_BYTE - bOffset)) & mask;
195  }

References sistrip::BITS_PER_BYTE, and data.

◆ 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 187 of file SiStripFEDBuffer.h.

187  {
188  // get ADC from two bytes, from wOffset until bOffset bits from the next byte (maximum decided by mask)
189  return (((data[wOffset ^ 7]) << bOffset) + (data[(wOffset + 1) ^ 7] >> (BITS_PER_BYTE - bOffset))) & mask;
190  }

References sistrip::BITS_PER_BYTE, and data.

◆ 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 181 of file SiStripFEDBuffer.h.

181  {
182  // get ADC from one or two bytes (at most 10 bits), and shift if needed
183  return (data[offset ^ 7] + (num_words == 2 ? ((data[(offset + 1) ^ 7] & 0x03) << 8) : 0)) << bits_shift;
184  }

References data, and hltrates_dqm_sourceclient-live_cfg::offset.

◆ readoutOrder()

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

Definition at line 335 of file SiStripFEDBuffer.h.

335  {
336  return (4 * ((static_cast<uint16_t>((static_cast<float>(physical_order) / 8.0))) % 4) +
337  static_cast<uint16_t>(static_cast<float>(physical_order) / 32.0) + 16 * (physical_order % 8));
338  }

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

◆ unpackRawB()

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

Definition at line 218 of file SiStripFEDBuffer.h.

218  {
219  static_assert(num_bits <= 16, "Word length must be between 0 and 16.");
220  if (channel.length() & 0xF000) {
221  LogDebug("FEDBuffer") << "Channel length is invalid. Channel length is " << uint16_t(channel.length()) << ".";
222  return StatusCode::BAD_CHANNEL_LENGTH;
223  }
224  constexpr uint16_t mask = (1 << num_bits) - 1;
225  const uint8_t* const data = channel.data();
226  const uint_fast16_t chEnd = channel.offset() + channel.length();
227  uint_fast16_t wOffset = channel.offset() + 3;
228  uint_fast8_t bOffset = 0;
229  while (((wOffset + 1) < chEnd) || ((chEnd - wOffset) * BITS_PER_BYTE - bOffset >= num_bits)) {
230  bOffset += num_bits;
231  if ((num_bits > BITS_PER_BYTE) || (bOffset > BITS_PER_BYTE)) {
232  bOffset -= BITS_PER_BYTE;
233  **out++ = SiStripRawDigi(getADC_B2<mask>(data, wOffset, bOffset));
234  ++wOffset;
235  } else {
236  **out++ = SiStripRawDigi(getADC_B1<mask>(data, wOffset, bOffset));
237  }
238  if (bOffset == BITS_PER_BYTE) {
239  bOffset = 0;
240  ++wOffset;
241  }
242  }
243  return StatusCode::SUCCESS;
244  }

References sistrip::fedchannelunpacker::BAD_CHANNEL_LENGTH, sistrip::BITS_PER_BYTE, data, sistrip::FEDChannel::data(), sistrip::FEDChannel::length(), LogDebug, sistrip::FEDChannel::offset(), MillePedeFileConverter_cfg::out, and sistrip::fedchannelunpacker::SUCCESS.

◆ 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 199 of file SiStripFEDBuffer.h.

199  {
200  constexpr auto num_words = num_bits / 8;
201  static_assert(((num_bits % 8) == 0) && (num_words > 0) && (num_words < 3));
202  if ((num_words > 1) && ((channel.length() - 3) % num_words)) {
203  LogDebug("FEDBuffer") << "Channel length is invalid. Raw channels have 3 header bytes and " << num_words
204  << " bytes per sample. "
205  << "Channel length is " << uint16_t(channel.length()) << ".";
206  return StatusCode::BAD_CHANNEL_LENGTH;
207  }
208  const uint8_t* const data = channel.data();
209  const uint_fast16_t end = channel.offset() + channel.length();
210  for (uint_fast16_t offset = channel.offset() + 3; offset != end; offset += num_words) {
211  *out++ = SiStripRawDigi(getADC_W<num_words>(data, offset, bits_shift));
212  }
213  return StatusCode::SUCCESS;
214  }

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

◆ 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 285 of file SiStripFEDBuffer.h.

285  {
286  constexpr uint16_t mask = (1 << num_bits) - 1;
287  if (channel.length() & 0xF000) {
288  LogDebug("FEDBuffer") << "Channel length is invalid. Channel length is " << uint16_t(channel.length()) << ".";
289  return StatusCode::BAD_CHANNEL_LENGTH;
290  }
291  const uint8_t* const data = channel.data();
292  uint_fast16_t wOffset = channel.offset() + headerLength; // header is 2 (lite) or 7
293  uint_fast8_t bOffset{0}, firstStrip{0}, nInCluster{0}, inCluster{0};
294  const uint_fast16_t chEnd = channel.offset() + channel.length();
295  while (((wOffset + 1) < chEnd) ||
296  ((inCluster != nInCluster) && ((chEnd - wOffset) * BITS_PER_BYTE - bOffset >= num_bits))) {
297  if (inCluster == nInCluster) {
298  if (wOffset + 2 >= chEnd) {
299  // offset should already be at end then (empty cluster)
300  break;
301  }
302  if (bOffset) {
303  ++wOffset;
304  bOffset = 0;
305  }
306  const uint_fast8_t newFirstStrip = data[(wOffset++) ^ 7];
307  if (newFirstStrip < (firstStrip + inCluster)) {
308  LogDebug("FEDBuffer") << "First strip of new cluster is not greater than last strip of previous cluster. "
309  << "Last strip of previous cluster is " << uint16_t(firstStrip + inCluster) << ". "
310  << "First strip of new cluster is " << uint16_t(newFirstStrip) << ".";
311  return StatusCode::UNORDERED_DATA;
312  }
313  firstStrip = newFirstStrip;
314  nInCluster = data[(wOffset++) ^ 7];
315  inCluster = 0;
316  bOffset = 0;
317  }
318  bOffset += num_bits;
319  if ((num_bits > BITS_PER_BYTE) || (bOffset > BITS_PER_BYTE)) {
320  bOffset -= BITS_PER_BYTE;
321  *out++ = SiStripDigi(stripStart + firstStrip + inCluster, getADC_B2<mask>(data, wOffset, bOffset));
322  ++wOffset;
323  } else {
324  *out++ = SiStripDigi(stripStart + firstStrip + inCluster, getADC_B1<mask>(data, wOffset, bOffset));
325  }
326  ++inCluster;
327  if (bOffset == BITS_PER_BYTE) {
328  bOffset = 0;
329  ++wOffset;
330  }
331  }
332  return StatusCode::SUCCESS;
333  }

References sistrip::fedchannelunpacker::BAD_CHANNEL_LENGTH, sistrip::BITS_PER_BYTE, data, sistrip::FEDChannel::data(), sistrip::FEDChannel::length(), LogDebug, sistrip::FEDChannel::offset(), MillePedeFileConverter_cfg::out, sistrip::fedchannelunpacker::SUCCESS, and sistrip::fedchannelunpacker::UNORDERED_DATA.

◆ 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 247 of file SiStripFEDBuffer.h.

248  {
249  constexpr auto num_words = num_bits / 8;
250  static_assert(((num_bits % 8) == 0) && (num_words > 0) && (num_words < 3));
251  if (channel.length() & 0xF000) {
252  LogDebug("FEDBuffer") << "Channel length is invalid. Channel length is " << uint16_t(channel.length()) << ".";
253  return StatusCode::BAD_CHANNEL_LENGTH;
254  }
255  const uint8_t* const data = channel.data();
256  uint_fast16_t offset = channel.offset() + headerLength; // header is 2 (lite) or 7
257  uint_fast8_t firstStrip{0}, nInCluster{0}, inCluster{0};
258  const uint_fast16_t end = channel.offset() + channel.length();
259  while (offset != end) {
260  if (inCluster == nInCluster) {
261  if (offset + 2 >= end) {
262  // offset should already be at end then (empty cluster)
263  break;
264  }
265  const uint_fast8_t newFirstStrip = data[(offset++) ^ 7];
266  if (newFirstStrip < (firstStrip + inCluster)) {
267  LogDebug("FEDBuffer") << "First strip of new cluster is not greater than last strip of previous cluster. "
268  << "Last strip of previous cluster is " << uint16_t(firstStrip + inCluster) << ". "
269  << "First strip of new cluster is " << uint16_t(newFirstStrip) << ".";
270  return StatusCode::UNORDERED_DATA;
271  }
272  firstStrip = newFirstStrip;
273  nInCluster = data[(offset++) ^ 7];
274  inCluster = 0;
275  }
276  *out++ = SiStripDigi(stripStart + firstStrip + inCluster, getADC_W<num_words>(data, offset, bits_shift));
277  offset += num_words;
278  ++inCluster;
279  }
280  return StatusCode::SUCCESS;
281  }

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

end
#define end
Definition: vmac.h:39
SiStripRawDigi
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
Definition: SiStripRawDigi.h:15
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
sistrip::BITS_PER_BYTE
constexpr uint16_t BITS_PER_BYTE
Definition: SiStripFEDBuffer.h:17
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
SiStripDigi
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
HTXS::SUCCESS
successful classification
Definition: HiggsTemplateCrossSections.h:13