def shoot(self): "Return a vector of sampled particles" p1 = PG.SampledParticle(11, self.mom1.shoot()) eta1 = p1.mom.Eta() phi1 = p1.mom.Phi() # TODO: will phi be properly wrapped into range? mom2 = PG.PtEtaMPhiSampler(pt=25000, eta=[eta1 - 0.5, eta1 + 0.5], phi=[phi1 - 0.5, phi1 + 0.5]) p2 = PG.SampledParticle(11, mom2.shoot()) return [p1, p2]
def shoot(self): "Return a vector of sampled particles from the provided pT--eta histogram" particles = [] for i in xrange(self.numparticles): ptrand, etarand = self.hist.GetRandom() ptrand *= 1000 # NB. This _particular_ histogram is in GeV, but Athena needs MeV! # TODO: Provide 4-mom construction functions to avoid building this one-time sampler pid = self.pid() mom = PG.PtEtaMPhiSampler(pt=ptrand, eta=etarand, mass=PG.MASSES[abs(pid)]) p = PG.SampledParticle(pid, mom()) #print p.mom.Pt(), "\t", p.mom.Eta(), "\t", p.mom.Phi(), "\t", p.mom.M() particles.append(p) return particles
athenaCommonFlags.SkipEvents.set_Off() from G4AtlasApps.SimFlags import simFlags simFlags.load_atlas_flags() simFlags.SimLayout.set_On() simFlags.SimLayout = 'ATLAS-R2-2015-03-01-00_VALIDATION' ## Enable the EtaPhi, VertexSpread and VertexRange checks simFlags.EventFilter.set_On() ## Use single particle generator import AthenaCommon.AtlasUnixGeneratorJob import ParticleGun as PG pg = PG.ParticleGun(randomSvcName=simFlags.RandomSvc.get_Value(), randomStream="SINGLE") pg.sampler.pid = PG.CyclicSeqSampler([-11, 11]) pg.sampler.mom = PG.PtEtaMPhiSampler(pt=10000, eta=[-3, 3]) job += pg include("G4AtlasApps/fragment.SimCopyWeights.py") ## Release GeoModel memory once sim is configured simFlags.ReleaseGeoModel = False include("G4AtlasApps/G4Atlas.flat.configuration.py") ## Add the G4 sim to the alg sequence after the generator from AthenaCommon.CfgGetter import getAlgorithm job += getAlgorithm("G4AtlasAlg", tryDefaultConfigurable=True) ## User algorithms from AthenaCommon.AppMgr import ServiceMgr
#! -*- python -*- include("GeneratorUtils/StdEvgenSetup.py") theApp.EvtMax = 10 import ParticleGun as PG pg = PG.ParticleGun() pg.randomSeed = 123456 pg.samplers.append(PG.ParticleSampler()) # add a second sampler pg.samplers[0].pid = (-13, 13) # cycle mu+- pg.samplers[0].mom = PG.PtEtaMPhiSampler(pt=[4000, 100000], eta=[1.0, 3.2]) # flat in pt and +ve eta pg.samplers[1].pid = (13, -13) # cycle mu-+ pg.samplers[1].mom = PG.PtEtaMPhiSampler(pt=[4000, 100000], eta=[-3.2, -1.0]) # flat in pt and -ve eta topSeq += pg include("GeneratorUtils/postJO.CopyWeights.py") include("GeneratorUtils/postJO.PoolOutput.py") include("GeneratorUtils/postJO.DumpMC.py")
athenaCommonFlags.PoolEvgenInput.set_Off() ### is this necessary? athenaCommonFlags.PoolHitsOutput = 'Hits.pool.root' #--- Simulation flags ----------------------------------------- from G4AtlasApps.SimFlags import simFlags simFlags.load_atlas_flags() # Going to use an ATLAS layout simFlags.SimLayout = myGeo simFlags.EventFilter.set_Off() include("GeneratorUtils/StdEvgenSetup.py") theApp.EvtMax = 50000 import ParticleGun as PG pg = PG.ParticleGun() pg.sampler.pid = (-13, 13) pg.sampler.mom = PG.PtEtaMPhiSampler(pt=5000, eta=[-3.5, 3.5]) topSeq += pg simFlags.RandomSeedOffset = myRandomOffset simFlags.RandomSeedList.addSeed("ParticleGun", myRandomSeed1, myRandomSeed2) from RngComps.RngCompsConf import AtRndmGenSvc myAtRndmGenSvc = AtRndmGenSvc() myAtRndmGenSvc.Seeds = [ "ParticleGun " + str(myRandomSeed1) + " " + str(myRandomSeed2) ] myAtRndmGenSvc.OutputLevel = VERBOSE myAtRndmGenSvc.EventReseeding = False ServiceMgr += myAtRndmGenSvc ############### The Material hit collection ##################
from AthenaCommon.JobProperties import jobproperties jobproperties.Global.ConditionsTag = ConditionsTag from AtlasGeoModel import SetGeometryVersion from AtlasGeoModel import GeoModelInit from GeoModelSvc.GeoModelSvcConf import GeoModelSvc GeoModelSvc = GeoModelSvc() GeoModelSvc.MuonVersionOverride = "MuonSpectrometer-R.07.00" #--- ParticleGun ---------------------------------------------- import ParticleGun as PG pg = PG.ParticleGun() #pg.sampler.pid = (13, -13) pg.sampler.pid = 999 #pg.sampler.mom = PG.PtEtaMPhiSampler(pt=1000000, eta=[-1.1,1.1], phi=[-PG.PI, PG.PI]) pg.sampler.mom = PG.PtEtaMPhiSampler(pt=100000, eta=[-1.1, 1.1], phi=[3.49, 5.934]) topSeq += pg #--- Output printout level ----------------------------------- #output threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL) MessageSvc = Service("MessageSvc") MessageSvc.OutputLevel = 3 #============================================================== # Job configuration # ***>> Do not add flags or simulation options below this line #============================================================== from G4AtlasApps import SimKernel
print 'SINGLE PARTICLE GENERATOR' ## Run ParticleGun import AthenaCommon.AtlasUnixGeneratorJob from AthenaCommon.AlgSequence import AlgSequence topSeq = AlgSequence() import ParticleGun as PG from G4AtlasApps.SimFlags import simFlags pg = PG.ParticleGun(randomSvcName=simFlags.RandomSvc.get_Value(), randomStream="SINGLE") pg.sampler.pid = PG.CyclicSeqSampler([-13, 13]) #pg.sampler.mom = PG.PtEtaMPhiSampler(pt=[5000000,7000000] , eta=[-2.9,2.9]) pg.sampler.mom = PG.PtEtaMPhiSampler(pt=[5000000, 7000000], eta=[1.0, 1.3]) topSeq += pg try: from GeneratorModules.GeneratorModulesConf import CopyEventWeight topSeq += CopyEventWeight(TruthCollKey="GEN_EVENT") except: include("G4AtlasApps/fragment.SimCopyWeights.py")
printfunc('SINGLE PARTICLE GENERATOR') ## Run ParticleGun import AthenaCommon.AtlasUnixGeneratorJob from AthenaCommon.AlgSequence import AlgSequence topSeq = AlgSequence() import ParticleGun as PG from G4AtlasApps.SimFlags import simFlags pg = PG.ParticleGun(randomSvcName=simFlags.RandomSvc.get_Value(), randomStream="SINGLE") pg.sampler.pid = PG.CyclicSeqSampler([-13, 13]) pg.sampler.mom = PG.PtEtaMPhiSampler(pt=50000, eta=[-4, 4]) topSeq += pg try: from GeneratorModules.GeneratorModulesConf import CopyEventWeight topSeq += CopyEventWeight(TruthCollKey="GEN_EVENT") except: include("G4AtlasApps/fragment.SimCopyWeights.py")
simFlags.SimLayout.set_On() # simFlags.SimLayout = 'ATLAS-SLHC-01-01-00_VALIDATION' simFlags.SimLayout = 'ATLAS-SLHC-01-03-00_VALIDATION' simFlags.RandomSeed = JobSpecs_Seed1 # sets the EtaPhi, VertexSpread and VertexRange checks on simFlags.EventFilter.set_Off() from AthenaCommon.AthenaCommonFlags import athenaCommonFlags athenaCommonFlags.PoolEvgenInput.set_Off() import AthenaCommon.AtlasUnixGeneratorJob import ParticleGun as PG pg = PG.ParticleGun(randomSvcName=simFlags.RandomSvc.get_Value(), randomStream="SINGLE") pg.sampler.pid = 999 #Geantino if 'pt' == str(myPt): pg.sampler.mom = PG.PtEtaMPhiSampler(pt=myMomentum, eta=[-5, 5]) else: printfunc('not sure what you want to do here') #pg.sampler.mom = PG.EEtaMPhiSampler(energy=50000, eta=[-3,3]) topSeq += pg printfunc(topSeq.ParticleGun) try: include("G4AtlasApps/fragment.SimCopyWeights.py") except: from GeneratorModules.GeneratorModulesConf import CopyEventWeight topSeq += CopyEventWeight(TruthCollKey="GEN_EVENT") ## Add an action from G4AtlasApps.SimFlags import simFlags simFlags.OptionalUserActionList.addAction('G4UA::MaterialStepRecorderTool')
topSeq = AlgSequence() ## Run ParticleGenerator athenaCommonFlags.PoolEvgenInput.set_Off() import AthenaCommon.AtlasUnixGeneratorJob import ParticleGun as PG from G4AtlasApps.SimFlags import simFlags # The following will work in later releases than 20.0 (From Nick) for breaking up jobs: athena -c 'myRandomSeed = 777' #if 'myRandomSeed' not in dir() : # myRandomSeed = 12398190 #pg = PG.ParticleGun(randomSvcName=simFlags.RandomSvc.get_Value(), randomStream="SINGLE", randomSeed=myRandomSeed) pg = PG.ParticleGun(randomSvcName=simFlags.RandomSvc.get_Value(), randomStream="SINGLE") pg.sampler.pid = 13 pg.sampler.mom = PG.PtEtaMPhiSampler(pt=100000, eta=[-2.7, 2.7]) topSeq += pg #try: # from EvgenProdTools.EvgenProdToolsConf import CopyEventWeight #except: # from GeneratorModules.GeneratorModulesConf import CopyEventWeight #topSeq += CopyEventWeight(TruthCollKey="GEN_EVENT") include("G4AtlasApps/G4Atlas.flat.configuration.py") from AthenaCommon.CfgGetter import getAlgorithm topSeq += getAlgorithm("G4AtlasAlg", tryDefaultConfigurable=True) # Output MessageSvc.defaultLimit = 500
def __init__(self): self.mom1 = PG.PtEtaMPhiSampler(pt=25000, eta=[-2, 2])