Belle II Software development
pxd_gain_validation.py
1
8
9'''
10Validation of PXD gain calibration.
11'''
12
13
14from prompt import ValidationSettings
15import sys
16import subprocess
17from glob import glob
18
19
20
21settings = ValidationSettings(name='PXD gain calibration',
22 description=__doc__,
23 download_files=['PXDPerformanceVariablesCollectorValidation.root'],
24 expert_config={})
25
26
27def run_validation(job_path, input_data_path, requested_iov, expert_config):
28 '''
29 Run the validation.
30 '''
31 from conditions_db.testing_payloads import parse_testing_payloads_file
32 txt_files = glob(f"{job_path}/*PXD*Gain*/outputdb/database.txt")
33 cmds = ["b2pxd-db-check", "--only-hist", "--maps",
34 "PXDGainMapPar"]
35 for txt_file in txt_files:
36 iov_entries = parse_testing_payloads_file(txt_file)
37 exp = iov_entries[0].firstRun["exp"]
38 run = iov_entries[0].firstRun["run"]
39 cmds_add = ["--tag", txt_file,
40 "--exp", f"{exp}", "--runs", f"{run}-9999",
41 "-o", f"conditions_gain_e{exp}_r{run}.root"]
42 subprocess.run(cmds + cmds_add, check=True)
43
44 root_files = glob(f"{job_path}/*PXD*Gain*/*/algorithm_output/PXDPerformanceVariablesCollectorValidation.root")
45 for root_file in root_files:
46 cmds = ["b2pxd-val", "-i", root_file]
47 subprocess.run(cmds, check=True)
48
49
50if __name__ == "__main__":
51 run_validation(*sys.argv[1:])