24 #define MAXBUFFERSIZE 256*8192
27 int main (
int argc,
char** argv)
32 if (argc>=4) filename=argv[1];
35 COUT <<
"usage: " << argv[0] <<
" DATAFILE outfile run-number [frames to combine]"<< std::endl;
39 int fd =
open(filename, O_RDONLY | O_LARGEFILE);
42 COUT <<
"ERROR: could not open " << filename << std::endl;
46 int outfile =
open(argv[2], O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE ,
47 S_IRWXU | S_IROTH | S_IRGRP );
50 COUT <<
"ERROR: could not open " << argv[2] << std::endl;
55 sscanf(argv[3],
"%d", &runnumber);
56 COUT <<
"will write run number " << runnumber << std::endl;
59 int frames_to_combine = 1;
62 sscanf(argv[4],
"%d", &frames_to_combine);
63 COUT <<
"will combine " << frames_to_combine <<
" frames for each event" <<std::endl;
78 nread =
read(fd, frame_ptr,4*6);
83 else framelen = frame_ptr[0];
86 nread =
read(fd, &frame_ptr[6], 4*(framelen-6));
97 reallength += frame_ptr[0];
102 nread =
read(fd, frame_ptr,4*6);
105 else framelen = frame_ptr[0];
108 nread =
read (fd, &frame_ptr[6], 4*(framelen-6));
110 if ( nframe >=frames_to_combine)
122 COUT << eventnumber <<
" data events written "