ATLAS Offline Software
Loading...
Searching...
No Matches
ParticleGun_EoverP_Config.py
Go to the documentation of this file.
1#! -*- python -*-
2evgenConfig.description = "Single particle gun for E/p event generation"
3evgenConfig.keywords = ["singleParticle",]
4evgenConfig.generators = ["ParticleGun"]
5evgenConfig.contact = ["zach.marshall@cern.ch"]
6
7import ParticleGun as PG
8import ROOT
9from ParticleGun.samplers import *
10class 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
59a_particle = int(jofile.split('_')[-1].split('.py')[0].replace('m','-'))
60
61pg = PG.ParticleGun()
62pg.sampler.pid = int(a_particle) #PID
63pg.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))
65genSeq += pg
66
__init__(self, momentum, eta, pid=211, phi=[0, math.pi *2.])
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177