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