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