Output particle information at parallel world boundary

Hi,
I’ve been trying to stop gammas at a parallel world boundary and output their parameters (pos, mom, energy, ID etc.) to root files. Does anyone know how to do this?
Cheers,
Jemima