Belle II Software development
run_BS13d_calibration_rawdata.py
1#!/usr/bin/env python3
2
3
10
11# ---------------------------------------------------------------------------------------
12# CAF calibration script: BS13d carrier shifts
13# data type: raw data
14#
15# usage: basf2 run_BS13d_calibration_rawdata.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 BS13d_calibration_rawdata
24
25# ----- those parameters need to be adjusted before running -----------------------------
26#
27globalTags = ['Reco_master_patch', 'data_reprocessing_proc10'] # highest priority first
28localDBs = [] # highest priority first, local DB's have higher priority than global tags
29data_dir = '/group/belle2/dataprod/Data/Raw'
30main_output_dir = 'top_calibration'
31maxFiles = 10 # maximum number of input files per run (0 or negative means all)
32#
33# ---------------------------------------------------------------------------------------
34
35# Argument parsing
36argvs = sys.argv
37if len(argvs) < 4:
38 print("usage: basf2", argvs[0], "experiment runFirst runLast")
39 sys.exit()
40experiment = int(argvs[1])
41run_first = int(argvs[2])
42run_last = int(argvs[3])
43
44# Make list of files
45inputFiles = []
46expNo = 'e' + f'{experiment:04d}'
47for run in range(run_first, run_last + 1):
48 runNo = 'r' + f'{run:05d}'
49 filename = f"{data_dir}/{expNo}/{runNo}/sub00/physics.*.root"
50 files = glob.glob(filename)
51 if maxFiles > 0:
52 for i in range(min(len(files), maxFiles)):
53 inputFiles.append(files[i])
54 else:
55 inputFiles += files
56
57if len(inputFiles) == 0:
58 B2ERROR('No rawdata files found in ' + data_dir + ' for exp=' + str(experiment) +
59 ' runFirst=' + str(run_first) + ' runLast=' + str(run_last))
60 sys.exit()
61
62# Output folder name
63run_range = 'r' + f'{run_first:05d}' + '-' + f'{run_last:05d}'
64output_dir = f"{main_output_dir}/BS13d-rawdata-{expNo}-{run_range}"
65
66# Define calibration
67cal = BS13d_calibration_rawdata(inputFiles, globalTags, localDBs)
68cal.backend_args = {"queue": "s"}
69
70# Add calibration to CAF
71cal_fw = CAF()
72cal_fw.add_calibration(cal)
73cal_fw.output_dir = output_dir
74cal_fw.backend = backends.LSF()
75
76# Run calibration
77cal_fw.run()