  The OPERA detector, designed to search for $\nu_{\mu} \to \nu_{\tau}$
oscillations in the CNGS beam, is located in the underground Gran Sasso
laboratory, a privileged location to study TeV-scale cosmic rays. For the
analysis here presented, the detector was used to measure the atmospheric muon
charge ratio in the TeV region. OPERA collected charge-separated cosmic ray
data between 2008 and 2012. More than 3 million atmospheric muon events were
detected and reconstructed, among which about 110000 multiple muon bundles. The
charge ratio $R_{\mu} \equiv N_{\mu^+}/N_{\mu^-}$ was measured separately for
single and for multiple muon events. The analysis exploited the inversion of
the magnet polarity which was performed on purpose during the 2012 Run. The
combination of the two data sets with opposite magnet polarities allowed
minimizing systematic uncertainties and reaching an accurate determination of
the muon charge ratio. Data were fitted to obtain relevant parameters on the
composition of primary cosmic rays and the associated kaon production in the
forward fragmentation region. In the surface energy range 1-20 TeV investigated
by OPERA, $R_{\mu}$ is well described by a parametric model including only pion
and kaon contributions to the muon flux, showing no significant contribution of
the prompt component. The energy independence supports the validity of Feynman
scaling in the fragmentation region up to $200$ TeV/nucleon primary energy.
