Measurement of the charge ratio of atmospheric muons with the CMS detector