def eventstr(event_tuple=None, event=None, register=None, parameters=None):
    """
    Return a LIKWID event string from an event tuple or keyword arguments.

    *event_tuple* may have two or three arguments: (event, register) or
    (event, register, parameters)

    Keyword arguments will be overwritten by *event_tuple*.

    >>> eventstr(('L1D_RE'+'PLACEMENT', 'PMC0', None))
    'L1D_RE'+'PLACEMENT:PMC0'
    >>> eventstr(('L1D_RE'+'PLACEMENT', 'PMC0'))
    'L1D_RE'+'PLACEMENT:PMC0'
    >>> eventstr(('MEM_UOPS_RETIRED_LOADS', 'PMC3', {'EDGEDETECT': None, 'THRESHOLD': 2342}))
    'MEM_UOPS_RETIRED_LOADS:PMC3:EDGEDETECT:THRESHOLD=0x926'
    >>> eventstr(event='DTLB_LOAD_MISSES_WALK_DURATION', register='PMC3')
    'DTLB_LOAD_MISSES_WALK_DURATION:PMC3'
    """
    if len(event_tuple) == 3:
        event, register, parameters = event_tuple
    elif len(event_tuple) == 2:
        event, register = event_tuple
    event_dscr = [event, register]
    if parameters:
        for k, v in sorted(event_tuple[2].items()):
            if type(v) is int:
                k += '={}'.format(hex(v))
            event_dscr.append(k)
    return ':'.join(event_dscr)
