A unified treatment of track reconstruction and particle identification