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