ATLAS Offline Software
ParticleGun_EoverP_Config.py
Go to the documentation of this file.
1 #! -*- python -*-
2 evgenConfig.description = "Single particle gun for E/p event generation"
3 evgenConfig.keywords = ["singleParticle",]
4 evgenConfig.generators = ["ParticleGun"]
5 evgenConfig.contact = ["zach.marshall@cern.ch"]
6 
7 import ParticleGun as PG
8 import ROOT
9 from ParticleGun.samplers import *
10 class PEtaSampler(PG.MomSampler):
11  "Create a 4-momentum vector from pt, eta, m and phi distributions/samplers."
12 
13  def __init__(self, momentum, eta, pid=211, phi=[0, math.pi*2.]):
14  self.momentum = momentum
15  self.eta = eta
16  pdg_table = ROOT.TDatabasePDG.Instance() #Gives values in GeV
17  mass = pdg_table.GetParticle(pid).Mass()*1000.
18  self.mass = mass
19  self.phi = phi
20 
21  @property
22  def momentum(self):
23  "Momentum sampler"
24  return self._momentum
25  @momentum.setter
26  def momentum(self, x):
27  self._momentum = mksampler(x)
28 
29  @property
30  def eta(self):
31  "Pseudorapidity sampler"
32  return self._eta
33  @eta.setter
34  def eta(self, x):
35  self._eta = mksampler(x)
36 
37  @property
38  def mass(self):
39  "Mass sampler"
40  return self._m
41  @mass.setter
42  def mass(self, x):
43  self._m = mksampler(x)
44 
45  @property
46  def phi(self):
47  "Azimuthal angle sampler"
48  return self._phi
49  @phi.setter
50  def phi(self, x):
51  self._phi = mksampler(x)
52 
53  def shoot(self):
54  v4 = ROOT.TLorentzVector()
55  pt = p / math.cosh(self.eta())
56  v4.SetPtEtaPhiM(pt, self.eta(), self.phi(), self.mass())
57  return v4
58 
59 a_particle = int(jofile.split('_')[-1].split('.py')[0].replace('m','-'))
60 
61 pg = PG.ParticleGun()
62 pg.sampler.pid = int(a_particle) #PID
63 pg.sampler.mom = PEtaSampler(momentum=(500,800,1000,1200,1500,2000,3000,4000,5000,6000,7000,8000,9000,10000,11000,13000,15000,17000,20000,\
64  25000,35000,50000,75000,100000,200000,350000,500000), eta=[-0.3,0.3], pid=int(a_particle))
65 genSeq += pg
66 
ParticleGun_EoverP_Config.PEtaSampler._eta
_eta
Definition: ParticleGun_EoverP_Config.py:35
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
ParticleGun_EoverP_Config.PEtaSampler._phi
_phi
Definition: ParticleGun_EoverP_Config.py:51
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ParticleGun_EoverP_Config.PEtaSampler
Definition: ParticleGun_EoverP_Config.py:10
ParticleGun_EoverP_Config.PEtaSampler._m
_m
Definition: ParticleGun_EoverP_Config.py:43
samplers
ParticleGun_EoverP_Config.PEtaSampler.mass
mass
Definition: ParticleGun_EoverP_Config.py:18
ParticleGun_EoverP_Config.PEtaSampler.__init__
def __init__(self, momentum, eta, pid=211, phi=[0, math.pi *2.])
Definition: ParticleGun_EoverP_Config.py:13
python.samplers.mksampler
def mksampler(x)
Convenience function for sampler-making from Python literals.
Definition: samplers.py:245
ParticleGun_EoverP_Config.PEtaSampler.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:14
ParticleGun_EoverP_Config.PEtaSampler._momentum
_momentum
Definition: ParticleGun_EoverP_Config.py:27
ParticleGun_EoverP_Config.PEtaSampler.phi
phi
Definition: ParticleGun_EoverP_Config.py:19
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
ParticleGun_EoverP_Config.PEtaSampler.shoot
def shoot(self)
Definition: ParticleGun_EoverP_Config.py:53
ParticleGun_EoverP_Config.PEtaSampler.eta
eta
Definition: ParticleGun_EoverP_Config.py:15