11 import modularAnalysis
as ma
12 from ROOT
import Belle2
18 class Generator(basf2.Module):
19 """Generate list of 10 electrons which have random momenta and one
20 electron where all momentum components are nan"""
23 """We need to register the mc particles"""
26 self.mcp.registerInDataStore()
29 """And then we generate particles"""
31 p = self.mcp.appendNew()
34 p.setMomentum(random.randrange(0, 5), random.randrange(0, 5), random.randrange(0, 5))
36 p = self.mcp.appendNew()
39 p.setMomentum(math.nan, math.nan, math.nan)
42 class MergingChecker(basf2.Module):
43 """Check if merging works correctly"""
46 """Create particle list objects"""
56 """Check if the particle lists have the expected size"""
57 allsize = self.all.getListSize()
58 below2size = self.below2.getListSize()
59 above3size = self.above3.getListSize()
60 onlyallsize = self.onlyall.getListSize()
61 goodmergesize = self.goodmerge.getListSize()
62 bestsize = self.best.getListSize()
64 assert onlyallsize == allsize
65 assert goodmergesize == below2size + above3size
66 assert bestsize == below2size + above3size
71 path.add_module(
"EventInfoSetter", evtNumList=10)
72 path.add_module(Generator())
74 ma.fillParticleListFromMC(
"e-:allMC",
"", path=path)
75 ma.variablesToExtraInfo(
'e-:allMC', {
'formula(0)':
'identifier',
'random':
'quality'}, path=path)
77 ma.fillParticleListFromMC(
"e-:below2",
"px < 2", path=path)
78 ma.variablesToExtraInfo(
'e-:below2', {
'formula(2)':
'identifier',
'formula(1 + random)':
'quality'}, option=2, path=path)
80 ma.fillParticleListFromMC(
"e-:above3",
"px > 3", path=path)
81 ma.variablesToExtraInfo(
'e-:above3', {
'formula(3)':
'identifier',
'formula(2 + random)':
'quality'}, option=2, path=path)
88 ma.copyLists(
'e-:onlyall', [
'e-:allMC',
'e-:below2',
'e-:above3'], path=path)
90 ma.printVariableValues(
'e-:onlyall', [
'extraInfo(identifier)'], path=path)
94 ma.copyLists(
'e-:goodmerge', [
'e-:below2',
'e-:above3',
'e-:allMC'], path=path)
99 ma.printVariableValues(
'e-:goodmerge', [
'extraInfo(identifier)'], path=path)
100 ma.applyCuts(
'e-:goodmerge',
'extraInfo(identifier) > 0', path=path)
103 path.add_module(
'ParticleListManipulator', outputListName=
'e-:best', inputListNames=[
'e-:allMC',
'e-:below2',
'e-:above3'],
104 variable=
'extraInfo(quality)', preferLowest=
False)
106 ma.printVariableValues(
'e-:best', [
'extraInfo(identifier)'], path=path)
107 ma.applyCuts(
'e-:best',
'extraInfo(identifier) > 0', path=path)
109 path.add_module(MergingChecker())
A (simplified) python wrapper for StoreArray.
a (simplified) python wrapper for StoreObjPtr.