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