SND@LHC Software
Loading...
Searching...
No Matches
g4Ex_gap.MyGeneratorAction Class Reference
Inheritance diagram for g4Ex_gap.MyGeneratorAction:
Collaboration diagram for g4Ex_gap.MyGeneratorAction:

Public Member Functions

 GeneratePrimaries (self, anEvent)
 

Static Public Attributes

 pos = G4ThreeVector(0*cm, 0*cm, -world_r/2.)
 

Detailed Description

Definition at line 191 of file g4Ex_gap.py.

Member Function Documentation

◆ GeneratePrimaries()

g4Ex_gap.MyGeneratorAction.GeneratePrimaries (   self,
  anEvent 
)

Definition at line 195 of file g4Ex_gap.py.

195 def GeneratePrimaries(self,anEvent):
196 global debug,nevTot,particleGun,fullTungsten
197 t_0 = time.time()
198 npart = 0
199 if particleGun:
200# to evaluate interaction position
201 ztarget = G4ThreeVector(0*cm, 0*cm, -50.*m)
202 vertex = G4PrimaryVertex(ztarget,0.)
203 G4particle = G4PrimaryParticle( 2212 )
204 G4particle.Set4Momentum( 0,0,400*GeV,400.0011*GeV )
205# store mother ID
206 w = 2212 + 0 * 100000
207 G4particle.SetWeight(w)
208 vertex.SetPrimary( G4particle )
209 npart += 1
210 else:
211 while npart == 0:
212 myPythia.GenerateEvent()
213 nevTot+=1
214 myTimer['pythia']+=time.time()-t_0
215# pythia interaction happens at 0,0,0
216 #x = rnr.Uniform(-3.,3.)
217 #y = rnr.Uniform(-3.,3.)
218 # leave this smearing for later
219 # create new primaries and set them to the vertex
220 particles = myPythia.GetListOfParticles()
221 if fullTungsten: z = rnr.Exp(10*cm) -50.*m # tungsten interaction length
222 else: z = rnr.Exp(16*cm) -50.*m # Mo/H20/W average interaction length
223 ztarget = G4ThreeVector(0*cm, 0*cm, z)
224 vertex = G4PrimaryVertex(ztarget,0.)
225 v = ROOT.TLorentzVector()
226 for p in particles:
227 if p.GetStatusCode()!=1 : continue
228 pid = p.GetPdgCode()
229 mkey = p.GetMother(0)+1
230 mother = myPythia.GetParticle(mkey)
231 if JpsiMainly and abs(pid) != 13 : continue
232 if tauOnly and abs(pid) != 16 : continue
233 if JpsiMainly and mother.GetPdgCode() != 443 : continue
234 if tauOnly :
235 mmkey = mother.GetMother(0)+1
236 mmother = myPythia.GetParticle(mmkey)
237 if abs(mother.GetPdgCode()) != 431 and abs(mmother.GetPdgCode()) != 431 :
238 myPythia.EventListing()
239 continue
240 qed = pid in qedlist # use cut only for photons, leptons/neutrinos, protons and neutrons
241 p.Momentum(v)
242 Ekin = (v.E()-v.M())
243 if Ekin*GeV < ecut and (qed or allPart): continue
244 G4particle = G4PrimaryParticle( pid )
245 G4particle.Set4Momentum( v.Px()*GeV,v.Py()*GeV,v.Pz()*GeV,v.E()*GeV )
246# store mother ID
247 curPid = p.GetPdgCode() + 10000 # make it positive
248 moPid = mother.GetPdgCode() + 10000
249 w = curPid + moPid * 100000
250 G4particle.SetWeight(w)
251 vertex.SetPrimary( G4particle )
252 npart += 1
253 # if debug: myPythia.EventListing()
254 anEvent.AddPrimaryVertex( vertex )
255 if debug and not particleGun: print('new event at ',ztarget.z/m)
256 myTimer['geant4_conv']+=time.time()-t_0

Member Data Documentation

◆ pos

g4Ex_gap.MyGeneratorAction.pos = G4ThreeVector(0*cm, 0*cm, -world_r/2.)
static

Definition at line 193 of file g4Ex_gap.py.


The documentation for this class was generated from the following file: