The relativistic self focusing of an ultraintense laser propagating through an underdense plasma is analyzed from a geometrical optics point of view, exploiting the classical hamiltonian formalism. The distribution of the laser intensity along the self-generated plasma channel is studied and compared to measurements.