예제 #1
0
def rho_centrality(rho_hist: Hist,
                   output_info: analysis_objects.PlottingOutputWrapper,
                   includes_constituent_cut: bool = True) -> None:
    """ Plot rho as a function of centrality vs jet pt.

    Args:
        rho_hist: Rho centrality dependent hist.
        output_info: Output information.
        includes_constituent_cut: True if the plot was produced using the constituent cut.
    Returns:
        None. The figure is plotted.
    """
    # Setup
    import ROOT
    canvas = ROOT.TCanvas("c", "c")
    canvas.SetRightMargin(0.15)
    # Set labels
    rho_hist.SetTitle("")
    rho_hist.Draw("colz")
    # Keep the range more meaningful.
    rho_hist.GetYaxis().SetRangeUser(0, 50)
    # Draw a profile of the mean
    rho_hist_profile = rho_hist.ProfileX(f"{rho_hist.GetName()}_profile")
    rho_hist_profile.SetMarkerStyle(ROOT.kFullCircle)
    rho_hist_profile.SetMarkerColor(ROOT.kRed)
    rho_hist_profile.SetMarkerSize(1.4)
    rho_hist_profile.Draw("same")

    # Finally, save and cleanup
    output_name = "rho_background"
    if includes_constituent_cut:
        output_name += "_3GeVConstituents"
    plot_base.save_plot(output_info, canvas, output_name)
예제 #2
0
def plot_particle_level_spectra_agreement(
        difference: Hist, absolute_value_of_difference: Hist,
        output_info: analysis_objects.PlottingOutputWrapper) -> None:
    """ Plot the agreement of the particle level spectra between the inclusive and sum of all EP orientations.

    Args:
        difference: Hist of the sum of the EP orientations spectra minus the inclusive spectra.
        absolute_value_of_difference: Same as the difference hist, but having taken the absolute value.
            This allows us to plot the difference on a log scale (which is useful if the differences
            are small).
        output_info: Output information.
    Returns:
        None.
    """
    # Setup
    output_name = "difference_of_sum_EP_orientations_vs_inclusive"
    canvas = ROOT.TCanvas("canvas", "canvas")
    # Labeling
    x_label = labels.use_label_with_root(
        fr"{labels.jet_pt_display_label(upper_label = 'part')}\:({labels.momentum_units_label_gev()})"
    )
    y_label = r"\mathrm{d}N/\mathrm{d}p_{\mathrm{T}}"

    # Apply settings to hists
    for h in [difference, absolute_value_of_difference]:
        # Labeling
        h.GetXaxis().SetTitle(x_label)
        h.GetYaxis().SetTitle(y_label)
        # Center axis title
        h.GetXaxis().CenterTitle(True)
        h.GetYaxis().CenterTitle(True)

    # Draw and save the difference histogram.
    difference.Draw()
    plot_base.save_plot(output_info, canvas, output_name)

    # Draw and save the absolute value of the difference histogram.
    absolute_value_of_difference.Draw()
    canvas.SetLogy(True)
    output_name += "_abs"
    plot_base.save_plot(output_info, canvas, output_name)
예제 #3
0
def _plot_response_matrix_with_ROOT(
        name: str, x_label: str, y_label: str, output_name: str, hist: Hist,
        plot_errors_hist: bool,
        output_info: analysis_objects.PlottingOutputWrapper) -> None:
    """ Underlying function to actually plot a response matrix with ROOT.

    Args:
        name: Name of the histogram.
        x_label: X axis label.
        y_label: Y axis label.
        output_name: Output name of the histogram.
        hist: The response matrix related 2D hist.
        errors_hist: True if the hist is the response matrix errors hist.
        output_info: Output information.
    Returns:
        None
    """
    # Setup
    canvas = ROOT.TCanvas("canvas", "canvas")
    canvas.SetLogz(True)

    # Plot the histogram
    hist.SetTitle(name)
    hist.GetXaxis().SetTitle(labels.use_label_with_root(x_label))
    hist.GetYaxis().SetTitle(labels.use_label_with_root(y_label))
    hist.Draw("colz")

    # Set the final axis ranges.
    # Z axis
    min_val = ctypes.c_double(0)
    max_val = ctypes.c_double(0)
    hist.GetMinimumAndMaximum(min_val, max_val)
    # * 1.1 to put it slightly above the max value
    # min_val doesn't work here, because there are some entries at 0
    hist.GetZaxis().SetRangeUser(10e-7, max_val.value * 1.1)

    # Save
    output_name += "_ROOT"
    plot_base.save_plot(output_info, canvas, output_name)