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

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

220  : data_(payload),
221  oldWordOffset_(0), currentWordOffset_(channelPayloadOffset),
223  bitOffsetIncrement_(offsetIncrement),
224  currentStrip_(0),
225  channelPayloadOffset_(channelPayloadOffset),
226  channelPayloadLength_(channelPayloadLength),
227  useZS_(useZS), valuesLeftInCluster_(0)
228  {
229  if (bitOffsetIncrement_>16) throwBadWordLength(bitOffsetIncrement_); // more than 2 words... still to be implemented
231  }
static void throwBadWordLength(const uint16_t word_length)

Member Function Documentation

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

Definition at line 263 of file SiStripFEDBuffer.h.

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

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

264  {
265  uint16_t bits_missing = (bitOffsetIncrement_-BITS_PER_BYTE)+currentLocalBitOffset_;
266  uint16_t adc = (data_[currentWordOffset_^7]<<bits_missing);
268  adc += ( (data_[(currentWordOffset_+1)^7]>>(BITS_PER_BYTE-bits_missing)) );
269  }
270  return (adc&((1<<bitOffsetIncrement_)-1));
271  }
uint16_t BITS_PER_BYTE
bool sistrip::FEDBSChannelUnpacker::hasData ( ) const
inline

Definition at line 273 of file SiStripFEDBuffer.h.

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

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

274  {
275  const uint16_t nextChanWordOffset = channelPayloadOffset_+channelPayloadLength_;
276  if ( currentWordOffset_ + 1 < nextChanWordOffset ) {
277  return true; // fast case: 2 bytes always fit an ADC (even if offset)
278  } else { // close to end
279  const uint16_t plusOneBitOffset = currentLocalBitOffset_+bitOffsetIncrement_;
280  const uint16_t plusOneWordOffset = currentWordOffset_ + plusOneBitOffset/BITS_PER_BYTE;
281  return ( plusOneBitOffset % BITS_PER_BYTE ) ? ( plusOneWordOffset < nextChanWordOffset ) : ( plusOneWordOffset <= nextChanWordOffset );
282  }
283  }
uint16_t BITS_PER_BYTE
FEDBSChannelUnpacker & sistrip::FEDBSChannelUnpacker::operator++ ( void  )
inline

Definition at line 285 of file SiStripFEDBuffer.h.

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

286  {
292  }
293  if (useZS_) {
295  else {
296  if (hasData()) {
297  const uint8_t oldStrip = currentStrip_;
299  if ( !(currentStrip_ > oldStrip) ) throwUnorderedData(oldStrip,currentStrip_);
300  }
301  }
302  } else { currentStrip_++; }
303  return (*this);
304  }
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 306 of file SiStripFEDBuffer.h.

307  {
308  ++(*this); return *this;
309  }
void sistrip::FEDBSChannelUnpacker::readNewClusterInfo ( )
inlineprivate
uint8_t sistrip::FEDBSChannelUnpacker::sampleNumber ( ) const
inline

Definition at line 258 of file SiStripFEDBuffer.h.

References currentStrip_.

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

259  {
260  return currentStrip_;
261  }
void sistrip::FEDBSChannelUnpacker::throwBadChannelLength ( const uint16_t  length)
staticprivate

Definition at line 424 of file SiStripFEDBuffer.cc.

References Exception.

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

425  {
426  std::ostringstream ss;
427  ss << "Channel length is invalid. "
428  << "Channel length is " << uint16_t(length) << "."
429  << std::endl;
430  throw cms::Exception("FEDBuffer") << ss.str();
431  }
void sistrip::FEDBSChannelUnpacker::throwBadWordLength ( const uint16_t  word_length)
staticprivate

Definition at line 433 of file SiStripFEDBuffer.cc.

References Exception.

Referenced by FEDBSChannelUnpacker(), and virginRawModeUnpacker().

434  {
435  std::ostringstream ss;
436  ss << "Word length is invalid. "
437  << "Word length is " << word_length << "."
438  << std::endl;
439  throw cms::Exception("FEDBuffer") << ss.str();
440  }
void sistrip::FEDBSChannelUnpacker::throwUnorderedData ( const uint8_t  currentStrip,
const uint8_t  firstStripOfNewCluster 
)
staticprivate

Definition at line 442 of file SiStripFEDBuffer.cc.

References Exception.

Referenced by operator++().

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

Definition at line 233 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().

234  {
235  uint16_t length = channel.length();
236  if (length & 0xF000) throwBadChannelLength(length);
237  if (num_bits<=0 or num_bits>16) throwBadWordLength(num_bits);
238  FEDBSChannelUnpacker result(channel.data(), channel.offset()+3, length-3, num_bits, false);
239  return result;
240  }
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 250 of file SiStripFEDBuffer.h.

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

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

251  {
252  uint16_t length = channel.length();
253  if (length & 0xF000) throwBadChannelLength(length);
254  FEDBSChannelUnpacker result(channel.data(), channel.offset()+2, length-2, num_bits, true);
255  return result;
256  }
static void throwBadChannelLength(const uint16_t length)
FEDBSChannelUnpacker sistrip::FEDBSChannelUnpacker::zeroSuppressedModeUnpacker ( const FEDChannel channel,
uint16_t  num_bits 
)
inlinestatic

Definition at line 242 of file SiStripFEDBuffer.h.

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

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

243  {
244  uint16_t length = channel.length();
245  if (length & 0xF000) throwBadChannelLength(length);
246  FEDBSChannelUnpacker result(channel.data(), channel.offset()+7, length-7, num_bits, true);
247  return result;
248  }
static void throwBadChannelLength(const uint16_t length)

Member Data Documentation

uint16_t sistrip::FEDBSChannelUnpacker::bitOffsetIncrement_
private

Definition at line 163 of file SiStripFEDBuffer.h.

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

uint16_t sistrip::FEDBSChannelUnpacker::channelPayloadLength_
private

Definition at line 166 of file SiStripFEDBuffer.h.

Referenced by FEDBSChannelUnpacker(), and hasData().

uint16_t sistrip::FEDBSChannelUnpacker::channelPayloadOffset_
private

Definition at line 165 of file SiStripFEDBuffer.h.

Referenced by hasData().

uint16_t sistrip::FEDBSChannelUnpacker::currentLocalBitOffset_
private

Definition at line 162 of file SiStripFEDBuffer.h.

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

uint8_t sistrip::FEDBSChannelUnpacker::currentStrip_
private

Definition at line 164 of file SiStripFEDBuffer.h.

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

uint16_t sistrip::FEDBSChannelUnpacker::currentWordOffset_
private

Definition at line 161 of file SiStripFEDBuffer.h.

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

const uint8_t* sistrip::FEDBSChannelUnpacker::data_
private

Definition at line 159 of file SiStripFEDBuffer.h.

Referenced by adc(), and readNewClusterInfo().

uint16_t sistrip::FEDBSChannelUnpacker::oldWordOffset_
private

Definition at line 160 of file SiStripFEDBuffer.h.

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

bool sistrip::FEDBSChannelUnpacker::useZS_
private

Definition at line 167 of file SiStripFEDBuffer.h.

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

uint8_t sistrip::FEDBSChannelUnpacker::valuesLeftInCluster_
private

Definition at line 168 of file SiStripFEDBuffer.h.

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