Belle II Software development
run_moduleT0_with_cosmics.py
1#!/usr/bin/env python3
2
3
10
11# ---------------------------------------------------------------------------------------
12# CAF calibration script: module T0 with cosmics
13# data type: raw or cdst
14#
15# usage: basf2 run_moduleT0_with_cosmics.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 moduleT0_calibration_cosmics
24
25# ----- those parameters need to be adjusted before running -----------------------------
26#
27globalTags = ['patch_main_release-08',
28 'patch_main_release-07_noTOP',
29 'data_reprocessing_prompt',
30 'online'] # highest priority first
31localDBs = [] # highest priority first, local DB's have higher priority than global tags
32data_dir = '/gpfs/group/belle2/dataprod/Data/PromptSkim'
33skim_dir = 'skim/cosmic_calib'
34data_format = 'raw' # raw or cdst
35full_reco = True # run full cosmic reconstruction if data_format == 'cdst' (we need separate track segments!)
36main_output_dir = 'top_calibration'
37#
38# ---------------------------------------------------------------------------------------
39
40# Argument parsing
41argvs = sys.argv
42if len(argvs) < 4:
43 print("usage: basf2", argvs[0], "experiment runFirst runLast")
44 sys.exit()
45experiment = int(argvs[1])
46run_first = int(argvs[2])
47run_last = int(argvs[3])
48
49# Make list of files
50inputFiles = []
51expNo = 'e' + f'{experiment:04d}'
52for run in range(run_first, run_last + 1):
53 runNo = 'r' + f'{run:05d}'
54 filename = f"{data_dir}/{expNo}/*/{runNo}/{skim_dir}/{data_format}/sub00/*.root"
55 inputFiles += glob.glob(filename)
56
57if len(inputFiles) == 0:
58 B2ERROR('No files found in ' + data_dir + ' for exp=' + str(experiment) +
59 ' runFirst=' + str(run_first) + ' runLast=' + str(run_last) +
60 ' (skim_dir=' + skim_dir + ')')
61 sys.exit()
62
63# Output folder name
64run_range = 'r' + f'{run_first:05d}' + '-' + f'{run_last:05d}'
65output_dir = f"{main_output_dir}/moduleT0-cosmics-{expNo}-{run_range}"
66
67# Define calibrations
68cal = moduleT0_calibration_cosmics(inputFiles, globalTags, localDBs, data_format, full_reco)
69if data_format == 'raw' or full_reco:
70 cal.backend_args = {"queue": "l"}
71else:
72 cal.backend_args = {"queue": "s"}
73
74# Add calibrations to CAF
75cal_fw = CAF()
76cal_fw.add_calibration(cal)
77cal_fw.output_dir = output_dir
78cal_fw.backend = backends.LSF()
79
80# Run calibration
81cal_fw.run()