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