Belle II Software  release-08-01-10
v0_roe_compatibility.py
1 #!/usr/bin/env python3
2 
3 
10 
11 """
12 This is a log-type unit test on compatibility of the ROE and the reconstructed
13 V0 objects created by V0Finder. It runs over a mdst file which contains two muons,
14 converted gamma, K_S0 and Lambda0. It uses two muons as a signal side, so ROE should
15 contain only 3 V0 objects. The mdst file was generated by scripts in the
16 external repository: https://stash.desy.de/projects/B2A/repos/roe-unittest-mc/browse
17 There is no larger equivalent of this test.
18 """
19 
20 import b2test_utils
21 from basf2 import set_random_seed, create_path, process
22 
23 # make logging more reproducible by replacing some strings
25 set_random_seed("1337")
26 testinput = [b2test_utils.require_file('analysis/tests/pgun-roe-mdst.root')]
27 fsp_signal_side = 'mu+'
28 fsp_tag_side = 'pi-'
29 
31 testpath = create_path()
32 testpath.add_module('RootInput', inputFileNames=testinput)
33 testpath.add_module('ParticleLoader', decayStrings=[fsp_signal_side])
34 testpath.add_module('ParticleListManipulator', outputListName=fsp_signal_side,
35  inputListNames=[fsp_signal_side + ':all'], cut='isSignal == 1')
36 testpath.add_module('ParticleLoader', decayStrings=[fsp_tag_side])
37 testpath.add_module('ParticleListManipulator', outputListName=fsp_tag_side, inputListNames=[fsp_tag_side + ':all'])
38 testpath.add_module('ParticleStats', particleLists=[fsp_signal_side])
39 
40 signal_side_name = 'B0'
41 testpath.add_module('ParticleCombiner',
42  decayString=signal_side_name + ' -> mu+ mu-',
43  cut='')
44 
45 testpath.add_module('RestOfEventBuilder', particleList=signal_side_name,
46  particleListsInput=[fsp_tag_side])
47 mask = ('cleanMask', '', '', '')
48 testpath.add_module('RestOfEventInterpreter', particleList=signal_side_name,
49  ROEMasks=mask)
50 
51 
52 roe_path = create_path()
53 
54 v0list = ['gamma:conv -> e+ e-',
55  'Lambda0 -> p+ pi-',
56  'K_S0 -> pi+ pi-']
57 cut = "daughter(0, isSignal) > 0 and daughter(1, isSignal) >0"
58 for v0 in v0list:
59  roe_path.add_module('ParticleLoader', decayStrings=[v0], addDaughters=True)
60  roe_path.add_module('ParticleListManipulator', outputListName=v0.split()[0],
61  inputListNames=[v0.split()[0].split(":")[0] + ':V0'], cut='-0.1 < dM < 0.1')
62  roe_path.add_module('ParticleSelector',
63  decayString=v0.split(' ->', 1)[0],
64  cut=cut)
65 
66  roe_path.add_module('RestOfEventUpdater',
67  particleList=v0.split(' ->', 1)[0],
68  updateMasks=[mask[0]])
69 roe_path.add_module('RestOfEventPrinter',
70  maskNames=[mask[0]],
71  unpackComposites=False,
72  fullPrint=False)
73 testpath.for_each('RestOfEvent', 'RestOfEvents', path=roe_path)
74 
75 testpath.add_module('ParticlePrinter', listName=signal_side_name, fullPrint=False,
76  variables=['nROE_Composites(cleanMask)'])
77 
78 process(testpath, 2)
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