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