Optical gates are basicly an infra LED and photo sensor facing eachother. If infrawave is sensed then the optical gate is open.
It is closed otherwise. If everything functions normally a closed optical gate means something is blocking the space between the infra LED and photo sensor.
They are widely used for counting objects.
More information