Belle II Software development
run_pulseHeight_calibration_rawdata.py
1#!/usr/bin/env python3
2
3
10
11# ---------------------------------------------------------------------------------------
12# CAF calibration script: pulse height distributions and threshold efficiencies
13# data type: raw data
14#
15# usage: basf2 run_pulseHeight_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 pulseHeight_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'
31#
32# ---------------------------------------------------------------------------------------
33
34# Argument parsing
35argvs = sys.argv
36if len(argvs) < 4:
37 print("usage: basf2", argvs[0], "experiment runFirst runLast")
38 sys.exit()
39experiment = int(argvs[1])
40run_first = int(argvs[2])
41run_last = int(argvs[3])
42
43# Make list of files
44inputFiles = []
45expNo = 'e' + f'{experiment:04d}'
46for run in range(run_first, run_last + 1):
47 runNo = 'r' + f'{run:05d}'
48 filename = f"{data_dir}/{expNo}/{runNo}/sub00/physics.*.root"
49 inputFiles += glob.glob(filename)
50
51if len(inputFiles) == 0:
52 B2ERROR('No rawdata files found in ' + data_dir + ' for exp=' + str(experiment) +
53 ' runFirst=' + str(run_first) + ' runLast=' + str(run_last))
54 sys.exit()
55
56# Output folder name
57run_range = 'r' + f'{run_first:05d}' + '-' + f'{run_last:05d}'
58output_dir = f"{main_output_dir}/pulseHeight-rawdata-{expNo}-{run_range}"
59
60# Define calibration
61cal = pulseHeight_calibration_rawdata(inputFiles, globalTags, localDBs)
62cal.backend_args = {"queue": "s"}
63
64# Add calibration to CAF
65cal_fw = CAF()
66cal_fw.add_calibration(cal)
67cal_fw.output_dir = output_dir
68cal_fw.backend = backends.LSF()
69
70# Run calibration
71cal_fw.run()