def calculate_chp_share_and_efficiency(eb, fix_total=True):
    """Efficiency and fuel share of combined heat and power plants (chp) and
    heat plants (hp) from conversion balance.

    Examples
    --------
    >>> cb=energy_balance.get_transformation_balance(2014)
    >>> efficiency=calculate_chp_share_and_efficiency(cb, fix_total=False)
    >>> round(efficiency['NI']['hp'], 4)
    0.9888
    >>> round(efficiency['BB']['hp'], 4)
    inf
    >>> efficiency=calculate_chp_share_and_efficiency(cb)
    >>> round(efficiency['NI']['hp'], 4)
    0.9888
    >>> round(efficiency['BB']['hp'], 4)
    0.8885
    """
    row_chp = 'Heizkraftwerke der allgemeinen Versorgung (nur KWK)'
    row_hp = 'Heizwerke'
    row_total = 'Insgesamt'
    regions = list(eb.index.get_level_values(0).unique())
    eta = {}
    rows = ['Heizkraftwerke der allgemeinen Versorgung (nur KWK)', 'Heizwerke']
    if fix_total:
        eb.loc[eb.total == 0, 'total'] = eb.loc[eb.total == 0].sum(axis=1)
    for region in regions:
        eta[region] = {}
        in_chp = eb.loc[region, 'input', row_chp]
        in_hp = eb.loc[region, 'input', row_hp]
        elec_chp = eb.loc[(region, 'output', row_chp), 'electricity']
        heat_chp = eb.loc[(region, 'output', row_chp), 'district heating']
        heat_hp = eb.loc[(region, 'output', row_hp), 'district heating']
        heat_total = eb.loc[(region, 'output', row_total), 'district heating']
        end_total_heat = eb.loc[(region, 'usage', 'Endenergieverbrauch'),
            'district heating']
        eta[region]['sys_heat'] = end_total_heat / heat_total
        eta[region]['hp'] = float(heat_hp / in_hp.total)
        eta[region]['heat_chp'] = heat_chp / in_chp.total
        eta[region]['elec_chp'] = elec_chp / in_chp.total
        eta[region]['fuel_share'] = eb.loc[region, 'input', rows].div(eb.
            loc[region, 'input', rows].total.sum(), axis=0)
        eta[region]['out_share_factor_chp'] = heat_chp / in_chp.total * (in_chp
            .total + in_hp.total) / (heat_chp + heat_hp)
        eta[region]['out_share_factor_hp'] = heat_hp / in_hp.total * (in_chp
            .total + in_hp.total) / (heat_chp + heat_hp)
    return eta
