Tracklength on mesh

i want get fluence and energy of photon at different position in a World, one of way is to get tracklength firstly on grid which is divided by mesh to the World.
But i don’t konw how to mesh physical world to grid, and how to calculate photon tracklength in grid.
If someone have idea plase help me.
Thank you in advance.