示例#1
0
def crabdir_source(directory):
    #print "Getting list of files from crab dir:", directory
    crab_files = list(crab.map_lfns_to_castor(crab.lfns(directory)))

    good_ids = set(get_crab_id(file) for file in crab_files)
    # Get good crab 'ids' - a tuple of the crab job, retry, and random code
    # Figure out what castor directory we are in so we can get all the
    # information.
    #print "getting all files"
    if crab_files:
        castor_dir = os.path.dirname(crab_files[0]) + '/'
        castor_files_info = castor.nslsl(castor_dir)
        for file_info in castor_files_info:
            if get_crab_id(file_info['file']) in good_ids:
                yield file_info
示例#2
0
def crabdir_source(directory):
    #print "Getting list of files from crab dir:", directory
    crab_files = list(crab.map_lfns_to_castor(crab.lfns(directory)))

    good_ids = set(get_crab_id(file) for file in crab_files)
    # Get good crab 'ids' - a tuple of the crab job, retry, and random code
    # Figure out what castor directory we are in so we can get all the
    # information.
    #print "getting all files"
    if crab_files:
        castor_dir = os.path.dirname(crab_files[0]) + '/'
        castor_files_info = castor.nslsl(castor_dir)
        for file_info in castor_files_info:
            if get_crab_id(file_info['file']) in good_ids:
                yield file_info
# Map samples to their crab directories
crab_dir_map = {}

for sample in SAMPLES_TO_ANALYZE:
    crab_dir_map[sample] = os.path.join(
        'crab', 'crabdir_runAHtoMuTau_AHtoMuTau_%s_%s' % (sample, ID))

harvest_jobs = []

for sample in SAMPLES_TO_ANALYZE:
    print "Finding input files for", sample
    output_file = "harvested_%s_%s_%s.root" % (CHANNEL, sample, ID)
    output_path = os.path.join(PLOT_OUTPUT_DIRECTORY, output_file)
    files_to_merge = list(
        'rfio:%s' % file
        for file in crab.map_lfns_to_castor(crab.lfns(crab_dir_map[sample])))
    harvest_jobs.append((sample, output_path, files_to_merge))

makefile_name = 'Makefile2.harvest_%s_%s' % (CHANNEL, ID)
buildMakefile(
    harvest_jobs,
    WORKING_DIRECTORY,
    makefile_name,
    merge_per_job=7,
    ana_defs=
    "TauAnalysis.Configuration.recoSampleDefinitionsAHtoMuTau_7TeV_grid_cfi",
    # Defintion of the plots to make
    plot_defs="TauAnalysis.Configuration.plotAHtoMuTau_cff",
    # Plotter modules
    plotters=['plotAHtoMuTau_woBtag', 'plotAHtoMuTau_wBtag'])
if not os.path.exists(WORKING_DIRECTORY):
    os.mkdir(WORKING_DIRECTORY)

# Map samples to their crab directories
crab_dir_map = {}

for sample in SAMPLES_TO_ANALYZE:
    crab_dir_map[sample] = os.path.join("crab", "crabdir_runAHtoMuTau_AHtoMuTau_%s_%s" % (sample, ID))

harvest_jobs = []

for sample in SAMPLES_TO_ANALYZE:
    print "Finding input files for", sample
    output_file = "harvested_%s_%s_%s.root" % (CHANNEL, sample, ID)
    output_path = os.path.join(PLOT_OUTPUT_DIRECTORY, output_file)
    files_to_merge = list("rfio:%s" % file for file in crab.map_lfns_to_castor(crab.lfns(crab_dir_map[sample])))
    harvest_jobs.append((sample, output_path, files_to_merge))

makefile_name = "Makefile2.harvest_%s_%s" % (CHANNEL, ID)
buildMakefile(
    harvest_jobs,
    WORKING_DIRECTORY,
    makefile_name,
    merge_per_job=7,
    ana_defs="TauAnalysis.Configuration.recoSampleDefinitionsAHtoMuTau_7TeV_grid_cfi",
    # Defintion of the plots to make
    plot_defs="TauAnalysis.Configuration.plotAHtoMuTau_cff",
    # Plotter modules
    plotters=["plotAHtoMuTau_woBtag", "plotAHtoMuTau_wBtag"],
)