def draw_regularisation_histograms( h_truth, h_measured, h_response, h_fakes = None, h_data = None ): global method, variable, output_folder, output_formats, test k_max = h_measured.nbins() unfolding = Unfolding( h_truth, h_measured, h_response, h_fakes, method = method, k_value = k_max, error_treatment = 4, verbose = 1 ) RMSerror, MeanResiduals, RMSresiduals, Chi2 = unfolding.test_regularisation ( h_data, k_max ) histogram_properties = Histogram_properties() histogram_properties.name = 'chi2_%s_channel_%s' % ( channel, variable ) histogram_properties.title = '$\chi^2$ for $%s$ in %s channel, %s test' % ( variables_latex[variable], channel, test ) histogram_properties.x_axis_title = '$i$' histogram_properties.y_axis_title = '$\chi^2$' histogram_properties.set_log_y = True make_plot(Chi2, 'chi2', histogram_properties, output_folder, output_formats, draw_errorbar = True, draw_legend = False) histogram_properties = Histogram_properties() histogram_properties.name = 'RMS_error_%s_channel_%s' % ( channel, variable ) histogram_properties.title = 'Mean error for $%s$ in %s channel, %s test' % ( variables_latex[variable], channel, test ) histogram_properties.x_axis_title = '$i$' histogram_properties.y_axis_title = 'Mean error' make_plot(RMSerror, 'RMS', histogram_properties, output_folder, output_formats, draw_errorbar = True, draw_legend = False) histogram_properties = Histogram_properties() histogram_properties.name = 'RMS_residuals_%s_channel_%s' % ( channel, variable ) histogram_properties.title = 'RMS of residuals for $%s$ in %s channel, %s test' % ( variables_latex[variable], channel, test ) histogram_properties.x_axis_title = '$i$' histogram_properties.y_axis_title = 'RMS of residuals' if test == 'closure': histogram_properties.set_log_y = True make_plot(RMSresiduals, 'RMSresiduals', histogram_properties, output_folder, output_formats, draw_errorbar = True, draw_legend = False) histogram_properties = Histogram_properties() histogram_properties.name = 'mean_residuals_%s_channel_%s' % ( channel, variable ) histogram_properties.title = 'Mean of residuals for $%s$ in %s channel, %s test' % ( variables_latex[variable], channel, test ) histogram_properties.x_axis_title = '$i$' histogram_properties.y_axis_title = 'Mean of residuals' make_plot(MeanResiduals, 'MeanRes', histogram_properties, output_folder, output_formats, draw_errorbar = True, draw_legend = False)
# We want to store this variable in a histogram # 80 bins, from 0 to 400 (GeV) h_gen_met = Hist(80, 0, 400) # since we are planning to run over many events, let's cache the fill function fill = h_gen_met.Fill # ready to read all events n_processed_events = 0 stop_at = 10**5 # this is enough for this example for event in chain: gen_met = event.__getattr__("unfolding.genMET") fill(gen_met) n_processed_events += 1 if (n_processed_events % 50000 == 0): print 'Processed', n_processed_events, 'events.' if n_processed_events >= stop_at: break print 'Processed', n_processed_events, 'events.' # lets draw this histogram # define the style histogram_properties = Histogram_properties() histogram_properties.name = 'read_ntuples_gen_met' # it will be saved as that histogram_properties.title = 'My awesome MET plot' histogram_properties.x_axis_title = 'MET [GeV]' histogram_properties.y_axis_title = 'Events / 5 GeV' make_plot(h_gen_met, r'$t\bar{t}$', histogram_properties, save_folder='examples/plots/', save_as=['png'])
# We want to store this variable in a histogram # 80 bins, from 0 to 400 (GeV) h_gen_met = Hist(80, 0, 400) # since we are planning to run over many events, let's cache the fill function fill = h_gen_met.Fill # ready to read all events n_processed_events = 0 stop_at = 10**5 # this is enough for this example for event in chain: gen_met = event.__getattr__("unfolding.genMET") fill(gen_met) n_processed_events += 1 if (n_processed_events % 50000 == 0): print 'Processed', n_processed_events, 'events.' if n_processed_events >= stop_at: break print 'Processed', n_processed_events, 'events.' # lets draw this histogram # define the style histogram_properties = Histogram_properties() histogram_properties.name = 'read_ntuples_gen_met' # it will be saved as that histogram_properties.title = 'My awesome MET plot' histogram_properties.x_axis_title = 'MET [GeV]' histogram_properties.y_axis_title = 'Events / 5 GeV' make_plot(h_gen_met, r'$t\bar{t}$', histogram_properties, save_folder = 'examples/plots/', save_as = ['png'])