Belle II Software development
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
20import sys
21import basf2 as b2
22b2.logging.log_level = b2.LogLevel.WARNING
23
24print('')
25print('Use the script as: basf2 ARICHBkg.py arguments')
26print('Arguments are in the following order: type (RBB,Touschek_HER,...), path to files , '
27 'job number , number of input files')
28print('')
29print('example: basf2 ARICHBkg.py RBB /gpfs/home/belle/nakayama/basf2_opt/release_201502_development/Work_MCgen/output/ 2 100 0')
30print('will analyse files in output dir with index numbers from 200-299.')
31print('Background tag is int appended to all hits (to identify contributions from different sources at later analysis')
32print('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')
34print('')
35
36typs = ["RBB", "BHWide", "Touschek_HER", "Touschek_LER", "Coulomb_HER", "Coulomb_LER", "twoPhoton", "brems", "BHWideLargeAngle"]
37
38# -------------------------
39# here we register modules
40# -------------------------
41
42input = b2.register_module('RootInput')
43paramloader = b2.register_module('Gearbox')
44geobuilder = b2.register_module('Geometry')
45back = b2.register_module('ARICHBackground')
46
47# --------------------------------------
48# here we set the parameters of modules
49# --------------------------------------
50
51typee = sys.argv[1]
52path = sys.argv[2]
53n = int(sys.argv[3])
54nfiles = int(sys.argv[4])
55
56fnames = []
57
58# input file naming
59patha = path + typee + '_study-phase32-'
60
61for i in range(n * nfiles, (n + 1) * nfiles):
62 filenn = patha + str(i) + '.root'
63 fnames.append(filenn)
64
65# output file name
66out = 'arich_' + typee + '_' + sys.argv[3] + '_phase32.root'
67
68print('Output file: ' + out)
69
70input.param('inputFileNames', fnames)
71geobuilder.param('components', ['ARICH'])
72back.param('FileName', out)
73back.param('BkgTag', typs.index(typee))
74# create path
75main = b2.create_path()
76
77# add modules to path
78main.add_module(input)
79main.add_module(paramloader)
80main.add_module(geobuilder)
81main.add_module(back)
82
83b2.process(main)