Applies a correction function to the MS1 ion m/z arrays in order to
    correct for a m/z dependent m/z error.

    :param msrunContainer: intance of :class:`maspy.core.MsrunContainer`,
        containing the :class:`maspy.core.Sai` items of the "specfile".
    :param specfile: filename of an ms-run file to which the m/z calibration
        should be applied
    :param dataFit: a :class:`maspy.auxiliary.DataFit` object, containing
        processed calibration data.
    :param toleranceMode: "relative" or "absolute"
        Specifies how the ``massTolerance`` value is applied, by default
        "relative".

def applyMassCalMs1(msrunContainer, specfile, dataFit, **kwargs):
    """Applies a correction function to the MS1 ion m/z arrays in order to
    correct for a m/z dependent m/z error.

    :param msrunContainer: intance of :class:`maspy.core.MsrunContainer`,
        containing the :class:`maspy.core.Sai` items of the "specfile".
    :param specfile: filename of an ms-run file to which the m/z calibration
        should be applied
    :param dataFit: a :class:`maspy.auxiliary.DataFit` object, containing
        processed calibration data.
    :param toleranceMode: "relative" or "absolute"
        Specifies how the ``massTolerance`` value is applied, by default
        "relative".
    """
    toleranceMode = kwargs.get('toleranceMode', 'relative')

    if toleranceMode == 'relative':
        for si in msrunContainer.getItems(specfile,
                                          selector=lambda si: si.msLevel==1):
            mzArr = msrunContainer.saic[specfile][si.id].arrays['mz']
            corrArr = dataFit.corrArray(mzArr)
            mzArr *= (1 + corrArr)
    elif toleranceMode == 'absolute':
        for si in msrunContainer.getItems(specfile,
                                          selector=lambda si: si.msLevel==1):
            mzArr = msrunContainer.saic[specfile][si.id].arrays['mz']
            corrArr = dataFit.corrArray(mzArr)
            mzArr += corrArr
    else:
        raise Exception('#TODO: a proper exception text')