1. A method for measuring flatness along a Z-axis of a detection stage, the method comprising: (a) obtaining two or more images of a first XY coordinate on a substantially flat substrate positioned on the detection stage, wherein the two or more images represent different Z coordinates at the first XY coordinate; (b) determining a sharpest Z coordinate at the first XY coordinate based on sharpness of the two or more images representing different Z coordinates at the first XY coordinate; (c) obtaining two or more images of a second XY coordinate spaced apart from the first XY coordinate on the substantially flat substrate, wherein the two or more images of the second XY coordinate represent different Z coordinates at the second XY coordinate; (d) determining a sharpest Z coordinate at the second XY coordinate based on sharpness of the two or more images representing different Z coordinates at the second XY coordinate; and (e) calculating a difference between the sharpest Z coordinate at the first XY coordinate and the sharpest Z coordinate at the second XY coordinate to measure the flatness of the detection stage along the Z-axis.