def __make_overlay(self, hists, fits, labels, thresholds, suffix=""): with preserve_current_style(): # Draw each rate vs pileup (with fit) xtitle = "< \\mu >" ytitle = "Rate (kHz)" canvas = draw(hists, draw_args={"xtitle": xtitle, "ytitle": ytitle, "xlimits": (20, 50), "ylimits": (0, 5)}) if fits: for fit, hist in zip(fits, hists): fit["asymmetric"].linecolor = hist.GetLineColor() fit["asymmetric"].Draw("same") # Add labels label_canvas() # Add a legend legend = Legend( len(hists), header=self.legend_title, topmargin=0.02, leftmargin=0.22, rightmargin=0.78, textsize=0.025, entryheight=0.028, ) for hist, label in zip(hists, labels): legend.AddEntry(hist, label) legend.SetBorderSize(0) legend.Draw() # Save canvas to file name = self.filename_format.format(threshold=thresholds[0]) self.save_canvas(canvas, name + suffix)
def __make_overlay(self, pileup, threshold, hists, fits, labels, header): with preserve_current_style(): # Draw each efficiency (with fit) canvas = draw(hists, draw_args={ "xtitle": self.offline_title, "ytitle": "Efficiency" }) if len(fits) > 0: for fit, hist in zip(fits, hists): fit["asymmetric"].linecolor = hist.GetLineColor() fit["asymmetric"].Draw("same") # Add labels label_canvas() # Add a legend legend = Legend( len(hists), header=self.legend_title, topmargin=0.35, rightmargin=0.3, leftmargin=0.7, textsize=0.035, entryheight=0.035, ) for hist, label in zip(hists, labels): legend.AddEntry(hist, label) legend.SetBorderSize(0) legend.Draw() # Save canvas to file name = self.filename_format.format(pileup=pileup, threshold=threshold) self.save_canvas(canvas, name)
def __make_overlay(self, hists, fits, labels, ytitle, suffix=""): with preserve_current_style(): # Draw each resolution (with fit) xtitle = self.online_title canvas = draw(hists, draw_args={ "xtitle": xtitle, "ytitle": ytitle }) if fits: for fit, hist in zip(fits, hists): fit["asymmetric"].linecolor = hist.GetLineColor() fit["asymmetric"].Draw("same") # Add labels label_canvas() # Add a legend legend = Legend(len(hists), header="Pile-up bin", topmargin=0.35, entryheight=0.035) for hist, label in zip(hists, labels): legend.AddEntry(hist, label) legend.SetBorderSize(0) legend.Draw() # Save canvas to file name = self.filename_format.format(pileup="all") self.save_canvas(canvas, name + suffix)
def __make_overlay(self, pileup, threshold, hists, fits, labels, header): with preserve_current_style(): name = self.filename_format.format(pileup=pileup, threshold=threshold) xmin = hists[0].GetTotalHistogram().GetBinLowEdge(1) xmax = hists[0].GetTotalHistogram().GetBinLowEdge( hists[0].GetTotalHistogram().GetNbinsX() + 1) # Draw each efficiency (with fit) draw_args = { "xtitle": self.offline_title, "ytitle": "Efficiency", "xlimits": [xmin, xmax] } canvas = draw(hists, draw_args=draw_args) if len(fits) > 0: for fit, hist in zip(fits, hists): fit["asymmetric"].linecolor = hist.GetLineColor() fit["asymmetric"].Draw("same") # Add labels label_canvas() # Add a legend legend = Legend( len(hists), header=self.legend_title, topmargin=0.35, rightmargin=0.3, leftmargin=0.7, textsize=0.025, entryheight=0.028, ) for hist, label in zip(hists, labels): legend.AddEntry(hist, label) legend.SetBorderSize(0) legend.Draw() for val in [0.25, 0.5, 0.75, 0.95, 1.]: line = ROOT.TLine(xmin, val, xmax, val) line.SetLineStyle("dashed") line.SetLineColor(15) line.Draw() for thresh in self.thresholds.bins: line = ROOT.TLine(thresh, 0., thresh, 1.) line.SetLineStyle("dashed") line.SetLineColor(15) line.Draw() # Save canvas to file self.save_canvas(canvas, name)
def __make_overlay(self, hists, fits, labels, ytitle, suffix="", setlogy=False): with preserve_current_style(): # Draw each resolution (with fit) xtitle = "" if 'Jet' in self.online_title: xtitle = "Jet #it{p}_{T} (GeV)" if 'HT' in self.online_title: xtitle = "#it{H}_{T} (GeV)" if 'MET' in self.online_title: xtitle = "#it{E}_{T}^{miss} (GeV)" canvas = draw(hists, draw_args={ "xtitle": xtitle, "ytitle": ytitle, "logy": setlogy, "ylimits": (0.1, 50000) }) if fits: for fit, hist in zip(fits, hists): fit["asymmetric"].linecolor = hist.GetLineColor() fit["asymmetric"].Draw("same") # Add labels label_canvas() # Add a legend legend = Legend(len(hists), header=self.legend_title, topmargin=0.35, rightmargin=0.2, leftmargin=0.8, entryheight=0.028, textsize=0.03) for hist, label in zip(hists, labels): legend.AddEntry(hist, label) legend.SetBorderSize(0) legend.Draw() # Save canvas to file name = self.filename_format.format(pileup="all") self.save_canvas(canvas, name + suffix)
def __do_draw(self, pileup, hist): with preserve_current_style(): # Draw each efficiency (with fit) canvas = draw2D(hist, draw_args={ "xtitle": self.offline_title, "ytitle": self.online_title }) canvas.SetLogz(True) # Add labels label_canvas() # Save canvas to file name = self.filename_format.format(pileup=pileup) self.save_canvas(canvas, name)
def __make_overlay(self, hists, fits, labels, ytitle, suffix=""): with preserve_current_style(): # Draw each resolution (with fit) # TODO: this feels like it does not belong here for hist in hists: hist.GetYaxis().SetRangeUser(0, 0.1) hist.GetYaxis().SetTitleOffset(1.4) xtitle = self.resolution_method.label.format( on=self.online_title, off=self.offline_title) canvas = draw(hists, draw_args={ "xtitle": xtitle, "ytitle": ytitle }) if fits: for fit, hist in zip(fits, hists): fit["asymmetric"].linecolor = hist.GetLineColor() fit["asymmetric"].Draw("same") # Add labels label_canvas() # Add a legend legend = Legend( len(hists), header=self.legend_title, topmargin=0.35, rightmargin=0.3, leftmargin=0.7, textsize=0.03, entryheight=0.03, ) for hist, label in zip(hists, labels): legend.AddEntry(hist, label) legend.SetBorderSize(0) legend.Draw() ymax = 1.2 * max([hist.GetMaximum() for hist in hists]) line = ROOT.TLine(0., 0., 0., ymax) line.SetLineColor(15) # Save canvas to file name = self.filename_format.format(pileup="all") self.save_canvas(canvas, name + suffix)
def __apply_colour_map(hists, colourmap, colour_values, change_colour): # Clean change_colour change_colour = [c.lower() for c in change_colour] with preserve_current_style(): # Resolve the requested palette if it's not a function if isinstance(colourmap, str): colourmap = set_palette(colourmap) # Set the colour of each hist max = len(hists) for value, hist in enumerate(hists): if colour_values: value, max = colour_values(value) colour = colourmap(value + 0.5, max) if "line" in change_colour: hist.linecolor = colour if "marker" in change_colour: hist.markercolor = colour
def __do_draw(self, pileup, hist, suffix=""): with preserve_current_style(): # Draw each efficiency (with fit) if suffix == "": ytitle = "Online Jet Energy / Offline Jet Energy" elif suffix == "_profile": ytitle = "RMS/Mean (Online Jet Energy/Offline Jet Energy)" else: ytitle = self.resolution_method.label.format( on=self.online_title, off=self.offline_title, ) canvas = draw2D( hist, draw_args={"xtitle": self.versus_title, "ytitle": ytitle}, ) # Add labels label_canvas() # Save canvas to file name = self.filename_format.format(pileup=pileup) self.save_canvas(canvas, name + suffix)
def __make_overlay(self, pileup, threshold, hists, fits, labels, header): with preserve_current_style(): name = self.filename_format.format(pileup=pileup, threshold=threshold) # Draw each efficiency (with fit) draw_args = {"xtitle": self.offline_title, "ytitle": "Efficiency"} # TODO: special case should not be implemented here! if 'Jet' in name and 'HiRange' in name: draw_args['xlimits'] = [20, 2000] canvas = draw(hists, draw_args=draw_args) if len(fits) > 0: for fit, hist in zip(fits, hists): fit["asymmetric"].linecolor = hist.GetLineColor() fit["asymmetric"].Draw("same") # Add labels label_canvas() # Add a legend legend = Legend( len(hists), header=self.legend_title, topmargin=0.35, rightmargin=0.3, leftmargin=0.7, textsize=0.025, entryheight=0.028, ) for hist, label in zip(hists, labels): legend.AddEntry(hist, label) legend.SetBorderSize(0) legend.Draw() xmin = 0 xmax = self.x_max # TODO: also specialisation, needs removal if ("HT" in name): xmax = 800 xmin = 30 if ("MET" in name): xmin = 0 xmax = 400 if ("Jet" in name): xmin = 20 xmax = 400 if ("HiRange" in name): xmax = 2000 for val in [0.25, 0.5, 0.75, 0.95, 1.]: line = ROOT.TLine(xmin, val, xmax, val) line.SetLineStyle("dashed") line.SetLineColor(15) line.Draw() for val in range(100, xmax, 100): line = ROOT.TLine(val, 0., val, 1.) line.SetLineStyle("dashed") line.SetLineColor(15) line.Draw() # Save canvas to file self.save_canvas(canvas, name)