The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
IOTest.py
Go to the documentation of this file.
11"""
12
13Simple test application to read LHCb dst files
14For reading other root files: change the data access
15if '/Event/Rec/Header' is not present.
16
17Requires: 'SetupProject LHCb'
18
19Script inherited from T.Ruf
20M.Frank CERN/LHCb
21
22"""
23
24import sys
25import time
26
27from Configurables import ApplicationMgr, EventSelector, Gaudi__RootCnvSvc
28
29from Gaudi.Configuration import INFO, EventDataSvc, EventPersistencySvc, MessageSvc
30
31input_file = "castor://castorlhcb.cern.ch//castor/cern.ch/grid/lhcb/LHCb/Collision11/SEMILEPTONIC.DST/00012569/0000/00012569_00000004_1.semileptonic.dst?svcClass=lhcbdisk"
32input_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
37def 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
48if len(sys.argv) > 1:
49 input_file = sys.argv[1]
50
51appConf = ApplicationMgr(OutputLevel=INFO)
52appConf.HistogramPersistency = "NONE"
53appConf.ExtSvc.append("Gaudi::IODataManager/IODataManager")
54appConf.ExtSvc.append("Gaudi::RootCnvSvc/RootCnvSvc")
55appConf.TopAlg.append(storeExplorer(freq=1.0))
56
57EventDataSvc().RootCLID = 1
58EventDataSvc().EnableFaultHandler = True
59root = Gaudi__RootCnvSvc("RootCnvSvc")
60root.CacheBranches = []
61root.VetoBranches = ["*"]
62
63# root.OutputLevel = 2
64# Enable specialized branch caching:
65root.CacheBranches = [
66 "_Event.*",
67 "_Event_R.*",
68 "_Event_Rec.*",
69 "_Event_Rec_R.*",
70 "_Event_Rec_Header.*" "_Event_Rec_Header_R.*",
71]
72root.VetoBranches = [
73 # '_Event_pRec_*',
74 # '_Event_Semileptonic_*'
75]
76
77EventPersistencySvc().CnvServices.append(root)
78EventSelector().Input = ["DATA='PFN:" + input_file + "' SVC='Gaudi::RootEvtSelector'"]
79EventSelector().PrintFreq = 1000
80MessageSvc().OutputLevel = 3
81
82
83def 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
95def 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
103import GaudiPython
104
106sel = appMgr.evtsel()
107evt = appMgr.evtsvc()
108print(sel.Input)
109
110start = update()
111# test 1
112N = 0
113while 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
125end = update()
126print("Read %d events" % N)
127printDelta(start, end)
The Application Manager class.
Definition of class EventSelector.
Small algorith, which traverses the data store and prints generic information about all leaves,...
storeExplorer(load=1, freq=0.0001, name="StoreExplorerAlg")
Definition IOTest.py:37
printDelta(s0, s1)
Definition IOTest.py:95
update()
Definition IOTest.py:83