00001
00002 '''
00003 Put the same type of object into different streams
00004 '''
00005
00006 from GaudiPython.GaudiAlgs import GaudiAlgo
00007 from GaudiPython import SUCCESS, FAILURE, Bindings, gbl
00008 import time
00009
00010 class MultiStreams(GaudiAlgo):
00011 '''
00012 Place multiple objects of the same type at multiple locations in
00013 the event store.
00014 '''
00015 def __init__(self,name='MultiStreams'):
00016 GaudiAlgo.__init__(self,name)
00017 self.count = 0;
00018 print 'MultiStreams: making one'
00019 return
00020
00021 def execute(self):
00022 self.count += 1
00023
00024 evt = self.evtSvc()
00025
00026 print 'MultiStreams: reading in Lotsa headers'
00027 for ind in range(0,10):
00028
00029 gh_path = '/Event/Gen/GenHeader%d'%ind
00030 gh = evt[gh_path]
00031 sh_path = '/Event/Sim/SimHeader%d'%ind
00032 sh = evt[sh_path]
00033 if not sh:
00034 print 'Failed to get "%s"'%sh_path
00035 return FAILURE
00036
00037 ihs = sh.inputHeaders()
00038 if ihs.size():
00039 gh_input = ihs[0]
00040 else:
00041 print 'Got empty input headers from',sh_path
00042 return FAILURE
00043
00044 print gh_path,gh.execNumber(),gh.timeStamp().AsString()
00045 print gh_path,gh_input.execNumber(),gh_input.timeStamp().AsString()
00046 print sh_path,sh.execNumber(),sh.timeStamp().AsString()
00047 print
00048
00049 if gh.execNumber() != gh_input.execNumber():
00050 print 'GenHeader exec numbers differ: %d != %d'%\
00051 (gh.execNumber(), gh_input.execNumber())
00052 return FAILURE
00053 if gh.timeStamp() != gh_input.timeStamp():
00054 print 'GenHeader time stamps differ: "%s" != "%s"'%\
00055 (gh.timeStamp().AsString(),gh_input.timeStamp().AsString())
00056 return FAILURE
00057 continue
00058 return SUCCESS
00059
00060
00061 def configure(argv=None):
00062 if not argv: return
00063
00064 print argv
00065 if argv[0] == "LotsaGens":
00066 print 'Generating some stuff'
00067 from RootIOTest.RootIOTestConf import LotsaGens
00068 alg = LotsaGens()
00069 from Gaudi.Configuration import ApplicationMgr
00070 theApp = ApplicationMgr()
00071 theApp.TopAlg.append(alg)
00072
00073 return
00074
00075 def run(app):
00076 alg = MultiStreams()
00077 app.addAlgorithm(alg)
00078 return
00079