Return name of candsfile for a given dictionary. Must have d['segment'] defined.
    domock is option to save simulated cands.

def getcandsfile(d, segment=-1, domock=False):
    """ Return name of candsfile for a given dictionary. Must have d['segment'] defined.
    domock is option to save simulated cands.
    """
    if domock:
        prefix = 'candsmock_'
    else:
        prefix= 'cands_'

    if d.has_key('segment'):
        return os.path.join(d['workdir'], prefix + d['fileroot'] + '_sc' + str(d['scan']) + 'seg' + str(d['segment']) + '.pkl')
    elif segment >= 0:
        return os.path.join(d['workdir'], prefix + d['fileroot'] + '_sc' + str(d['scan']) + 'seg' + str(segment) + '.pkl')
    else:
        return ''