Adding and "controlling" a process

Dear Users, i am developing some code with hadronic interactions that i want to interface with Pythia8.
I want to shoot an hadron and when an inelastic interaction occurs the primary particle must be killed. Until here no problem, i am using a SteppingAction looking for the hadronic interaction in a volume and it is doing what i need.
My problem is, at that point i want to introduce the output from Pythia8 (in my case an ascii file). As far as i understood from the manual, just processes can add particles/tracks etc… So i do have created and registered a process in the physics list to read the ascii file and introduce the new particles through the particle change method. By the way, i am using a G4DiscreteProcess and its PostSetDoIt method. It is working, the particles are being added, but not in the volume that i want, sometimes before that volume as an hadronic interaction can occur with the air.
How can i tell to a process to apply “right now” i mean, how can i fully control when the process is trigered? I tried by returning the PostStepGetPhysicalInteractionLength as DLB_MAX or zero but i did not have observed any difference.
Can someone provide me some tips, hints, on this subject?
Thank you:
Carlos

Hello,

I would suggest to consider G4VUserPrimaryGenerator interface. Using G4VProcess seems not to be fully excluded but is not natural, because it is designed to be used at each step of a track, not only for one point, where particle is created.

VI

Thanks civanch. Indeed i have already the approach with G4VUserPrimaryGenerator working. The only advantage to use the process was to consider “few” interactions that can occur prior to the inelastic hadrónic interaction, like elastic or ionizations, but indeed, i have to check if the difficulty of “controlling the process” brings something different that just use the primary generator as you suggested.
Thank you
Carlos