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

Public Member Functions

 GeneratePrimaries (self, anEvent)
 

Detailed Description

Definition at line 98 of file g4Ex.py.

Member Function Documentation

◆ GeneratePrimaries()

g4Ex.MyGeneratorAction.GeneratePrimaries (   self,
  anEvent 
)

Definition at line 100 of file g4Ex.py.

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# pythia interaction happens at 0,0,0
109 #x = rnr.Uniform(-3.,3.)
110 #y = rnr.Uniform(-3.,3.)
111 # leave this smearing for later
112 pos = G4ThreeVector(0*cm, 0*cm, -50*m)
113 vertex = G4PrimaryVertex(pos,0.)
114 # create new primaries and set them to the vertex
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# store mother ID
128 mkey = p.GetMother(0)+1
129 mother = myPythia.GetParticle(mkey)
130 curPid = p.GetPdgCode() + 10000 # make it positive
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

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