Belle II Software development
trggdlDataTsim.py
1#!/usr/bin/env python3
2
3
10
11# -----------------------------------------------------------------------------------
12#
13# Example of GDL trigger Summary Module
14#
15# usage : %> basf2 trggdlSummary.py [input sroot file name]
16#
17# -----------------------------------------------------------------------------------
18
19import basf2 as b2
20
21import sys # get argv
22import re
23import os.path
24argvs = sys.argv # get arg
25argc = len(argvs) # of arg
26if argc != 2:
27 sys.exit("trggdlSummary.py> # of arg is strange. Exit.")
28if argc == 2:
29 f_in_root = argvs[1]
30
31
32b2.set_log_level(b2.LogLevel.INFO)
33
34# 0
35# use_central_database("online")
36# use_local_database("./localdb/database.txt")
37# use_central_database("staging_online")
38
39# use_central_database("master_2019-09-26")
40# use_central_database("data_reprocessing_prompt_bucket6")
41# use_central_database("TRGGDL_201811")
42# use_central_database("online")
43# use_central_database("staging_online")
44
45# 1
46b2.conditions.disable_globaltag_replay()
47b2.conditions.prepend_testing_payloads('./localdb/database.txt')
48
49# 2
50# b2.conditions.disable_globaltag_replay()
51# b2.conditions.globaltags = ['data_reprocessing_prompt_rel4_patchb', 'online']
52# b2.conditions.prepend_testing_payloads('./localdb/database.txt')
53
54main = b2.create_path()
55
56# input
57if f_in_root[-6:] == ".sroot":
58 rootfiletype = "sroot"
59 input = b2.register_module('SeqRootInput')
60 matchobj = re.search("([^\\/]+)\\.sroot", f_in_root)
61 basename = re.sub('\\.sroot$', '', matchobj.group())
62if f_in_root[-5:] == ".root":
63 rootfiletype = "root"
64 input = b2.register_module('RootInput')
65 matchobj = re.search("([^\\/]+)\\.root", f_in_root)
66 basename = re.sub('\\.root$', '', matchobj.group())
67
68input.param('inputFileName', f_in_root)
69main.add_module(input)
70
71
72# Unpacker
73trggdlUnpacker = b2.register_module("TRGGDLUnpacker")
74# trggdlUnpacker.param('print_dbmap', True)
75main.add_module(trggdlUnpacker)
76
77#
78trggdlsummary = b2.register_module('TRGGDLSummary')
79main.add_module(trggdlsummary)
80
81datatsim = b2.register_module('TRGGDL')
82datatsim.param('SimulationMode', 3)
83datatsim.param('Belle2Phase', "Belle2Phase")
84# datatsim.param('algFromDB', False)
85# datatsim.param('algFilePath', "ftd_0023.alg")
86main.add_module(datatsim)
87
88histo = b2.register_module('HistoManager')
89histo.param("histoFileName", f"trgsum/dsim.{basename}.root")
90main.add_module(histo)
91if not os.path.isdir('trgsum'):
92 os.mkdir('trgsum')
93
94progress = b2.register_module('Progress')
95main.add_module(progress)
96
97# main.add_module(output, branchNames=["TRGSummary"])
98
99b2.process(main)
100# process(main, max_event=200)
101
102print(b2.statistics)