def gsetting_to_R(G, oldmezz=False):
    """This function converts an analog gain setting into the corresponding effective
    resistance set in the switchable resistor.

    Parameters
    ----------
    G : Integer [0, 15]
        Mezzanine gain setting

    oldmezz : Boolean, default=False
        For use with the Rev2 mezzanines (Not part of any PB2 or SPT3G allocation)

    Returns
    -------
    float
        Effective resistance of the switchable resitive network for the gain
        stage.
    """

    if G not in range(16):
        raise(Exception("Mezzanine Gain settings are integers in set [0, 15]"))

    if oldmezz:
        return 100+(15-G)*15.
    else:
        Rs = [300.0000, 212.0000, 174.2857, 153.3333, 140.0000, 130.7692,
              124.0000, 118.8235, 114.7368, 111.4286, 108.6957, 106.4000,
              104.4444, 102.7586, 101.2903, 100.0000]
        return Rs[G]