An optimal Poincaré inequality for convex domains