Study of the fragmentation of b quarks into B mesons at the Z peak