Geometry and entanglement in the scattering matrix