155 def GeneratePrimaries(self,anEvent):
156 global debug,nevTot
157 t_0 = time.time()
158 npart = 0
159 while npart == 0:
160 myPythia.GenerateEvent()
161 nevTot+=1
162 myTimer['pythia']+=time.time()-t_0
163
164
165
166
167 pos = G4ThreeVector(0*cm, 0*cm, -50*m)
168 vertex = G4PrimaryVertex(pos,0.)
169
170 particles = myPythia.GetListOfParticles()
171 for p in particles:
172 if p.GetStatusCode()!=1 : continue
173 pid = p.GetPdgCode()
174 if tauOnly and abs(pid) != 16: continue
175 if pid in notWanted : continue
176 G4particle = G4PrimaryParticle( pid )
177 v = TLorentzVector()
178 p.Momentum(v)
179 if v.E()*GeV < ecut : continue
180 G4particle.Set4Momentum( v.Px()*GeV,v.Py()*GeV,v.Pz()*GeV,v.E()*GeV )
181 vertex.SetPrimary( G4particle )
182
183 mkey = p.GetMother(0)+1
184 mother = myPythia.GetParticle(mkey)
185 curPid = p.GetPdgCode() + 10000
186 moPid = mother.GetPdgCode() + 10000
187 w = curPid + moPid * 100000
188 G4particle.SetWeight(w)
189 npart += 1
190 if tauOnly and debug: myPythia.EventListing()
191 anEvent.AddPrimaryVertex( vertex )
192 myTimer['geant4_conv']+=time.time()-t_0