The script you want to submit to SGE is the one below, called check_storage.sh. This sets up the appropriate environment variables and calls the python script check_storage.py which actually opens the files on the storage and reads the data from them (all done using
ROOT).
The scripts can be found in the group CVS under User/gcowan/storage/scripts .
check_storage.sh
#! /bin/bash
PROTOCOL=dcap
#PROTOCOL=rfio
#PROTOCOL=xroot
# LHCb software
source /exports/work/ppe/lhcb/lhcb-soft/scripts/local-setup.sh
# SetupProject
unset CMTPROJECTPATH
source /exports/work/physics_ifp_ppe/lhcb/lhcb-soft/scripts/SetupProject.sh DaVinci v19r14
# Grid UI
export ECDF_UI=/exports/work/ppe/lhcb/lhcb-soft/lcg/external/Grid
#export PATH=$PATH:$ECDF_UI/glite/bin:$ECDF_UI/lcg/bin:$ECDF_UI/lcg/bin/dpm:$ECDF_UI/globus/bin
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ECDF_UI/glite/lib:$ECDF_UI/lcg/lib:$ECDF_UI/globus/lib:/Disk/lochnagar0/lhcb/lhcb-soft/lcg/external/castor/2.1.1-9/slc4_ia32_gcc34/usr/lib
# dCache
export DCACHE_CLIENT_ACTIVE=1
export DCACHE_REPLY="eddie`hostname|cut -d\"e\" -f2`.ecdf.ed.ac.uk"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/exports/work/physics_ifp_ppe/lhcb/lhcb-soft/lcg/external/dcache_client/1.8.0/slc4_ia32_gcc34/dcap/lib/
# DPM
# This picks up libshift.so (for the ROOT libRFIO.so lib). In fact, libshift.so is a copy of libdpm.so.1.6.7
export DPM_HOST=srm.glite.ecdf.ed.ac.uk
export DPNS_HOST=srm.glite.ecdf.ed.ac.uk
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/exports/work/ppe/sw/builds
# Run check
python ~/test/check_storage.py ${PROTOCOL}
check_storage.py
#! /usr/bin/env python
# $Id: $
__author__ = 'Greig A Cowan'
__date__ = 'July 2008'
__version = 0.1
'''
Do "SetupProject Davinci" before running this script.
For rfio, make sure that DPM_HOST and DPNS_HOST are set appropriately. You will
need to have a valid grid proxy (for the GSI) and your LD_LIBRARY_PATH set so
that libRFIO can pick up the GSI libs.
For dcap, make sure that DCACHE_CLIENT_ACTIVE=1 is you are having firewall
troubles.
For xroot, you probably do not need anything special.
'''
import sys
from optparse import OptionParser
def main():
parser = OptionParser(
usage = 'usage: %prog [options] protocol')
parser.add_option('-v', '--verbose', dest='verbose', action='store_true',
help='Use verbose flag only for testing')
(options, args) = parser.parse_args()
try:
protocol = args[0]
except:
parser.print_help()
if len( args) != 1:
parser.print_help()
if protocol == 'dcap':
dst = 'dcap://pool1.epcc.ed.ac.uk:22125/pnfs/epcc.ed.ac.uk/data/lhcb/production/DC06/L0-v1-lumi2/00001959/DST/0000/00001959_00000840_1.dst?filetype=raw' elif protocol == 'rfio':
dst = 'rfio:///dpm/ecdf.ed.ac.uk/home/lhcb/production/DC06/L0-v1-lumi2/00001959/DST/0000/00001959_00001641_1.dst?filetype=raw'
elif protocol == 'xroot':
dst = 'root://srm.glite.ecdf.ed.ac.uk//dpm/ecdf.ed.ac.uk/home/lhcb/production/DC06/L0-v1-lumi2/00001959/DST/0000/00001959_00001641_1.dst?filetype=raw'
exit = False
try:
import ROOT
f = ROOT.TFile.Open( dst)
if f:
print 'Successfully opened the RAW file: %s' % dst
else:
print '[ERROR]=3 Failed to open the RAW file: %s' % dst
exit = True
except Exception,x:
print '[ERROR]=4 Exception while opening the RAW file: %s' % dst
print str(x)
exit = True
if exit == True:
sys.exit()
fileSize = f.GetSize()
bufferSize = 35*1024
buffer = ''
for i in range( bufferSize):
buffer += ' '
bytes = 0
event = 0
while( bytes < ( fileSize - bufferSize)):
bytes += bufferSize
event += 1
try:
res = f.ReadBuffer( buffer, bufferSize)
except Exception,x:
print '[ERROR]=7 Failed to read event %s.' % event
res = 'ERROR'
f.Close()
print '[SUCCESS]'
if __name__ == '__main__':
main()
--
GreigCowan - 18 Jul 2008