Belle II Software development
dump_header.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
9#include <stdio.h>
10#include <unistd.h>
11#include <vector>
12
13using namespace std;
14
15enum {
16 POS_NWORDS = 0,
17 POS_HDR_NWORDS = 1,
18 POS_NUM_EVE_NUM_NODES = 2,
19 POS_EXP_RUN_NUM = 3,
20 POS_EVE_NUM = 4,
21 POS_NODE_ID = 5
22};
23
24enum {
25 EXP_MASK = 0xFFC00000,
26 EXP_SHIFT = 22,
27 RUNNO_MASK = 0x003FFF00,
28 RUNNO_SHIFT = 8,
29 SUBRUNNO_MASK = 0x000000FF
30};
31
32
33
34int main()
35{
36 vector<unsigned int> buf(400000);
37 int infn = fileno(stdin);
38 printf("infn = %d\n", infn);
39
40 int nrec = 0;
41 for (;;) {
42 int is = read(infn, &buf[0], 4);
43 // printf ( "buf[0] = %d\n", buf[0] );
44 if (is <= 0) break;
45 is = read(infn, &buf[1], (buf[0] - 1) * 4);
46 // printf ( "nw = %d, 1st = %d, 2nd = %d, 3rd = %d\n",
47 // buf[0], buf[1], buf[2], buf[3] );
48 // printf ( "exprunnum = %8.8x, evtnum = %8.8x\n", buf[POS_EXP_RUN_NUM],
49 // buf[POS_EVE_NUM] );
50 int exp = (buf[ POS_EXP_RUN_NUM ] & EXP_MASK) >> EXP_SHIFT;
51 int run = (buf[ POS_EXP_RUN_NUM ] & RUNNO_MASK) >> RUNNO_SHIFT;
52 int evt = buf[ POS_EVE_NUM ];
53
54 printf("Nrec:%d ; Nw:%u ; Exp:%d, Run:%d, Evt:%d\n",
55 nrec, buf[0], exp, run, evt);
56 nrec++;
57 }
58
59}
STL namespace.