00001
00002
00003 __all__ = ['DybAlgConf','Configure','RandomSeeder']
00004
00005
00006 class Configure:pass
00007
00008 class RandomSeeder:
00009 '''Random seed algorithm config'''
00010
00011 def __init__(self,hostid=0,run=0,execcountoffset=0,burncount=1000,
00012 engine="HepRndm::Engine<CLHEP::Ranlux64Engine>",):
00013 '''Do default configuration of the random seeds, optionally
00014 setting hostid, run, execcountoffset, burncount or random engine'''
00015
00016 if hostid&0xffff0000 == int("0x007f0000",16):
00017 print '''
00018 WARNING: Your hostID corresponds to a localhost/loopback IP number.
00019 This is not very unique and you may sharing random seeds
00020 with other processing nodes.
00021 Check /etc/hosts to make sure your host has a real IP address.
00022 '''
00023 pass
00024
00025
00026 from Gaudi.Configuration import ApplicationMgr
00027 theApp = ApplicationMgr()
00028
00029 from GaudiSvc.GaudiSvcConf import RndmGenSvc
00030 rndSvc = RndmGenSvc()
00031 rndSvc.Engine = engine
00032 theApp.ExtSvc.append(rndSvc)
00033
00034 def munge(x):
00035 if x == ':' or x == '<' or x == '>': return '_'
00036 return x
00037 engModName = ''.join(map(munge,engine))
00038 exec('from GaudiSvc.GaudiSvcConf import %s'%engModName)
00039 engMod = eval(engModName)
00040 engMod = engMod('RndmGenSvc.Engine')
00041 engMod.SetSingleton = True
00042
00043
00044 from DybAlg.DybAlgConf import DybShuffle
00045 self.random_seeder = DybShuffle("random_seeder")
00046
00047 self.random_seeder.HostID = hostid&0x7fffffff
00048 self.random_seeder.Run = run
00049 self.random_seeder.ExecCountOffset = execcountoffset
00050 self.random_seeder.BurnCount = burncount
00051 theApp.TopAlg.append(self.random_seeder)
00052 return
00053
00054 pass
00055