Belle II Software  release-05-01-25
eventsampler.cc
1 //+
2 // File : eventsampler.cc
3 // Description : Sample events from each ERECO processing nodes and
4 // put them in a ring buffer
5 //
6 // Author : Ryosuke Itoh, IPNS, KEK
7 // Date : 31 - Jul - 2017
8 //-
9 
10 #include <cstring>
11 #include <string>
12 #include <vector>
13 
14 #include <stdio.h>
15 #include <stdlib.h>
16 
17 #include "daq/expreco/EventSampler.h"
18 #include "daq/rfarm/manager/RFConf.h"
19 
20 using namespace Belle2;
21 using namespace std;
22 
23 int main(int argc, char** argv)
24 {
25  // Retrieve RingBuffer name[1], port number[2], Shmname[3], and id[4]
26  if (argc < 2) {
27  printf("syntax : eventsampler configfile\n");
28  exit(-1);
29  }
30 
31  RFConf* conf = new RFConf(argv[1]);
32 
33  int nnodes = 0;
34  int maxnodes = conf->getconfi("processor", "nnodes");
35  int idbase = conf->getconfi("processor", "idbase");
36  char* hostbase = conf->getconf("processor", "ctlhostbase");
37  char* badlist = conf->getconf("processor", "badlist");
38 
39  vector<string> nodelist;
40  char hostname[512], idname[3], shmid[3];
41  for (int i = 0; i < maxnodes; i++) {
42  sprintf(idname, "%2.2d", idbase + i);
43  sprintf(shmid, "%2.2d", i);
44  if (badlist == NULL ||
45  strstr(badlist, idname) == 0) {
46  sprintf(hostname, "%s%2.2d", hostbase, idbase + i);
47  nodelist.push_back(string(hostname));
48  nnodes++;
49  }
50  }
51 
52  int port = conf->getconfi("processor", "eventserver", "port");
53 
54  char* rbuf = conf->getconf("eventsampler", "ringbufout");
55  int interval = conf->getconfi("eventsampler", "interval");
56 
57  EventSampler es(nodelist, port, rbuf, interval);
58 
59  es.server();
60 }
61 
62 
63 
Belle2::EventSampler
Definition: EventSampler.h:25
main
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:77
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::RFConf
Definition: RFConf.h:24