def merge_files_by_process(root_files): global input_folder, output_folder electron_qcd_samples = [ 'QCD_Pt-20to30_BCtoE', 'QCD_Pt-30to80_BCtoE', 'QCD_Pt-80to170_BCtoE', 'QCD_Pt-20to30_EMEnriched', 'QCD_Pt-30to80_EMEnriched', 'QCD_Pt-80to170_EMEnriched', 'GJets_HT-40To100', 'GJets_HT-100To200', 'GJets_HT-200'] singleTop_samples = [ 'T_tW-channel', 'T_t-channel', 'T_s-channel', 'Tbar_tW-channel', 'Tbar_t-channel', 'Tbar_s-channel'] wplusjets_samples = [ 'W1Jet', 'W2Jets', 'W3Jets', 'W4Jets'] vplusjets_samples = wplusjets_samples vplusjets_samples.append('DYJetsToLL') diboson_samples = [ 'WWtoAnything', 'WZtoAnything', 'ZZtoAnything'] signal_samples = [ 'TTJet', 'SingleTop'] summations = { 'QCD_Electron':electron_qcd_samples, 'SingleTop' : singleTop_samples, 'WPlusJets' : wplusjets_samples, 'VPlusJets' : vplusjets_samples, 'DiBoson': diboson_samples, 'Signal': signal_samples } summation_files = {} file_template = '' template_token = '<temp>' for summation, samples in summations.iteritems(): summation_files[summation] = [] for file_in_path in root_files: process_name = get_process_from_file(file_in_path) if not file_template: file_template = file_in_path.replace(process_name, template_token) file_template = file_template.replace(input_folder, output_folder) if process_name in samples: summation_files[summation].append(file_in_path) for summation, files in summation_files.iteritems(): output_file = file_template.replace(template_token, summation) merge_ROOT_files(files, output_file)
def merge_files_by_process(root_files): global input_folder, output_folder electron_qcd_samples = [ 'QCD_Pt-20to30_BCtoE', 'QCD_Pt-30to80_BCtoE', 'QCD_Pt-80to170_BCtoE', 'QCD_Pt-20to30_EMEnriched', 'QCD_Pt-30to80_EMEnriched', 'QCD_Pt-80to170_EMEnriched', 'GJets_HT-40To100', 'GJets_HT-100To200', 'GJets_HT-200' ] singleTop_samples = [ 'T_tW-channel', 'T_t-channel', 'T_s-channel', 'Tbar_tW-channel', 'Tbar_t-channel', 'Tbar_s-channel' ] wplusjets_samples = ['W1Jet', 'W2Jets', 'W3Jets', 'W4Jets'] vplusjets_samples = wplusjets_samples vplusjets_samples.append('DYJetsToLL') diboson_samples = ['WWtoAnything', 'WZtoAnything', 'ZZtoAnything'] signal_samples = ['TTJet', 'SingleTop'] summations = { 'QCD_Electron': electron_qcd_samples, 'SingleTop': singleTop_samples, 'WPlusJets': wplusjets_samples, 'VPlusJets': vplusjets_samples, 'DiBoson': diboson_samples, 'Signal': signal_samples } summation_files = {} file_template = '' template_token = '<temp>' for summation, samples in summations.iteritems(): summation_files[summation] = [] for file_in_path in root_files: process_name = get_process_from_file(file_in_path) if not file_template: file_template = file_in_path.replace(process_name, template_token) file_template = file_template.replace(input_folder, output_folder) if process_name in samples: summation_files[summation].append(file_in_path) for summation, files in summation_files.iteritems(): output_file = file_template.replace(template_token, summation) merge_ROOT_files(files, output_file)
def scale_file(file_in_path): process_name = get_process_from_file(file_in_path)