Main sequence fitting (or cluster fitting) is the determination of the distance to a stellar cluster through matching spectrography or color index to the H-R diagram. The goal is to determine the absolute magnitude of the stars, and through that, stellar distance determination. It is much like spectroscopic parallax, but by applying it to a number of stars, accuracy is better since random errors can be averaged and outliers can be noted and handled appropriately.
The cluster is presumed to have been formed by a single molecular cloud, formed around the same time, with the same metallicity, and remaining in the region of their formation. Once reasonable estimates of distance and absolute magnitude are determined, they provide observation targets for study of the stars and calibration of other methods of stellar distance determination.