categories = deepcopy(measurement_config.categories_and_prefixes.keys())
    ttbar_generator_systematics = [ttbar_theory_systematic_prefix + systematic for systematic in measurement_config.generator_systematics]
    vjets_generator_systematics = [vjets_theory_systematic_prefix + systematic for systematic in measurement_config.generator_systematics]
    categories.extend(ttbar_generator_systematics)
    categories.extend(vjets_generator_systematics)
    
    # all MET uncertainties except JES as this is already included
    met_uncertainties = [met_type + suffix for suffix in met_systematics_suffixes if not 'JetEn' in suffix and not 'JetRes' in suffix]
    new_uncertainties = ['hadronisation', 'QCD_shape', 'PDF_total_lower', 'PDF_total_upper']
    rate_changing_systematics = [systematic + '+' for systematic in measurement_config.rate_changing_systematics.keys()]
    rate_changing_systematics.extend([systematic + '-' for systematic in measurement_config.rate_changing_systematics.keys()])
    all_measurements = deepcopy(categories)
    all_measurements.extend(met_uncertainties)
    all_measurements.extend(new_uncertainties)
    all_measurements.extend(rate_changing_systematics)

    for channel in ['electron', 'muon', 'combined']:                        
        normalised_xsection_measured_unfolded, normalised_xsection_measured_errors, normalised_xsection_unfolded_errors = read_xsection_measurement_results_with_errors(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 not channel == 'combined':
            fit_input = read_fit_input(path_to_JSON, variable, 'central', channel, met_type)
            fit_results = read_fit_results(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_fit_results( path,
                                                variable,
                                                category,
                                                'electron',
                                                 met_type )
        fit_results_muon[fit_variable] = read_fit_results( 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_fit_input( path_to_JSON + 'absolute_eta' + '/' + str( come ) + 'TeV/',
                                             variable,
                                             category,
                                             'electron',
                                             met_type )
    initial_values_muon = read_fit_input( path_to_JSON + 'absolute_eta' + '/' + str( come ) + 'TeV/',
        "absolute_eta_angle_bl",
        "absolute_eta_M3",
        "absolute_eta_M_bl",
        "absolute_eta_M_bl_angle_bl",
        "absolute_eta_M3_angle_bl",
        "absolute_eta_M_bl_M3",
        "absolute_eta_M_bl_M3_angle_bl",
    ]

    fit_results_electron = {}
    fit_results_muon = {}
    initial_values_electron = {}
    initial_values_muon = {}
    for fit_var_input in fit_var_inputs:
        path = path_to_JSON + fit_var_input + "/" + str(come) + "TeV/"
        fit_results_electron[fit_var_input] = read_fit_results(path, variable, category, "electron", met_type)
        fit_results_muon[fit_var_input] = read_fit_results(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_fit_input(
        path_to_JSON + "absolute_eta" + "/" + str(come) + "TeV/", variable, category, "electron", met_type
    )
    initial_values_muon = read_fit_input(
        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_fit_results(
            "data_single_var_fit/8TeV/", variable, category, "electron", met_type
        )
        fit_results_muon["before"] = read_fit_results("data_single_var_fit/8TeV/", variable, category, "muon", met_type)