00001
00002
00003 __all__ = ['RootIOSvcConf','Configure']
00004
00005 def wash_streams(stream):
00006 'Assure that all "root:" URLs have ?mkpath=1 appended'
00007 ret = {}
00008 def appender(fname,end='?mkpath=1',scheme='root:'):
00009 'Append to fname the given "end" string if it is URL of given scheme and lacks it. Return fname'
00010 if scheme != fname[:len(scheme)]: return fname
00011 if end == fname[-len(end):]: return fname
00012 return fname + '?mkpath=1'
00013
00014 for name,flist in stream.iteritems():
00015 ret[name] = map(appender,flist)
00016 continue
00017 return ret
00018
00019
00020 class Configure:
00021 'Configure RootIOSvc'
00022
00023 def __init__(self,input_streams,output_streams,force_readout):
00024 '''Do default configuration of RootIOSvc. The given input and
00025 output streams are maps between locations in the TES and
00026 files. The special location "default" is used when locations
00027 are not explicitly listed.'''
00028
00029 from Gaudi.Configuration import ApplicationMgr
00030 theApp = ApplicationMgr()
00031
00032 theApp.EvtSel = "NONE"
00033
00034 if not (input_streams or output_streams):
00035 print "Note: No file I/O requested."
00036 return
00037
00038 if input_streams:
00039 theApp.EvtSel = ""
00040 from DybIO.DybIOConf import DybEvtSelector
00041 theApp.ExtSvc += [ DybEvtSelector("EventSelector") ]
00042
00043 if output_streams:
00044 from DybIO.DybIOConf import DybStorageSvc
00045 theApp.ExtSvc += [ DybStorageSvc() ]
00046
00047 from RootIOSvc.RootIOSvcConf import RootIOCnvSvc
00048 rio = RootIOCnvSvc()
00049 theApp.ExtSvc.append(rio)
00050 from GaudiSvc.GaudiSvcConf import EvtPersistencySvc
00051 per = EvtPersistencySvc()
00052 per.CnvServices = [ rio ];
00053
00054 print 'input_streams=',str(input_streams)
00055 print 'output_streams=',str(output_streams)
00056
00057 rio.InputStreams = wash_streams(input_streams)
00058 rio.OutputStreams = output_streams
00059 rio.ForceReadout = force_readout
00060
00061 return
00062
00063
00064 pass