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