def smdgen(run, timestamps=None, first=None, last=None):
    if (first is None):
        first = 0
    if (last is None):
        last = 1e+20
    if (size == 1):
        nom = rank
        denom = size
    else:
        nom = (rank - 1)
        denom = (size - 1)
    if (timestamps is None):
        for (nevent, evt) in enumerate(run.events()):
            if (nevent < first):
                continue
            elif (nevent == last):
                return
            elif ((nevent % denom) == nom):
                (yield ((nevent - first), evt))
    else:
        ct = 0
        for (nevent, evt) in enumerate(run.events()):
            t = pnccd_tbx.get_psana_time(evt)
            if np.equal(t, timestamps).all(axis=1).any():
                if (ct < first):
                    continue
                elif (ct == last):
                    return
                elif ((ct % denom) == nom):
                    (yield (ct, evt))
                ct += 1
def smdgen(run, timestamps=None, first=None, last=None):
    if (first is None):
        first = 0
    if (last is None):
        last = 1e+20
    if (size == 1):
        nom = rank
        denom = size
    else:
        nom = (rank - 1)
        denom = (size - 1)
    if (timestamps is None):
        for (nevent, evt) in enumerate(run.events()):
            if (nevent < first):
                continue
            elif (nevent == last):
                return
            elif ((nevent % denom) == nom):
                (yield ((nevent - first), evt))
    else:
        ct = 0
        for (nevent, evt) in enumerate(run.events()):
            t = pnccd_tbx.get_psana_time(evt)
            if np.equal(t, timestamps).all(axis=1).any():
                if (ct < first):
                    continue
                elif (ct == last):
                    return
                elif ((ct % denom) == nom):
                    (yield (ct, evt))
                ct += 1