Belle II Software  release-08-01-10
ARICHBkg.py
1 #!/usr/bin/env python3
2 
3 
10 
11 #
12 # This is example script to run extract ARICH background relevant data
13 # from prepared background samples. In runs ARICHBackground module and
14 # produces root file with TTree, needed to produce arich background plots.
15 #
16 # Please check and adjust input file list and method, as this example is
17 # specific for background files produced by Nakayama-san.
18 #
19 
20 import sys
21 import basf2 as b2
22 b2.logging.log_level = b2.LogLevel.WARNING
23 
24 print('')
25 print('Use the script as: basf2 ARICHBkg.py arguments')
26 print('Arguments are in the following order: type (RBB,Touschek_HER,...), path to files , '
27  'job number , number of input files')
28 print('')
29 print('example: basf2 ARICHBkg.py RBB /gpfs/home/belle/nakayama/basf2_opt/release_201502_development/Work_MCgen/output/ 2 100 0')
30 print('will analyse files in output dir with index numbers from 200-299.')
31 print('Background tag is int appended to all hits (to identify contributions from different sources at later analysis')
32 print('0 for RBB, 1 for BHWide, 2 Touschek_HER, 3 Touschek_LER, 4 Coulomb_HER, 5 Coulomb_LER, 6 twoPhoton, 7 brems,' +
33  ' 8 BHWideLargeAngle')
34 print('')
35 
36 typs = ["RBB", "BHWide", "Touschek_HER", "Touschek_LER", "Coulomb_HER", "Coulomb_LER", "twoPhoton", "brems", "BHWideLargeAngle"]
37 
38 # -------------------------
39 # here we register modules
40 # -------------------------
41 
42 input = b2.register_module('RootInput')
43 paramloader = b2.register_module('Gearbox')
44 geobuilder = b2.register_module('Geometry')
45 back = b2.register_module('ARICHBackground')
46 
47 # --------------------------------------
48 # here we set the parameters of modules
49 # --------------------------------------
50 
51 typee = sys.argv[1]
52 path = sys.argv[2]
53 n = int(sys.argv[3])
54 nfiles = int(sys.argv[4])
55 
56 fnames = []
57 
58 # input file naming
59 patha = path + typee + '_study-phase32-'
60 
61 for i in range(n * nfiles, (n + 1) * nfiles):
62  filenn = patha + str(i) + '.root'
63  fnames.append(filenn)
64 
65 # output file name
66 out = 'arich_' + typee + '_' + sys.argv[3] + '_phase32.root'
67 
68 print('Output file: ' + out)
69 
70 input.param('inputFileNames', fnames)
71 geobuilder.param('components', ['ARICH'])
72 back.param('FileName', out)
73 back.param('BkgTag', typs.index(typee))
74 # create path
75 main = b2.create_path()
76 
77 # add modules to path
78 main.add_module(input)
79 main.add_module(paramloader)
80 main.add_module(geobuilder)
81 main.add_module(back)
82 
83 b2.process(main)