  We study the baryon mass fraction in a set of hydrodynamical simulations of
galaxy clusters performed using the Tree+SPH code GADGET-2. We investigate the
dependence of the baryon fraction upon the radiative cooling, star formation,
feedback through galactic winds, conduction and redshift. Both the cold stellar
component and the hot X-ray emitting gas have narrow distributions that, at
large cluster-centric distances r>R500, are nearly independent of the physics
included in the simulations. Only the non-radiative runs reproduce the gas
fraction inferred from observations of the inner regions (r ~ R2500) of massive
clusters. When cooling is turned on, the excess star formation is mitigated by
the action of galactic winds, but yet not by the amount required by
observational data. The baryon fraction within a fixed overdensity increases
slightly with redshift, independent of the physical processes involved in the
accumulation of baryons in the cluster potential well. In runs with cooling and
feedback, the increase in baryons is associated with a larger stellar mass
fraction that arises at high redshift as a consequence of more efficient gas
cooling. For the same reason, the gas fraction appears less concentrated at
higher redshift. We discuss the possible cosmological implications of our
results and find that two assumptions generally adopted, (1) mean value of Yb =
fb / (Omega_b/Omega_m) not evolving with redshift, and (2) a fixed ratio
between f_star and f_gas independent of radius and redshift, might not be
valid. In the estimate of the cosmic matter density parameter, this implies
some systematic effects of the order of Delta Omega_m/Omega_m < +0.15 for
non-radiative runs and Delta Omega_m/Omega_m ~ +0.05 and < -0.05 for radiative
simulations.
