Belle II Software  release-08-01-10
DataStoragerRoot.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 import basf2 as b2
5 import hbasf2
6 import sys
7 import socket
8 
9 
10 b2.logging.add_udp(socket.gethostname(), 6900)
11 
12 hltid = [int(i) for i in socket.gethostname().split('store') if i.isdigit()][0]
13 hltname = 'HLT%02d' % hltid
14 ndisk = 3
15 if hltid == 1 or hltid == 2:
16  ndisk = 4
17 
18 argv = sys.argv
19 
20 b2.set_nprocesses(int(argv[1])) # zmq
21 
22 b2.conditions.override_globaltags(["online"])
23 
24 # Create main path
25 main = b2.create_path()
26 outpath = b2.create_path()
27 phypath = b2.create_path()
28 
29 # Set the log level to show only error and fatal messages
30 # set_log_level(LogLevel.ERROR)
31 # set_log_level(LogLevel.INFO)
32 # set_log_level(LogLevel.DEBUG)
33 # set_debug_level(30)
34 
35 zmq2ds = b2.register_module('StorageZMQ2Ds')
36 zmq2ds.param('addExpressRecoObjects', 1)
37 zmq2ds.param('inInitialize', True)
38 zmq2ds.param('input', argv[2]) # hbasf2
39 
40 ds2zmq = b2.register_module('HLTDs2ZMQ')
41 ds2zmq.param('output', argv[3]) # hbasf2
42 ds2zmq.param('raw', False)
43 
44 ds2zmq_phy = b2.register_module('HLTDs2ZMQ')
45 ds2zmq_phy.param('output', argv[4]) # hbasf2
46 ds2zmq_phy.param('raw', False)
47 
48 output_root = b2.register_module('StorageRootOutput')
49 output_root.param('additionalDataDescription', {"dataLevel": "raw"})
50 output_root.param('compressionAlgorithm', int(argv[5]))
51 output_root.param('compressionLevel', int(argv[6]))
52 output_root.param('runType', argv[7])
53 output_root.param('HLTName', hltname)
54 output_root.param('nDisk', ndisk)
55 output_root.param('skipFirstEvent', True)
56 output_root.param('outputSplitSize', 210) # Megabytes, should be controlled outside of basf2
57 
58 hltskim = b2.register_module('TriggerSkim')
59 # This trigger line should be controlled outside of the script
60 # Maybe, through config file in daq_slc
61 hltskim.param('triggerLines',
62  [
63  ('software_trigger_cut&skim&accept_dstar_1', 1),
64  ('software_trigger_cut&skim&accept_dstar_2', 2)
65  ])
66 hltskim.param('resultOnMissing', 1)
67 hltskim.param('skipFirstEvent', True)
68 hltskim.if_value(">0", phypath, b2.AfterConditionPath.END)
69 
70 output_root.set_property_flags(b2.ModulePropFlags.PARALLELPROCESSINGCERTIFIED) # zmq
71 zmq2ds.set_property_flags(b2.ModulePropFlags.PARALLELPROCESSINGCERTIFIED) # zmq
72 ds2zmq.set_property_flags(b2.ModulePropFlags.PARALLELPROCESSINGCERTIFIED) # zmq
73 ds2zmq_phy.set_property_flags(b2.ModulePropFlags.PARALLELPROCESSINGCERTIFIED) # zmq
74 hltskim.set_property_flags(b2.ModulePropFlags.PARALLELPROCESSINGCERTIFIED) # zmq
75 
76 
77 # Add modules to main path
78 main.add_module(zmq2ds) # zmq
79 
80 # if "null" not in argv[7].lower():
81 if "hlttest" in argv[7].lower():
82  main.add_module(output_root)
83 
84 main.add_module(ds2zmq)
85 main.add_module(hltskim)
86 phypath.add_module(ds2zmq_phy)
87 
88 # Process all events
89 hbasf2.processNumbered(main, [], False, True) # zmq