  We use a particle tracking analysis to study the origins of the
circumgalactic medium (CGM), separating it into (1) accretion from the
intergalactic medium (IGM), (2) wind from the central galaxy, and (3) gas
ejected from other galaxies. Our sample consists of 21 FIRE-2 simulations,
spanning the halo mass range log(Mh/Msun) ~ 10-12 , and we focus on z=0.25 and
z=2. Owing to strong stellar feedback, only ~L* halos retain a baryon mass
>~50% of their cosmic budget. Metals are more efficiently retained by halos,
with a retention fraction >~50%. Across all masses and redshifts analyzed >~60%
of the CGM mass originates as IGM accretion (some of which is associated with
infalling halos). Overall, the second most important contribution is wind from
the central galaxy, though gas ejected or stripped from satellites can
contribute a comparable mass in ~L* halos. Gas can persist in the CGM for
billions of years, resulting in well-mixed halo gas. Sight lines through the
CGM are therefore likely to intersect gas of multiple origins. For low-redshift
~L* halos, cool gas (T<10^4.7 K) is distributed on average preferentially along
the galaxy plane, however with strong halo-to-halo variability. The metallicity
of IGM accretion is systematically lower than the metallicity of winds
(typically by >~1 dex), although CGM and IGM metallicities depend significantly
on the treatment of subgrid metal diffusion. Our results highlight the multiple
physical mechanisms that contribute to the CGM and will inform observational
efforts to develop a cohesive picture.
