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"
17 #define DATA_BLOCKS_PER_MU2E_FRAGMENT 2500
23 std::ostream & operator << (std::ostream &, ArtFragment
const &);
29 typedef uint16_t adc_t;
38 const adc_t* curPos = dataBegin();
39 if(dataBegin()!=dataEnd()) {
40 while(curPos<dataEnd()) {
43 index[block_count_-1] = curIndex + *(curPos);
44 curIndex += *(curPos);
45 curPos = curPos + *(curPos) / 2;
52 adc_t
const * dataBegin()
const {
53 return reinterpret_cast<mu2e::ArtFragment::adc_t
const *
>(&*artdaq_Fragment_.dataBegin());
56 adc_t
const * dataEnd()
const {
57 return reinterpret_cast<mu2e::ArtFragment::adc_t
const *
>(&*artdaq_Fragment_.dataEnd());
61 size_t block_count()
const {
return block_count_; }
63 size_t byte_count()
const {
64 return index[block_count_-1];
68 size_t blockIndexBytes(
size_t offset)
const {
69 if(offset>=block_count()) {
return 0; }
70 else if(offset==0) {
return 0;}
71 return index[ offset-1 ];
74 size_t blockEndBytes(
size_t offset)
const {
75 if(offset>=block_count()) {
return byte_count(); }
76 return index[ offset ];
81 size_t blockSizeBytes(
size_t offset)
const {
82 if(offset > block_count()-1) {
return 0; }
83 else if(offset==0) {
return index[ offset ]; }
84 return index[ offset ] - index[ offset-1 ];
88 adc_t
const * dataAtBytes(
size_t offset)
const {
89 return dataBegin() + (offset/2);
93 adc_t
const * dataAtBlockIndex(
size_t offset)
const {
94 return dataAtBytes(blockIndexBytes(offset));
97 void printPacketAtByte(
size_t byteIdx)
const {
98 std::cout <<
"\t\t" <<
"Packet Bits (128): " << std::endl ;
99 for(
int adcIdx = 0; adcIdx<8; adcIdx++) {
101 for(
int offset = 15; offset>=0; offset--) {
102 if( ( (*((adc_t
const *)(dataAtBytes(byteIdx)+adcIdx))) & (1<<offset) ) != 0) {
109 }
else if(offset==0) {
110 std::cout << std::endl;
114 std::cout << std::endl;
119 artdaq::Fragment
const & artdaq_Fragment_;
121 size_t index[DATA_BLOCKS_PER_MU2E_FRAGMENT];