After plastic caps are conveyed, they must be checked to verify that they are positioned correctly (top/bottom) for further process steps. The cap has a different diameter on the outside surface (e.g. a collar). Depending on the position, the outer diameter will deviate.
The laser distance sensor is taught in on the shorter working distance (large diameter). If the distance is greater, it is deviating and the sensor switches off.