Compositing puzzle - combining 2D and 3D

Compositing puzzle. I have 3d geometry and a 2d element I want to composite together.
For simplicity sake, think of the 3d element as a vertical Plane (wall) and 2d element a horizontal ‘beam of light’ in a TOP.
I need to give the illusion that this beam is penetrating the wall.
Some type of depth masking or?