Belle II Software light-2406-ragdoll
independent_path.py
1#!/usr/bin/env python3
2
3
10
11# @cond
12
13import basf2
14from ROOT import Belle2
15
16
17class CreateData(basf2.Module):
18
19 """create some data"""
20
21 def initialize(self):
22 """reimplementation"""
23
24 self.obj = Belle2.PyStoreObj(Belle2.EventMetaData.Class())
25 self.obj.registerInDataStore('obj')
26 self.array = Belle2.PyStoreArray(Belle2.EventMetaData.Class())
27 self.array.registerInDataStore('array')
28
29 def event(self):
30 """reimplementation"""
31
32 self.obj.create()
33 self.obj.obj().setExperiment(19)
34
35 for i in range(13):
36 self.array.appendNew()
37
38
39class CheckData(basf2.Module):
40
41 """check output of CreateData"""
42
43 def initialize(self):
44 """reimplementation"""
45
46 self.obj = Belle2.PyStoreObj('obj')
47 self.array = Belle2.PyStoreArray('array')
48
49 def event(self):
50 """reimplementation"""
51
52 assert self.obj.obj().getExperiment() == 19
53 assert self.array.getEntries() == 13
54
55
56class CheckAbsence(basf2.Module):
57
58 """check output of CreateData"""
59
60 def initialize(self):
61 """reimplementation"""
62
63 assert not Belle2.PyStoreObj('obj').isOptional()
64 assert not Belle2.PyStoreArray('array').isOptional()
65
66 def event(self):
67 """reimplementation"""
68
69 assert not Belle2.PyStoreObj('obj').obj()
70
71
72main = basf2.Path()
73main.add_module('EventInfoSetter')
74main.add_module(CheckAbsence())
75
76indep = basf2.Path()
77indep.add_module(CreateData())
78indep.add_module(CheckData()).set_name("checkdata 1")
79main.add_independent_path(indep)
80main.add_module(CheckAbsence())
81
82indep2 = basf2.Path()
83indep2.add_module(CheckAbsence())
84indep2.add_module(CreateData())
85indep2.add_module(CheckData()).set_name("checkdata 2")
86main.add_independent_path(indep2, merge_back_event=['obj', 'array'])
87main.add_module(CheckData()).set_name("checkdata 3")
88
89basf2.print_path(main)
90basf2.process(main)
91
92print(basf2.statistics)
93# @endcond
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:67