def _merge_two_curves(curve1: Curve, curve2: Curve, qmin, qmax, qsep, use_additive_constant=False):
curve1=curve1.sanitize()<EOL>curve2=curve2.sanitize()<EOL>if len(curve1.trim(qmin, qmax)) > len(curve2.trim(qmin, qmax)):<EOL><INDENT>curve2_interp = curve2.trim(qmin, qmax)<EOL>curve1_interp = curve1.interpolate(curve2_interp.q)<EOL><DEDENT>else:<EOL><INDENT>curve1_interp = curve1.trim(qmin, qmax)<EOL>curve2_interp = curve2.interpolate(curve1_interp.q)<EOL><DEDENT>if use_additive_constant:<EOL><INDENT>bg_init = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>bg_init = FixedParameter(<NUM_LIT:0>)<EOL><DEDENT>factor, bg, stat = nonlinear_odr(curve2_interp.Intensity, curve1_interp.Intensity,<EOL>curve2_interp.Error, curve1_interp.Error,<EOL>lambda x, factor, bg: x * factor + bg, [<NUM_LIT:1.0>, bg_init])<EOL>return Curve.merge(curve1 - bg, curve2 * factor, qsep), factor, bg, stat<EOL>
Merge two scattering curves

    :param curve1: the first curve (longer distance)
    :type curve1: sastool.classes.curve.GeneralCurve
    :param curve2: the second curve (shorter distance)
    :type curve2: sastool.classes.curve.GeneralCurve
    :param qmin: lower bound of the interval for determining the scaling factor
    :type qmin: float
    :param qmax: upper bound of the interval for determining the scaling factor
    :type qmax: float
    :param qsep: separating (tailoring) point for the merge
    :type qsep: float
    :return: merged_curve, factor, background, stat
    :rtype tuple of a sastool.classes2.curve.Curve and a float