def _apply_labels_ROOT(self, hist: Hist) -> None: if self.title is not None: hist.SetTitle(labels.use_label_with_root(self.title)) if self.x_label is not None: hist.GetXaxis().SetTitle(labels.use_label_with_root(self.x_label)) if self.y_label is not None: hist.GetYaxis().SetTitle(labels.use_label_with_root(self.y_label))
def post_projection_processing_for_2d_correlation( hist: Hist, normalization_factor: float, title_label: str, jet_pt: analysis_objects.JetPtBin, track_pt: analysis_objects.TrackPtBin, rebin_factors: Optional[Tuple[int, int]] = None) -> None: """ Basic post processing tasks for a new 2D correlation observable. Args: hist: Histogram to be post processed. normalization_factor: Factor by which the hist should be scaled. title_label: Histogram title label. jet_pt: Jet pt bin. track_pt: Track pt bin. rebin_factors: (x rebin factor, y rebin factor). Both values must be specified (can set to 1 if you don't want to rebin a particular axis). Default: None. Returns: None. The histogram is modified in place. """ # If we specify a rebin factor, then rebin. if rebin_factors is not None: hist.Rebin2D(*rebin_factors) # Scale hist.Scale(1.0 / normalization_factor) # Set title, axis labels jet_pt_bins_title = labels.jet_pt_range_string(jet_pt) track_pt_bins_title = labels.track_pt_range_string(track_pt) hist.SetTitle( rf"{title_label}\:\mathrm{{with}}\:{jet_pt_bins_title} \mathrm{{,}} {track_pt_bins_title}" ) hist.GetXaxis().SetTitle(r"$\Delta\varphi$") hist.GetYaxis().SetTitle(r"$\Delta\eta$")
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)
def post_creation_processing_for_1d_correlations( hist: Hist, normalization_factor: float, rebin_factor: int, title_label: str, axis_label: str, jet_pt: analysis_objects.JetPtBin, track_pt: analysis_objects.TrackPtBin) -> None: """ Basic post processing tasks for a new 1D correlation observable. """ # Rebin to decrease the fluctuations in the correlations # We don't scale by the rebin factor here because we will scale by bin width later. # Since we will handle it later, it doesn't make sense to try to preserve normalization here. hist.Rebin(rebin_factor) # Scale hist.Scale(1.0 / normalization_factor) # Set title, labels jet_pt_bins_title = labels.jet_pt_range_string(jet_pt) track_pt_bins_title = labels.track_pt_range_string(track_pt) # This won't look so good in ROOT, but that's just because their latex rendering is absolutely atrocious... hist.SetTitle( rf"{title_label} with {jet_pt_bins_title}, {track_pt_bins_title}") hist.GetXaxis().SetTitle(axis_label) hist.GetYaxis().SetTitle(fr"$\mathrm{{dN}}/\mathrm{{d}}{axis_label}$")
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)