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