Belle II Software  release-08-01-10
run_channelMask_calibration.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 # ---------------------------------------------------------------------------------------
13 # CAF calibration script: channel masking calibration
14 # data type: cdst
15 #
16 # usage: basf2 run_channelMask_calibration.py expNo runFirst runLast
17 # ---------------------------------------------------------------------------------------
18 
19 import sys
20 import glob
21 from caf import backends
22 from caf.framework import CAF
23 from basf2 import B2ERROR
24 from top_calibration import channel_mask_calibration
25 
26 # ----- those parameters need to be adjusted before running -----------------------
27 #
28 globalTags = ['data_reprocessing_proc11'] # highest priority first
29 localDBs = [] # highest priority first, local DB's have higher priority than global tags
30 data_dir = '/group/belle2/dataprod/Data/OfficialReco/proc11/'
31 skim_dir = 'skim/hlt_hadron/cdst/sub00'
32 main_output_dir = 'top_calibration'
33 new_cdst_format = False # set to True for input in new cdst format
34 #
35 # ---------------------------------------------------------------------------------------
36 
37 # Argument parsing
38 argvs = sys.argv
39 if len(argvs) < 4:
40  print("usage: basf2", argvs[0], "experiment runFirst runLast")
41  sys.exit()
42 experiment = int(argvs[1])
43 run_first = int(argvs[2])
44 run_last = int(argvs[3])
45 
46 # Make list of files
47 inputFiles = []
48 expNo = 'e' + '{:0=4d}'.format(experiment)
49 for run in range(run_first, run_last + 1):
50  runNo = 'r' + '{:0=5d}'.format(run)
51  filename = f"{data_dir}/{expNo}/*/{runNo}/{skim_dir}/cdst*.root"
52  inputFiles += glob.glob(filename)
53 
54 if len(inputFiles) == 0:
55  B2ERROR('No cdst files found in ' + data_dir + ' for exp=' + str(experiment) +
56  ' runFirst=' + str(run_first) + ' runLast=' + str(run_last) +
57  ' (skim_dir=' + skim_dir + ')')
58  sys.exit()
59 
60 # Output folder name
61 run_range = 'r' + '{:0=5d}'.format(run_first) + '-' + '{:0=5d}'.format(run_last)
62 output_dir = f"{main_output_dir}/channelMask-{expNo}-{run_range}"
63 
64 # Define calibration
65 cal = channel_mask_calibration(inputFiles, globalTags, localDBs, new_cdst_format)
66 cal.backend_args = {"queue": "s"}
67 
68 # Add calibration to CAF
69 cal_fw = CAF()
70 cal_fw.add_calibration(cal)
71 cal_fw.output_dir = output_dir
72 cal_fw.backend = backends.LSF()
73 
74 # Run calibration
75 cal_fw.run()