コード例 #1
0
ファイル: makeSampleSheet.py プロジェクト: phylsix/FireROOT
def generate_signal_files(filedicts):
    """generate private signal file list json"""
    print("[generate_signal_files]")

    EOSPATH_SIG, EOSPATH_SIG2 = filedicts

    paramsubdirs = eosls(EOSPATH_SIG)
    json_4mu, json_2mu2e = {}, {}
    for subdir in paramsubdirs:
        if 'MDp-0p8' in subdir or 'MDp-2p5' in subdir:
            continue  # skipping unrequested darkphoton mass points

        if '4Mu' in subdir:
            key = subdir.replace('SIDM_BsTo2DpTo4Mu_', '').split('_ctau')[0]\
                        .replace('MBs', 'mXX').replace('MDp', 'mA')
            key += '_lxy-300'  # mXX-1000_mA-0p25_lxy-300
            json_4mu[key] = latest_files(join(EOSPATH_SIG, subdir))
        if '2Mu2e' in subdir:
            key = subdir.replace('SIDM_BsTo2DpTo2Mu2e_', '').split('_ctau')[0]\
                        .replace('MBs', 'mXX').replace('MDp', 'mA')
            key += '_lxy-300'
            json_2mu2e[key] = latest_files(join(EOSPATH_SIG, subdir))

    ## samples with new naming
    for subdir in eosls(EOSPATH_SIG2['4mu']):
        key = subdir.split('_ctau')[0]  # mXX-100_mA-5_lxy-0p3
        json_4mu[key] = latest_files(join(EOSPATH_SIG2['4mu'], subdir))
    for subdir in eosls(EOSPATH_SIG2['2mu2e']):
        key = subdir.split('_ctau')[0]  # mXX-100_mA-5_lxy-0p3
        json_2mu2e[key] = latest_files(join(EOSPATH_SIG2['2mu2e'], subdir))

    return json_4mu, json_2mu2e
コード例 #2
0
ファイル: makeSampleSheet.py プロジェクト: phylsix/FireROOT
def generate_background_files(eospathdict=EOSPATHS_BKG, forscale=False):
    print("[generate_background_files(forscale={})]".format(forscale))
    _dirmap = eospathdict
    if forscale:
        _dirmap = EOSPATHS_BKGAOD

    ## get max(latest) timestamp
    ## Note: for scale, it will scan AOD skim submissions, we do not put limit on
    ## submission timestamps as it can span over a longer time.
    if forscale is False:
        timestamps = []
        for group in _dirmap:
            for tag in _dirmap[group]:
                for path in _dirmap[group][tag]:
                    timestamps.append(
                        sorted(eosls(path),
                               key=lambda x: datetime.strptime(
                                   x, "%y%m%d_%H%M%S"))[-1])
        maxts = sorted(timestamps,
                       key=lambda x: datetime.strptime(x, "%y%m%d_%H%M%S"))[-1]
        maxts = datetime.strptime(maxts, "%y%m%d_%H%M%S")

    generated = dict()
    for group in _dirmap:
        generated[group] = {}
        for tag in _dirmap[group]:
            generated[group][tag] = []
            for path in _dirmap[group][tag]:
                # if forscale is False:
                #     if (maxts - last_submit_timestamp(path)).seconds > 60*60: continue
                generated[group][tag].extend(
                    latest_files(path, pattern='*ffNtuple*.root'))

    return generated
コード例 #3
0
def latest_files(parentPathOfTimestamps, pattern=None):
    """
    list file names of latest batch job submission

    :param str parentPathOfTimestamps: eos directory up to timestamp level
    :param str pattern: restrict pattern of file names
    :return: a list of file names
    :rtype: list
    """
    try:
        timestampdirs = eosls(parentPathOfTimestamps)
        timestampdirs = sorted(timestampdirs, key=lambda x: datetime.strptime(x, "%y%m%d_%H%M%S"))
        latest = join(parentPathOfTimestamps, timestampdirs[-1])

        return list_files(latest, pattern=pattern)
    except Exception as e:
        print(e)
        print("Error when stat eos path: {}! Empty list returned".format(parentPathOfTimestamps))
        return []
コード例 #4
0
ファイル: makeSampleSheet.py プロジェクト: phylsix/FireROOT
def last_submit_timestamp(parentPathOfTimestamps):
    timestamps = eosls(parentPathOfTimestamps)
    last_ts = sorted(timestamps,
                     key=lambda x: datetime.strptime(x, "%y%m%d_%H%M%S"))[-1]
    return datetime.strptime(last_ts, "%y%m%d_%H%M%S")