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