An analysis of the Rietveld refinement method