Belle II Software development
backgroundInfo.py
1#!/usr/bin/env python3
2
3
10
11import basf2 as b2
12from ROOT import Belle2
13
14# -----------------------------------------------------------
15# Prints BackgroundInfo stored in the root file
16# Use -i switch to specify the input file
17# -----------------------------------------------------------
18
19
20class printBGInfo(b2.Module):
21
22 '''
23 Print BackgroundInfo stored in the root file
24 '''
25
26 def event(self):
27 ''' event function '''
28
29 bgInfo = Belle2.PyStoreObj('BackgroundInfo', 1) # new version
30 bgInfos = Belle2.PyStoreArray('BackgroundInfos', 1) # old version
31 if bgInfo.isValid():
32 bgInfo.print()
33 elif bgInfos.isValid():
34 if bgInfos.getEntries() == 0:
35 print("Background info is empty")
36 i = 0
37 for bgInfo in bgInfos:
38 print("===========================")
39 print("* Backgroud info: entry", str(i))
40 print("===========================")
41 bgInfo.print()
42 i += 1
43 else:
44 print("No background info available")
45
46 evtMetaData = Belle2.PyStoreObj('EventMetaData')
47 evtMetaData.obj().setEndOfData()
48
49
50b2.set_log_level(b2.LogLevel.ERROR)
51
52# Create path
53main = b2.create_path()
54
55# input
56roinput = b2.register_module('RootInput')
57main.add_module(roinput)
58
59# print info
60main.add_module(printBGInfo())
61
62b2.process(main)
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:67