Belle II Software development
rawdata.py
1#!/usr/bin/env python
2
3
10
11# -----------------------------------------------------------------------------------
12#
13# GDL trigger Unpacker module
14#
15# usage : %> basf2 TrgGdlUnpacker.py [input sroot file name]
16#
17# -----------------------------------------------------------------------------------
18
19import basf2 as b2
20
21import os
22import sys
23import re
24
25argvs = sys.argv # get arg
26argc = len(argvs) # of arg
27
28if argc != 2:
29 sys.exit("...py> # of arg is strange.\n 1.rootname\n Exit.")
30
31if argc == 2:
32 f_in_root = argvs[1]
33
34
35# set_log_level(LogLevel.ERROR)
36b2.set_log_level(b2.LogLevel.INFO)
37
38b2.use_central_database("TRGGDL_201811")
39
40# input
41if f_in_root[-6:] == ".sroot":
42 input = b2.register_module('SeqRootInput')
43 matchobj = re.search("([^\\/]+)\\.sroot", f_in_root)
44 basename = re.sub('\\.sroot$', '', matchobj.group())
45if f_in_root[-5:] == ".root":
46 input = b2.register_module('RootInput')
47 matchobj = re.search("([^\\/]+)\\.root", f_in_root)
48 basename = re.sub('\\.root$', '', matchobj.group())
49
50print(f_in_root)
51input.param('inputFileName', f_in_root)
52
53anarawdata = b2.register_module('TRGRAWDATA')
54
55anarawdata.param('nwd_2ds', 3939)
56anarawdata.param('nwd_3ds', 3939)
57
58anarawdata.param('print_dbmap', True)
59anarawdata.param('print_clkcyc_err', True)
60anarawdata.param('cc_check', True)
61anarawdata.param('print_cc', True)
62anarawdata.param('on_2d0', True)
63anarawdata.param('on_2d1', True)
64anarawdata.param('on_2d2', True)
65anarawdata.param('on_2d3', True)
66anarawdata.param('on_gdl', True)
67anarawdata.param('on_sl5', True)
68anarawdata.param('on_sl6', True)
69anarawdata.param('on_sl8', False)
70anarawdata.param('on_etf', False)
71anarawdata.param('on_grl', False)
72anarawdata.param('on_nn0', True)
73anarawdata.param('on_nn1', True)
74anarawdata.param('on_nn2', True)
75anarawdata.param('on_nn3', True)
76anarawdata.param('on_3d0', True)
77anarawdata.param('on_3d1', True)
78anarawdata.param('on_3d2', True)
79anarawdata.param('on_3d3', True)
80anarawdata.param('on_top', True)
81anarawdata.param('scale_top', 32)
82
83# Create main path
84main = b2.create_path()
85
86# Add modules to main path
87main.add_module(input)
88main.add_module(anarawdata)
89
90gen_hist = False
91anarawdata.param('histRecord', False)
92if gen_hist:
93 if not os.path.isdir('rawdatahist'):
94 os.mkdir('rawdatahist')
95
96 histo = b2.register_module('HistoManager')
97 histo.param("histoFileName", f"rawdatahist/raw.{basename}.root")
98 main.add_module(histo)
99
100b2.process(main)
101print(b2.statistics)