2 evgenConfig.description =
"Single particle gun for Sampling Fraction event generation"
3 evgenConfig.keywords = [
"singleParticle",]
4 evgenConfig.generators = [
"ParticleGun"]
5 evgenConfig.contact = [
"michael.duehrssen@cern.ch"]
7 import ParticleGun
as PG
8 import ROOT, math, random
12 Projective showers starting at entrance of calorimeter, flat in eta, constant energy
15 def __init__(self,pid=11,momentum=50000.,eta1=0.,eta2=1.4,bec=0,radius=1500.,z=3740.5):
20 pdg_table = ROOT.TDatabasePDG.Instance()
21 self.
mass = pdg_table.GetParticle(self.
pid()).Mass()*1000.
28 eta = random.uniform(self.
eta1, self.
eta2)
29 phi = random.uniform(0, math.tau)
30 v4 = ROOT.TLorentzVector()
32 v4.SetPtEtaPhiM(pt, eta, phi, self.
mass)
35 x=radius*math.cos(phi)
36 y=radius*math.sin(phi)
37 z=radius*math.sinh(eta)
40 radius=z/math.sinh(eta)
41 x=radius*math.cos(phi)
42 y=radius*math.sin(phi)
43 t=math.sqrt(x*x+y*y+z*z)
44 vp = ROOT.TLorentzVector(x,y,z,t)
45 p = PG.SampledParticle(pid=self.
pid(),mom=v4,pos=vp)
54 FIRST_DIR = (os.environ[
'JOBOPTSEARCHPATH']).
split(
":")[0]
55 jofiles = [f
for f
in os.listdir(FIRST_DIR)
if (f.startswith(
'mc')
and f.endswith(
'.py'))]
57 print "================ SETTTINGS ================="
58 print (
"jofiles = ", jofiles)
61 args = jofiles[0].
split(
'.py')[0]
62 print (
"args = ", args)
65 print (
"Momentum = ", myMomentum,
"MeV")
68 print (
"pid = ", myPDGID)
71 print (
"etalow = ", myLowEta)
74 print (
"etahigh = ", myHighEta)
77 myRadius = 0.001*
float(args.split(
'_Radius')[1].
split(
'_')[0])
80 print (
"radius = ", myRadius,
"mm")
86 print (
"Z = ", myZ,
"mm")
93 print "============================================"
95 genSeq += PG.ParticleGun()
96 genSeq.ParticleGun.sampler =
MyParticleSampler(momentum=myMomentum,eta1=myLowEta,eta2=myHighEta,pid=myPDGID,bec=bec,radius=myRadius,z=myZ)