ATLAS Offline Software
Loading...
Searching...
No Matches
python.samplers Namespace Reference

Classes

class  ConstSampler
class  ContinuousSampler
 Continuous distribution samplers. More...
class  CyclicSeqSampler
class  DiscreteSampler
 Discrete sequence samplers. More...
class  DisjointUniformSampler
class  EEtaMPhiSampler
class  ERapMPhiSampler
class  EThetaMPhiSampler
class  GaussianSampler
class  InvSampler
class  LogSampler
class  ModUniformSampler
class  MomSampler
 Momentum sampling. More...
class  MXYZSampler
class  NullMomSampler
class  ParticleSampler
class  PosSampler
 Beam-spot (origin vertex) sampling. More...
class  PtEtaMPhiSampler
class  PtRapMPhiSampler
class  PtThetaMPhiSampler
class  RandomSeqSampler
class  SampledParticle
class  Sampler
class  TH1Sampler
class  UniformSampler

Functions

 mksampler (x)
 Convenience function for sampler-making from Python literals.

Variables

 PI = math.pi
 For convenience.
int TWOPI = 2*math.pi
 RndmSeq = RandomSeqSampler
 Sequence = CyclicSeqSampler
 Alias:
dict MASSES
 Combined samplers returning a particle configuration.

Function Documentation

◆ mksampler()

python.samplers.mksampler ( x)

Convenience function for sampler-making from Python literals.

Automatically cast the provided object to a sampler type. This is used
extensively inside the particle and position samplers, so that the user
can pass in a primitive type like a number or list and it will be
treated as if the more verbose sampler constructors had been called.

Behaviour:
 - if x can be called, i.e. x() is valid, we just return x;
 - a Python list (square brackets) will be converted to a continuous
   UniformSampler or DisjointUniformSampler;
 - a Python tuple (round brackets/parentheses) will be treated
   as a discrete CyclicSeqSampler;
 - a Python set (curly brackets/braces) will be treated
   as a discrete RandomSeqSampler;
 - otherwise a ConstSampler will be created from x, so that x is
   returned when the sampler is called.

Definition at line 245 of file samplers.py.

245def mksampler(x):
246 """
247 Automatically cast the provided object to a sampler type. This is used
248 extensively inside the particle and position samplers, so that the user
249 can pass in a primitive type like a number or list and it will be
250 treated as if the more verbose sampler constructors had been called.
251
252 Behaviour:
253 - if x can be called, i.e. x() is valid, we just return x;
254 - a Python list (square brackets) will be converted to a continuous
255 UniformSampler or DisjointUniformSampler;
256 - a Python tuple (round brackets/parentheses) will be treated
257 as a discrete CyclicSeqSampler;
258 - a Python set (curly brackets/braces) will be treated
259 as a discrete RandomSeqSampler;
260 - otherwise a ConstSampler will be created from x, so that x is
261 returned when the sampler is called.
262 """
263 if callable(x):
264 return x
265 elif type(x) is list:
266 # NB: disjoint ranges can be given as nested lists, e.g. [(1,2), (4,5)]
267 if len(x) == 2 and type(x[0]) in (int,float) and type(x[1]) in (int,float):
268 return UniformSampler(*x)
269 elif len(x) > 2 or (len(x) > 0 and type(x[0]) not in (int,float)):
270 return DisjointUniformSampler(x)
271 if len(x) < 2:
272 raise Exception("Supplied list could not be converted to a continuous sampler")
273 elif type(x) is tuple:
274 return CyclicSeqSampler(*x)
275 elif type(x) is set:
276 return RandomSeqSampler(*x)
277 else:
278 return ConstSampler(x)
279
280

Variable Documentation

◆ MASSES

dict python.samplers.MASSES
Initial value:
1= { 22 : 0.0, # photon
2 11 : 0.5, # electron
3 12 : 0.0, # nu_e
4 13 : 105.7, # muon
5 14 : 0.0, # nu_mu
6 15 : 1777.8, # tau
7 16 : 0.0, # nu_tau
8 2212 : 938.0, # proton
9 2112 : 940.0, # neutron
10 111 : 135.0, # pi0
11 211 : 140.0, # pi+-
12 221 : 547.0, # eta
13 321 : 494.0, # K+-
14 311 : 598.0 # K0
15 }

Combined samplers returning a particle configuration.

A default dictionary of particle masses (in MeV)

Definition at line 820 of file samplers.py.

◆ PI

python.samplers.PI = math.pi

For convenience.

Definition at line 7 of file samplers.py.

◆ RndmSeq

python.samplers.RndmSeq = RandomSeqSampler

Definition at line 220 of file samplers.py.

◆ Sequence

python.samplers.Sequence = CyclicSeqSampler

Alias:

Definition at line 237 of file samplers.py.

◆ TWOPI

int python.samplers.TWOPI = 2*math.pi

Definition at line 8 of file samplers.py.