def getRootname(input, suffix):
    """Return the root of a file name.

    If suffix is found in input, return the portion of input
    that precedes suffix.  Otherwise, if input ends in ".fits",
    return everything from input that precedes ".fits".

    Parameters
    ----------
    input: str
        Name of a raw input file.

    suffix: str
        Suffix that might be found in input.

    Returns
    -------
    root: str
        input truncated before suffix, or truncated before ".fits"
        if suffix is not found.

    Examples
    --------
    >>> print getRootname("abc_asn.fits", "_asn")
    abc

    >>> print getRootname("abc_rawtag_b.fits", "_asn")
    abc_rawtag_b

    >>> print getRootname("abc_rawtag_b.fits", "_raw")
    abc

    >>> print getRootname("abc_rawtag_b.fits", "_rawtag")
    abc

    >>> print getRootname("abc_rawtag_b.fits", "_rawtag_b")
    abc

    >>> print getRootname("abc", "_asn")
    abc
    """
    if input.find(suffix) < 0:
        suffix = '_corr'
    pieces = input.split(suffix)
    if len(pieces) > 1:
        root = suffix.join(pieces[:-1])
    elif input.endswith('.fits'):
        extn = input.rfind('.fits')
        root = input[:extn]
    else:
        root = input[:]
    return root
