Study of the Gamma Ray Horizon with MAGIC as a new method to perform cosmological measurements