Belle II Software  release-08-01-10
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 
19 import basf2 as b2
20 
21 import os
22 import sys
23 import re
24 
25 argvs = sys.argv # get arg
26 argc = len(argvs) # of arg
27 
28 if argc != 2:
29  sys.exit("...py> # of arg is strange.\n 1.rootname\n Exit.")
30 
31 if argc == 2:
32  f_in_root = argvs[1]
33 
34 
35 # set_log_level(LogLevel.ERROR)
36 b2.set_log_level(b2.LogLevel.INFO)
37 
38 b2.use_central_database("TRGGDL_201811")
39 
40 # input
41 if 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())
45 if 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 
50 print(f_in_root)
51 input.param('inputFileName', f_in_root)
52 
53 anarawdata = b2.register_module('TRGRAWDATA')
54 
55 anarawdata.param('nwd_2ds', 3939)
56 anarawdata.param('nwd_3ds', 3939)
57 
58 anarawdata.param('print_dbmap', True)
59 anarawdata.param('print_clkcyc_err', True)
60 anarawdata.param('cc_check', True)
61 anarawdata.param('print_cc', True)
62 anarawdata.param('on_2d0', True)
63 anarawdata.param('on_2d1', True)
64 anarawdata.param('on_2d2', True)
65 anarawdata.param('on_2d3', True)
66 anarawdata.param('on_gdl', True)
67 anarawdata.param('on_sl5', True)
68 anarawdata.param('on_sl6', True)
69 anarawdata.param('on_sl8', False)
70 anarawdata.param('on_etf', False)
71 anarawdata.param('on_grl', False)
72 anarawdata.param('on_nn0', True)
73 anarawdata.param('on_nn1', True)
74 anarawdata.param('on_nn2', True)
75 anarawdata.param('on_nn3', True)
76 anarawdata.param('on_3d0', True)
77 anarawdata.param('on_3d1', True)
78 anarawdata.param('on_3d2', True)
79 anarawdata.param('on_3d3', True)
80 anarawdata.param('on_top', True)
81 anarawdata.param('scale_top', 32)
82 
83 # Create main path
84 main = b2.create_path()
85 
86 # Add modules to main path
87 main.add_module(input)
88 main.add_module(anarawdata)
89 
90 gen_hist = False
91 anarawdata.param('histRecord', False)
92 if gen_hist:
93  if not os.path.isdir('rawdatahist'):
94  os.mkdir('rawdatahist')
95 
96  histo = b2.register_module('HistoManager')
97  histo.param("histoFileName", "rawdatahist/raw.%s.root" % basename)
98  main.add_module(histo)
99 
100 b2.process(main)
101 print(b2.statistics)