The Gaudi Framework  v36r1 (3e2fb5a8)
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 import os
25 import sys
26 import time
27 from Configurables import ApplicationMgr, EventSelector, Gaudi__RootCnvSvc
28 from Gaudi.Configuration import *
29 from GaudiKernel import *
30 
31 input_file = 'castor://castorlhcb.cern.ch//castor/cern.ch/grid/lhcb/LHCb/Collision11/SEMILEPTONIC.DST/00012569/0000/00012569_00000004_1.semileptonic.dst?svcClass=lhcbdisk'
32 input_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 
37 def storeExplorer(load=1, freq=0.0001, name='StoreExplorerAlg'):
38  from Configurables import StoreExplorerAlg
39  alg = StoreExplorerAlg(name)
40  alg.Load = load
41  alg.PrintFreq = freq
42  return alg
43 
44 
45 # -----------------------------------------------------------------------------
46 
47 if len(sys.argv) > 1:
48  input_file = sys.argv[1]
49 
50 appConf = ApplicationMgr(OutputLevel=INFO)
51 appConf.HistogramPersistency = "NONE"
52 appConf.ExtSvc.append('Gaudi::IODataManager/IODataManager')
53 appConf.ExtSvc.append('Gaudi::RootCnvSvc/RootCnvSvc')
54 appConf.TopAlg.append(storeExplorer(freq=1.0))
55 
56 EventDataSvc().RootCLID = 1
57 EventDataSvc().EnableFaultHandler = True
58 root = Gaudi__RootCnvSvc('RootCnvSvc')
59 root.CacheBranches = []
60 root.VetoBranches = ['*']
61 
62 #root.OutputLevel = 2
63 # Enable specialized branch caching:
64 root.CacheBranches = [
65  '_Event.*', '_Event_R.*', '_Event_Rec.*', '_Event_Rec_R.*',
66  '_Event_Rec_Header.*'
67  '_Event_Rec_Header_R.*'
68 ]
69 root.VetoBranches = [
70  # '_Event_pRec_*',
71  # '_Event_Semileptonic_*'
72 ]
73 
74 EventPersistencySvc().CnvServices.append(root)
75 EventSelector().Input = [
76  "DATA='PFN:" + input_file + "' SVC='Gaudi::RootEvtSelector'"
77 ]
78 EventSelector().PrintFreq = 1000
79 MessageSvc().OutputLevel = 3
80 
81 
82 def update():
83  statistic = {}
84  test = open('/proc/self/io')
85  io = test.readlines()
86  test.close()
87  for l in io:
88  temp = l.split(':')
89  statistic[temp[0]] = int(temp[1])
90  statistic['time'] = time.time()
91  return statistic
92 
93 
94 def printDelta(s0, s1):
95  for s in s1:
96  if s == 'time':
97  print('%15s : %10.2F sec' % (s, (s1[s] - s0[s])))
98  else:
99  print('%15s : %10.2F MB' % (s, (s1[s] - s0[s]) / 1.E6))
100 
101 
102 import GaudiPython
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.storeExplorer
def storeExplorer(load=1, freq=0.0001, name='StoreExplorerAlg')
Definition: IOTest.py:37
IOTest.printDelta
def printDelta(s0, s1)
Definition: IOTest.py:94
StoreExplorerAlg
Definition: StoreExplorerAlg.cpp:42
GaudiPython.Bindings.AppMgr
Definition: Bindings.py:842
Gaudi.Configuration
Definition: Configuration.py:1
MessageSvc
Definition: MessageSvc.h:40
IOTest.update
def update()
Definition: IOTest.py:82