Tracking beginning of the light path I am writing postprocessing script to the cycles rendering.

Can I somehow track the whole lightpath of a single pixel from the camera to the origin of the light? 
For example the I have 3 lamps(A, B, C) and an environment map in my scene. I want to know that pixel (200,100) is in 30% made from light of lamp A and in 70% from lamp B.(some of render samples came across one, some across another) And pixel (300, 200) reflects the environment map’s coordinate (2000,1000). 
Is there any way to extract the information about from where the light comes, maybe at least from single render sample?(since in one sample each pixel should reflect/refract only one light source) If so, at which level I should integrate with blender? Python scripting is ok or do I need to recompile some parts of cycles?

My final point is to find origin of each light path and track how the object interacts with environment.
Rendering doesn't work like that. Tracking only 1 light path would give a very bad representation of the scene and would be inaccurate.

Each pixel is an origin for infinite amount of light paths leading into different light sources, each bounce determined by probability. Rendering infinite samples is not doable, so the more samples (light paths traced), the better the image (better representing the scene).

There are 2 approaches you can go:


Render the image in N-dimensional color space, N being the number of light sources, each light-source being monochromatic only. Render as many samples as you can. Each pixel's color will exactly correspond with what light influenced it.

My guess is you will have to compile your own Cycles for this.
Render the image multiple times, one light source at a time. This can be scripted with python, or even done by animating the lights and rendering N-frames long animation, where N is number of lights. Each frame will be an exact map of how that light influences the scene.