D Flip-Flop as pulse detector
If I understand the question, take the "clk" to one input of an XOR and the phototransistor - suitably biased - to the other XOR input.  When "in sync" the output will be zero most of the time, except for delay between the "clk" and the sensor.  A low-pass, perhaps an RC, followed by a schmitt trigger will tell if the signals are "in-sync" most of the time or not.  If the delay is a large fraction of the "clk" period, then other circuitry would be required.