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