Commit 4600d6ea authored by Atlas-Software Librarian's avatar Atlas-Software Librarian Committed by Graeme Stewart
Browse files

'CMakeLists.txt' (ParticleGun-02-00-07)

	* Tagging: ParticleGun-02-00-07

	* Try harder to distinguish between single and disjoint uniform sampling interval shorthand sequences.

	* Fix accidental tuple expansion in DisjointRandomSequence expansion.

	* Adding randomSeed property setting to examples (ParticleGun RNG stream not configured for vanilla Athena).
parent b6717e99
################################################################################
# Package: ParticleGun
################################################################################
# Declare the package name:
atlas_subdir( ParticleGun )
# Install files from the package:
atlas_install_python_modules( python/*.py )
......@@ -26,6 +26,7 @@ class MyParticleSampler(PG.ParticleSampler):
return [p1, p2]
topSeq += PG.ParticleGun()
topSeq.ParticleGun.randomSeed = 123456
topSeq.ParticleGun.sampler = MyParticleSampler()
include("GeneratorUtils/postJO.CopyWeights.py")
......
......@@ -33,6 +33,7 @@ class PtEtaHistParticleSampler(PG.ParticleSampler):
return particles
topSeq += PG.ParticleGun()
topSeq.ParticleGun.randomSeed = 123456
topSeq.ParticleGun.sampler = PtEtaHistParticleSampler(11, "data_histos_el_1470pt.root")
include("GeneratorUtils/postJO.CopyWeights.py")
......
......@@ -7,6 +7,7 @@ theApp.EvtMax = 100
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
......
......@@ -7,6 +7,7 @@ theApp.EvtMax = 100
import ParticleGun as PG
pg = PG.ParticleGun()
pg.randomSeed = 123456
pg.sampler.pid = (2112, 22, 2112, 22)
pg.sampler.mom = PG.EThetaMPhiSampler(energy=(1360000, 500000, 1360000, 500000),
theta=(0, 0, PG.PI, PG.PI))
......
......@@ -7,6 +7,7 @@ theApp.EvtMax = 100
import ParticleGun as PG
pg = PG.ParticleGun()
pg.randomSeed = 123456
pg.sampler.pid = 13
pg.sampler.pos = PG.PosSampler(x=3140.0, y=[-154.134,154.134], z=[4938.76,5121.29], t=5929.7)
pg.sampler.mom = PG.EEtaMPhiSampler(energy=100000, eta=1.25, phi=0.0)
......
......@@ -34,7 +34,7 @@ class ParticleGun(EvgenAlg):
def initialize(self):
"""
Pass the AtRndmGenSvc seed to Python's random module (or fall back to a fixed value for reproducibility).
Pass the AtRndmGenSvc seed to Python's random module, or use a fixed value set via pg.randomSeed.
"""
seed = None
## Use self.randomSeed directly, or if it's None find a seed string from the ATLAS random number service
......@@ -57,6 +57,7 @@ class ParticleGun(EvgenAlg):
random.seed(seed)
return StatusCode.Success
else:
self.msg.error("ParticleGun: randomSeed property not set, and no %s random number service found" % self.randomSvcName)
return StatusCode.Failure
......
......@@ -252,13 +252,13 @@ def mksampler(x):
if hasattr(x, "__call__"):
return x
elif type(x) is list:
# TODO: allow disjoint ranges as nested lists, e.g. [(1,2), (4,5)]
if len(x) == 2:
# NB: disjoint ranges can be given as nested lists, e.g. [(1,2), (4,5)]
if len(x) == 2 and type(x[0]) in (int,float) and type(x[1]) in (int,float):
#print "MKSAMPLER: Casting %s to UniformSampler" % str(x)
return UniformSampler(*x)
elif len(x) > 2:
elif len(x) > 2 or (len(x) > 0 and type(x[0]) not in (int,float)):
#print "MKSAMPLER: Casting %s to DisjointUniformSampler" % str(x)
return DisjointUniformSampler(*x)
return DisjointUniformSampler(x)
if len(x) < 2:
raise Exception("Supplied list could not be converted to a continuous sampler")
elif type(x) is tuple:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment