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 scale_by_bin_width(hist: Hist) -> None: """ Scale a histogram by it's bin width. Args: hist: Hist to be scaled. Returns: None. The histogram is scaled in place. """ scale_factor = _calculate_bin_width_scale_factor(hist) hist.Scale(scale_factor)
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 scale_CPU_time(hist: Hist) -> None: """ Rebin the CPU time for improved presentation. Time is only reported in increments of 10 ms. So we rebin by those 10 bins (since each bin is 1 ms) and then scale them down to be on the same scale as the real time hist. We can perform this scaling in place. Note: This scaling appears to be the same as one would usually do for a rebin, but it is slightly more subtle, because it is as if the data was already binned. That being said, the end result is effectively the same. Args: hist: CPU time histogram to be scaled. Returns: None. """ logger.debug("Performing CPU time hist scaling.") timeIncrement = 10 hist.Rebin(timeIncrement) hist.Scale(1.0 / timeIncrement)