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