14from ROOT
import Belle2
17class CreateDataMain(basf2.Module):
19 """create some data"""
22 """reimplementation"""
25 self.obj.registerInDataStore(
'EventMetaData')
27 self.array.registerInDataStore(
'Particles')
29 self.arrayRel.registerInDataStore(
'MCParticles')
31 self.array.registerRelationTo(self.arrayRel)
34 self.objFirst.registerInDataStore(
'EventMetaDataFirst')
36 self.arrayFirst.registerInDataStore(
'ParticlesFirst')
38 self.arrayRelFirst.registerInDataStore(
'MCParticlesFirst')
40 self.arrayFirst.registerRelationTo(self.arrayRelFirst)
43 """reimplementation"""
46 self.obj.obj().setExperiment(500)
49 newptr = self.array.appendNew()
53 newptr = self.arrayRel.appendNew()
57 self.array[i].addRelationTo(self.arrayRel[i])
59 self.objFirst.create()
60 self.objFirst.obj().setExperiment(600)
63 newptr = self.arrayFirst.appendNew()
67 newptr = self.arrayRelFirst.appendNew()
71 self.arrayFirst[i].addRelationTo(self.arrayRelFirst[i])
74class CreateDataIndep(basf2.Module):
76 """create some data"""
79 """reimplementation"""
82 self.obj.registerInDataStore(
'EventMetaData')
84 self.array.registerInDataStore(
'Particles')
86 self.arrayRel.registerInDataStore(
'MCParticles')
88 self.array.registerRelationTo(self.arrayRel)
91 self.objSecond.registerInDataStore(
'EventMetaDataSecond')
93 self.arraySecond.registerInDataStore(
'ParticlesSecond')
95 self.arrayRelSecond.registerInDataStore(
'MCParticlesSecond')
97 self.arraySecond.registerRelationTo(self.arrayRelSecond)
100 """reimplementation"""
103 self.obj.obj().setExperiment(700)
106 newptr = self.array.appendNew()
110 newptr = self.arrayRel.appendNew()
114 self.array[i].addRelationTo(self.arrayRel[i])
116 self.objSecond.create()
117 self.objSecond.obj().setExperiment(800)
120 newptr = self.arraySecond.appendNew()
124 newptr = self.arrayRelSecond.appendNew()
128 self.arraySecond[i].addRelationTo(self.arrayRelSecond[i])
131class CheckData(basf2.Module):
133 """check output of CreateData"""
135 def initialize(self):
136 """reimplementation"""
150 """reimplementation"""
154 assert self.obj.obj().getExperiment() == 500
155 assert self.obj_indepPath.obj().getExperiment() == 700
156 assert self.objFirst.obj().getExperiment() == 600
157 assert self.objSecond.obj().getExperiment() == 800
158 assert self.array.getEntries() == 5 + 7
159 assert self.arrayFirst.getEntries() == 6
160 assert self.arraySecond.getEntries() == 8
162 for arr
in self.array:
163 print(arr.getPValue())
165 for arr
in self.arrayRel:
168 for arr
in self.array:
169 print(arr.getPValue(),
'->', arr.getRelated(
'MCParticles').getPDG())
173main.add_module(
'EventInfoSetter')
175main.add_module(CreateDataMain())
178indep.add_module(CreateDataIndep())
180main.add_independent_merge_path(
182 merge_back_event=[
'ALL'])
184main.add_module(CheckData())
186basf2.print_path(main)
189print(basf2.statistics)
A (simplified) python wrapper for StoreArray.
a (simplified) python wrapper for StoreObjPtr.