Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v38r0 (2143aa4c)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 import sys
24 import time
25 
26 from Configurables import ApplicationMgr, EventSelector, Gaudi__RootCnvSvc
27 from Gaudi.Configuration import INFO, EventDataSvc, EventPersistencySvc, MessageSvc
28 
29 input_file = "castor://castorlhcb.cern.ch//castor/cern.ch/grid/lhcb/LHCb/Collision11/SEMILEPTONIC.DST/00012569/0000/00012569_00000004_1.semileptonic.dst?svcClass=lhcbdisk"
30 input_file = "root://castorlhcb.cern.ch//castor/cern.ch/grid//lhcb/data/2010/BHADRON.DST/00008399/0000/00008399_00001052_1.bhadron.dst?svcClass=lhcbdisk"
31 
32 # -----------------------------------------------------------------------------
33 
34 
35 def storeExplorer(load=1, freq=0.0001, name="StoreExplorerAlg"):
36  from Configurables import StoreExplorerAlg
37 
38  alg = StoreExplorerAlg(name)
39  alg.Load = load
40  alg.PrintFreq = freq
41  return alg
42 
43 
44 # -----------------------------------------------------------------------------
45 
46 if len(sys.argv) > 1:
47  input_file = sys.argv[1]
48 
49 appConf = ApplicationMgr(OutputLevel=INFO)
50 appConf.HistogramPersistency = "NONE"
51 appConf.ExtSvc.append("Gaudi::IODataManager/IODataManager")
52 appConf.ExtSvc.append("Gaudi::RootCnvSvc/RootCnvSvc")
53 appConf.TopAlg.append(storeExplorer(freq=1.0))
54 
55 EventDataSvc().RootCLID = 1
56 EventDataSvc().EnableFaultHandler = True
57 root = Gaudi__RootCnvSvc("RootCnvSvc")
58 root.CacheBranches = []
59 root.VetoBranches = ["*"]
60 
61 # root.OutputLevel = 2
62 # Enable specialized branch caching:
63 root.CacheBranches = [
64  "_Event.*",
65  "_Event_R.*",
66  "_Event_Rec.*",
67  "_Event_Rec_R.*",
68  "_Event_Rec_Header.*" "_Event_Rec_Header_R.*",
69 ]
70 root.VetoBranches = [
71  # '_Event_pRec_*',
72  # '_Event_Semileptonic_*'
73 ]
74 
75 EventPersistencySvc().CnvServices.append(root)
76 EventSelector().Input = ["DATA='PFN:" + input_file + "' SVC='Gaudi::RootEvtSelector'"]
77 EventSelector().PrintFreq = 1000
78 MessageSvc().OutputLevel = 3
79 
80 
81 def update():
82  statistic = {}
83  test = open("/proc/self/io")
84  io = test.readlines()
85  test.close()
86  for l in io:
87  temp = l.split(":")
88  statistic[temp[0]] = int(temp[1])
89  statistic["time"] = time.time()
90  return statistic
91 
92 
93 def printDelta(s0, s1):
94  for s in s1:
95  if s == "time":
96  print("%15s : %10.2F sec" % (s, (s1[s] - s0[s])))
97  else:
98  print("%15s : %10.2F MB" % (s, (s1[s] - s0[s]) / 1.0e6))
99 
100 
101 import GaudiPython
102 
104 sel = appMgr.evtsel()
105 evt = appMgr.evtsvc()
106 print(sel.Input)
107 
108 start = update()
109 # test 1
110 N = 0
111 while 1 > 0:
112  rc = appMgr.run(1)
113  if N == 10:
114  start = update()
115  # if not evt['/Event/DAQ/RawEvent']:
116  # print 'Failed to access /Event/DAQ/RawEvent'
117  if not evt["/Event/Rec/Header"]:
118  print("Failed to access /Event/Rec/Header")
119  break
120  N += 1
121  if N > 100000:
122  break
123 end = update()
124 print("Read %d events" % N)
125 printDelta(start, end)
IOTest.printDelta
def printDelta(s0, s1)
Definition: IOTest.py:93
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:35
GaudiPython.Bindings.AppMgr
Definition: Bindings.py:884
Gaudi.Configuration
Definition: Configuration.py:1
IOTest.update
def update()
Definition: IOTest.py:81