14#include "eformat/util.h"
15#include "eformat/ROBFragment.h"
16#include "eformat/ROSFragment.h"
17#include "eformat/SubDetectorFragment.h"
18#include "eformat/FullEventFragment.h"
19#include "ers/StreamFactory.h"
20#include "eformat/WrongMarkerIssue.h"
27 off_t offset = fs.tellg();
28 ERS_DEBUG_3(
"Current stream position is 0x%lx", offset);
31 if (fs && fs.good() && ! fs.eof()) {
33 fs.read((
char*)
data, 8);
34 if (!fs.good() || fs.eof())
return 0;
44 std::cout <<
"Word at offset " <<
HEX(offset) <<
" is not one of "
49 <<
HEX(
ROS) <<
". Stopping execution..." << std::endl;
56 ERS_DEBUG_3(
"Resetting stream position to 0x%lx...", offset);
58 if (addr && (size >= (
data[1]*4))) {
61 fs.read((
char*)addr,
data[1]*4);
63 ERS_DEBUG_3(
"Stream position is 0x%lx", offset = fs.tellg());
67 std::cout <<
"The fragment at offset " <<
HEX(offset) <<
" has "
68 <<
data[1]*4 <<
" bytes and you provided only "
69 << size <<
" bytes in your buffer. Stopping execution..."
75 ERS_DEBUG_3(
"Allocating fragment data storage of size %ud bytes", 4*
data[1]);
76 uint32_t* retval =
new uint32_t[
data[1]];
78 fs.read((
char*)retval,
data[1]*4);
80 ERS_DEBUG_3(
"Stream position is 0x%lx", offset = fs.tellg());
85 const uint32_t** rod, uint32_t* rod_size,
88 const uint32_t* block_end = block_start + block_size;
90 while (block_end > block_start) {
91 uint32_t curr_rod_size = 12;
92 curr_rod_size += *(block_end-3) + *(block_end-2);
93 block_end -= curr_rod_size;
94 if (rod && counter < max_count) {
97 rod_size[counter] = curr_rod_size;
98 rod[counter] = block_end;
109 ERS_DEBUG_1(
"Getting all ROB's from 0x%x...", fragment[0]);
117 if ( max_count > 0 ) {
127 counter += ros.
children(rob, max_count);
134 const uint32_t* ros[256];
135 size_t ros_counter = sd.
children(ros, 256);
136 for (
size_t i=0; i<ros_counter; ++i)
137 counter +=
get_robs(ros[i], &rob[counter], max_count - counter);
145 const uint32_t* sd[64];
146 size_t sd_counter = fe.
children(sd, 64);
147 for (
size_t i=0; i<sd_counter; ++i)
148 counter +=
get_robs(sd[i], &rob[counter], max_count - counter);