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