The COSMOS density field: a reconstruction using both weak lensing and galaxy distributions