Belle II Software  release-05-01-25
roemodules.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 """
5 a test of the ROE-related modules using the small test file for running quickly
6 there is a clone of this file which requires the presence of mdst12.root (a
7 larger file) that is present on the buildbot server but not bamboo
8 """
9 
10 import b2test_utils
11 from basf2 import set_random_seed, create_path, process
12 
13 # make logging more reproducible by replacing some strings
15 set_random_seed("1337")
16 testinput = [b2test_utils.require_file('analysis/tests/mdst.root')]
17 fsps = ['K-', 'pi-', 'gamma', 'K_L0']
18 
19 
21 testpath = create_path()
22 testpath.add_module('RootInput', inputFileNames=testinput)
23 for fsp in fsps:
24  testpath.add_module('ParticleLoader', decayStringsWithCuts=[(fsp, '')])
25 testpath.add_module('ParticleStats', particleLists=[fsps[0]])
26 
27 testpath.add_module('RestOfEventBuilder', particleList=fsps[0],
28  particleListsInput=['pi+', 'gamma', 'K_L0'])
29 mask = ('cleanMask', 'E > 0.05', 'E > 0.05')
30 testpath.add_module('RestOfEventInterpreter', particleList=fsps[0],
31  ROEMasks=mask)
32 
33 
34 roe_path = create_path()
35 v0list = 'K_S0 -> pi+ pi-'
36 roe_path.add_module('ParticleLoader', decayStringsWithCuts=[(v0list, '')])
37 
38 roe_path.add_module('ParticleLoader', decayStringsWithCuts=[('mu+:roe',
39  'isInRestOfEvent == 1 and isSignal == 1')])
40 
41 roe_path.add_module('RestOfEventUpdater',
42  particleList=v0list.split(' ->', 1)[0],
43  updateMasks=[mask[0]])
44 roe_path.add_module('RestOfEventPrinter',
45  maskNames=[mask[0]],
46  fullPrint=False)
47 
48 jpsi_roe_list = 'J/psi:roe'
49 roe_path.add_module('ParticleCombiner',
50  decayString=jpsi_roe_list+' -> mu+:roe mu-:roe',
51  cut='')
52 
53 roe_path.add_module('RestOfEventBuilder', particleList=jpsi_roe_list,
54  createNestedROE=True, nestedROEMask=mask[0])
55 
56 # --------------------------------------------------------------------------- #
57 nested_roe_path = create_path()
58 
59 nested_roe_path.add_module('RestOfEventPrinter',
60  fullPrint=False)
61 
62 roe_path.for_each('RestOfEvent', 'NestedRestOfEvents', path=nested_roe_path)
63 # --------------------------------------------------------------------------- #
64 
65 nested_list = 'B+:other'
66 roe_path.add_module('ParticleLoader',
67  decayStringsWithCuts=[(nested_list+' -> '+jpsi_roe_list, '')],
68  useROEs=True)
69 
70 roe_path.add_module('ParticleStats', particleLists=[nested_list])
71 roe_path.add_module('ParticlePrinter', listName=nested_list, fullPrint=True)
72 
73 testpath.for_each('RestOfEvent', 'RestOfEvents', path=roe_path)
74 
75 
76 process(testpath, 5)
b2test_utils.configure_logging_for_tests
def configure_logging_for_tests(user_replacements=None)
Definition: __init__.py:99
b2test_utils.require_file
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:47