Physics of the L-mode to H-mode transition in tokamaks