The Gaudi Framework  master (37c0b60a)
IOTest.py
Go to the documentation of this file.
1 
11 """
12 
13 Simple test application to read LHCb dst files
14 For reading other root files: change the data access
15 if '/Event/Rec/Header' is not present.
16 
17 Requires: 'SetupProject LHCb'
18 
19 Script inherited from T.Ruf
20 M.Frank CERN/LHCb
21 
22 """
23 
24 import sys
25 import time
26 
27 from Configurables import ApplicationMgr, EventSelector, Gaudi__RootCnvSvc
28 
29 from Gaudi.Configuration import INFO, EventDataSvc, EventPersistencySvc, MessageSvc
30 
31 input_file = "castor://castorlhcb.cern.ch//castor/cern.ch/grid/lhcb/LHCb/Collision11/SEMILEPTONIC.DST/00012569/0000/00012569_00000004_1.semileptonic.dst?svcClass=lhcbdisk"
32 input_file = "root://castorlhcb.cern.ch//castor/cern.ch/grid//lhcb/data/2010/BHADRON.DST/00008399/0000/00008399_00001052_1.bhadron.dst?svcClass=lhcbdisk"
33 
34 # -----------------------------------------------------------------------------
35 
36 
37 def storeExplorer(load=1, freq=0.0001, name="StoreExplorerAlg"):
38  from Configurables import StoreExplorerAlg
39 
40  alg = StoreExplorerAlg(name)
41  alg.Load = load
42  alg.PrintFreq = freq
43  return alg
44 
45 
46 # -----------------------------------------------------------------------------
47 
48 if len(sys.argv) > 1:
49  input_file = sys.argv[1]
50 
51 appConf = ApplicationMgr(OutputLevel=INFO)
52 appConf.HistogramPersistency = "NONE"
53 appConf.ExtSvc.append("Gaudi::IODataManager/IODataManager")
54 appConf.ExtSvc.append("Gaudi::RootCnvSvc/RootCnvSvc")
55 appConf.TopAlg.append(storeExplorer(freq=1.0))
56 
57 EventDataSvc().RootCLID = 1
58 EventDataSvc().EnableFaultHandler = True
59 root = Gaudi__RootCnvSvc("RootCnvSvc")
60 root.CacheBranches = []
61 root.VetoBranches = ["*"]
62 
63 # root.OutputLevel = 2
64 # Enable specialized branch caching:
65 root.CacheBranches = [
66  "_Event.*",
67  "_Event_R.*",
68  "_Event_Rec.*",
69  "_Event_Rec_R.*",
70  "_Event_Rec_Header.*" "_Event_Rec_Header_R.*",
71 ]
72 root.VetoBranches = [
73  # '_Event_pRec_*',
74  # '_Event_Semileptonic_*'
75 ]
76 
77 EventPersistencySvc().CnvServices.append(root)
78 EventSelector().Input = ["DATA='PFN:" + input_file + "' SVC='Gaudi::RootEvtSelector'"]
79 EventSelector().PrintFreq = 1000
80 MessageSvc().OutputLevel = 3
81 
82 
83 def update():
84  statistic = {}
85  test = open("/proc/self/io")
86  io = test.readlines()
87  test.close()
88  for l in io:
89  temp = l.split(":")
90  statistic[temp[0]] = int(temp[1])
91  statistic["time"] = time.time()
92  return statistic
93 
94 
95 def printDelta(s0, s1):
96  for s in s1:
97  if s == "time":
98  print("%15s : %10.2F sec" % (s, (s1[s] - s0[s])))
99  else:
100  print("%15s : %10.2F MB" % (s, (s1[s] - s0[s]) / 1.0e6))
101 
102 
103 import GaudiPython
104 
106 sel = appMgr.evtsel()
107 evt = appMgr.evtsvc()
108 print(sel.Input)
109 
110 start = update()
111 # test 1
112 N = 0
113 while 1 > 0:
114  rc = appMgr.run(1)
115  if N == 10:
116  start = update()
117  # if not evt['/Event/DAQ/RawEvent']:
118  # print 'Failed to access /Event/DAQ/RawEvent'
119  if not evt["/Event/Rec/Header"]:
120  print("Failed to access /Event/Rec/Header")
121  break
122  N += 1
123  if N > 100000:
124  break
125 end = update()
126 print("Read %d events" % N)
127 printDelta(start, end)
IOTest.printDelta
def printDelta(s0, s1)
Definition: IOTest.py:95
StoreExplorerAlg
Definition: StoreExplorerAlg.cpp:42
GPython.MessageSvc
MessageSvc
Definition: GPython.py:17
IOTest.storeExplorer
def storeExplorer(load=1, freq=0.0001, name="StoreExplorerAlg")
Definition: IOTest.py:37
GaudiPython.Bindings.AppMgr
Definition: Bindings.py:887
Gaudi.Configuration
Definition: Configuration.py:1
IOTest.update
def update()
Definition: IOTest.py:83