100 def GeneratePrimaries(self,anEvent):
101 global debug,nevTot
102 t_0 = time.time()
103 npart = 0
104 while npart == 0:
105 myPythia.GenerateEvent()
106 nevTot+=1
107 myTimer['pythia']+=time.time()-t_0
108
109
110
111
112 pos = G4ThreeVector(0*cm, 0*cm, -50*m)
113 vertex = G4PrimaryVertex(pos,0.)
114
115 particles = myPythia.GetListOfParticles()
116 for p in particles:
117 if p.GetStatusCode()!=1 : continue
118 pid = p.GetPdgCode()
119 if tauOnly and abs(pid) != 16: continue
120 if pid in notWanted : continue
121 G4particle = G4PrimaryParticle( pid )
122 v = TLorentzVector()
123 p.Momentum(v)
124 if v.E()*GeV < ecut : continue
125 G4particle.Set4Momentum( v.Px()*GeV,v.Py()*GeV,v.Pz()*GeV,v.E()*GeV )
126 vertex.SetPrimary( G4particle )
127
128 mkey = p.GetMother(0)+1
129 mother = myPythia.GetParticle(mkey)
130 curPid = p.GetPdgCode() + 10000
131 moPid = mother.GetPdgCode() + 10000
132 w = curPid + moPid * 100000
133 G4particle.SetWeight(w)
134 npart += 1
135 if tauOnly and debug: myPythia.EventListing()
136 anEvent.AddPrimaryVertex( vertex )
137 myTimer['geant4_conv']+=time.time()-t_0