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