Primary particle weight

Dear Experts,

Is there a way to set primary particle weight? It seems that particleGun class doesnt have this method or am i wrong?

You’re correct that G4ParticleGun doesn’t do weights, nor does G4GeneralParticleSource (GPS).

G4PrimaryParticle does have a weight, with public SetWeight(w) and GetWeight() functions. If you have a sufficiently complex event generator that you need to apply weights to the primaries, you probably want to write your own subclass of G4VPrimaryGenerator to handle it.

1 Like

see examples/extended/eventgenerator/userPrimaryGenerator

1 Like

As i understood in class Primary Generator we can create source with multiple verticies(in this example they have 2 verticies and 3 particles. One from vert A and two from vert B) and in PrimaryGeneratorAction we just generate those verticies(So command /run/beamOn 1 will produce 3 particles from those verticies)?
upd: I guess i answered my own question. Thank you for pointing to the example, it helped