Access beam particle information after passing to G4PrimaryVertex

Dear Experts,

I currently face the following problem: I have an external generator that, given a kaon 4-momentum, returns the momenta of the daughter particles for some decay channel (e.g. K->pi+pi0). I call this generator in my PrimaryGeneratorAction class (which is the concrete implementation of G4VUserPrimaryGeneratorAction) with the momentum of the kaon at its production. The problem is that the kaon decays in-flight after some 100 meters from its production point. Hence, the momenta of the daughter particles are not the ones in my generator since, from what I understand, Geant boosts again the daughters from the kaon’s initial frame to the its final frame.
My question is: is there any way to retrieve the beamparticle mometum at its decay point inside PrimaryGeneratorAction?

Thank you very much in advance!


I think you can access all information of decay point by using UserSteppingAction.
This “track step” is for incident particle, then you can use the following function to get your daughter particle information.

Hope it is helpful for you.




Thank you for the reply! The problem with this approach is that I start generating the event. What I want is to be able to generate again the vertex if the daughters momenta do not fulfill some requirements. I was thinking that if I can access the beam particle momentum at its decay point inside PrimaryGeneratorAction, then it would be trivial to implement my logic. Otherwise I have to reject the event inside SteppingAction, I believe.



Your issue sounds to refer to the bias techniques.
I think you can find some hint from the following links.
Hope it is helpful for you.


I understand you deal with a charged kaon (final state pi+ pi0). Are the 100 meters filled with some gas for example ? In what case, the K+ will loose energy by ionization, which will be reflected to its daughter particle energies. These one will not have then the energy they had in the generator, as corresponding to the initial K+ energy. Is this correct ?

Yes, that is correct. The issue I’m facing is: can I access the daughter momenta at the decay of the beam particle, i.e. doing the same thing I’m doing now in PrimaryGeneratorAction, but at the decay point of the Kaon, not at its production? This would be very helpful for biasing as I can keep all events simulated by Geant.

If you have the daughter tracks in hand (in a tracking action or stepping action, for example), then you can use track->GetVertexPosition() and track->GetVertexMomentum() to get their initial information.

Sure! This is not what I meant. My idea is to feed the generator with the Kaon momentum at its decay point. I do not know if this is possible.