Code for particle tracking.