Belle II Software  release-08-01-10
sendroi.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 import sys
13 
14 import basf2 as b2
15 # from simulation import register_simulation
16 # from reconstruction import register_reconstruction
17 
18 b2.set_log_level(b2.LogLevel.ERROR)
19 
20 argvs = sys.argv
21 argc = len(argvs)
22 
23 # print argvs[1]
24 # print argc
25 # argvs[1] = input ring buffer
26 # argvs[2] = input ring buffer
27 # argvs[3] = RoI queue name
28 
29 print("MQname = " + argvs[3])
30 
31 # detecor components to be reconstructed
32 components = [
33  'MagneticField',
34  'BeamPipe',
35  'PXD',
36  'SVD',
37  'CDC',
38  'TOP',
39  'ARICH',
40  'BKLM',
41  'ECL',
42 ]
43 
44 # Local database access
45 databasefile = "/dev/shm/LocalDB/database.txt"
46 b2.prepend_testing_payloads(databasefile)
47 
48 # Register modules to declare objects
49 # register_simulation(components)
50 # register_reconstruction(components)
51 
52 # Register RoI related modules for object decoding
53 # roiGen = register_module('ROIGenerator')
54 # roiPayloadAssembler = register_module('ROIPayloadAssembler')
55 
56 # to avoid undefined symbol
57 geom = b2.register_module("Geometry")
58 
59 # create a main path
60 main = b2.create_path()
61 
62 # Add input module
63 # input = register_module("SeqRootInput")
64 # input.param ( "inputFileName", "/fcdisk1-1/data/sim/sim-evtgen.sroot")
65 # main.add_module(input)
66 
67 # Add output module
68 # output= register_module("SeqRootOutput")
69 # output.param ( "outputFileName", "/dev/null" )
70 # main.add_module(output)
71 
72 # Add Rbuf2Ds
73 rbuf2ds = b2.register_module("Rbuf2Ds")
74 # rbuf2ds = register_module("FastRbuf2Ds")
75 rbuf2ds.param("RingBufferName", argvs[1])
76 main.add_module(rbuf2ds)
77 
78 # RoI related codes here
79 # roiReadTest = register_module('ROIReadTest')
80 # param_roiReadTest = {'outfileName': 'ROIoutReceiver.txt',
81 # 'ROIpayloadName': 'ROIpayload'}
82 # roiReadTest.param(param_roiReadTest)
83 # main.add_module(roiReadTest)
84 
85 # RoI sender
86 roisender = b2.register_module('ROISender')
87 roisender.param("MessageQueueName", argvs[3])
88 roisender.param("MessageQueueDepth", 20)
89 roisender.param("MessageSize", 16384)
90 roisender.param("ROIpayloadName", "ROIpayload")
91 main.add_module(roisender)
92 
93 # Add Progress
94 progress = b2.register_module("Progress")
95 progress.param('maxN', 4)
96 main.add_module(progress)
97 
98 # Add Elapsed Time
99 etime = b2.register_module("ElapsedTime")
100 etime.param("EventInterval", 20000)
101 main.add_module(etime)
102 
103 # Add Ds2Raw
104 ds2raw = b2.register_module("Ds2Raw")
105 ds2raw.param("RingBufferName", argvs[2])
106 main.add_module(ds2raw)
107 
108 
109 # Run
110 b2.process(main)