8 #ifndef __MUPIX_HH_4GZYCGCM__
9 #define __MUPIX_HH_4GZYCGCM__
16 #include "eudaq/Logger.hh"
17 #include "eudaq/RawDataEvent.hh"
29 inline uint8_t gray_decode(uint8_t graystamp) {
33 for (mask = graystamp >> 1; mask != 0; mask = mask >> 1) {
34 graystamp = graystamp ^ mask;
39 inline uint8_t gray_encode(uint8_t timestamp) {
41 return (timestamp >> 1) ^ timestamp;
66 EUDAQ_WARN(
"event " +
to_string(e.GetEventNumber()) +
67 ": invalid number of data blocks " +
72 const std::vector<uint8_t> &block = e.
GetBlock(0);
74 if (block.size() < 9) {
75 EUDAQ_WARN(
"event " +
to_string(e.GetEventNumber()) +
76 ": data block is too small");
81 if (block.size() != proxy.size()) {
82 EUDAQ_WARN(
"event " +
to_string(e.GetEventNumber()) +
83 ": inconsistent data size. " +
"received " +
84 to_string(block.size()) +
" " +
"from header " +
92 return from_event(dynamic_cast<const RawDataEvent &>(e));
95 operator bool()
const {
return (_data != NULL); }
97 uint32_t event_id()
const {
98 return eudaq::getlittleendian<uint32_t>(&_data[0]);
100 uint16_t trigger_id()
const {
101 return eudaq::getlittleendian<uint16_t>(&_data[4]);
103 uint8_t trigger_graystamp()
const {
return _data[6]; }
104 uint8_t trigger_timestamp()
const {
105 return gray_decode(trigger_graystamp());
107 bool overflow()
const {
return static_cast<bool>(_data[7]); }
109 uint8_t num_hits()
const {
return _data[8]; }
110 uint8_t hit_col(
unsigned i)
const {
return _data[9 + i * 3 + 0]; }
111 uint8_t hit_row(
unsigned i)
const {
return _data[9 + i * 3 + 1]; }
112 uint8_t hit_graystamp(
unsigned i)
const {
return _data[9 + i * 3 + 2]; }
113 uint8_t hit_timestamp(
unsigned i)
const {
114 return gray_decode(hit_graystamp(i));
117 unsigned size()
const {
return 9 + 3 * num_hits(); }
120 const uint8_t *_data;
126 #endif // __MUPIX_HH_4GZYCGCM__
size_t NumBlocks() const
Return the number of data blocks in the RawDataEvent.
Definition: RawDataEvent.hh:80
std::string to_string(const T &x, int digits=0)
Definition: Utils.hh:54
Definition: RawDataEvent.hh:14
const data_t & GetBlock(size_t i) const
Definition: RawDataEvent.cc:34