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

Constructor & Destructor Documentation

sistrip::FEDBSChannelUnpacker::FEDBSChannelUnpacker ( )
inline

Definition at line 209 of file SiStripFEDBuffer.h.

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_, and throwBadWordLength().

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

Member Function Documentation

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

Definition at line 261 of file SiStripFEDBuffer.h.

References bitOffsetIncrement_, currentLocalBitOffset_, currentWordOffset_, data_, and oldWordOffset_.

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

262  {
263  uint16_t bits_missing = (bitOffsetIncrement_-8)+currentLocalBitOffset_;
264  uint16_t adc = (data_[currentWordOffset_^7]<<bits_missing);
266  adc += ( (data_[(currentWordOffset_+1)^7]>>(8-bits_missing)) );
267  }
268  return (adc&((1<<bitOffsetIncrement_)-1));
269  }
bool sistrip::FEDBSChannelUnpacker::hasData ( ) const
inline
FEDBSChannelUnpacker & sistrip::FEDBSChannelUnpacker::operator++ ( void  )
inline

Definition at line 276 of file SiStripFEDBuffer.h.

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

277  {
281  while (currentLocalBitOffset_>=8) {
284  }
285  if (useZS_) {
287  else {
288  if (hasData()) {
289  const uint8_t oldStrip = currentStrip_;
291  if ( !(currentStrip_ > oldStrip) ) throwUnorderedData(oldStrip,currentStrip_);
292  }
293  }
294  } else { currentStrip_++; }
295  return (*this);
296  }
static void throwUnorderedData(const uint8_t currentStrip, const uint8_t firstStripOfNewCluster)
FEDBSChannelUnpacker & sistrip::FEDBSChannelUnpacker::operator++ ( int  )
inline

Definition at line 298 of file SiStripFEDBuffer.h.

299  {
300  ++(*this); return *this;
301  }
void sistrip::FEDBSChannelUnpacker::readNewClusterInfo ( )
inlineprivate
uint8_t sistrip::FEDBSChannelUnpacker::sampleNumber ( ) const
inline

Definition at line 256 of file SiStripFEDBuffer.h.

References currentStrip_.

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

257  {
258  return currentStrip_;
259  }
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 231 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().

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

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

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

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

Definition at line 240 of file SiStripFEDBuffer.h.

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

241  {
242  uint16_t length = channel.length();
243  if (length & 0xF000) throwBadChannelLength(length);
244  FEDBSChannelUnpacker result(channel.data(), channel.offset()+7, length-7, num_bits, true);
245  return result;
246  }
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(), and operator++().

uint16_t sistrip::FEDBSChannelUnpacker::channelPayloadLength_
private

Definition at line 166 of file SiStripFEDBuffer.h.

Referenced by hasData().

uint16_t sistrip::FEDBSChannelUnpacker::channelPayloadOffset_
private

Definition at line 165 of file SiStripFEDBuffer.h.

Referenced by hasData().

uint16_t sistrip::FEDBSChannelUnpacker::currentBitOffset_
private

Definition at line 161 of file SiStripFEDBuffer.h.

Referenced by operator++().

uint16_t sistrip::FEDBSChannelUnpacker::currentLocalBitOffset_
private

Definition at line 162 of file SiStripFEDBuffer.h.

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

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

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

const uint8_t* sistrip::FEDBSChannelUnpacker::data_
private

Definition at line 158 of file SiStripFEDBuffer.h.

Referenced by adc(), and readNewClusterInfo().

uint16_t sistrip::FEDBSChannelUnpacker::oldWordOffset_
private

Definition at line 159 of file SiStripFEDBuffer.h.

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

bool sistrip::FEDBSChannelUnpacker::useZS_
private

Definition at line 167 of file SiStripFEDBuffer.h.

Referenced by operator++().

uint8_t sistrip::FEDBSChannelUnpacker::valuesLeftInCluster_
private

Definition at line 168 of file SiStripFEDBuffer.h.

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