diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 0000000..50be40f --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,21 @@ +name: Black Code Formatter + +on: [push, pull_request] + +jobs: + black: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install Black + run: pip install black==23.3.0 + + - name: Run Black + run: black --check . \ No newline at end of file diff --git a/Dumbledraw/dumbledraw.py b/Dumbledraw/dumbledraw.py index c1be9d3..857c0b1 100644 --- a/Dumbledraw/dumbledraw.py +++ b/Dumbledraw/dumbledraw.py @@ -152,7 +152,14 @@ def DrawChannelCategoryLabel( begin_left = 0.145 latex2.DrawLatex(begin_left, 0.960, text) - def DrawCMS(self, position=0, preliminary=True, subtext="", own_work=False, thesisstyle=False): + def DrawCMS( + self, + position=0, + preliminary=True, + subtext="", + own_work=False, + thesisstyle=False, + ): additional_string = "" if subtext != "": additional_string = subtext diff --git a/Dumbledraw/rootfile_parser_inputshapes_wh.py b/Dumbledraw/rootfile_parser_inputshapes_wh.py index db28bc4..d946b71 100644 --- a/Dumbledraw/rootfile_parser_inputshapes_wh.py +++ b/Dumbledraw/rootfile_parser_inputshapes_wh.py @@ -10,7 +10,6 @@ class Rootfile_parser(object): - _dataset_map = { "data": "data", "ggZZ": "ggZZ", diff --git a/Dumbledraw/rootfile_parser_ntuple_processor_inputshapes.py b/Dumbledraw/rootfile_parser_ntuple_processor_inputshapes.py index 0669c49..3386140 100644 --- a/Dumbledraw/rootfile_parser_ntuple_processor_inputshapes.py +++ b/Dumbledraw/rootfile_parser_ntuple_processor_inputshapes.py @@ -10,7 +10,6 @@ class Rootfile_parser(object): - _dataset_map = { "data": "data", "ZTT": "DY", diff --git a/Dumbledraw/styles.py b/Dumbledraw/styles.py index b634b5f..9e6e530 100644 --- a/Dumbledraw/styles.py +++ b/Dumbledraw/styles.py @@ -19,7 +19,6 @@ def CreateTransparentColor(color, alpha): return new_idx - legend_label_dict = yaml.load(open(labels_path))["legend_label"] x_label_dict = yaml.load(open(labels_path))["x_label"] @@ -44,14 +43,14 @@ def CreateTransparentColor(color, alpha): "WH": R.TColor.GetColor("#001EFF"), "ZH": R.TColor.GetColor("#001EFF"), "ttH": R.TColor.GetColor("#FF00FF"), -# "HWW": R.TColor.GetColor("#FF8C00"), -# "ggH_hww": R.TColor.GetColor("#FF8C00"), -# "qqH_hww": R.TColor.GetColor("#FF8C00"), + # "HWW": R.TColor.GetColor("#FF8C00"), + # "ggH_hww": R.TColor.GetColor("#FF8C00"), + # "qqH_hww": R.TColor.GetColor("#FF8C00"), "HWW": R.TColor.GetColor("#006106"), "ggH_hww": R.TColor.GetColor("#006106"), "qqH_hww": R.TColor.GetColor("#006106"), "dummy": R.TColor.GetColor(254, 74, 73), -# "inclusive": R.TColor.GetColor(254, 74, 73), + # "inclusive": R.TColor.GetColor(254, 74, 73), "ZTT": R.TColor.GetColor(248, 206, 104), "ZTT_NLO": R.TColor.GetColor(248, 206, 104), "EMB": R.TColor.GetColor(248, 206, 104), @@ -390,18 +389,21 @@ def DrawText(pad, text, scale_text_size, pos, angle, custom_pos=None): latex.SetTextSize(0.04 * scale_text_size) latex.DrawLatex(x_pos, y_pos, text) -def DrawCMSLogo(pad, - cmsText, - extraText, - iPosX, - relPosX, - relPosY, - relExtraDY, - extraText2='', - extraOverCmsTextSize=0.76, - extraTextFont=52, - cmsTextSize=0.8, - thesisstyle=False): + +def DrawCMSLogo( + pad, + cmsText, + extraText, + iPosX, + relPosX, + relPosY, + relExtraDY, + extraText2="", + extraOverCmsTextSize=0.76, + extraTextFont=52, + cmsTextSize=0.8, + thesisstyle=False, +): """Blah Args: @@ -495,9 +497,13 @@ def DrawCMSLogo(pad, latex.SetTextAlign(align_) latex.SetTextSize(extraTextSize * t * pad_ratio) if pad_ratio_raw > 0.8: - latex.DrawLatex(l + (relPosX + 0.081) * (1 - l - r), posY_ - 0.007 , "data") + latex.DrawLatex( + l + (relPosX + 0.081) * (1 - l - r), posY_ - 0.007, "data" + ) if pad_ratio_raw < 0.8: - latex.DrawLatex(l + (relPosX + 0.065) * (1 - l - r), posY_ - 0.007 , "data") + latex.DrawLatex( + l + (relPosX + 0.065) * (1 - l - r), posY_ - 0.007, "data" + ) else: latex.SetTextFont(cmsTextFont) latex.SetTextSize(cmsTextSize * t * pad_ratio) diff --git a/example_script.py b/example_script.py index 4839f8e..ef067d1 100755 --- a/example_script.py +++ b/example_script.py @@ -9,6 +9,7 @@ from copy import deepcopy import logging + logger = logging.getLogger("") @@ -31,8 +32,7 @@ def main(): # create canvas: # First argument defines subplot structure: List of splits from top to bottom (max. 1.0 to min. 0.0). A split can be a single position or a pair resulting in gap. # Further arguments set general style. - plot = dd.Plot( - [0.65, [0.47, 0.45], [0.22, 0.20]], "ModTDR", r=0.04, l=0.14) + plot = dd.Plot([0.65, [0.47, 0.45], [0.22, 0.20]], "ModTDR", r=0.04, l=0.14) bkg_processes = ["EWK", "QCD", "VV", "W", "TTT", "TTJ", "ZJ", "ZL", "ZTT"] @@ -41,33 +41,29 @@ def main(): plot.add_hist( rootfile.get("mt", "qqh", process), process, "bkg" ) # get(channel, category, process) and assign specific name and group name to histogram. The group name is optional. - plot.setGraphStyle( - process, "hist", fillcolor=styles.color_dict[process]) + plot.setGraphStyle(process, "hist", fillcolor=styles.color_dict[process]) for i in range(2): plot.subplot(i + 1).add_hist( rootfile.get("mt", "qqh", "ggH"), "ggH" ) # signal histograms are used twice in order to realize a two color line style - plot.subplot(i + 1).add_hist( - rootfile.get("mt", "qqh", "ggH"), "ggH_top") + plot.subplot(i + 1).add_hist(rootfile.get("mt", "qqh", "ggH"), "ggH_top") plot.subplot(i + 1).add_hist(rootfile.get("mt", "qqh", "qqH"), "qqH") - plot.subplot(i + 1).add_hist( - rootfile.get("mt", "qqh", "qqH"), "qqH_top") + plot.subplot(i + 1).add_hist(rootfile.get("mt", "qqh", "qqH"), "qqH_top") plot.add_hist(rootfile.get("mt", "qqh", "data_obs"), "data_obs") plot.add_hist(rootfile.get("mt", "qqh", "TotalBkg"), "unc_band") # set some graph styles plot.subplot(1).setGraphStyle( - "ggH", "hist", linecolor=styles.color_dict["ggH"], linewidth=3) + "ggH", "hist", linecolor=styles.color_dict["ggH"], linewidth=3 + ) plot.subplot(1).setGraphStyle("ggH_top", "hist", linecolor=0) plot.subplot(1).setGraphStyle( - "qqH", "hist", linecolor=styles.color_dict["qqH"], linewidth=3) + "qqH", "hist", linecolor=styles.color_dict["qqH"], linewidth=3 + ) plot.subplot(1).setGraphStyle("qqH_top", "hist", linecolor=0) plot.setGraphStyle( - "unc_band", - "e2", - markersize=0, - fillcolor=styles.color_dict["unc"], - linecolor=0) + "unc_band", "e2", markersize=0, fillcolor=styles.color_dict["unc"], linecolor=0 + ) # in order to show S+B in the ratio plot, add total background to signal hists (get_hist returns a copy) and register the results bkg_ggH = plot.subplot(2).get_hist("ggH") @@ -79,20 +75,22 @@ def main(): plot.subplot(2).add_hist(bkg_qqH, "bkg_qqH") plot.subplot(2).add_hist(bkg_qqH, "bkg_qqH_top") plot.subplot(2).setGraphStyle( - "bkg_ggH", "hist", linecolor=styles.color_dict["ggH"], linewidth=3) + "bkg_ggH", "hist", linecolor=styles.color_dict["ggH"], linewidth=3 + ) plot.subplot(2).setGraphStyle("bkg_ggH_top", "hist", linecolor=0) plot.subplot(2).setGraphStyle( - "bkg_qqH", "hist", linecolor=styles.color_dict["qqH"], linewidth=3) + "bkg_qqH", "hist", linecolor=styles.color_dict["qqH"], linewidth=3 + ) plot.subplot(2).setGraphStyle("bkg_qqH_top", "hist", linecolor=0) # apply normalizations for the ratio and the background fractions plot: # First argument: Name of a single histogram or list of names / group names that shall be normalized # Second argument: Name of a single histogram or list of names / group names that shall be contained in the denominator - plot.subplot(2).normalize([ - "unc_band", "bkg_ggH", "bkg_ggH_top", "bkg_qqH", "bkg_qqH_top", - "data_obs" - ], "unc_band") - #plot.subplot(2).normalize(["unc_band", "bkg_ggH", "bkg_ggH_top", "bkg_qqH", "bkg_qqH_top", "data_obs"], "bkg") # would also work but add up the single bkg histograms in the background + plot.subplot(2).normalize( + ["unc_band", "bkg_ggH", "bkg_ggH_top", "bkg_qqH", "bkg_qqH_top", "data_obs"], + "unc_band", + ) + # plot.subplot(2).normalize(["unc_band", "bkg_ggH", "bkg_ggH_top", "bkg_qqH", "bkg_qqH_top", "data_obs"], "bkg") # would also work but add up the single bkg histograms in the background plot.subplot(3).normalize("bkg", "bkg") # stack background histograms for all subplots and assign a name @@ -106,8 +104,7 @@ def main(): plot.subplot(1).setLogY() plot.subplot(3).setXlabel("NN score") plot.subplot(0).setYlabel("N_{events}") - plot.subplot(1).setYlabel( - "") # otherwise number labels are not drawn on axis + plot.subplot(1).setYlabel("") # otherwise number labels are not drawn on axis plot.subplot(2).setYlabel("ratio to bkg") plot.subplot(3).setYlabel("bkg frac.") @@ -123,11 +120,11 @@ def main(): # draw subplots. Argument contains names of objects to be drawn in corresponding order. plot.subplot(0).Draw(["stack", "unc_band", "data_obs"]) plot.subplot(1).Draw( - ["stack", "unc_band", "ggH", "ggH_top", "qqH", "qqH_top", "data_obs"]) - plot.subplot(2).Draw([ - "unc_band", "bkg_ggH", "bkg_ggH_top", "bkg_qqH", "bkg_qqH_top", - "data_obs" - ]) + ["stack", "unc_band", "ggH", "ggH_top", "qqH", "qqH_top", "data_obs"] + ) + plot.subplot(2).Draw( + ["unc_band", "bkg_ggH", "bkg_ggH_top", "bkg_qqH", "bkg_qqH_top", "data_obs"] + ) plot.subplot(3).Draw("stack") # create legends @@ -136,13 +133,13 @@ def main(): for i in range(2): plot.add_legend(width=0.48, height=0.15) for process in bkg_processes: - plot.legend(i).add_entry(0, process, - styles.label_dict[process.replace( - "EWK", "EWKZ")], 'f') - plot.legend(i).add_entry(0, "unc_band", "Bkg. unc.", 'f') - plot.legend(i).add_entry(1, "ggH%s" % suffix[i], "ggH", 'l') - plot.legend(i).add_entry(1, "qqH%s" % suffix[i], "qqH", 'l') - plot.legend(i).add_entry(0, "data_obs", "Data", 'PE') + plot.legend(i).add_entry( + 0, process, styles.label_dict[process.replace("EWK", "EWKZ")], "f" + ) + plot.legend(i).add_entry(0, "unc_band", "Bkg. unc.", "f") + plot.legend(i).add_entry(1, "ggH%s" % suffix[i], "ggH", "l") + plot.legend(i).add_entry(1, "qqH%s" % suffix[i], "qqH", "l") + plot.legend(i).add_entry(0, "data_obs", "Data", "PE") plot.legend(i).setNColumns(3) plot.legend(0).Draw() plot.legend(1).setAlpha(0.0) @@ -150,9 +147,9 @@ def main(): for i in range(2): plot.add_legend(reference_subplot=2, pos=1, width=0.4, height=0.03) - plot.legend(i + 2).add_entry(0, "data_obs", "Data", 'PE') - plot.legend(i + 2).add_entry(1, "ggH%s" % suffix[i], "ggH+bkg.", 'l') - plot.legend(i + 2).add_entry(1, "qqH%s" % suffix[i], "qqH+bkg.", 'l') + plot.legend(i + 2).add_entry(0, "data_obs", "Data", "PE") + plot.legend(i + 2).add_entry(1, "ggH%s" % suffix[i], "ggH+bkg.", "l") + plot.legend(i + 2).add_entry(1, "qqH%s" % suffix[i], "qqH+bkg.", "l") plot.legend(i + 2).setNColumns(3) plot.legend(2).Draw() plot.legend(3).setAlpha(0.0) diff --git a/plot_variable.py b/plot_variable.py index 6909934..ec18fb9 100755 --- a/plot_variable.py +++ b/plot_variable.py @@ -13,6 +13,7 @@ import numpy as np import matplotlib.pyplot as plt import logging + logger = logging.getLogger("") @@ -28,148 +29,184 @@ def setup_logging(output_file, level=logging.DEBUG): file_handler.setFormatter(formatter) logger.addHandler(file_handler) + def parse_arguments(): parser = argparse.ArgumentParser( - description="Produce shapes for 2016 Standard Model analysis.") + description="Produce shapes for 2016 Standard Model analysis." + ) parser.add_argument( - "--channels", - default=[], - nargs='+', - type=str, - help="Channels to be considered.") + "--channels", default=[], nargs="+", type=str, help="Channels to be considered." + ) parser.add_argument( "--categories", default=[], - nargs='+', + nargs="+", type=str, - help="Categories to be considered.") + help="Categories to be considered.", + ) parser.add_argument( "--variables", default=[], - nargs='+', + nargs="+", type=str, - help="Variables to be considered.") + help="Variables to be considered.", + ) return parser.parse_args() -#xlabels = { "pt": r'Reconstructed p_{T}^{H} (GeV)', "eta":r'Reconstructed #eta',"phi": r' Reconstructed #phi',"m":r'Reconstructed mass m_{H} (GeV)'} -def main(args): - hack = [] - roc = {} - shapes = {} - for channel in args.channels: - roc[channel] = {} - shapes[channel] = {} - for category in args.categories: - roc[channel][category] = {} - shapes[channel][category] = {} - for variable in args.variables: - for channel in args.channels: - for category in args.categories: - rootfile = rootfile_parser.Rootfile_parser("2016_shapes.root", "smhtt", "Run2016", variable, 125) - #print rootfile.list_contents() - name = "_".join([channel, category]) - out_name = "_".join([channel, category, variable]) - print(name) - - # create canvas: - # First argument defines subplot structure: List of splits from top to bottom (max. 1.0 to min. 0.0). A split can be a single position or a pair resulting in gap. - # Further arguments set general style. - plot = dd.Plot( - [0.05], "ModTDR", r=0.04, l=0.14) - - #bkg_processes = ["EWK", "QCD", "VV", "W", "TTT", "TTJ", "ZJ", "ZL", "ZTT"] - bkg_processes = ["EWK", "QCD", "VV", "W", "TTT", "TTJ", "ZL", "ZJ", "ZTT"] - if channel == 'tt': - bkg_processes = ["QCD", "VVT", "VVJ", "W", "TTT", "TTJ", "ZL", "ZJ", "ZTT"] - - # register histograms in the subplots (can be done globally or for specific subplots). regustered histograms are not necessarily plotted later. - for process in bkg_processes: - plot.add_hist( - rootfile.get(channel, name, process), process, "bkg" - ) # get(channel, category, process) and assign specific name and group name to histogram. The group name is optional. - plot.setGraphStyle( - process, "hist", fillcolor=styles.color_dict[process]) - -# for i in range(1): -# plot.add_hist( -# rootfile.get(channel, name, "ggh"), "ggh" -# ) # signal histograms are used twice in order to realize a two color line style -# plot.add_hist( -# rootfile.get(channel, name, "ggh"), "ggh_top") -# plot.add_hist(rootfile.get(channel, name, "qqH"), "qqH") -# plot.add_hist( -# rootfile.get(channel, name, "qqH"), "qqH_top") - plot.add_hist(rootfile.get(channel, name, "data_obs"), "data_obs", "data_obs") - # set some graph styles -# plot.setGraphStyle( -# "ggh", "hist", linecolor=styles.color_dict["ggh"], linewidth=3) -# plot.setGraphStyle("ggh_top", "hist", linecolor=0) -# plot.setGraphStyle( -# "qqH", "hist", linecolor=styles.color_dict["qqH"], linewidth=3) - -# plot.setGraphStyle("qqH_top", "hist", linecolor=0) - plot.setGraphStyle( - "data_obs", - "e0", - markersize=1, - fillcolor=styles.color_dict["unc"], - linecolor=1) - plot.create_stack(bkg_processes, "stack") -# plot.subplot(1).normalize(["data_obs"], bkg_processes) # would also work but add up the single bkg histograms in the background - if channel == 'tt': - plot.subplot(0).setYlims(1, 1e5) - plot.DrawChannelCategoryLabel("#tau_{h}#tau_{h}") - elif channel == 'mt': - plot.subplot(0).setYlims(1, 1e7) - plot.DrawChannelCategoryLabel("#mu#tau_{h}") - elif channel == 'et': - plot.subplot(0).setYlims(0.1, 1e7) - plot.DrawChannelCategoryLabel("e#tau_{h}") - - # plot.subplot(0).setXlims(-200, 200) - # plot.subplot(1).setXlims(-200, ) - plot.subplot(1).setYlims(0, 2) - plot.subplot(0).setLogY() - plot.subplot(0).setXlabel(variable) - plot.subplot(0).setYlabel("N_{events}") - plot.subplot(1).setYlabel("ratio to bkg") - - plot.scaleXTitleSize(0.8) - plot.scaleXLabelSize(0.8) - plot.scaleYTitleSize(0.8) - plot.scaleYLabelSize(0.8) - plot.scaleXLabelOffset(2.0) - plot.scaleYTitleOffset(1.1) - plot.subplot(0).Draw(['stack', "data_obs", - "ggh", "qqH", "ggh_top", "qqH_top", ]) - # plot.subplot(1).add_hist(R.TF1("line", "1", 0, 1000), "line") -# plot.subplot(1).Draw(["data_obs", "line"]) - - # create legends - bkg_processes.reverse() - suffix = ["", "_top"] - for i in range(2): - plot.add_legend(width=0.5, height=0.08) - for process in bkg_processes: - plot.legend(i).add_entry(0, process, - styles.legend_label_dict[process], 'f') - #plot.legend(i).add_entry(1, "ggh%s" % suffix[i], "ggh", 'l') - #plot.legend(i).add_entry(1, "qqH%s" % suffix[i], "qqH", 'l') -# plot.legend(i).add_entry(0, "data_obs", "Data", 'PE') - plot.legend(i).setNColumns(3) - plot.legend(0).Draw() - plot.subplot(1)._pad.SetGrid() - - # draw additional labels - plot.DrawCMS() - plot.DrawLumi("35.9 fb^{-1} (13 TeV)") - - # save plot - plot.save(out_name + ".png") - plot.save(out_name + ".pdf") - hack.append(plot) +# xlabels = { "pt": r'Reconstructed p_{T}^{H} (GeV)', "eta":r'Reconstructed #eta',"phi": r' Reconstructed #phi',"m":r'Reconstructed mass m_{H} (GeV)'} + +def main(args): + hack = [] + roc = {} + shapes = {} + for channel in args.channels: + roc[channel] = {} + shapes[channel] = {} + for category in args.categories: + roc[channel][category] = {} + shapes[channel][category] = {} + for variable in args.variables: + for channel in args.channels: + for category in args.categories: + rootfile = rootfile_parser.Rootfile_parser( + "2016_shapes.root", "smhtt", "Run2016", variable, 125 + ) + # print rootfile.list_contents() + name = "_".join([channel, category]) + out_name = "_".join([channel, category, variable]) + print(name) + + # create canvas: + # First argument defines subplot structure: List of splits from top to bottom (max. 1.0 to min. 0.0). A split can be a single position or a pair resulting in gap. + # Further arguments set general style. + plot = dd.Plot([0.05], "ModTDR", r=0.04, l=0.14) + + # bkg_processes = ["EWK", "QCD", "VV", "W", "TTT", "TTJ", "ZJ", "ZL", "ZTT"] + bkg_processes = [ + "EWK", + "QCD", + "VV", + "W", + "TTT", + "TTJ", + "ZL", + "ZJ", + "ZTT", + ] + if channel == "tt": + bkg_processes = [ + "QCD", + "VVT", + "VVJ", + "W", + "TTT", + "TTJ", + "ZL", + "ZJ", + "ZTT", + ] + + # register histograms in the subplots (can be done globally or for specific subplots). regustered histograms are not necessarily plotted later. + for process in bkg_processes: + plot.add_hist( + rootfile.get(channel, name, process), process, "bkg" + ) # get(channel, category, process) and assign specific name and group name to histogram. The group name is optional. + plot.setGraphStyle( + process, "hist", fillcolor=styles.color_dict[process] + ) + + # for i in range(1): + # plot.add_hist( + # rootfile.get(channel, name, "ggh"), "ggh" + # ) # signal histograms are used twice in order to realize a two color line style + # plot.add_hist( + # rootfile.get(channel, name, "ggh"), "ggh_top") + # plot.add_hist(rootfile.get(channel, name, "qqH"), "qqH") + # plot.add_hist( + # rootfile.get(channel, name, "qqH"), "qqH_top") + plot.add_hist( + rootfile.get(channel, name, "data_obs"), "data_obs", "data_obs" + ) + # set some graph styles + # plot.setGraphStyle( + # "ggh", "hist", linecolor=styles.color_dict["ggh"], linewidth=3) + # plot.setGraphStyle("ggh_top", "hist", linecolor=0) + # plot.setGraphStyle( + # "qqH", "hist", linecolor=styles.color_dict["qqH"], linewidth=3) + + # plot.setGraphStyle("qqH_top", "hist", linecolor=0) + plot.setGraphStyle( + "data_obs", + "e0", + markersize=1, + fillcolor=styles.color_dict["unc"], + linecolor=1, + ) + plot.create_stack(bkg_processes, "stack") + # plot.subplot(1).normalize(["data_obs"], bkg_processes) # would also work but add up the single bkg histograms in the background + if channel == "tt": + plot.subplot(0).setYlims(1, 1e5) + plot.DrawChannelCategoryLabel("#tau_{h}#tau_{h}") + elif channel == "mt": + plot.subplot(0).setYlims(1, 1e7) + plot.DrawChannelCategoryLabel("#mu#tau_{h}") + elif channel == "et": + plot.subplot(0).setYlims(0.1, 1e7) + plot.DrawChannelCategoryLabel("e#tau_{h}") + + # plot.subplot(0).setXlims(-200, 200) + # plot.subplot(1).setXlims(-200, ) + plot.subplot(1).setYlims(0, 2) + plot.subplot(0).setLogY() + plot.subplot(0).setXlabel(variable) + plot.subplot(0).setYlabel("N_{events}") + plot.subplot(1).setYlabel("ratio to bkg") + + plot.scaleXTitleSize(0.8) + plot.scaleXLabelSize(0.8) + plot.scaleYTitleSize(0.8) + plot.scaleYLabelSize(0.8) + plot.scaleXLabelOffset(2.0) + plot.scaleYTitleOffset(1.1) + plot.subplot(0).Draw( + [ + "stack", + "data_obs", + "ggh", + "qqH", + "ggh_top", + "qqH_top", + ] + ) + # plot.subplot(1).add_hist(R.TF1("line", "1", 0, 1000), "line") + # plot.subplot(1).Draw(["data_obs", "line"]) + + # create legends + bkg_processes.reverse() + suffix = ["", "_top"] + for i in range(2): + plot.add_legend(width=0.5, height=0.08) + for process in bkg_processes: + plot.legend(i).add_entry( + 0, process, styles.legend_label_dict[process], "f" + ) + # plot.legend(i).add_entry(1, "ggh%s" % suffix[i], "ggh", 'l') + # plot.legend(i).add_entry(1, "qqH%s" % suffix[i], "qqH", 'l') + # plot.legend(i).add_entry(0, "data_obs", "Data", 'PE') + plot.legend(i).setNColumns(3) + plot.legend(0).Draw() + plot.subplot(1)._pad.SetGrid() + + # draw additional labels + plot.DrawCMS() + plot.DrawLumi("35.9 fb^{-1} (13 TeV)") + + # save plot + plot.save(out_name + ".png") + plot.save(out_name + ".pdf") + hack.append(plot) if __name__ == "__main__":