Belle II Software light-2406-ragdoll
emptyrelations.py
1#!/usr/bin/env python3
2
3
10
11from basf2 import set_random_seed, create_path, Module
12from ROOT import Belle2
13from b2test_utils import safe_process, clean_working_directory
14
15set_random_seed("something important")
16
17
18class MakeRelations(Module):
19 '''Simple module that creates some relations.'''
20
21 def initialize(self):
22 '''Initialize.'''
23
24 self.tracks = Belle2.PyStoreArray('Tracks')
25
26 self.clusters = Belle2.PyStoreArray('KLMClusters')
27 self.tracks.registerInDataStore()
28 self.clusters.registerInDataStore()
29 self.tracks.registerRelationTo(self.clusters)
30
31 self.first = True
32
33 def event(self):
34 '''Event.'''
35 if not self.first:
36 track = self.tracks.appendNew()
37 cluster = self.clusters.appendNew()
38 track.addRelationTo(cluster)
39 self.first = False
40
41
42def create_file():
43 """Create file with empty first event"""
44 path = create_path()
45 path.add_module('EventInfoSetter')
46 path.add_module(MakeRelations())
47 path.add_module('RootOutput', outputFileName='test.root')
48 safe_process(path, 2)
49
50
51def read_file():
52 """Read file with empty first event"""
53 path = create_path()
54 path.add_module('RootInput', inputFileName='test.root')
55 path.add_module('PrintCollections', printForEvent=0)
56 safe_process(path)
57
58
59if __name__ == "__main__":
60 with clean_working_directory():
61 create_file()
62 read_file()
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
first
Bool for flagging the first event processed.