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

Public Member Functions

 GeneratePrimaries (self, anEvent)
 

Detailed Description

Definition at line 153 of file g4Ex_args.py.

Member Function Documentation

◆ GeneratePrimaries()

g4Ex_args.MyGeneratorAction.GeneratePrimaries (   self,
  anEvent 
)

Definition at line 155 of file g4Ex_args.py.

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# pythia interaction happens at 0,0,0
164 #x = rnr.Uniform(-3.,3.)
165 #y = rnr.Uniform(-3.,3.)
166 # leave this smearing for later
167 pos = G4ThreeVector(0*cm, 0*cm, -50*m)
168 vertex = G4PrimaryVertex(pos,0.)
169 # create new primaries and set them to the vertex
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# store mother ID
183 mkey = p.GetMother(0)+1
184 mother = myPythia.GetParticle(mkey)
185 curPid = p.GetPdgCode() + 10000 # make it positive
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

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