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/exception.h"
15 #define DATA_BLOCKS_PER_MU2E_FRAGMENT 2500
21 std::ostream & operator << (std::ostream &, ArtFragment
const &);
27 typedef uint16_t adc_t;
36 const adc_t* curPos = dataBegin();
37 if(dataBegin()!=dataEnd()) {
38 while(curPos<dataEnd()) {
41 index[block_count_-1] = curIndex + *(curPos);
42 curIndex += *(curPos);
43 curPos = curPos + *(curPos) / 2;
50 adc_t
const * dataBegin()
const {
51 return reinterpret_cast<mu2e::ArtFragment::adc_t
const *
>(&*artdaq_Fragment_.dataBegin());
54 adc_t
const * dataEnd()
const {
55 return reinterpret_cast<mu2e::ArtFragment::adc_t
const *
>(&*artdaq_Fragment_.dataEnd());
59 size_t block_count()
const {
return block_count_; }
61 size_t byte_count()
const {
62 return index[block_count_-1];
66 size_t blockIndexBytes(
size_t offset)
const {
67 if(offset>=block_count()) {
return 0; }
68 else if(offset==0) {
return 0;}
69 return index[ offset-1 ];
72 size_t blockEndBytes(
size_t offset)
const {
73 if(offset>=block_count()) {
return byte_count(); }
74 return index[ offset ];
79 size_t blockSizeBytes(
size_t offset)
const {
80 if(offset > block_count()-1) {
return 0; }
81 else if(offset==0) {
return index[ offset ]; }
82 return index[ offset ] - index[ offset-1 ];
86 adc_t
const * dataAtBytes(
size_t offset)
const {
87 return dataBegin() + (offset/2);
91 adc_t
const * dataAtBlockIndex(
size_t offset)
const {
92 return dataAtBytes(blockIndexBytes(offset));
95 void printPacketAtByte(
size_t byteIdx)
const {
96 std::cout <<
"\t\t" <<
"Packet Bits (128): " << std::endl ;
97 for(
int adcIdx = 0; adcIdx<8; adcIdx++) {
99 for(
int offset = 15; offset>=0; offset--) {
100 if( ( (*((adc_t
const *)(dataAtBytes(byteIdx)+adcIdx))) & (1<<offset) ) != 0) {
107 }
else if(offset==0) {
108 std::cout << std::endl;
112 std::cout << std::endl;
117 artdaq::Fragment
const & artdaq_Fragment_;
119 size_t index[DATA_BLOCKS_PER_MU2E_FRAGMENT];