00001
00002
00003 __all__ = ['SimHistsExampleConf','Configure', 'Tutorial']
00004
00005 import GaudiKernel.SystemOfUnits as units
00006
00007
00008 class Configure:
00009 '''
00010 Do default configuration for SimHistsExample package
00011 '''
00012
00013 def __init__(self,do_detsim = True, volume = '/dd/Structure/AD/far-oil1', particle = 'e+'):
00014
00015 print "Configuring GenTools..."
00016 import GenTools
00017 from GenTools.Helpers import Gun
00018 gtc = GenTools.Configure()
00019 gunner = Gun()
00020 gtc.register(gunner)
00021
00022
00023
00024 gunner.timerator.LifeTime = 1*units.microsecond
00025
00026 gunner.positioner.Strategy = "FullVolume"
00027 gunner.positioner.Volume = volume
00028 gunner.positioner.Mode = "Smeared"
00029 gunner.positioner.Spread = 1*units.meter
00030 gunner.positioner.Position = [0,0,0]
00031
00032 gunner.gun.ParticlesPerEvent = 1
00033 gunner.gun.ParticleName = particle
00034 gunner.gun.Momentum = 4*units.MeV
00035 gunner.gun.MomentumMode = "Smeared"
00036 gunner.gun.MomentumSpread = 1*units.MeV
00037 gunner.gun.DirectionMode = "Uniform"
00038 gunner.gun.DirectionSpread = 180*units.degree
00039 gunner.gun.PolarizeMode = "Random"
00040
00041
00042 dump = GenTools.Dumper()
00043 print "... GenTools done."
00044
00045 print 'Configure the THistSvc...'
00046 from GaudiSvc.GaudiSvcConf import THistSvc
00047 histsvc = THistSvc()
00048 histsvc.Output = [
00049 "file1 DATAFILE='simhists.root' OPT='RECREATE' TYP='ROOT' "
00050 ]
00051 print '... THistSvc config done.'
00052
00053
00054 from Gaudi.Configuration import ApplicationMgr
00055 theApp = ApplicationMgr()
00056
00057 print 'Configure the GenHists alg...'
00058 from SimHistsExample.SimHistsExampleConf import GenHists
00059 gh = GenHists()
00060 theApp.TopAlg.append(gh)
00061 gh.Location = "/Event/Gen/GenHeader"
00062 gh.Volume = volume
00063 gh.FilePath = "/file1/gen"
00064 gh.MaxEnergy = 5
00065 gh.EnergyUnits = units.MeV
00066 print '... GenHists alg configured.'
00067
00068 if not do_detsim:
00069 print "Not doing DetSim configuration, only GenTools level."
00070 return
00071
00072 print "Configuring DetSim with only basic physics list..."
00073 import DetSim
00074 from DetSim.Default import physics_list_basic
00075 detsim = DetSim.Configure(physlist = physics_list_basic)
00076 print '... done.'
00077
00078 print 'Configure the SimHists alg...'
00079 from SimHistsExample.SimHistsExampleConf import SimHists
00080 sh = SimHists()
00081 theApp.TopAlg.append(sh)
00082 sh.Location = "/Event/Sim/SimHeader"
00083 sh.FilePath = "/file1/sim"
00084 print '... SimHists alg configured.'
00085
00086
00087 return
00088 pass