Belle II Software  release-05-01-25
particleloader_clone.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 """
5 A clone of the test of the ParticleLoader using a larger test file (mdst12.root)
6 this is not present on the bamboo server so this test only runs on buildbot or
7 wherever the validation-data are visible (it's also a bit slower).
8 """
9 
10 import basf2
11 import b2test_utils
12 
13 inputFile = b2test_utils.require_file('mdst12.root', 'validation')
14 # make logging more reproducible by replacing some strings
16 basf2.set_random_seed("1337")
17 fsps = ['e+', 'pi+', 'K+', 'p+', 'mu+', 'K_S0 -> pi+ pi-', 'Lambda0 -> p+ pi-', 'K_L0', 'gamma', 'n0']
18 
19 
21 testpath = basf2.create_path()
22 testpath.add_module('RootInput', inputFileName=inputFile)
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 # add RestOfEvents
37 signal_side = 'K_S0'
38 roe_side = 'Upsilon(4S)'
39 testpath.add_module('RestOfEventBuilder', particleList=signal_side,
40  particleListsInput=['pi+', 'gamma', 'K_L0'])
41 # Load RestOfEvents
42 testpath.add_module('ParticleLoader', decayStringsWithCuts=[(roe_side, '')],
43  sourceParticleListName=signal_side, useROEs=True)
44 
45 
46 testpath.add_module('ParticleStats', particleLists=fsps)
47 testpath.add_module('ParticleStats', particleLists=mcps)
48 testpath.add_module('ParticleStats', particleLists=[roe_side])
49 basf2.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 basf2.process(testpath, 1)
b2test_utils.configure_logging_for_tests
def configure_logging_for_tests(user_replacements=None)
Definition: __init__.py:99
basf2.process
def process(path, max_event=0)
Definition: __init__.py:25
b2test_utils.require_file
def require_file(filename, data_type="", py_case=None)
Definition: __init__.py:47