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