Belle II Software  release-05-01-25
rf_eventprocessor.cc
1 //+
2 // File : RFEventServer.cc
3 // Description : Receive data from event builder 1 and distribute them to
4 // Processing nodes
5 //
6 // Author : Ryosuke Itoh, IPNS, KEK
7 // Date : 24 - June - 2013
8 // Daet : 17 - Oct - 2013, Special version for DESY test nodes
9 //-
10 
11 //#define DESY
12 
13 #include "daq/rfarm/manager/RFEventProcessor.h"
14 #include "daq/rfarm/manager/RFNSM.h"
15 
16 #include <unistd.h>
17 
18 #include <csignal>
19 #include <cstring>
20 
21 using namespace std;
22 using namespace Belle2;
23 
24 static RFEventProcessor* evproc = NULL;
25 
26 extern "C" void sighandler(int sig)
27 {
28  printf("SIGTERM handler here\n");
29  evproc->cleanup();
30 }
31 
32 int main(int argc, char** argv)
33 {
34  RFConf conf(argv[1]);
35 
36  // RFEventProcessor* evproc = new RFEventProcessor(argv[1]);
37  evproc = new RFEventProcessor(argv[1]);
38 
39  char nodename[256];
40  strcpy(nodename, "evp_");
41 #ifndef DESY
42  gethostname(&nodename[4], sizeof(nodename));
43 #else
44  // Special treatment for DESY test nodes!!
45  char hostnamebuf[256];
46  gethostname(hostnamebuf, sizeof(hostnamebuf));
47  strcat(&nodename[4], &hostnamebuf[6]);
48  int lend = strlen(nodename);
49  nodename[lend + 1] = (char)0;
50  nodename[lend] = nodename[lend - 1];
51  strncpy(&nodename[lend - 1], "0", 1);
52  printf("DESY node name = %s\n", nodename);
53  // End of DESY special treatment
54 #endif
55 
56  signal(SIGINT, sighandler);
57  signal(SIGTERM, sighandler);
58 
59  RFNSM nsm(nodename, evproc);
60  nsm.AllocMem(conf.getconf("system", "nsmdata"));
61  evproc->SetNodeInfo(nsm.GetNodeInfo());
62 
63  evproc->server();
64 
65 }
Belle2::RFEventProcessor
Definition: RFEventProcessor.h:31
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::RFNSM
Definition: RFNSM.h:61
Belle2::RFConf
Definition: RFConf.h:24