1 #ifndef mu2e_artdaq_core_Overlays_ArtFragment_hh
2 #define mu2e_artdaq_core_Overlays_ArtFragment_hh
4 #include "artdaq-core/Data/Fragment.hh"
5 #include "cetlib_except/exception.h"
15 #define DATA_BLOCKS_PER_MU2E_FRAGMENT 2500
21 std::ostream &operator<<(std::ostream &, ArtFragment
const &);
27 typedef uint16_t adc_t;
35 const adc_t *curPos = dataBegin();
36 if (dataBegin() != dataEnd()) {
37 while (curPos < dataEnd()) {
40 index[block_count_ - 1] = curIndex + *(curPos);
41 curIndex += *(curPos);
42 curPos = curPos + *(curPos) / 2;
49 adc_t
const *dataBegin()
const
51 return reinterpret_cast<mu2e::ArtFragment::adc_t
const *
>(&*artdaq_Fragment_.dataBegin());
54 adc_t
const *dataEnd()
const
56 return reinterpret_cast<mu2e::ArtFragment::adc_t
const *
>(&*artdaq_Fragment_.dataEnd());
60 size_t block_count()
const {
return block_count_; }
62 size_t byte_count()
const {
return index[block_count_ - 1]; }
65 size_t blockIndexBytes(
size_t offset)
const
67 if (offset >= block_count()) {
74 return index[offset - 1];
77 size_t blockEndBytes(
size_t offset)
const
79 if (offset >= block_count()) {
86 size_t blockSizeBytes(
size_t offset)
const
88 if (offset > block_count() - 1) {
95 return index[offset] - index[offset - 1];
99 adc_t
const *dataAtBytes(
size_t offset)
const {
return dataBegin() + (offset / 2); }
102 adc_t
const *dataAtBlockIndex(
size_t offset)
const {
return dataAtBytes(blockIndexBytes(offset)); }
104 void printPacketAtByte(
size_t byteIdx)
const
107 <<
"Packet Bits (128): " << std::endl;
108 for (
int adcIdx = 0; adcIdx < 8; adcIdx++) {
110 for (
int offset = 15; offset >= 0; offset--) {
111 if (((*((adc_t
const *)(dataAtBytes(byteIdx) + adcIdx))) & (1 << offset)) != 0) {
121 else if (offset == 0)
123 std::cout << std::endl;
127 std::cout << std::endl;
132 artdaq::Fragment
const &artdaq_Fragment_;
134 size_t index[DATA_BLOCKS_PER_MU2E_FRAGMENT];