Belle II Software development
best_candidate_selection_reserved.py
1#!/usr/bin/env python3
2
3
10
11'''
12Forbid users from using the Best Candidate Selection module to remove candidates from particle lists with protected identifiers.
13'''
14
15import b2test_utils
16from basf2 import create_path, set_random_seed
17import modularAnalysis as ma
18
19# make logging more reproducible by replacing some strings
21set_random_seed('1337')
22testinput = [b2test_utils.require_file('analysis/tests/mdst.root')]
23
24# the particle list with identifier 'all' cannot be modified
25badpath_all = create_path()
26badpath_all.add_module('RootInput', inputFileNames=testinput)
27badpath_all.add_module('ParticleLoader', decayStrings=['e+:all'])
28ma.rankByLowest("e+:all", "px", numBest=0, path=badpath_all) # legal
29ma.rankByLowest("e+:all", "px", numBest=1, path=badpath_all) # illegal
30b2test_utils.safe_process(badpath_all, 1)
31
32# same for identifier 'MC'
33badpath_MC = create_path()
34badpath_MC.add_module('RootInput', inputFileNames=testinput)
35ma.fillParticleListFromMC("e-:MC", "", path=badpath_MC)
36ma.rankByLowest("e+:MC", "px", numBest=0, path=badpath_MC) # legal
37ma.rankByLowest("e+:MC", "px", numBest=1, path=badpath_MC) # illegal
38b2test_utils.safe_process(badpath_MC, 1)
39
40# and identifier V0
41badpath_V0 = create_path()
42badpath_V0.add_module('RootInput', inputFileNames=testinput)
43ma.fillParticleList('K_S0:V0 -> pi+ pi-', '', True, path=badpath_V0)
44ma.rankByLowest("K_S0:V0", "px", numBest=0, path=badpath_V0) # legal
45ma.rankByLowest("K_S0:V0", "px", numBest=1, path=badpath_V0) # illegal
46b2test_utils.safe_process(badpath_V0, 1)
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:54
def safe_process(*args, **kwargs)
Definition: __init__.py:236
def configure_logging_for_tests(user_replacements=None)
Definition: __init__.py:106