CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
sistrip::FEDBSChannelUnpacker Class Reference

#include <SiStripFEDBuffer.h>

Public Member Functions

uint16_t adc () const
 
 FEDBSChannelUnpacker ()
 
bool hasData () const
 
FEDBSChannelUnpackeroperator++ ()
 
FEDBSChannelUnpackeroperator++ (int)
 
uint8_t sampleNumber () const
 

Static Public Member Functions

static FEDBSChannelUnpacker virginRawModeUnpacker (const FEDChannel &channel, uint16_t num_bits)
 
static FEDBSChannelUnpacker zeroSuppressedLiteModeUnpacker (const FEDChannel &channel, uint16_t num_bits)
 
static FEDBSChannelUnpacker zeroSuppressedModeUnpacker (const FEDChannel &channel, uint16_t num_bits)
 

Private Member Functions

 FEDBSChannelUnpacker (const uint8_t *payload, const uint16_t channelPayloadOffset, const int16_t channelPayloadLength, const uint16_t offsetIncrement, bool useZS)
 
void readNewClusterInfo ()
 

Static Private Member Functions

static void throwBadChannelLength (const uint16_t length)
 
static void throwBadWordLength (const uint16_t word_length)
 
static void throwUnorderedData (const uint8_t currentStrip, const uint8_t firstStripOfNewCluster)
 

Private Attributes

uint16_t bitOffsetIncrement_
 
uint16_t channelPayloadLength_
 
uint16_t channelPayloadOffset_
 
uint16_t currentLocalBitOffset_
 
uint8_t currentStrip_
 
uint16_t currentWordOffset_
 
const uint8_t * data_
 
uint16_t oldWordOffset_
 
bool useZS_
 
uint8_t valuesLeftInCluster_
 

Detailed Description

Definition at line 147 of file SiStripFEDBuffer.h.

Constructor & Destructor Documentation

sistrip::FEDBSChannelUnpacker::FEDBSChannelUnpacker ( )
inline
sistrip::FEDBSChannelUnpacker::FEDBSChannelUnpacker ( const uint8_t *  payload,
const uint16_t  channelPayloadOffset,
const int16_t  channelPayloadLength,
const uint16_t  offsetIncrement,
bool  useZS 
)
inlineprivate

Definition at line 223 of file SiStripFEDBuffer.h.

References bitOffsetIncrement_, channelPayloadLength_, readNewClusterInfo(), throwBadWordLength(), and useZS_.

228  : data_(payload),
229  oldWordOffset_(0),
230  currentWordOffset_(channelPayloadOffset),
232  bitOffsetIncrement_(offsetIncrement),
233  currentStrip_(0),
234  channelPayloadOffset_(channelPayloadOffset),
235  channelPayloadLength_(channelPayloadLength),
236  useZS_(useZS),
238  if (bitOffsetIncrement_ > 16)
239  throwBadWordLength(bitOffsetIncrement_); // more than 2 words... still to be implemented
242  }
static void throwBadWordLength(const uint16_t word_length)

Member Function Documentation

uint16_t sistrip::FEDBSChannelUnpacker::adc ( ) const
inline

Definition at line 275 of file SiStripFEDBuffer.h.

References bitOffsetIncrement_, sistrip::BITS_PER_BYTE, currentLocalBitOffset_, currentWordOffset_, data_, and oldWordOffset_.

Referenced by sistrip::RawToDigiUnpacker::createDigis().

275  {
276  uint16_t bits_missing = (bitOffsetIncrement_ - BITS_PER_BYTE) + currentLocalBitOffset_;
277  uint16_t adc = (data_[currentWordOffset_ ^ 7] << bits_missing);
279  adc += ((data_[(currentWordOffset_ + 1) ^ 7] >> (BITS_PER_BYTE - bits_missing)));
280  }
281  return (adc & ((1 << bitOffsetIncrement_) - 1));
282  }
uint16_t BITS_PER_BYTE
bool sistrip::FEDBSChannelUnpacker::hasData ( ) const
inline

Definition at line 284 of file SiStripFEDBuffer.h.

References bitOffsetIncrement_, sistrip::BITS_PER_BYTE, channelPayloadLength_, channelPayloadOffset_, currentLocalBitOffset_, and currentWordOffset_.

Referenced by sistrip::RawToDigiUnpacker::createDigis(), and operator++().

284  {
285  const uint16_t nextChanWordOffset = channelPayloadOffset_ + channelPayloadLength_;
286  if (currentWordOffset_ + 1 < nextChanWordOffset) {
287  return true; // fast case: 2 bytes always fit an ADC (even if offset)
288  } else { // close to end
289  const uint16_t plusOneBitOffset = currentLocalBitOffset_ + bitOffsetIncrement_;
290  const uint16_t plusOneWordOffset = currentWordOffset_ + plusOneBitOffset / BITS_PER_BYTE;
291  return (plusOneBitOffset % BITS_PER_BYTE) ? (plusOneWordOffset < nextChanWordOffset)
292  : (plusOneWordOffset <= nextChanWordOffset);
293  }
294  }
uint16_t BITS_PER_BYTE
FEDBSChannelUnpacker & sistrip::FEDBSChannelUnpacker::operator++ ( void  )
inline

Definition at line 296 of file SiStripFEDBuffer.h.

References bitOffsetIncrement_, sistrip::BITS_PER_BYTE, currentLocalBitOffset_, currentStrip_, currentWordOffset_, hasData(), oldWordOffset_, readNewClusterInfo(), throwUnorderedData(), useZS_, and valuesLeftInCluster_.

296  {
302  }
303  if (useZS_) {
304  if (valuesLeftInCluster_) {
305  currentStrip_++;
307  } else {
308  if (hasData()) {
309  const uint8_t oldStrip = currentStrip_;
311  if (!(currentStrip_ > oldStrip))
313  }
314  }
315  } else {
316  currentStrip_++;
317  }
318  return (*this);
319  }
static void throwUnorderedData(const uint8_t currentStrip, const uint8_t firstStripOfNewCluster)
uint16_t BITS_PER_BYTE
FEDBSChannelUnpacker & sistrip::FEDBSChannelUnpacker::operator++ ( int  )
inline

Definition at line 321 of file SiStripFEDBuffer.h.

321  {
322  ++(*this);
323  return *this;
324  }
void sistrip::FEDBSChannelUnpacker::readNewClusterInfo ( )
inlineprivate
uint8_t sistrip::FEDBSChannelUnpacker::sampleNumber ( ) const
inline

Definition at line 273 of file SiStripFEDBuffer.h.

References currentStrip_.

Referenced by sistrip::RawToDigiUnpacker::createDigis().

void sistrip::FEDBSChannelUnpacker::throwBadChannelLength ( const uint16_t  length)
staticprivate

Definition at line 435 of file SiStripFEDBuffer.cc.

References Exception, and contentValuesCheck::ss.

Referenced by virginRawModeUnpacker(), zeroSuppressedLiteModeUnpacker(), and zeroSuppressedModeUnpacker().

435  {
436  std::ostringstream ss;
437  ss << "Channel length is invalid. "
438  << "Channel length is " << uint16_t(length) << "." << std::endl;
439  throw cms::Exception("FEDBuffer") << ss.str();
440  }
void sistrip::FEDBSChannelUnpacker::throwBadWordLength ( const uint16_t  word_length)
staticprivate

Definition at line 442 of file SiStripFEDBuffer.cc.

References Exception, and contentValuesCheck::ss.

Referenced by FEDBSChannelUnpacker(), and virginRawModeUnpacker().

442  {
443  std::ostringstream ss;
444  ss << "Word length is invalid. "
445  << "Word length is " << word_length << "." << std::endl;
446  throw cms::Exception("FEDBuffer") << ss.str();
447  }
void sistrip::FEDBSChannelUnpacker::throwUnorderedData ( const uint8_t  currentStrip,
const uint8_t  firstStripOfNewCluster 
)
staticprivate

Definition at line 449 of file SiStripFEDBuffer.cc.

References Exception, and contentValuesCheck::ss.

Referenced by operator++().

449  {
450  std::ostringstream ss;
451  ss << "First strip of new cluster is not greater than last strip of previous cluster. "
452  << "Last strip of previous cluster is " << uint16_t(currentStrip) << ". "
453  << "First strip of new cluster is " << uint16_t(firstStripOfNewCluster) << "." << std::endl;
454  throw cms::Exception("FEDBuffer") << ss.str();
455  }
FEDBSChannelUnpacker sistrip::FEDBSChannelUnpacker::virginRawModeUnpacker ( const FEDChannel channel,
uint16_t  num_bits 
)
inlinestatic

Definition at line 244 of file SiStripFEDBuffer.h.

References sistrip::FEDChannel::data(), sistrip::FEDChannel::length(), sistrip::FEDChannel::offset(), mps_fire::result, throwBadChannelLength(), and throwBadWordLength().

Referenced by sistrip::RawToDigiUnpacker::createDigis(), and SiStripClusterizerFromRaw::run().

245  {
246  uint16_t length = channel.length();
247  if (length & 0xF000)
248  throwBadChannelLength(length);
249  if (num_bits <= 0 or num_bits > 16)
250  throwBadWordLength(num_bits);
251  FEDBSChannelUnpacker result(channel.data(), channel.offset() + 3, length - 3, num_bits, false);
252  return result;
253  }
static void throwBadWordLength(const uint16_t word_length)
static void throwBadChannelLength(const uint16_t length)
FEDBSChannelUnpacker sistrip::FEDBSChannelUnpacker::zeroSuppressedLiteModeUnpacker ( const FEDChannel channel,
uint16_t  num_bits 
)
inlinestatic

Definition at line 264 of file SiStripFEDBuffer.h.

References sistrip::FEDChannel::data(), sistrip::FEDChannel::length(), sistrip::FEDChannel::offset(), mps_fire::result, and throwBadChannelLength().

Referenced by sistrip::RawToDigiUnpacker::createDigis().

265  {
266  uint16_t length = channel.length();
267  if (length & 0xF000)
268  throwBadChannelLength(length);
269  FEDBSChannelUnpacker result(channel.data(), channel.offset() + 2, length - 2, num_bits, true);
270  return result;
271  }
static void throwBadChannelLength(const uint16_t length)
FEDBSChannelUnpacker sistrip::FEDBSChannelUnpacker::zeroSuppressedModeUnpacker ( const FEDChannel channel,
uint16_t  num_bits 
)
inlinestatic

Definition at line 255 of file SiStripFEDBuffer.h.

References sistrip::FEDChannel::data(), sistrip::FEDChannel::length(), sistrip::FEDChannel::offset(), mps_fire::result, and throwBadChannelLength().

Referenced by sistrip::RawToDigiUnpacker::createDigis().

256  {
257  uint16_t length = channel.length();
258  if (length & 0xF000)
259  throwBadChannelLength(length);
260  FEDBSChannelUnpacker result(channel.data(), channel.offset() + 7, length - 7, num_bits, true);
261  return result;
262  }
static void throwBadChannelLength(const uint16_t length)

Member Data Documentation

uint16_t sistrip::FEDBSChannelUnpacker::bitOffsetIncrement_
private

Definition at line 174 of file SiStripFEDBuffer.h.

Referenced by adc(), FEDBSChannelUnpacker(), hasData(), and operator++().

uint16_t sistrip::FEDBSChannelUnpacker::channelPayloadLength_
private

Definition at line 177 of file SiStripFEDBuffer.h.

Referenced by FEDBSChannelUnpacker(), and hasData().

uint16_t sistrip::FEDBSChannelUnpacker::channelPayloadOffset_
private

Definition at line 176 of file SiStripFEDBuffer.h.

Referenced by hasData().

uint16_t sistrip::FEDBSChannelUnpacker::currentLocalBitOffset_
private

Definition at line 173 of file SiStripFEDBuffer.h.

Referenced by adc(), hasData(), operator++(), and readNewClusterInfo().

uint8_t sistrip::FEDBSChannelUnpacker::currentStrip_
private

Definition at line 175 of file SiStripFEDBuffer.h.

Referenced by operator++(), readNewClusterInfo(), and sampleNumber().

uint16_t sistrip::FEDBSChannelUnpacker::currentWordOffset_
private

Definition at line 172 of file SiStripFEDBuffer.h.

Referenced by adc(), hasData(), operator++(), and readNewClusterInfo().

const uint8_t* sistrip::FEDBSChannelUnpacker::data_
private

Definition at line 170 of file SiStripFEDBuffer.h.

Referenced by adc(), and readNewClusterInfo().

uint16_t sistrip::FEDBSChannelUnpacker::oldWordOffset_
private

Definition at line 171 of file SiStripFEDBuffer.h.

Referenced by adc(), and operator++().

bool sistrip::FEDBSChannelUnpacker::useZS_
private

Definition at line 178 of file SiStripFEDBuffer.h.

Referenced by FEDBSChannelUnpacker(), and operator++().

uint8_t sistrip::FEDBSChannelUnpacker::valuesLeftInCluster_
private

Definition at line 179 of file SiStripFEDBuffer.h.

Referenced by operator++(), and readNewClusterInfo().