| # Gaudi Framework, version v23r1 |

Home |  | Generated: Wed Feb 29 2012

# IOTest.py

Go to the documentation of this file.

    00001 """
    00002
    00003    Simple test application to read LHCb dst files
    00004    For reading other root files: change the data access
    00005    if '/Event/Rec/Header' is not present.
    00006
    00007    Requires: 'SetupProject LHCb'
    00008
    00009    Script inherited from T.Ruf
    00010    M.Frank  CERN/LHCb
    00011
    00012 """
    00013 import os, sys, time
    00014 from Configurables import ApplicationMgr, EventSelector, Gaudi__RootCnvSvc
    00015 from Gaudi.Configuration import *
    00016 from GaudiKernel import *
    00017
    00018 input_file = 'castor://castorlhcb.cern.ch//castor/cern.ch/grid/lhcb/LHCb/Collision11/SEMILEPTONIC.DST/00012569/0000/00012569_00000004_1.semileptonic.dst?svcClass=lhcbdisk'
    00019 input_file = 'root://castorlhcb.cern.ch//castor/cern.ch/grid//lhcb/data/2010/BHADRON.DST/00008399/0000/00008399_00001052_1.bhadron.dst?svcClass=lhcbdisk'
    00020
    00021 #------------------------------------------------------------------------------------------------
    00022 def storeExplorer(load=1,freq=0.0001,name='StoreExplorerAlg'):
    00023   from Configurables import StoreExplorerAlg
    00024   alg                = StoreExplorerAlg(name)
    00025   alg.Load           = load
    00026   alg.PrintFreq      = freq
    00027   return alg
    00028
    00029 #------------------------------------------------------------------------------------------------
    00030
    00031 if len(sys.argv)>1:
    00032   input_file = sys.argv[1]
    00033
    00034 appConf = ApplicationMgr(OutputLevel = INFO)
    00035 appConf.HistogramPersistency  = "NONE";
    00036 appConf.ExtSvc.append('Gaudi::IODataManager/IODataManager')
    00037 appConf.ExtSvc.append('Gaudi::RootCnvSvc/RootCnvSvc')
    00038 appConf.TopAlg.append(storeExplorer(freq=1.0))
    00039
    00040 EventDataSvc().RootCLID         = 1
    00041 EventDataSvc().EnableFaultHandler = True
    00042 root = Gaudi__RootCnvSvc('RootCnvSvc')
    00043 root.CacheBranches = []
    00044 root.VetoBranches = ['*']
    00045
    00046 #root.OutputLevel  = 2
    00047 # Enable specialized branch caching:
    00048 root.CacheBranches = [
    00049     '_Event.*',
    00050     '_Event_R.*',
    00051     '_Event_Rec.*',
    00052     '_Event_Rec_R.*',
    00053     '_Event_Rec_Header.*'
    00054     '_Event_Rec_Header_R.*'
    00055     ]
    00056 root.VetoBranches = [
    00057 #    '_Event_pRec_*',
    00058 #    '_Event_Semileptonic_*'
    00059     ]
    00060
    00061 EventPersistencySvc().CnvServices.append(root)
    00062 EventSelector().Input = [ "DATA='PFN:"+input_file+"' SVC='Gaudi::RootEvtSelector'" ]
    00063 EventSelector().PrintFreq = 1000
    00064 MessageSvc().OutputLevel = 3
    00065
    00066 def update():
    00067  statistic = {}
    00068  test = open('/proc/self/io')
    00069  io = test.readlines()
    00070  test.close()
    00071  for l in io:
    00072    temp = l.split(':')
    00073    statistic[temp[0]]=int(temp[1])
    00074  statistic['time']=time.time()
    00075  return statistic
    00076
    00077 def printDelta(s0,s1):
    00078  for s in s1:
    00079   if s=='time':  print '%15s : %10.2F sec'%(s,(s1[s]-s0[s]))
    00080   else:          print '%15s : %10.2F MB'%(s,(s1[s]-s0[s])/1.E6)
    00081
    00082 import GaudiPython
    00083 appMgr = GaudiPython.AppMgr()
    00084 sel    = appMgr.evtsel()
    00085 evt    = appMgr.evtsvc()
    00086 print sel.Input
    00087
    00088 start = update()
    00089 # test 1
    00090 N=0
    00091 while 1>0:
    00092  rc = appMgr.run(1)
    00093  if N==10: start=update()
    00094  #if not evt['/Event/DAQ/RawEvent']:
    00095  #    print 'Failed to access /Event/DAQ/RawEvent'
    00096  if not evt['/Event/Rec/Header']:
    00097      print 'Failed to access /Event/Rec/Header'
    00098      break
    00099  N+=1
    00100  if N > 100000: break
    00101 end = update()
    00102 print 'Read %d events'%N
    00103 printDelta(start,end)

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines