Belle II Software light-2406-ragdoll
particleloader.py
1#!/usr/bin/env python3
2
3
10
11"""
12A test of the ParticleLoader using a relatively large test file
13(mdst14.root in the validation data)
14"""
15
16import basf2
17import b2test_utils
18
19# make logging more reproducible by replacing some strings
21basf2.set_random_seed("1337")
22
23fsps = ['e+', 'pi+', 'K+', 'p+', 'mu+', 'K_S0 -> pi+ pi-', 'Lambda0 -> p+ pi-', 'K_L0', 'gamma', 'n0']
24
25
27testpath = basf2.create_path()
28inputFile = b2test_utils.require_file('mdst14.root', 'validation')
29testpath.add_module('RootInput', inputFileName=inputFile)
30for fsp in fsps:
31 testpath.add_module('ParticleLoader', decayStrings=[fsp])
32testpath.add_module('ParticleListManipulator', outputListName='gamma',
33 inputListNames=['gamma:all'], cut='isFromECL')
34
35# manipulate the string to remove the daughters in case of v0
36for i in range(len(fsps)):
37 if " -> " in fsps[i]:
38 fsps[i] = fsps[i].split(' ->', 1)[0]
39
40# also load MC particles
41mcps = [particle + ':MC' for particle in fsps + ['B0', 'D0']]
42testpath.add_module('ParticleLoader', decayStrings=mcps, useMCParticles=True)
43
44# load photons from KLMCluster
45testpath.add_module('ParticleListManipulator', outputListName='gamma:fromKLM',
46 inputListNames=['gamma:all'], cut='isFromKLM')
47
48# add RestOfEvents
49signal_side = 'K_S0:V0'
50roe_side = 'Upsilon(4S):ROE'
51testpath.add_module('RestOfEventBuilder', particleList=signal_side,
52 particleListsInput=['pi+:all', 'gamma', 'K_L0:all'])
53# Load RestOfEvents
54testpath.add_module('ParticleLoader', decayStrings=[roe_side],
55 sourceParticleListName=signal_side, useROEs=True)
56
57for i in range(len(fsps)):
58 if 'K_S0' in fsps[i] or 'Lambda0' in fsps[i]:
59 fsps[i] = fsps[i] + ':V0'
60 elif "gamma" not in fsps[i]:
61 fsps[i] = fsps[i] + ':all'
62
63testpath.add_module('ParticleStats', particleLists=fsps)
64testpath.add_module('ParticleStats', particleLists=mcps)
65testpath.add_module('ParticleStats', particleLists=['gamma:fromKLM'])
66testpath.add_module('ParticleStats', particleLists=[roe_side])
67basf2.process(testpath)
68
69# process the first event (again) with the verbose ParticlePrinter
70for fsp in fsps:
71 testpath.add_module('ParticlePrinter', listName=fsp, fullPrint=True)
72testpath.add_module('ParticlePrinter', listName='gamma:fromKLM', fullPrint=True)
73basf2.process(testpath, 1)
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