### # all MET uncertainties except JES as this is already included
    new_uncertainties = ['QCD_shape']
    rate_changing_systematics = measurement_config.rate_changing_systematics_names
    all_measurements = deepcopy(categories)
    all_measurements.extend(pdf_uncertainties)
    all_measurements.extend(new_uncertainties)

    all_measurements.extend(rate_changing_systematics)

    for channel in ['electron', 'muon', 'combined', 'combinedBeforeUnfolding']:                        
    # for channel in ['combined']:                        
        normalised_xsection_measured_unfolded, normalised_xsection_measured_errors, normalised_xsection_unfolded_errors = read_xsection_measurement_results_with_errors(path_to_JSON, variable, met_type, phase_space, method, channel)

        print_xsections(normalised_xsection_measured_unfolded, channel, toFile = True, print_before_unfolding = False)
        print_xsections(normalised_xsection_measured_unfolded, channel, toFile = True, print_before_unfolding = True)

        print_error_table(normalised_xsection_measured_unfolded, normalised_xsection_unfolded_errors, channel, toFile = True, print_before_unfolding = False)
        print_error_table(normalised_xsection_measured_unfolded, normalised_xsection_measured_errors, channel, toFile = True, print_before_unfolding = True)

        if channel == 'combined':
            print_typical_systematics_table(normalised_xsection_measured_unfolded, normalised_xsection_unfolded_errors, channel, toFile = True, print_before_unfolding = False)
            print_typical_systematics_table(normalised_xsection_measured_unfolded, normalised_xsection_measured_errors, channel, toFile = True, print_before_unfolding = True)

        if not channel == 'combined' and not channel == 'combinedBeforeUnfolding':
            fit_input = read_initial_normalisation(path_to_JSON, variable, 'central', channel, met_type)
            fit_results = read_normalisation(path_to_JSON, variable, 'central', channel, met_type)
            print_fit_results_table(fit_input, fit_results, channel, toFile = True)

    
    variable = options.variable

    electron_histogram_title = 'CMS Preliminary, $\mathcal{L}$ = %.1f fb$^{-1}$ at $\sqrt{s}$ = %d TeV \n e+jets, $\geq$4 jets' % (
        lumi / 1000, come)
    muon_histogram_title = 'CMS Preliminary, $\mathcal{L}$ = %.1f fb$^{-1}$ at $\sqrt{s}$ = %d TeV \n $\mu$+jets, $\geq$4 jets' % (
        lumi / 1000, come)

    fit_variables = fit_var_inputs

    fit_results_electron = {}
    fit_results_muon = {}
    initial_values_electron = {}
    initial_values_muon = {}
    for fit_variable in fit_variables:
        path = path_to_JSON + fit_variable + '/' + str(come) + 'TeV/'
        fit_results_electron[fit_variable] = read_normalisation(
            path, variable, category, 'electron', met_type)
        fit_results_muon[fit_variable] = read_normalisation(
            path, variable, category, 'muon', met_type)
    # it doesn't matter which one to use, all of them are identical
    # so lets use the 2011 and 2012 default, |eta|
    initial_values_electron = read_initial_normalisation(
        path_to_JSON + 'absolute_eta' + '/' + str(come) + 'TeV/', variable,
        category, 'electron', met_type)
    initial_values_muon = read_initial_normalisation(
        path_to_JSON + 'absolute_eta' + '/' + str(come) + 'TeV/', variable,
        category, 'muon', met_type)

    if not 'closure' in path_to_JSON:
        fit_results_electron['before'] = read_normalisation(
            'data_single_var_fit/8TeV/', variable, category, 'electron',
            met_type)
    variable = options.variable
    
    electron_histogram_title = 'CMS Preliminary, $\mathcal{L}$ = %.1f fb$^{-1}$ at $\sqrt{s}$ = %d TeV \n e+jets, $\geq$4 jets' % ( lumi/1000, come )
    muon_histogram_title = 'CMS Preliminary, $\mathcal{L}$ = %.1f fb$^{-1}$ at $\sqrt{s}$ = %d TeV \n $\mu$+jets, $\geq$4 jets' % ( lumi/1000, come )
    
    fit_variables = fit_var_inputs

    fit_results_electron = {}
    fit_results_muon = {}
    initial_values_electron = {}
    initial_values_muon = {}
    for fit_variable in fit_variables:
        path = path_to_JSON + fit_variable + '/' + str( come ) + 'TeV/'
        fit_results_electron[fit_variable] = read_normalisation( path,
                                                variable,
                                                category,
                                                'electron',
                                                 met_type )
        fit_results_muon[fit_variable] = read_normalisation( path,
                                                variable,
                                                category,
                                                'muon',
                                                 met_type )
    # it doesn't matter which one to use, all of them are identical
    # so lets use the 2011 and 2012 default, |eta|
    initial_values_electron = read_initial_normalisation( path_to_JSON + 'absolute_eta' + '/' + str( come ) + 'TeV/',
                                             variable,
                                             category,
                                             'electron',
                                             met_type )
    initial_values_muon = read_initial_normalisation( path_to_JSON + 'absolute_eta' + '/' + str( come ) + 'TeV/',
Пример #4
0
        print_error_table(normalised_xsection_measured_unfolded,
                          normalised_xsection_measured_errors,
                          channel,
                          toFile=True,
                          print_before_unfolding=True)

        if channel == 'combined':
            print_typical_systematics_table(
                normalised_xsection_measured_unfolded,
                normalised_xsection_unfolded_errors,
                channel,
                toFile=True,
                print_before_unfolding=False)
            print_typical_systematics_table(
                normalised_xsection_measured_unfolded,
                normalised_xsection_measured_errors,
                channel,
                toFile=True,
                print_before_unfolding=True)

        if not channel == 'combined' and not channel == 'combinedBeforeUnfolding':
            fit_input = read_initial_normalisation(path_to_JSON, variable,
                                                   'central', channel,
                                                   met_type)
            fit_results = read_normalisation(path_to_JSON, variable, 'central',
                                             channel, met_type)
            print_fit_results_table(fit_input,
                                    fit_results,
                                    channel,
                                    toFile=True)