Skip to content
Snippets Groups Projects

Add support for realistic RICH PMT encoding and decoding

Compare and Show latest version
2 files
+ 51
24
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -31,6 +31,7 @@
#include "Event/RawEvent.h"
// Boost
#include "boost/container/static_vector.hpp"
#include "boost/format.hpp"
#include "boost/format/group.hpp"
#include "boost/range/adaptor/reversed.hpp"
@@ -55,22 +56,27 @@ namespace Rich::Future::DAQ {
/// 8-bit data words for the two halves of each Tel40 data frame
class DataHalves final {
public:
/// Basic data type
using DataType = std::uint8_t;
/// Bits in data words
static constexpr const std::uint8_t BitsPerWord = 8;
static constexpr const DataType BitsPerWord = 8u;
/// maximum bit index
static constexpr const DataType MaxBitIndex = BitsPerWord - 1u;
/// Bit offset for second half of data payload
static constexpr const std::array<std::uint8_t, 2> bit_offsets{0, 39};
static constexpr const std::array<DataType, 2> bit_offsets{0u, 39u};
/// Max ZS data sizes for each half
static constexpr const std::array<std::uint8_t, 2> maxZSByteSize{4, 5};
static constexpr const std::array<DataType, 2> maxZSByteSize{4u, 5u};
public:
/// Add a frame bit to the data
void add( Rich::DAQ::FrameBitIndex bit );
void add( const Rich::DAQ::FrameBitIndex bit );
public:
/// Append the data to the given byte vector
void appendTo( std::vector<std::uint8_t>& data ) const {
template <typename BANK>
inline void appendTo( BANK& data ) const {
// note adding 'backwards' so that words appear in Rawbank in the expected order
for ( const int half : {1, 0} ) {
for ( const std::size_t half : {1, 0} ) {
for ( const auto w : boost::adaptors::reverse( m_data[half] ) ) { data.emplace_back( w ); }
}
}
@@ -78,18 +84,6 @@ namespace Rich::Future::DAQ {
/// Access the number of words (bytes) in this data frame
auto nBytes() const noexcept { return m_data[0].size() + m_data[1].size(); }
private:
/// Is the given frame bit already on ?
inline bool isBitOn( const std::uint8_t pos, //
const std::uint8_t data ) noexcept {
return ( 0 != ( data & ( 1 << pos ) ) );
}
/// Set a given bit on
inline void setBitOn( const std::uint8_t pos, //
std::uint8_t& data ) const noexcept {
data |= 1 << pos;
}
public:
/// ostream operator
friend std::ostream& operator<<( std::ostream& os, const DataHalves& d ) {
@@ -110,10 +104,26 @@ namespace Rich::Future::DAQ {
}
private:
// types
/// Container type for words in one half of a link payload
using HalfPayload = boost::container::static_vector<DataHalves::DataType, 6>;
/// array type for payload halves
template <typename TYPE>
using HalfArray = std::array<TYPE, 2>;
/// Type for overall link payload
using LinkPayload = HalfArray<HalfPayload>;
private:
// data
/// data storage
std::array<std::vector<std::uint8_t>, 2> m_data;
LinkPayload m_data;
/// Is ZS or not
std::array<bool, 2> m_zs{true, true};
HalfArray<bool> m_zs{true, true};
};
/// Data frame for each connection in a Tel40
Loading