Belle II Software
release-08-01-10
rb2file.cc
1
/**************************************************************************
2
* basf2 (Belle II Analysis Software Framework) *
3
* Author: The Belle II Collaboration *
4
* *
5
* See git log for contributors and copyright holders. *
6
* This file is licensed under LGPL-3.0, see LICENSE.md. *
7
**************************************************************************/
8
#include <string>
9
10
#include <stdio.h>
11
#include <stdlib.h>
12
#include <unistd.h>
13
14
#include "framework/pcore/SeqFile.h"
15
#include "framework/pcore/RingBuffer.h"
16
#include "framework/pcore/EvtMessage.h"
17
18
#define RBUFSIZE 100000000
19
#define MAXEVTSIZE 400000000
20
21
using namespace
Belle2
;
22
using namespace
std;
23
24
int
main
(
int
argc,
char
** argv)
25
{
26
if
(argc < 3) {
27
printf(
"file2rb : rbufname filename neof\n"
);
28
exit(-1);
29
}
30
31
SeqFile
* file =
new
SeqFile
(argv[2],
"w"
);
32
if
(file->status() <= 0) {
33
perror(
"file open"
);
34
exit(-1);
35
}
36
// RingBuffer* rbuf = new RingBuffer(argv[1], RBUFSIZE);
37
RingBuffer
* rbuf =
new
RingBuffer
(argv[1]);
38
char
* evbuf =
new
char
[MAXEVTSIZE];
39
40
for
(;;) {
41
// Get a record from ringbuf
42
int
size;
43
while
((size = rbuf->
remq
((
int
*)evbuf)) == 0) {
44
// printf ( "Rx : evtbuf is not available yet....\n" );
45
// usleep(100);
46
usleep(20);
47
}
48
EvtMessage
* msg =
new
EvtMessage
(evbuf);
49
if
(msg->
type
() == MSG_TERMINATE) {
50
printf(
"EoF found. Exitting.....\n"
);
51
}
52
53
// Put the record in a file
54
int
wstat = file->write(evbuf);
55
if
(wstat <= 0) {
56
perror(
"write"
);
57
exit(-99);
58
}
59
delete
msg;
60
}
61
}
62
63
64
65
Belle2::EvtMessage
Class to manage streamed object.
Definition:
EvtMessage.h:59
Belle2::EvtMessage::type
ERecordType type() const
Get record type.
Definition:
EvtMessage.cc:114
Belle2::RingBuffer
Class to manage a Ring Buffer placed in an IPC shared memory.
Definition:
RingBuffer.h:39
Belle2::RingBuffer::remq
int remq(int *buf)
Pick up a buffer from the RingBuffer.
Definition:
RingBuffer.cc:308
Belle2::SeqFile
A class to manage I/O for a chain of blocked files.
Definition:
SeqFile.h:22
Belle2
Abstract base class for different kinds of events.
Definition:
MillepedeAlgorithm.h:17
main
int main(int argc, char **argv)
Run all tests.
Definition:
test_main.cc:91
daq
rfarm
event
tools
rb2file.cc
Generated on Mon Sep 23 2024 14:01:15 for Belle II Software by
1.9.1