Belle II Software  release-05-02-19
particleloader.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 """
5 a test of the ParticleLoader 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 = ['e+', 'pi+', 'K+', 'p+', 'mu+', 'K_S0 -> pi+ pi-', 'Lambda0 -> p+ pi-', 'K_L0', 'gamma', 'n0']
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 
26 # manipulate the string to remove the daughters in case of v0
27 for i in range(len(fsps)):
28  if " -> " in fsps[i]:
29  fsps[i] = fsps[i].split(' ->', 1)[0]
30 
31 # also load MC particles
32 mcps = [particle + ':frommc' for particle in fsps + ['B0', 'D0']]
33 for mcp in mcps:
34  testpath.add_module('ParticleLoader', decayStringsWithCuts=[(mcp, '')],
35  useMCParticles=True)
36 
37 # add RestOfEvents
38 signal_side = 'K_S0'
39 roe_side = 'Upsilon(4S)'
40 testpath.add_module('RestOfEventBuilder', particleList=signal_side,
41  particleListsInput=['pi+', 'gamma', 'K_L0'])
42 # Load RestOfEvents
43 testpath.add_module('ParticleLoader', decayStringsWithCuts=[(roe_side, '')],
44  sourceParticleListName=signal_side, useROEs=True)
45 
46 testpath.add_module('ParticleStats', particleLists=fsps)
47 testpath.add_module('ParticleStats', particleLists=mcps)
48 testpath.add_module('ParticleStats', particleLists=[roe_side])
49 process(testpath)
50 
51 # process the first event (again) with the verbose ParticlePrinter
52 for fsp in fsps:
53  testpath.add_module('ParticlePrinter', listName=fsp, fullPrint=True)
54 process(testpath, 1)
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