Belle II Software development
pid_priors.py
1#!/usr/bin/env python3
2
3
10
11from basf2 import set_random_seed, create_path, register_module, process, find_file
12from b2test_utils import clean_working_directory, require_file, configure_logging_for_tests, is_ci, skip_test
13import modularAnalysis as ma
14import subprocess
15
16
17if is_ci():
18 skip_test("The test is too slow for running on our pipeline")
19
20configure_logging_for_tests()
21set_random_seed('pid_priors')
22
23with clean_working_directory():
24
25 main = create_path()
26
27 inputfile = require_file('analysis/1000_B_DstD0Kpi_skimmed.root', 'validation')
28 ma.inputMdst(inputfile, path=main)
29
30 ma.fillParticleList('pi+', '', path=main)
31 ma.matchMCTruth('pi+', path=main)
32
33 ntupler = register_module('VariablesToNtuple')
34 ntupler.param('fileName', 'pid_priors.root')
35 ntupler.param('variables', ['cosTheta', 'p', 'mcPDG'])
36 ntupler.param('particleList', 'pi+')
37 main.add_module(ntupler)
38
39 process(main)
40
41 assert 0 == subprocess.run(['analysis-train-priors', '-i', 'pid_priors.root', '-k', 'ntuple', '-o',
42 'pid_priors.pth', '-p', '211', '321'], stdout=subprocess.DEVNULL).returncode
43
44 assert 0 == subprocess.run(['basf2', find_file('analysis/tests/pid_priors.py_noexec')]).returncode