Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dune::FelixFragmentReordered Class Reference

#include <FelixFragment.hh>

Inheritance diagram for dune::FelixFragmentReordered:
dune::FelixFragmentBase

Public Member Functions

uint8_t sof (const unsigned &frame_ID=0) const
 
uint8_t version (const unsigned &frame_ID=0) const
 
uint8_t fiber_no (const unsigned &frame_ID=0) const
 
uint8_t slot_no (const unsigned &frame_ID=0) const
 
uint8_t crate_no (const unsigned &frame_ID=0) const
 
uint8_t mm (const unsigned &frame_ID=0) const
 
uint8_t oos (const unsigned &frame_ID=0) const
 
uint16_t wib_errors (const unsigned &frame_ID=0) const
 
uint64_t timestamp (const unsigned &frame_ID=0) const
 
uint16_t wib_counter (const unsigned &frame_ID=0) const
 
uint8_t s1_error (const unsigned &frame_ID, const uint8_t &block_num) const
 
uint8_t s2_error (const unsigned &frame_ID, const uint8_t &block_num) const
 
uint16_t checksum_a (const unsigned &frame_ID, const uint8_t &block_num) const
 
uint16_t checksum_b (const unsigned &frame_ID, const uint8_t &block_num) const
 
uint16_t coldata_convert_count (const unsigned &frame_ID, const uint8_t &block_num) const
 
uint16_t error_register (const unsigned &frame_ID, const uint8_t &block_num) const
 
uint8_t hdr (const unsigned &frame_ID, const uint8_t &block_num, const uint8_t &hdr_num) const
 
adc_t get_ADC (const unsigned &frame_ID, const uint8_t channel_ID) const
 
void print_timestamps () const
 
void print (const unsigned i) const
 
void print_frames () const
 
 FelixFragmentReordered (artdaq::Fragment const &fragment)
 
size_t total_words () const
 
size_t total_frames () const
 
size_t total_adc_values () const
 
- Public Member Functions inherited from dune::FelixFragmentBase
 FelixFragmentBase (const artdaq::Fragment &fragment)
 
virtual ~FelixFragmentBase ()
 
virtual size_t adc_range (int daq_adc_bits=12)
 
const uint8_t * dataBeginBytes () const
 
size_t dataSizeBytes () const
 

Protected Member Functions

bool header_is_faulty (const unsigned int frame_num) const
 
dune::WIBHeader const * head_ (const unsigned int frame_num) const
 
dune::ColdataHeader const * blockhead_ (const unsigned int frame_num, const uint8_t block_num) const
 
dune::adc_t channel_ (const unsigned int frame_num, const uint8_t ch_num) const
 

Protected Attributes

const unsigned int adc_start = 0
 
const unsigned int bitlist_start
 
const unsigned int header_start = bitlist_start + (meta_.num_frames + 7) / 8
 
const unsigned int header_set_size
 
std::vector< unsigned int > bad_header_num
 
- Protected Attributes inherited from dune::FelixFragmentBase
Metadata meta_
 
const void * artdaq_Fragment_
 
size_t sizeBytes_
 

Detailed Description

Definition at line 316 of file FelixFragment.hh.

Constructor & Destructor Documentation

dune::FelixFragmentReordered::FelixFragmentReordered ( artdaq::Fragment const &  fragment)
inline

Definition at line 413 of file FelixFragment.hh.

415  // Go through the bad headers and assign each a number.
416  unsigned int bad_header_count = 1;
417  for (unsigned int i = 0; i < meta_.num_frames; ++i) {
418  if (header_is_faulty(i)) {
419  bad_header_num[i] = bad_header_count++;
420  }
421  // std::cout << bad_header_num[i] << '\n';
422  }
423  }
bool header_is_faulty(const unsigned int frame_num) const
FelixFragmentBase(const artdaq::Fragment &fragment)
std::vector< unsigned int > bad_header_num

Member Function Documentation

dune::ColdataHeader const* dune::FelixFragmentReordered::blockhead_ ( const unsigned int  frame_num,
const uint8_t  block_num 
) const
inlineprotected

Definition at line 469 of file FelixFragment.hh.

470  {
471  if (header_is_faulty(frame_num)) {
472  // Return faulty header.
473  return reinterpret_cast<dune::ColdataHeader const*>(
474  static_cast<uint8_t const*>(artdaq_Fragment_) + header_start +
475  sizeof(dune::WIBHeader) +
476  bad_header_num[frame_num] * header_set_size) +
477  block_num;
478  } else {
479  // Return the first header unchanged if the requested header is good.
480  return reinterpret_cast<dune::ColdataHeader const*>(
481  static_cast<uint8_t const*>(artdaq_Fragment_) + header_start +
482  sizeof(dune::WIBHeader)) +
483  block_num;
484  }
485  }
const void * artdaq_Fragment_
bool header_is_faulty(const unsigned int frame_num) const
std::vector< unsigned int > bad_header_num
const unsigned int header_set_size
const unsigned int header_start
dune::adc_t dune::FelixFragmentReordered::channel_ ( const unsigned int  frame_num,
const uint8_t  ch_num 
) const
inlineprotected

Definition at line 487 of file FelixFragment.hh.

488  {
489  return *(reinterpret_cast<dune::adc_t const*>(
490  static_cast<uint8_t const*>(artdaq_Fragment_) + adc_start) +
491  frame_num + ch_num * meta_.num_frames);
492  }
uint16_t adc_t
Definition: FelixFormat.hh:18
const unsigned int adc_start
const void * artdaq_Fragment_
uint16_t dune::FelixFragmentReordered::checksum_a ( const unsigned &  frame_ID,
const uint8_t &  block_num 
) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 360 of file FelixFragment.hh.

361  {
362  return blockhead_(frame_ID, block_num)->checksum_a();
363  }
dune::ColdataHeader const * blockhead_(const unsigned int frame_num, const uint8_t block_num) const
uint16_t checksum_a() const
Definition: FelixFormat.hh:95
uint16_t dune::FelixFragmentReordered::checksum_b ( const unsigned &  frame_ID,
const uint8_t &  block_num 
) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 364 of file FelixFragment.hh.

365  {
366  return blockhead_(frame_ID, block_num)->checksum_b();
367  }
dune::ColdataHeader const * blockhead_(const unsigned int frame_num, const uint8_t block_num) const
uint16_t checksum_b() const
Definition: FelixFormat.hh:98
uint16_t dune::FelixFragmentReordered::coldata_convert_count ( const unsigned &  frame_ID,
const uint8_t &  block_num 
) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 368 of file FelixFragment.hh.

369  {
370  uint16_t result = blockhead_(frame_ID, block_num)->coldata_convert_count;
371  if (header_is_faulty(frame_ID) == false) {
372  // Deduce count from first header.
373  result += frame_ID;
374  }
375  return result;
376  }
static QCString result
bool header_is_faulty(const unsigned int frame_num) const
word_t coldata_convert_count
Definition: FelixFormat.hh:90
dune::ColdataHeader const * blockhead_(const unsigned int frame_num, const uint8_t block_num) const
uint8_t dune::FelixFragmentReordered::crate_no ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 331 of file FelixFragment.hh.

331  {
332  return head_(frame_ID)->crate_no;
333  }
dune::WIBHeader const * head_(const unsigned int frame_num) const
uint16_t dune::FelixFragmentReordered::error_register ( const unsigned &  frame_ID,
const uint8_t &  block_num 
) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 377 of file FelixFragment.hh.

378  {
379  return blockhead_(frame_ID, block_num)->error_register;
380  }
dune::ColdataHeader const * blockhead_(const unsigned int frame_num, const uint8_t block_num) const
uint8_t dune::FelixFragmentReordered::fiber_no ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 325 of file FelixFragment.hh.

325  {
326  return head_(frame_ID)->fiber_no;
327  }
dune::WIBHeader const * head_(const unsigned int frame_num) const
adc_t dune::FelixFragmentReordered::get_ADC ( const unsigned &  frame_ID,
const uint8_t  channel_ID 
) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 387 of file FelixFragment.hh.

387  {
388  return channel_(frame_ID, channel_ID);
389  }
dune::adc_t channel_(const unsigned int frame_num, const uint8_t ch_num) const
uint8_t dune::FelixFragmentReordered::hdr ( const unsigned &  frame_ID,
const uint8_t &  block_num,
const uint8_t &  hdr_num 
) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 381 of file FelixFragment.hh.

382  {
383  return blockhead_(frame_ID, block_num)->hdr(hdr_num);
384  }
dune::ColdataHeader const * blockhead_(const unsigned int frame_num, const uint8_t block_num) const
uint8_t hdr(const uint8_t i) const
Definition: FelixFormat.hh:101
dune::WIBHeader const* dune::FelixFragmentReordered::head_ ( const unsigned int  frame_num) const
inlineprotected

Definition at line 456 of file FelixFragment.hh.

456  {
457  if (header_is_faulty(frame_num)) {
458  // Return faulty header.
459  return reinterpret_cast<dune::WIBHeader const*>(
460  static_cast<uint8_t const*>(artdaq_Fragment_) + header_start +
461  bad_header_num[frame_num] * header_set_size);
462  } else {
463  // Return the first header unchanged if requested header is good.
464  return reinterpret_cast<dune::WIBHeader const*>(
465  static_cast<uint8_t const*>(artdaq_Fragment_) + header_start);
466  }
467  }
const void * artdaq_Fragment_
bool header_is_faulty(const unsigned int frame_num) const
std::vector< unsigned int > bad_header_num
const unsigned int header_set_size
const unsigned int header_start
bool dune::FelixFragmentReordered::header_is_faulty ( const unsigned int  frame_num) const
inlineprotected

Definition at line 447 of file FelixFragment.hh.

447  {
448  const uint8_t* curr_byte = static_cast<uint8_t const*>(artdaq_Fragment_) +
449  bitlist_start + frame_num / 8;
450  return ((*curr_byte) >> (frame_num % 8)) & 1;
451  }
const void * artdaq_Fragment_
const unsigned int bitlist_start
uint8_t dune::FelixFragmentReordered::mm ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 334 of file FelixFragment.hh.

334 { return head_(frame_ID)->mm; }
dune::WIBHeader const * head_(const unsigned int frame_num) const
uint8_t dune::FelixFragmentReordered::oos ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 335 of file FelixFragment.hh.

335  {
336  return head_(frame_ID)->oos;
337  }
dune::WIBHeader const * head_(const unsigned int frame_num) const
void dune::FelixFragmentReordered::print ( const unsigned  i) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 400 of file FelixFragment.hh.

400  {
401  std::cout << "Frame " << i
402  << " should be printed here.\n"; /* frames_()->print(i); */
403  }
void dune::FelixFragmentReordered::print_frames ( ) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 405 of file FelixFragment.hh.

405  {
406  // for (unsigned i = 0; i < total_frames(); i++) {
407  // frames_()->print(i);
408  // }
409  }
void dune::FelixFragmentReordered::print_timestamps ( ) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 392 of file FelixFragment.hh.

392  {
393  // for (unsigned int i = 0; i < total_frames(); i++) {
394  // std::cout << std::hex << frames_()->timestamp(i) << '\t' << std::dec <<
395  // i
396  // << std::endl;
397  // }
398  }
uint8_t dune::FelixFragmentReordered::s1_error ( const unsigned &  frame_ID,
const uint8_t &  block_num 
) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 354 of file FelixFragment.hh.

354  {
355  return blockhead_(frame_ID, block_num)->s1_error;
356  }
dune::ColdataHeader const * blockhead_(const unsigned int frame_num, const uint8_t block_num) const
uint8_t dune::FelixFragmentReordered::s2_error ( const unsigned &  frame_ID,
const uint8_t &  block_num 
) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 357 of file FelixFragment.hh.

357  {
358  return blockhead_(frame_ID, block_num)->s2_error;
359  }
dune::ColdataHeader const * blockhead_(const unsigned int frame_num, const uint8_t block_num) const
uint8_t dune::FelixFragmentReordered::slot_no ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 328 of file FelixFragment.hh.

328  {
329  return head_(frame_ID)->slot_no;
330  }
dune::WIBHeader const * head_(const unsigned int frame_num) const
uint8_t dune::FelixFragmentReordered::sof ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 319 of file FelixFragment.hh.

319  {
320  return head_(frame_ID)->sof;
321  }
dune::WIBHeader const * head_(const unsigned int frame_num) const
uint64_t dune::FelixFragmentReordered::timestamp ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 341 of file FelixFragment.hh.

341  {
342  uint64_t result = head_(frame_ID)->timestamp();
343  if (header_is_faulty(frame_ID) == false) {
344  // Deduce timestamp from first header,
345  result += frame_ID * 25;
346  }
347  return result;
348  }
static QCString result
bool header_is_faulty(const unsigned int frame_num) const
uint64_t timestamp() const
Definition: FelixFormat.hh:31
dune::WIBHeader const * head_(const unsigned int frame_num) const
size_t dune::FelixFragmentReordered::total_adc_values ( ) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 432 of file FelixFragment.hh.

432  {
434  }
static constexpr size_t num_ch_per_frame
Definition: FelixFormat.hh:298
size_t dune::FelixFragmentReordered::total_frames ( ) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 429 of file FelixFragment.hh.

size_t dune::FelixFragmentReordered::total_words ( ) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 426 of file FelixFragment.hh.

426 { return sizeBytes_ / sizeof(word_t); }
uint32_t word_t
Definition: FelixFormat.hh:17
uint8_t dune::FelixFragmentReordered::version ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 322 of file FelixFragment.hh.

322  {
323  return head_(frame_ID)->version;
324  }
dune::WIBHeader const * head_(const unsigned int frame_num) const
uint16_t dune::FelixFragmentReordered::wib_counter ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 349 of file FelixFragment.hh.

349  {
350  return head_(frame_ID)->wib_counter();
351  }
uint16_t wib_counter() const
Definition: FelixFormat.hh:38
dune::WIBHeader const * head_(const unsigned int frame_num) const
uint16_t dune::FelixFragmentReordered::wib_errors ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 338 of file FelixFragment.hh.

338  {
339  return head_(frame_ID)->wib_errors;
340  }
dune::WIBHeader const * head_(const unsigned int frame_num) const

Member Data Documentation

const unsigned int dune::FelixFragmentReordered::adc_start = 0
protected

Definition at line 438 of file FelixFragment.hh.

std::vector<unsigned int> dune::FelixFragmentReordered::bad_header_num
protected

Definition at line 453 of file FelixFragment.hh.

const unsigned int dune::FelixFragmentReordered::bitlist_start
protected
Initial value:
=
adc_start + meta_.num_frames * 256 * sizeof(adc_t)

Definition at line 439 of file FelixFragment.hh.

const unsigned int dune::FelixFragmentReordered::header_set_size
protected
Initial value:
=
sizeof(dune::WIBHeader) + 4 * sizeof(dune::ColdataHeader)

Definition at line 443 of file FelixFragment.hh.

const unsigned int dune::FelixFragmentReordered::header_start = bitlist_start + (meta_.num_frames + 7) / 8
protected

Definition at line 441 of file FelixFragment.hh.


The documentation for this class was generated from the following file: