diff --git a/Dumbledraw/dumbledraw.py b/Dumbledraw/dumbledraw.py index 0acfbfa..99fe232 100644 --- a/Dumbledraw/dumbledraw.py +++ b/Dumbledraw/dumbledraw.py @@ -6,10 +6,11 @@ import copy import ROOT as R import math -#import rootfile_parser + +# import rootfile_parser logger = logging.getLogger(__name__) -import styles +from . import styles class Plot(object): @@ -24,7 +25,7 @@ def __init__(self, splitlist, style="none", legend_outside=False, **kwargs): self._inlets = [] self._inlets_legends = [] # evaluate splitlist and book - if isinstance(splitlist, basestring): + if isinstance(splitlist, str): splitlist = [splitlist] lower = 1.0 upper = 1.0 @@ -91,7 +92,7 @@ def inlet_legend(self, index): logger.fatal("Inlet Legend index is out of range!") raise Exception return self._inlets_legends[index] - + def line(self, index): if not isinstance(index, int): logger.fatal("Line index is supposed to be of type int!") @@ -105,7 +106,14 @@ def save(self, outputname): self._canvas.SaveAs(outputname) logger.info("Created %s" % outputname) - def DrawChannelCategoryLabel(self, text, textsize=0.04, begin_left=None, print_inside=False,legend_outside=False): + def DrawChannelCategoryLabel( + self, + text, + textsize=0.04, + begin_left=None, + print_inside=False, + legend_outside=False, + ): if legend_outside: latex2 = R.TLatex() latex2.SetNDC() @@ -134,23 +142,61 @@ def DrawChannelCategoryLabel(self, text, textsize=0.04, begin_left=None, print_i begin_left = 0.145 latex2.DrawLatex(begin_left, 0.960, text) - def DrawCMS(self,position=0, preliminary=True): + def DrawCMS(self, position=0, preliminary=True, own_work=False): if preliminary: - additional_string = 'Preliminary' + additional_string = "Preliminary" + if own_work: + additional_string = "Own Work" else: additional_string = "" - if position==0: - styles.DrawCMSLogo(self._subplots[0]._pad, 'CMS', additional_string , 11, - 0.045, 0.05, 1.0, '', 0.6) - elif position=="outside": - styles.DrawCMSLogo(self._subplots[0]._pad, 'CMS', additional_string , 0, - 0.095, 0.05, 1.0, '', 0.6) - elif position=="legend_outside": - styles.DrawCMSLogo(self._subplots[0]._pad, 'CMS', additional_string , 11, - 0.045, 0.05, 1.0, '', 0.4) + if position == 0: + styles.DrawCMSLogo( + self._subplots[0]._pad, + "CMS", + additional_string, + 11, + 0.095, + 0.05, + 1.0, + "", + 0.6, + ) + elif position == "outside": + styles.DrawCMSLogo( + self._subplots[0]._pad, + "CMS", + additional_string, + 0, + 0.095, + 0.05, + 1.0, + "", + 0.6, + ) + elif position == "legend_outside": + styles.DrawCMSLogo( + self._subplots[0]._pad, + "CMS", + additional_string, + 11, + 0.045, + 0.05, + 1.0, + "", + 0.4, + ) else: - styles.DrawCMSLogo(self._subplots[0]._pad, 'CMS', additional_string , 11, - 0.795, 0.05, 1.0, '', 0.6) + styles.DrawCMSLogo( + self._subplots[0]._pad, + "CMS", + additional_string, + 11, + 0.795, + 0.05, + 1.0, + "", + 0.6, + ) def DrawLumi(self, lumi, textsize=0.6, legend_outside=False): if legend_outside: @@ -184,48 +230,59 @@ def add_graph(self, graph, name, group_name="invisible"): def add_inlet(self, inlet): self._inlets.append(inlet) - def add_legend(self, - reference_subplot=0, - width=0.30, - height=0.20, - pos=3, - offset=0.03): + def add_legend( + self, reference_subplot=0, width=0.30, height=0.20, pos=3, offset=0.03 + ): self._legends.append( - Legend(reference_subplot, width, height, pos, offset, - self._subplots)) - - def add_inlet_legend(self, - reference_inlet=0, - width=0.30, - height=0.20, - pos=3, - offset=0.03): + Legend(reference_subplot, width, height, pos, offset, self._subplots) + ) + + def add_inlet_legend( + self, reference_inlet=0, width=0.30, height=0.20, pos=3, offset=0.03 + ): self._inlets_legends.append( - Legend(reference_inlet, width, height, pos, offset, - self._inlets)) - - def add_line(self, - reference_subplot=0, - xmin=0.30, - ymin=0.20, - xmax=3, - ymax=0.03, color=1, linestyle=0, linewidth=1): + Legend(reference_inlet, width, height, pos, offset, self._inlets) + ) + + def add_line( + self, + reference_subplot=0, + xmin=0.30, + ymin=0.20, + xmax=3, + ymax=0.03, + color=1, + linestyle=0, + linewidth=1, + ): self._lines.append( - Line(reference_subplot, xmin, ymin, xmax, ymax, color, linestyle, linewidth, self._subplots)) - - - def setGraphStyle(self, - name, - markerstyle, - markershape=20, - markercolor=R.kBlack, - linecolor=1, - fillcolor=0, - linewidth=1, - linestyle=1, - markersize=1, - fillstyle=1001, - alpha=1.0): + Line( + reference_subplot, + xmin, + ymin, + xmax, + ymax, + color, + linestyle, + linewidth, + self._subplots, + ) + ) + + def setGraphStyle( + self, + name, + markerstyle, + markershape=20, + markercolor=R.kBlack, + linecolor=1, + fillcolor=0, + linewidth=1, + linestyle=1, + markersize=1, + fillstyle=1001, + alpha=1.0, + ): for subplot in self._subplots: subplot.setGraphStyle( name=name, @@ -238,12 +295,14 @@ def setGraphStyle(self, linewidth=linewidth, markersize=markersize, fillstyle=fillstyle, - alpha=alpha) + alpha=alpha, + ) def create_stack(self, hist_names, name, group_name="invisible"): for subplot in self._subplots: subplot.create_stack( - hist_names=hist_names, name=name, group_name=group_name) + hist_names=hist_names, name=name, group_name=group_name + ) def scaleXLabelSize(self, val): for subplot in self._subplots: @@ -289,13 +348,30 @@ def scaleYLabelOffset(self, val): for subplot in self._subplots: subplot.scaleYLabelOffset(val) - def unroll(self, ur_bin_labels, ur_label_pos = 9, ur_label_angle = 270, ur_label_size = 1.0, selection = None, pads_to_print_labels = None): + def unroll( + self, + ur_bin_labels, + ur_label_pos=9, + ur_label_angle=270, + ur_label_size=1.0, + selection=None, + pads_to_print_labels=None, + ): empty_labels = ["" for label in ur_bin_labels] for i, subplot in enumerate(self._subplots): - subplot.unroll(ur_bin_labels if (pads_to_print_labels == None or i in pads_to_print_labels) else empty_labels, - ur_label_pos, ur_label_angle, ur_label_size, selection) - - def changeXLabels(self, replacement_list): #requires list of strings with one string per labeled tick + subplot.unroll( + ur_bin_labels + if (pads_to_print_labels == None or i in pads_to_print_labels) + else empty_labels, + ur_label_pos, + ur_label_angle, + ur_label_size, + selection, + ) + + def changeXLabels( + self, replacement_list + ): # requires list of strings with one string per labeled tick for subplot in self._subplots: subplot.changeXLabels(replacement_list) @@ -308,28 +384,25 @@ class Subplot(object): def __init__(self, name, lower_bound=0.0, upper_bound=1.0): logger.debug( "Booking subplot with lower boundary at %f and upper boundary at %f" - % (lower_bound, upper_bound)) - self._pad = R.TPad("pad_" + str(name), "pad_" + str(name), 0., 0., 1., - 1.) - ''' + % (lower_bound, upper_bound) + ) + self._pad = R.TPad("pad_" + str(name), "pad_" + str(name), 0.0, 0.0, 1.0, 1.0) + """ if lower_bound==0.0: lower_bound+=self._pad.GetBottomMargin() if upper_bound==1.0: upper_bound-=self._pad.GetTopMargin() - ''' - drawspaceheight = 1.0 - self._pad.GetBottomMargin( - ) - self._pad.GetTopMargin() - lower_margin = self._pad.GetBottomMargin( - ) + lower_bound * drawspaceheight - upper_margin = self._pad.GetTopMargin() + ( - 1 - upper_bound) * drawspaceheight + """ + drawspaceheight = 1.0 - self._pad.GetBottomMargin() - self._pad.GetTopMargin() + lower_margin = self._pad.GetBottomMargin() + lower_bound * drawspaceheight + upper_margin = self._pad.GetTopMargin() + (1 - upper_bound) * drawspaceheight self._pad.SetBottomMargin(lower_margin) self._pad.SetTopMargin(upper_margin) self._pad.SetFillStyle(4000) self._pad.Draw() self._hists = {} - self._graphs= {} + self._graphs = {} self._xlabel = None self._ylabel = None self._logx = False @@ -367,45 +440,50 @@ def graphs(self): # adds histogram to subplot and assign individual name and group name. Default group name = "invisible" which is ignored by DrawAll function. def add_hist(self, hist, name, group_name="invisible"): - if name in self._hists.keys(): + if name in list(self._hists.keys()): logger.fatal("Histogram name %s already used!") raise Exception if not (isinstance(hist, R.TH1D) or isinstance(hist, R.TH1F)): logger.fatal( - "add_hist expects a TH1F with name {}, got object {}".format( - name, hist)) + "add_hist expects a TH1F with name {}, got object {}".format(name, hist) + ) raise Exception self._hists[name] = [ - copy.deepcopy(hist), group_name, "" + copy.deepcopy(hist), + group_name, + "", ] # last entry is used to save the markerstyle and set in a different function def add_graph(self, graph, name, group_name="invisible"): - if name in self._graphs.keys(): + if name in list(self._graphs.keys()): logger.fatal("Graph name %s already used!") raise Exception if not isinstance(graph, R.TGraph): logger.fatal( "add_graph expects a TGraph with name {}, got object {}".format( - name, graph)) + name, graph + ) + ) raise Exception self._graphs[name] = [ - copy.deepcopy(graph), group_name, "" + copy.deepcopy(graph), + group_name, + "", ] # last entry is used to save the markerstyle and set in a different function # returns histogram with given name or sum of histograms with given group name def get_hist(self, name): - if name in self._hists.keys(): + if name in list(self._hists.keys()): if isinstance(self._hists[name][0], R.THStack): logger.fatal("get_hist does not accept names of stacks!") raise Exception return self._hists[name][0] else: empty = True - for entry in self._hists.values(): + for entry in list(self._hists.values()): if entry[1] == name: if isinstance(entry[0], R.THStack): - logger.fatal( - "get_hist does not accept names of stacks!") + logger.fatal("get_hist does not accept names of stacks!") raise Exception if empty: hist = copy.deepcopy(entry[0]) @@ -420,16 +498,22 @@ def get_hist(self, name): return hist def get_graph(self, name): - if name in self._graphs.keys(): + if name in list(self._graphs.keys()): return self._graphs[name] # draws all histograms assigned to the subplot except those with group name "invisible" def DrawAll(self): if isinstance(self._unroll, list): - self.DrawUnrolled([entry for entry in self._hists() if not self._hists[entry][1] == "invisible"]) + self.DrawUnrolled( + [ + entry + for entry in self._hists() + if not self._hists[entry][1] == "invisible" + ] + ) else: isFirst = True - for hist in self._hists.values(): + for hist in list(self._hists.values()): if not hist[1] == "invisible": self.DrawSingle(hist, isFirst) isFirst = False @@ -440,18 +524,18 @@ def Draw(self, names): if isinstance(self._unroll, list): self.DrawUnrolled(names) else: - if isinstance(names, basestring): + if isinstance(names, str): names = [names] isFirst = True for name in names: - if name in self._hists.keys(): + if name in list(self._hists.keys()): self.DrawSingle(self._hists[name], isFirst) isFirst = False - elif name in self._graphs.keys(): + elif name in list(self._graphs.keys()): self.DrawSingle(self._graphs[name], isFirst) isFirst = False else: - for entry in self._hists.values(): + for entry in list(self._hists.values()): if entry[1] == name: self.DrawSingle(entry, isFirst) isFirst = False @@ -461,9 +545,9 @@ def Draw(self, names): def DrawSingle(self, hist, isFirst): self._pad.cd() if isFirst: - #hist[0].Draw() # needed for stacks + # hist[0].Draw() # needed for stacks if self._ylims != None and isinstance( - hist[0], R.THStack + hist[0], R.THStack ): # otherwise lims are not set without a unintended margin copystack = copy.deepcopy(hist[0]) axishist = copystack.GetHists()[0] @@ -483,7 +567,7 @@ def DrawUnrolled(self, names): raise Exception n_bins = len(self._unroll) n_selected_bins = len(self._selection) - #determine ranges + # determine ranges if self._xlims == None: hist = self._hists[names[0]][0] if isinstance(hist, R.THStack): @@ -492,22 +576,33 @@ def DrawUnrolled(self, names): axis_borders = [self._xlims[0]] pad_borders = [self._pad.GetLeftMargin()] axisrange = self._xlims[1] - self._xlims[0] - inv_round_order = 10.0**(4-math.floor(math.log10(axisrange))) + inv_round_order = 10.0 ** (4 - math.floor(math.log10(axisrange))) for i in range(n_bins): - axis_borders.append(int((self._xlims[0] + axisrange / n_bins * (i + 1))*inv_round_order)/inv_round_order) + axis_borders.append( + int((self._xlims[0] + axisrange / n_bins * (i + 1)) * inv_round_order) + / inv_round_order + ) for i in range(n_selected_bins): - pad_borders.append(self._pad.GetLeftMargin() + (1.0 - self._pad.GetRightMargin() - self._pad.GetLeftMargin()) / n_selected_bins * (i + 1)) - #fix ticklengths + pad_borders.append( + self._pad.GetLeftMargin() + + (1.0 - self._pad.GetRightMargin() - self._pad.GetLeftMargin()) + / n_selected_bins + * (i + 1) + ) + # fix ticklengths self._scale_ticklength = 2.0 / n_bins - #create subpads + # create subpads copy_me = copy.deepcopy(self) margin = 0.01 * axisrange / n_bins for i, idx in enumerate(self._selection): self._unroll_pads.append(copy.deepcopy(copy_me)) self._unroll_pads[i]._unroll = self._unroll[idx] - self._unroll_pads[i]._xlims = [axis_borders[idx] + margin, axis_borders[idx+1] - margin] + self._unroll_pads[i]._xlims = [ + axis_borders[idx] + margin, + axis_borders[idx + 1] - margin, + ] self._unroll_pads[i]._pad.SetLeftMargin(pad_borders[i]) - self._unroll_pads[i]._pad.SetRightMargin(1.0 - pad_borders[i+1]) + self._unroll_pads[i]._pad.SetRightMargin(1.0 - pad_borders[i + 1]) self._unroll_pads[i]._pad.Draw() if i > 0: self._unroll_pads[i]._ylabelsize = 0.0 @@ -519,25 +614,38 @@ def DrawUnrolled(self, names): offs = axis_borders[0] incr = (axis_borders[1] - axis_borders[0]) / 4.0 if self._unroll_pads[i]._changexlabels == None: - self._unroll_pads[i]._changexlabels = [" ", - "{:.1f}".format(offs + 1 * incr), - "{:.1f}".format(offs + 2 * incr), - "{:.1f}".format(offs + 3 * incr), - " "] - - #fix y range + self._unroll_pads[i]._changexlabels = [ + " ", + "{:.1f}".format(offs + 1 * incr), + "{:.1f}".format(offs + 2 * incr), + "{:.1f}".format(offs + 3 * incr), + " ", + ] + + # fix y range if self._ylims == None: hist = self._hists[names[0]][0] if isinstance(hist, R.THStack): copystack = copy.deepcopy(hist) hist = copystack.GetHists()[0] - self._unroll_pads[i]._ylims = [hist.GetMinimum()/1.1, hist.GetMaximum()*1.2] + self._unroll_pads[i]._ylims = [ + hist.GetMinimum() / 1.1, + hist.GetMaximum() * 1.2, + ] if self._logy and self._unroll_pads[i]._ylims[0] == 0.0: - self._unroll_pads[i]._ylims[0] = self._unroll_pads[i]._ylims[1]/10.0 - #draw subpads + self._unroll_pads[i]._ylims[0] = ( + self._unroll_pads[i]._ylims[1] / 10.0 + ) + # draw subpads for unroll_pad in self._unroll_pads: unroll_pad.Draw(names) - styles.DrawText(unroll_pad._pad, unroll_pad._unroll, unroll_pad._unroll_label_scalesize, self._unroll_label_pos, self._unroll_label_angle) + styles.DrawText( + unroll_pad._pad, + unroll_pad._unroll, + unroll_pad._unroll_label_scalesize, + self._unroll_label_pos, + self._unroll_label_angle, + ) def setXlabel(self, label): self._xlabel = label @@ -556,7 +664,7 @@ def setLogX(self): def setLogY(self): self._logy = True - + def setGrid(self): self._grid = True @@ -590,44 +698,51 @@ def scaleXLabelOffset(self, val): def scaleYLabelOffset(self, val): self._ylabeloffsetscale = val - # internal method to apply formatting to initial histograms def setAxisStyles(self, hist): # set axis labels if self._xlabel == None: hist.GetXaxis().SetTitleSize(0) hist.GetXaxis().SetLabelSize(0) - #hist.GetXaxis().SetTickLength(0) + # hist.GetXaxis().SetTickLength(0) else: hist.GetXaxis().SetTitle(self._xlabel) hist.GetXaxis().SetTitleOffset( - self._xtitleoffsetscale * hist.GetXaxis().GetTitleOffset()) + self._xtitleoffsetscale * hist.GetXaxis().GetTitleOffset() + ) hist.GetXaxis().SetLabelOffset( - self._xlabeloffsetscale * hist.GetXaxis().GetLabelOffset()) + self._xlabeloffsetscale * hist.GetXaxis().GetLabelOffset() + ) if self._ylabel == None: hist.GetYaxis().SetTitleSize(0) hist.GetYaxis().SetLabelSize(0) - #hist.GetYaxis().SetTickLength(0) + # hist.GetYaxis().SetTickLength(0) else: hist.GetYaxis().SetTitle(self._ylabel) hist.GetYaxis().SetTitleOffset( - self._ytitleoffsetscale * hist.GetYaxis().GetTitleOffset()) + self._ytitleoffsetscale * hist.GetYaxis().GetTitleOffset() + ) hist.GetYaxis().SetLabelOffset( - self._ylabeloffsetscale * hist.GetYaxis().GetLabelOffset()) + self._ylabeloffsetscale * hist.GetYaxis().GetLabelOffset() + ) # set label sizes if self._xlabelsize != None: hist.GetXaxis().SetLabelSize( - self._xlabelsize * hist.GetXaxis().GetLabelSize()) + self._xlabelsize * hist.GetXaxis().GetLabelSize() + ) if self._ylabelsize != None: hist.GetYaxis().SetLabelSize( - self._ylabelsize * hist.GetYaxis().GetLabelSize()) + self._ylabelsize * hist.GetYaxis().GetLabelSize() + ) if self._xtitlesize != None: hist.GetXaxis().SetTitleSize( - self._xtitlesize * hist.GetXaxis().GetTitleSize()) + self._xtitlesize * hist.GetXaxis().GetTitleSize() + ) if self._ytitlesize != None: hist.GetYaxis().SetTitleSize( - self._ytitlesize * hist.GetYaxis().GetTitleSize()) + self._ytitlesize * hist.GetYaxis().GetTitleSize() + ) # set log scale and fix customized range if necessary if self._logx: @@ -656,40 +771,42 @@ def setAxisStyles(self, hist): if self._nydivisions != None: hist.GetYaxis().SetNdivisions(*self._nydivisions) hist.GetYaxis().SetTickLength(0.02 / self._height * self._scale_ticklength) - - #change axis labels + + # change axis labels if self._changexlabels != None: for i, label in enumerate(self._changexlabels): - hist.GetXaxis().ChangeLabel(i+1, -1, -1, -1, -1, -1, label) + hist.GetXaxis().ChangeLabel(i + 1, -1, -1, -1, -1, -1, label) if self._changeylabels != None: for i, label in enumerate(self._changeylabels): - hist.GetYaxis().ChangeLabel(i+1, -1, -1, -1, -1, -1, label) - + hist.GetYaxis().ChangeLabel(i + 1, -1, -1, -1, -1, -1, label) + # add grid ticks if set if self._grid: self._pad.SetGridy(1) # always use scientific notation on y axis hist.GetYaxis().SetMaxDigits(3) + # sets style for specific histogram or group - def setGraphStyle(self, - name, - markerstyle, - markershape=20, - markercolor=R.kBlack, - linecolor=1, - fillcolor=0, - linewidth=1, - markersize=1, - linestyle=1, - fillstyle=1001, - alpha=1.0): + def setGraphStyle( + self, + name, + markerstyle, + markershape=20, + markercolor=R.kBlack, + linecolor=1, + fillcolor=0, + linewidth=1, + markersize=1, + linestyle=1, + fillstyle=1001, + alpha=1.0, + ): markerstyledict = {} - if markerstyle in markerstyledict.keys(): + if markerstyle in list(markerstyledict.keys()): markerstyle = markerstyledict[markerstyle] - if name in self._hists.keys(): + if name in list(self._hists.keys()): if isinstance(self._hists[name][0], R.THStack): - logger.warning( - "Adressed object is stack. Style cannot be set!") + logger.warning("Adressed object is stack. Style cannot be set!") return self._hists[name][2] = markerstyle self._hists[name][0].SetMarkerStyle(markershape) @@ -700,22 +817,21 @@ def setGraphStyle(self, self._hists[name][0].SetMarkerSize(markersize) self._hists[name][0].SetLineStyle(linestyle) self._hists[name][0].SetFillStyle(fillstyle) - elif name in self._graphs.keys(): + elif name in list(self._graphs.keys()): self._graphs[name][2] = markerstyle self._graphs[name][0].SetMarkerStyle(markershape) self._graphs[name][0].SetMarkerColor(markercolor) self._graphs[name][0].SetLineColor(linecolor) - self._graphs[name][0].SetFillColorAlpha(fillcolor,alpha) + self._graphs[name][0].SetFillColorAlpha(fillcolor, alpha) self._graphs[name][0].SetLineWidth(linewidth) self._graphs[name][0].SetMarkerSize(markersize) self._graphs[name][0].SetLineStyle(linestyle) self._graphs[name][0].SetFillStyle(fillstyle) else: - for hist in self._hists.values(): + for hist in list(self._hists.values()): if hist[1] == name: if isinstance(hist[0], R.THStack): - logger.warning( - "Adressed object is stack. Style cannot be set!") + logger.warning("Adressed object is stack. Style cannot be set!") return hist[2] = markerstyle hist[0].SetMarkerStyle(markershape) @@ -729,20 +845,19 @@ def setGraphStyle(self, # creates stack from registered histograms defined via name or group name def create_stack(self, hist_names, name, group_name="invisible"): - if name in self._hists.keys(): + if name in list(self._hists.keys()): logger.fatal("Stack name %s already used!" % name) raise Exception stack = R.THStack("hs", "") # regularize inputs - if isinstance(hist_names, basestring): + if isinstance(hist_names, str): hist_names = [hist_names] for hist_name in hist_names: - if hist_name in self._hists.keys(): + if hist_name in list(self._hists.keys()): stack.Add(self._hists[hist_name][0]) - logger.debug( - "Added histogram %s to stack %s" % (hist_name, name)) + logger.debug("Added histogram %s to stack %s" % (hist_name, name)) else: - for key, hist in self._hists.iteritems(): + for key, hist in self._hists.items(): if hist_name == hist[1]: if isinstance(hist[0], R.THStack): logger.fatal( @@ -750,16 +865,15 @@ def create_stack(self, hist_names, name, group_name="invisible"): ) raise Exception stack.Add(hist[0]) - logger.debug( - "Added histogram %s to stack %s" % (key, name)) + logger.debug("Added histogram %s to stack %s" % (key, name)) self._hists[name] = [stack, group_name, "hist"] # normalizes one or more histograms to a given denominator def normalize(self, nominator_names, denominator_names): # regularize inputs - if isinstance(nominator_names, basestring): + if isinstance(nominator_names, str): nominator_names = [nominator_names] - if isinstance(denominator_names, basestring): + if isinstance(denominator_names, str): denominator_names = [denominator_names] # sum up denominator @@ -771,18 +885,18 @@ def normalize(self, nominator_names, denominator_names): else: denominator.Add(self.get_hist(name)) # do not propagate denominator errors - for i in xrange(1, denominator.GetNbinsX() + 1): - denominator.SetBinError(i, 0.) + for i in range(1, denominator.GetNbinsX() + 1): + denominator.SetBinError(i, 0.0) # normalize all nominator inputs for name in nominator_names: - if name in self._hists.keys(): + if name in list(self._hists.keys()): if isinstance(self._hists[name][0], R.THStack): logger.fatal("Stacks cannot be normalized!") raise Exception self._hists[name][0].Divide(denominator) else: - for hist in self._hists.values(): + for hist in list(self._hists.values()): if hist[1] == name: if isinstance(hist[0], R.THStack): logger.fatal("Stacks cannot be normalized!") @@ -791,23 +905,28 @@ def normalize(self, nominator_names, denominator_names): # normalizes bin contents of all histograms in the subplot to their bin width def normalizeByBinWidth(self): - for hist in self._hists.values(): + for hist in list(self._hists.values()): if not isinstance(hist[0], R.THStack): denominator = copy.deepcopy(hist[0]) for i in range(denominator.GetNbinsX()): - denominator.SetBinContent(i + 1, - denominator.GetBinWidth(i + 1)) + denominator.SetBinContent(i + 1, denominator.GetBinWidth(i + 1)) denominator.SetBinError(i + 1, 0.0) hist[0].Divide(denominator) - - def unroll(self, ur_bin_labels, ur_label_pos = 9, ur_label_angle = 270, ur_label_size = 1.0, selection = None): + def unroll( + self, + ur_bin_labels, + ur_label_pos=9, + ur_label_angle=270, + ur_label_size=1.0, + selection=None, + ): self._unroll = ur_bin_labels self._unroll_label_pos = ur_label_pos self._unroll_label_angle = ur_label_angle self._unroll_label_scalesize = ur_label_size if selection == None: - self._selection = range(len(self._unroll)) + self._selection = list(range(len(self._unroll))) else: self._selection = selection @@ -828,15 +947,15 @@ class InletPlot(Subplot): """ Create an Inlet plot, where the position of the pad is set via the contructor, everything else is identical to a normal subplot """ + def __init__(self, name, x_1, x_2, y_1, y_2): - logger.debug( - "Booking inlet plot with size %s x %s" % (x_2 - x_1, y_2 - y_1)) + logger.debug("Booking inlet plot with size %s x %s" % (x_2 - x_1, y_2 - y_1)) self._pad = R.TPad("pad_" + str(name), "pad_" + str(name), x_1, y_1, x_2, y_2) self._pad.SetFillStyle(4000) self._pad.Draw() self._hists = {} - self._graphs= {} + self._graphs = {} self._xlabel = None self._ylabel = None self._logx = False @@ -864,8 +983,20 @@ def __init__(self, name, x_1, x_2, y_1, y_2): self._unroll_label_scalesize = 1.0 self._scale_ticklength = 1.0 + class Line(object): - def __init__(self, reference_subplot, xmin, ymin, xmax, ymax, color, linestyle, linewidth, subplots): + def __init__( + self, + reference_subplot, + xmin, + ymin, + xmax, + ymax, + color, + linestyle, + linewidth, + subplots, + ): if not isinstance(reference_subplot, int): logger.fatal("Subplot index is supposed to be of type int!") raise Exception @@ -878,7 +1009,7 @@ def __init__(self, reference_subplot, xmin, ymin, xmax, ymax, color, linestyle, self.color = color self.linestyle = linestyle self.linewidth = linewidth - + def Draw(self): self.reference_subplot._pad.cd() self._line.SetLineWidth(self.linewidth) @@ -886,9 +1017,9 @@ def Draw(self): self._line.SetLineColor(self.color) self._line.Draw("same") + class Legend(object): - def __init__(self, reference_subplot, width, height, pos, offset, - subplots): + def __init__(self, reference_subplot, width, height, pos, offset, subplots): if not isinstance(reference_subplot, int): logger.fatal("Subplot index is supposed to be of type int!") raise Exception @@ -903,31 +1034,34 @@ def __init__(self, reference_subplot, width, height, pos, offset, b = subplots[reference_subplot]._pad.GetBottomMargin() r = subplots[reference_subplot]._pad.GetRightMargin() if pos == 1: - self._legend = R.TLegend(l + o, 1 - t - o - h, l + o + w, - 1 - t - o, '', 'NBNDC') + self._legend = R.TLegend( + l + o, 1 - t - o - h, l + o + w, 1 - t - o, "", "NBNDC" + ) if pos == 2: c = l + 0.5 * (1 - l - r) - self._legend = R.TLegend(c - 0.5 * w, 1 - t - o - h, c + 0.5 * w, - 1 - t - o, '', 'NBNDC') + self._legend = R.TLegend( + c - 0.5 * w, 1 - t - o - h, c + 0.5 * w, 1 - t - o, "", "NBNDC" + ) if pos == 3: - self._legend = R.TLegend(1 - r - o - w, 1 - t - o - h, 1 - r - o, - 1 - t - o, '', 'NBNDC') + self._legend = R.TLegend( + 1 - r - o - w, 1 - t - o - h, 1 - r - o, 1 - t - o, "", "NBNDC" + ) if pos == 4: - self._legend = R.TLegend(l + o, b + o, l + o + w, b + o + h, '', - 'NBNDC') + self._legend = R.TLegend(l + o, b + o, l + o + w, b + o + h, "", "NBNDC") if pos == 5: c = l + 0.5 * (1 - l - r) - self._legend = R.TLegend(c - 0.5 * w, b + o, c + 0.5 * w, - b + o + h, '', 'NBNDC') + self._legend = R.TLegend( + c - 0.5 * w, b + o, c + 0.5 * w, b + o + h, "", "NBNDC" + ) if pos == 6: - self._legend = R.TLegend(1 - r - o - w, b + o, 1 - r - o, - b + o + h, '', 'NBNDC') + self._legend = R.TLegend( + 1 - r - o - w, b + o, 1 - r - o, b + o + h, "", "NBNDC" + ) # the position outside of the plot if pos == 7: - self._legend = R.TLegend(l + o - 0.03, 0.975, l + o + w, - 0.875, '', 'NBNDC') + self._legend = R.TLegend(l + o - 0.03, 0.975, l + o + w, 0.875, "", "NBNDC") self._subplots = subplots - self._textsizescale = 1. + self._textsizescale = 1.0 self._ncolumns = 1 self._FillColor = 0 self._alpha = 1.0 @@ -939,12 +1073,14 @@ def add_entry(self, subplot_index, histname, label, style): if subplot_index >= len(self._subplots): logger.fatal("Subplot index is out of range!") raise Exception - if histname in self._subplots[subplot_index]._hists.keys(): + if histname in list(self._subplots[subplot_index]._hists.keys()): self._legend.AddEntry( - self._subplots[subplot_index]._hists[histname][0], label, style) - elif histname in self._subplots[subplot_index]._graphs.keys(): + self._subplots[subplot_index]._hists[histname][0], label, style + ) + elif histname in list(self._subplots[subplot_index]._graphs.keys()): self._legend.AddEntry( - self._subplots[subplot_index]._graphs[histname][0], label, style) + self._subplots[subplot_index]._graphs[histname][0], label, style + ) else: logger.fatal("Requested histogram for legend does not exist!") raise Exception diff --git a/Dumbledraw/labels.yaml b/Dumbledraw/labels.yaml index e33cd6e..18ead3f 100644 --- a/Dumbledraw/labels.yaml +++ b/Dumbledraw/labels.yaml @@ -1,409 +1,501 @@ x_label: mm: # Dilepton Quantities - m_vis: 'Di-#mu mass / GeV' - ptvis: 'Di-#mu p_{T} / GeV' - DiTauDeltaR: '#DeltaR(#mu_{1}, #mu_{2})' - m_sv: 'SVFit di-#tau mass (PF) / GeV' - pt_sv: 'SVFit di-#tau p_{T} (PF) / GeV' - eta_sv: 'SVFit di-#tau #eta (PF)' - m_fastmtt: 'fastMTT di-#tau mass (PF) / GeV' - pt_fastmtt: 'fastMTT di-#tau p_{T} (PF) / GeV' - eta_fastmtt: 'fastMTT di-#tau #eta (PF)' - m_sv_puppi: 'SVFit di-#tau mass (Puppi) / GeV' - pt_sv_puppi: 'SVFit di-#tau p_{T} (Puppi) / GeV' - eta_sv_puppi: 'SVFit di-#tau #eta (Puppi)' - m_fastmtt_puppi: 'fastMTT di-#tau mass (Puppi) / GeV' - pt_fastmtt_puppi: 'fastMTT di-#tau p_{T} (Puppi) / GeV' - eta_fastmtt_puppi: 'fastMTT di-#tau #eta (Puppi)' - pt_tt: 'p_{T}(#tau#tau) (PF) / GeV' - pt_tt_puppi: 'p_{T}(#tau#tau) (Puppi) / GeV' + m_vis: "Di-#mu mass / GeV" + ptvis: "Di-#mu p_{T} / GeV" + DiTauDeltaR: "#DeltaR(#mu_{1}, #mu_{2})" + m_sv: "SVFit di-#tau mass (Puppi) / GeV" + pt_sv: "SVFit di-#tau p_{T} (Puppi) / GeV" + eta_sv: "SVFit di-#tau #eta (Puppi)" + m_fastmtt: "fastMTT di-#tau mass (Puppi) / GeV" + pt_fastmtt: "fastMTT di-#tau p_{T} (Puppi) / GeV" + eta_fastmtt: "fastMTT di-#tau #eta (Puppi)" + pt_tt: "p_{T}(#tau#tau) (Puppi) / GeV" + + m_sv_puppi: "SVFit di-#tau mass (Puppi) / GeV" + pt_sv_puppi: "SVFit di-#tau p_{T} (Puppi) / GeV" + eta_sv_puppi: "SVFit di-#tau #eta (Puppi)" + m_fastmtt_puppi: "fastMTT di-#tau mass (Puppi) / GeV" + pt_fastmtt_puppi: "fastMTT di-#tau p_{T} (Puppi) / GeV" + eta_fastmtt_puppi: "fastMTT di-#tau #eta (Puppi)" + pt_tt_puppi: "p_{T}(#tau#tau) (Puppi) / GeV" + + m_sv_pf: "SVFit di-#tau mass (PF) / GeV" + pt_sv_pf: "SVFit di-#tau p_{T} (PF) / GeV" + eta_sv_pf: "SVFit di-#tau #eta (PF)" + m_fastmtt_pf: "fastMTT di-#tau mass (PF) / GeV" + pt_fastmtt_pf: "fastMTT di-#tau p_{T} (PF) / GeV" + eta_fastmtt_pf: "fastMTT di-#tau #eta (PF)" + pt_tt_pf: "p_{T}(#tau#tau) (PF) / GeV" # Lepton quantities - pt_1: 'Leading Muon p_{T} / GeV' - pt_2: 'Trailing Muon p_{T} / GeV' - eta_1: 'Leading Muon #eta' - eta_2: 'Trailing Muon #eta' + pt_1: "Leading Muon p_{T} / GeV" + pt_2: "Trailing Muon p_{T} / GeV" + eta_1: "Leading Muon #eta" + eta_2: "Trailing Muon #eta" # Jet quantities - jpt_1: 'Leading Jet p_{T} / GeV' - jpt_2: 'Trailing Jet p_{T} / GeV' - jeta_1: 'Leading Jet #eta' - jeta_2: 'Trailing Jet #eta' - jdeta: '#Delta #eta_{jj}' - jphi_1: 'Leading Jet #varphi' - jphi_2: 'Trailing Jet #varphi' - mjj: 'Di-Jet mass m_{jj} / GeV' - dijetpt: 'Di-Jet p_{T} / GeV' - pt_ttjj: 'p_{T}(#tau#tau + di-Jet) (PF) / GeV' - pt_ttjj_puppi: 'p_{T}(#tau#tau + di-Jet) (Puppi) / GeV' - njets: 'Number of Jets' + jpt_1: "Leading Jet p_{T} / GeV" + jpt_2: "Trailing Jet p_{T} / GeV" + jeta_1: "Leading Jet #eta" + jeta_2: "Trailing Jet #eta" + jdeta: "#Delta #eta_{jj}" + jphi_1: "Leading Jet #varphi" + jphi_2: "Trailing Jet #varphi" + mjj: "Di-Jet mass m_{jj} / GeV" + dijetpt: "Di-Jet p_{T} / GeV" + pt_ttjj: "p_{T}(#tau#tau + di-Jet) (Puppi) / GeV" + pt_ttjj_puppi: "p_{T}(#tau#tau + di-Jet) (Puppi) / GeV" + pt_ttjj_pf: "p_{T}(#tau#tau + di-Jet) (PF) / GeV" + njets: "Number of Jets" # B-jet quantities - nbtag: 'Number of b-tagged Jets' - bpt_1: 'Leading b-Jet p_{T} / GeV' - bpt_2: 'Trailing b-Jet p_{T} / GeV' - beta_1: 'Leading b-Jet #eta' - beta_2: 'Trailing b-Jet #eta' + nbtag: "Number of b-tagged Jets" + bpt_1: "Leading b-Jet p_{T} / GeV" + bpt_2: "Trailing b-Jet p_{T} / GeV" + beta_1: "Leading b-Jet #eta" + beta_2: "Trailing b-Jet #eta" # MET quantities - met: 'Missing transverse Energy (PF) / GeV' - metphi: 'Missing transverse Energy (PF) #varphi' - puppimet: 'Missing transverse Energy (Puppi) / GeV' - puppimetphi: 'Missing transverse Energy (Puppi) #varphi' + met: "Missing transverse Energy (Puppi) / GeV" + metphi: "Missing transverse Energy (Puppi) #varphi" + puppimet: "Missing transverse Energy (Puppi) / GeV" + puppimetphi: "Missing transverse Energy (Puppi) #varphi" + pfmet: "Missing transverse Energy (PF) / GeV" + pfmetphi: "Missing transverse Energy (PF) #varphi" # Lepton-MET quantities - mt_1: 'Transverse mass m_{T}(#mu_{1}, #slash{E}_{T}) (PF) / GeV' - mt_2: 'Transverse mass m_{T}(#mu_{2}, #slash{E}_{T}) (PF) / GeV' - mt_tot: 'Total transverse mass m_{T}^{tot} (PF) / GeV' - mTdileptonMET: 'Transverse mass m_{T}(#mu_{1}+#mu_{2}, #slash{E}_{T}) (PF) / GeV' - pZetaMissVis: 'p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (PF) / GeV' - mt_1_puppi: 'Transverse mass m_{T}(#mu_{1}, #slash{E}_{T}) (Puppi) / GeV' - mt_2_puppi: 'Transverse mass m_{T}(#mu_{2}, #slash{E}_{T}) (Puppi) / GeV' - mt_tot_puppi: 'Total transverse mass m_{T}^{tot} (Puppi) / GeV' - mTdileptonMET_puppi: 'Transverse mass m_{T}(#mu_{1}+#mu_{2}, #slash{E}_{T}) (Puppi) / GeV' - pZetaPuppiMissVis: 'p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (Puppi) / GeV' + mt_1: "Transverse mass m_{T}(#mu_{1}, #slash{E}_{T}) (Puppi) / GeV" + mt_2: "Transverse mass m_{T}(#mu_{2}, #slash{E}_{T}) (Puppi) / GeV" + mt_tot: "Total transverse mass m_{T}^{tot} (Puppi) / GeV" + mTdileptonMET: "Transverse mass m_{T}(#mu_{1}+#mu_{2}, #slash{E}_{T}) (Puppi) / GeV" + pZetaMissVis: "p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (Puppi) / GeV" + mt_1_puppi: "Transverse mass m_{T}(#mu_{1}, #slash{E}_{T}) (Puppi) / GeV" + mt_2_puppi: "Transverse mass m_{T}(#mu_{2}, #slash{E}_{T}) (Puppi) / GeV" + mt_tot_puppi: "Total transverse mass m_{T}^{tot} (Puppi) / GeV" + mTdileptonMET_puppi: "Transverse mass m_{T}(#mu_{1}+#mu_{2}, #slash{E}_{T}) (Puppi) / GeV" + pZetaPuppiMissVis: "p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (Puppi) / GeV" + mt_1_pf: "Transverse mass m_{T}(#mu_{1}, #slash{E}_{T}) (PF) / GeV" + mt_2_pf: "Transverse mass m_{T}(#mu_{2}, #slash{E}_{T}) (PF) / GeV" + mt_tot_pf: "Total transverse mass m_{T}^{tot} (PF) / GeV" + mTdileptonMET_pf: "Transverse mass m_{T}(#mu_{1}+#mu_{2}, #slash{E}_{T}) (PF) / GeV" + pZetaMissVis_pf: "p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (PF) / GeV" # MELA quantities - ME_D: 'MELA D^{VBF}_{Z + 2 Jets}' - ME_vbf_vs_Z: 'MELA D^{VBF}_{Z + 2 Jets}' - ME_ggh_vs_Z: 'MELA D^{ggH}_{Z + 2 Jets}' - ME_vbf_vs_ggh: 'MELA D^{VBF}_{ggH}' - ME_ggh: 'MELA ^{}P(ggH)' - ME_vbf: 'MELA ^{}P(VBF)' - ME_z2j_1: 'MELA ^{}P_{1}(Z + 2 Jets)' - ME_z2j_2: 'MELA ^{}P_{2}(Z + 2 Jets)' - ME_q2v1: 'MELA Q^{2}(^{}V_{1}) / GeV^{2}' - ME_q2v2: 'MELA Q^{2}(^{}V_{2}) / GeV^{2}' - ME_costheta1: 'MELA cos(#Theta_{1})' - ME_costheta2: 'MELA cos(#Theta_{2})' - ME_costhetastar: 'MELA cos(#Theta*)' - ME_phi: 'MELA #Phi' - ME_phi1: 'MELA #Phi_{1}' + ME_D: "MELA D^{VBF}_{Z + 2 Jets}" + ME_vbf_vs_Z: "MELA D^{VBF}_{Z + 2 Jets}" + ME_ggh_vs_Z: "MELA D^{ggH}_{Z + 2 Jets}" + ME_vbf_vs_ggh: "MELA D^{VBF}_{ggH}" + ME_ggh: "MELA ^{}P(ggH)" + ME_vbf: "MELA ^{}P(VBF)" + ME_z2j_1: "MELA ^{}P_{1}(Z + 2 Jets)" + ME_z2j_2: "MELA ^{}P_{2}(Z + 2 Jets)" + ME_q2v1: "MELA Q^{2}(^{}V_{1}) / GeV^{2}" + ME_q2v2: "MELA Q^{2}(^{}V_{2}) / GeV^{2}" + ME_costheta1: "MELA cos(#Theta_{1})" + ME_costheta2: "MELA cos(#Theta_{2})" + ME_costhetastar: "MELA cos(#Theta*)" + ME_phi: "MELA #Phi" + ME_phi1: "MELA #Phi_{1}" em: # Dilepton Quantities - m_vis: 'Visible di-#tau mass / GeV' - ptvis: 'Visible di-#tau p_{T} / GeV' - DiTauDeltaR: '#DeltaR(e, #mu)' - m_sv: 'SVFit di-#tau mass (PF) / GeV' - pt_sv: 'SVFit di-#tau p_{T} (PF) / GeV' - eta_sv: 'SVFit di-#tau #eta (PF)' - m_fastmtt: 'fastMTT di-#tau mass (PF) / GeV' - pt_fastmtt: 'fastMTT di-#tau p_{T} (PF) / GeV' - eta_fastmtt: 'fastMTT di-#tau #eta (PF)' - m_sv_puppi: 'SVFit di-#tau mass (Puppi) / GeV' - pt_sv_puppi: 'SVFit di-#tau p_{T} (Puppi) / GeV' - eta_sv_puppi: 'SVFit di-#tau #eta (Puppi)' - m_fastmtt_puppi: 'fastMTT di-#tau mass (Puppi) / GeV' - pt_fastmtt_puppi: 'fastMTT di-#tau p_{T} (Puppi) / GeV' - eta_fastmtt_puppi: 'fastMTT di-#tau #eta (Puppi)' - pt_tt: 'p_{T}(#tau#tau) (PF) / GeV' - pt_tt_puppi: 'p_{T}(#tau#tau) (Puppi) / GeV' + m_vis: "Visible di-#tau mass / GeV" + ptvis: "Visible di-#tau p_{T} / GeV" + DiTauDeltaR: "#DeltaR(e, #mu)" + m_sv: "SVFit di-#tau mass (PF) / GeV" + pt_sv: "SVFit di-#tau p_{T} (PF) / GeV" + eta_sv: "SVFit di-#tau #eta (PF)" + m_fastmtt: "fastMTT di-#tau mass (PF) / GeV" + pt_fastmtt: "fastMTT di-#tau p_{T} (PF) / GeV" + eta_fastmtt: "fastMTT di-#tau #eta (PF)" + m_sv_puppi: "SVFit di-#tau mass (Puppi) / GeV" + pt_sv_puppi: "SVFit di-#tau p_{T} (Puppi) / GeV" + eta_sv_puppi: "SVFit di-#tau #eta (Puppi)" + m_fastmtt_puppi: "fastMTT di-#tau mass (Puppi) / GeV" + pt_fastmtt_puppi: "fastMTT di-#tau p_{T} (Puppi) / GeV" + eta_fastmtt_puppi: "fastMTT di-#tau #eta (Puppi)" + pt_tt: "p_{T}(#tau#tau) (PF) / GeV" + pt_tt_puppi: "p_{T}(#tau#tau) (Puppi) / GeV" # Lepton quantities - pt_1: 'Electron p_{T} / GeV' - pt_2: 'Muon p_{T} / GeV' - eta_1: 'Electron #eta' - eta_2: 'Muon #eta' + pt_1: "Electron p_{T} / GeV" + pt_2: "Muon p_{T} / GeV" + eta_1: "Electron #eta" + eta_2: "Muon #eta" # Jet quantities - jpt_1: 'Leading Jet p_{T} / GeV' - jpt_2: 'Trailing Jet p_{T} / GeV' - jeta_1: 'Leading Jet #eta' - jeta_2: 'Trailing Jet #eta' - jdeta: '#Delta #eta_{jj}' - jphi_1: 'Leading Jet #varphi' - jphi_2: 'Trailing Jet #varphi' - mjj: 'Di-Jet mass m_{jj} / GeV' - dijetpt: 'Di-Jet p_{T} / GeV' - pt_ttjj: 'p_{T}(#tau#tau + di-Jet) (PF) / GeV' - pt_ttjj_puppi: 'p_{T}(#tau#tau + di-Jet) (Puppi) / GeV' - njets: 'Number of Jets' + jpt_1: "Leading Jet p_{T} / GeV" + jpt_2: "Trailing Jet p_{T} / GeV" + jeta_1: "Leading Jet #eta" + jeta_2: "Trailing Jet #eta" + jdeta: "#Delta #eta_{jj}" + jphi_1: "Leading Jet #varphi" + jphi_2: "Trailing Jet #varphi" + mjj: "Di-Jet mass m_{jj} / GeV" + dijetpt: "Di-Jet p_{T} / GeV" + pt_ttjj: "p_{T}(#tau#tau + di-Jet) (PF) / GeV" + pt_ttjj_puppi: "p_{T}(#tau#tau + di-Jet) (Puppi) / GeV" + njets: "Number of Jets" # B-jet quantities - nbtag: 'Number of b-tagged Jets' - bpt_1: 'Leading b-Jet p_{T} / GeV' - bpt_2: 'Trailing b-Jet p_{T} / GeV' - beta_1: 'Leading b-Jet #eta' - beta_2: 'Trailing b-Jet #eta' + nbtag: "Number of b-tagged Jets" + bpt_1: "Leading b-Jet p_{T} / GeV" + bpt_2: "Trailing b-Jet p_{T} / GeV" + beta_1: "Leading b-Jet #eta" + beta_2: "Trailing b-Jet #eta" # MET quantities - met: 'Missing transverse Energy (PF) / GeV' - metphi: 'Missing transverse Energy (PF) #varphi' - puppimet: 'Missing transverse Energy (Puppi) / GeV' - puppimetphi: 'Missing transverse Energy (Puppi) #varphi' + met: "Missing transverse Energy (Puppi) / GeV" + metphi: "Missing transverse Energy (Puppi) #varphi" + puppimet: "Missing transverse Energy (Puppi) / GeV" + puppimetphi: "Missing transverse Energy (Puppi) #varphi" + pfmet: "Missing transverse Energy (PF) / GeV" + pfmetphi: "Missing transverse Energy (PF) #varphi" # Lepton-MET quantities - mt_1: 'Transverse mass m_{T}(e, #slash{E}_{T}) (PF) / GeV' - mt_2: 'Transverse mass m_{T}(#mu, #slash{E}_{T}) (PF) / GeV' - mt_tot: 'Total transverse mass m_{T}^{tot} (PF) / GeV' - mTdileptonMET: 'Transverse mass m_{T}(e+#mu, #slash{E}_{T}) (PF) / GeV' - pZetaMissVis: 'p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (PF) / GeV' - mt_1_puppi: 'Transverse mass m_{T}(e, #slash{E}_{T}) (Puppi) / GeV' - mt_2_puppi: 'Transverse mass m_{T}(#mu, #slash{E}_{T}) (Puppi) / GeV' - mt_tot_puppi: 'Total transverse mass m_{T}^{tot} (Puppi) / GeV' - mTdileptonMET_puppi: 'Transverse mass m_{T}(e+#mu, #slash{E}_{T}) (Puppi) / GeV' - pZetaPuppiMissVis: 'p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (Puppi) / GeV' + mt_1: "Transverse mass m_{T}(e, #slash{E}_{T}) (Puppi) / GeV" + mt_2: "Transverse mass m_{T}(#mu_{2}, #slash{E}_{T}) (Puppi) / GeV" + mt_tot: "Total transverse mass m_{T}^{tot} (Puppi) / GeV" + mTdileptonMET: "Transverse mass m_{T}(e+#mu_{2}, #slash{E}_{T}) (Puppi) / GeV" + pZetaMissVis: "p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (Puppi) / GeV" + mt_1_puppi: "Transverse mass m_{T}(e, #slash{E}_{T}) (Puppi) / GeV" + mt_2_puppi: "Transverse mass m_{T}(#mu_{2}, #slash{E}_{T}) (Puppi) / GeV" + mt_tot_puppi: "Total transverse mass m_{T}^{tot} (Puppi) / GeV" + mTdileptonMET_puppi: "Transverse mass m_{T}(e+#mu_{2}, #slash{E}_{T}) (Puppi) / GeV" + pZetaPuppiMissVis: "p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (Puppi) / GeV" + mt_1_pf: "Transverse mass m_{T}(e_{1}, #slash{E}_{T}) (PF) / GeV" + mt_2_pf: "Transverse mass m_{T}(#mu_{2}, #slash{E}_{T}) (PF) / GeV" + mt_tot_pf: "Total transverse mass m_{T}^{tot} (PF) / GeV" + mTdileptonMET_pf: "Transverse mass m_{T}(e+#mu_{2}, #slash{E}_{T}) (PF) / GeV" + pZetaMissVis_pf: "p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (PF) / GeV" # MELA quantities - ME_D: 'MELA D^{VBF}_{Z + 2 Jets}' - ME_vbf_vs_Z: 'MELA D^{VBF}_{Z + 2 Jets}' - ME_ggh_vs_Z: 'MELA D^{ggH}_{Z + 2 Jets}' - ME_vbf_vs_ggh: 'MELA D^{VBF}_{ggH}' - ME_ggh: 'MELA ^{}P(ggH)' - ME_vbf: 'MELA ^{}P(VBF)' - ME_z2j_1: 'MELA ^{}P_{1}(Z + 2 Jets)' - ME_z2j_2: 'MELA ^{}P_{2}(Z + 2 Jets)' - ME_q2v1: 'MELA Q^{2}(^{}V_{1}) / GeV^{2}' - ME_q2v2: 'MELA Q^{2}(^{}V_{2}) / GeV^{2}' - ME_costheta1: 'MELA cos(#Theta_{1})' - ME_costheta2: 'MELA cos(#Theta_{2})' - ME_costhetastar: 'MELA cos(#Theta*)' - ME_phi: 'MELA #Phi' - ME_phi1: 'MELA #Phi_{1}' + ME_D: "MELA D^{VBF}_{Z + 2 Jets}" + ME_vbf_vs_Z: "MELA D^{VBF}_{Z + 2 Jets}" + ME_ggh_vs_Z: "MELA D^{ggH}_{Z + 2 Jets}" + ME_vbf_vs_ggh: "MELA D^{VBF}_{ggH}" + ME_ggh: "MELA ^{}P(ggH)" + ME_vbf: "MELA ^{}P(VBF)" + ME_z2j_1: "MELA ^{}P_{1}(Z + 2 Jets)" + ME_z2j_2: "MELA ^{}P_{2}(Z + 2 Jets)" + ME_q2v1: "MELA Q^{2}(^{}V_{1}) / GeV^{2}" + ME_q2v2: "MELA Q^{2}(^{}V_{2}) / GeV^{2}" + ME_costheta1: "MELA cos(#Theta_{1})" + ME_costheta2: "MELA cos(#Theta_{2})" + ME_costhetastar: "MELA cos(#Theta*)" + ME_phi: "MELA #Phi" + ME_phi1: "MELA #Phi_{1}" mt: # Dilepton Quantities - m_vis: 'Visible di-#tau mass / GeV' - ptvis: 'Visible di-#tau p_{T} / GeV' - DiTauDeltaR: '#DeltaR(#mu, ^{}#tau_{h})' - m_sv: 'SVFit di-#tau mass (PF) / GeV' - pt_sv: 'SVFit di-#tau p_{T} (PF) / GeV' - eta_sv: 'SVFit di-#tau #eta (PF)' - m_fastmtt: 'fastMTT di-#tau mass (PF) / GeV' - pt_fastmtt: 'fastMTT di-#tau p_{T} (PF) / GeV' - eta_fastmtt: 'fastMTT di-#tau #eta (PF)' - m_sv_puppi: 'SVFit di-#tau mass (Puppi) / GeV' - pt_sv_puppi: 'SVFit di-#tau p_{T} (Puppi) / GeV' - eta_sv_puppi: 'SVFit di-#tau #eta (Puppi)' - m_fastmtt_puppi: 'fastMTT di-#tau mass (Puppi) / GeV' - pt_fastmtt_puppi: 'fastMTT di-#tau p_{T} (Puppi) / GeV' - eta_fastmtt_puppi: 'fastMTT di-#tau #eta (Puppi)' - pt_tt: 'p_{T}(#tau#tau) (PF) / GeV' - pt_tt_puppi: 'p_{T}(#tau#tau) (Puppi) / GeV' + m_vis: "Visible di-#tau mass / GeV" + ptvis: "Visible di-#tau p_{T} / GeV" + DiTauDeltaR: "#DeltaR(#mu, ^{}#tau_{h})" + m_sv: "SVFit di-#tau mass (PF) / GeV" + pt_sv: "SVFit di-#tau p_{T} (PF) / GeV" + eta_sv: "SVFit di-#tau #eta (PF)" + m_fastmtt: "fastMTT di-#tau mass (PF) / GeV" + pt_fastmtt: "fastMTT di-#tau p_{T} (PF) / GeV" + eta_fastmtt: "fastMTT di-#tau #eta (PF)" + m_sv_puppi: "SVFit di-#tau mass (Puppi) / GeV" + pt_sv_puppi: "SVFit di-#tau p_{T} (Puppi) / GeV" + eta_sv_puppi: "SVFit di-#tau #eta (Puppi)" + m_fastmtt_puppi: "fastMTT di-#tau mass (Puppi) / GeV" + pt_fastmtt_puppi: "fastMTT di-#tau p_{T} (Puppi) / GeV" + eta_fastmtt_puppi: "fastMTT di-#tau #eta (Puppi)" + pt_tt: "p_{T}(#tau#tau) (PF) / GeV" + pt_tt_puppi: "p_{T}(#tau#tau) (Puppi) / GeV" # Lepton quantities - pt_1: 'Muon p_{T} / GeV' - pt_2: 'Hadronic Tau p_{T} / GeV' - eta_1: 'Muon #eta' - eta_2: 'Hadronic Tau #eta' + pt_1: "Muon p_{T} / GeV" + pt_2: "Hadronic Tau p_{T} / GeV" + eta_1: "Muon #eta" + eta_2: "Hadronic Tau #eta" # Jet quantities - jpt_1: 'Leading Jet p_{T} / GeV' - jpt_2: 'Trailing Jet p_{T} / GeV' - jeta_1: 'Leading Jet #eta' - jeta_2: 'Trailing Jet #eta' - jdeta: '#Delta #eta_{jj}' - jphi_1: 'Leading Jet #varphi' - jphi_2: 'Trailing Jet #varphi' - mjj: 'Di-Jet mass m_{jj} / GeV' - dijetpt: 'Di-Jet p_{T} / GeV' - pt_ttjj: 'p_{T}(#tau#tau + di-Jet) (PF) / GeV' - pt_ttjj_puppi: 'p_{T}(#tau#tau + di-Jet) (Puppi) / GeV' - njets: 'Number of Jets' + jpt_1: "Leading Jet p_{T} / GeV" + jpt_2: "Trailing Jet p_{T} / GeV" + jeta_1: "Leading Jet #eta" + jeta_2: "Trailing Jet #eta" + jdeta: "#Delta #eta_{jj}" + jphi_1: "Leading Jet #varphi" + jphi_2: "Trailing Jet #varphi" + mjj: "Di-Jet mass m_{jj} / GeV" + dijetpt: "Di-Jet p_{T} / GeV" + pt_ttjj: "p_{T}(#tau#tau + di-Jet) (Puppi) / GeV" + pt_ttjj_pf: "p_{T}(#tau#tau + di-Jet) (PF) / GeV" + pt_ttjj_puppi: "p_{T}(#tau#tau + di-Jet) (Puppi) / GeV" + njets: "Number of Jets" # B-jet quantities - nbtag: 'Number of b-tagged Jets' - bpt_1: 'Leading b-Jet p_{T} / GeV' - bpt_2: 'Trailing b-Jet p_{T} / GeV' - beta_1: 'Leading b-Jet #eta' - beta_2: 'Trailing b-Jet #eta' + nbtag: "Number of b-tagged Jets" + bpt_1: "Leading b-Jet p_{T} / GeV" + bpt_2: "Trailing b-Jet p_{T} / GeV" + beta_1: "Leading b-Jet #eta" + beta_2: "Trailing b-Jet #eta" # MET quantities - met: 'Missing transverse Energy (PF) / GeV' - metphi: 'Missing transverse Energy (PF) #varphi' - puppimet: 'Missing transverse Energy (Puppi) / GeV' - puppimetphi: 'Missing transverse Energy (Puppi) #varphi' + met: "Missing transverse Energy (Puppi) / GeV" + metphi: "Missing transverse Energy (Puppi) #varphi" + puppimet: "Missing transverse Energy (Puppi) / GeV" + puppimetphi: "Missing transverse Energy (Puppi) #varphi" + pfmet: "Missing transverse Energy (PF) / GeV" + pfmetphi: "Missing transverse Energy (PF) #varphi" # Lepton-MET quantities - mt_1: 'Transverse mass m_{T}(#mu, #slash{E}_{T}) (PF) / GeV' - mt_2: 'Transverse mass m_{T}(^{}#tau_{h}, #slash{E}_{T}) (PF) / GeV' - mt_tot: 'Total transverse mass m_{T}^{tot} (PF) / GeV' - mTdileptonMET: 'Transverse mass m_{T}(#mu+^{}#tau_{h}, #slash{E}_{T}) (PF) / GeV' - pZetaMissVis: 'p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (PF) / GeV' - mt_1_puppi: 'Transverse mass m_{T}(#mu, #slash{E}_{T}) (Puppi) / GeV' - mt_2_puppi: 'Transverse mass m_{T}(^{}#tau_{h}, #slash{E}_{T}) (Puppi) / GeV' - mt_tot_puppi: 'Total transverse mass m_{T}^{tot} (Puppi) / GeV' - mTdileptonMET_puppi: 'Transverse mass m_{T}(#mu+^{}#tau_{h}, #slash{E}_{T}) (Puppi) / GeV' - pZetaPuppiMissVis: 'p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (Puppi) / GeV' + mt_1: "Transverse mass m_{T}(#mu, #slash{E}_{T}) (Puppi) / GeV" + mt_2: "Transverse mass m_{T}(#tau_{h}, #slash{E}_{T}) (Puppi) / GeV" + mt_tot: "Total transverse mass m_{T}^{tot} (Puppi) / GeV" + mTdileptonMET: "Transverse mass m_{T}(#mu+#tau_{h}, #slash{E}_{T}) (Puppi) / GeV" + pZetaMissVis: "p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (Puppi) / GeV" + mt_1_puppi: "Transverse mass m_{T}(#mu, #slash{E}_{T}) (Puppi) / GeV" + mt_2_puppi: "Transverse mass m_{T}(#tau_{h}, #slash{E}_{T}) (Puppi) / GeV" + mt_tot_puppi: "Total transverse mass m_{T}^{tot} (Puppi) / GeV" + mTdileptonMET_puppi: "Transverse mass m_{T}(#mu+#tau_{h}, #slash{E}_{T}) (Puppi) / GeV" + pZetaPuppiMissVis: "p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (Puppi) / GeV" + mt_1_pf: "Transverse mass m_{T}(#mu, #slash{E}_{T}) (PF) / GeV" + mt_2_pf: "Transverse mass m_{T}(#tau_{h}, #slash{E}_{T}) (PF) / GeV" + mt_tot_pf: "Total transverse mass m_{T}^{tot} (PF) / GeV" + mTdileptonMET_pf: "Transverse mass m_{T}(#mu+#tau_{h}, #slash{E}_{T}) (PF) / GeV" + pZetaMissVis_pf: "p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (PF) / GeV" # MELA quantities - ME_D: 'MELA D^{VBF}_{Z + 2 Jets}' - ME_vbf_vs_Z: 'MELA D^{VBF}_{Z + 2 Jets}' - ME_ggh_vs_Z: 'MELA D^{ggH}_{Z + 2 Jets}' - ME_vbf_vs_ggh: 'MELA D^{VBF}_{ggH}' - ME_ggh: 'MELA ^{}P(ggH)' - ME_vbf: 'MELA ^{}P(VBF)' - ME_z2j_1: 'MELA ^{}P_{1}(Z + 2 Jets)' - ME_z2j_2: 'MELA ^{}P_{2}(Z + 2 Jets)' - ME_q2v1: 'MELA Q^{2}(^{}V_{1}) / GeV^{2}' - ME_q2v2: 'MELA Q^{2}(^{}V_{2}) / GeV^{2}' - ME_costheta1: 'MELA cos(#Theta_{1})' - ME_costheta2: 'MELA cos(#Theta_{2})' - ME_costhetastar: 'MELA cos(#Theta*)' - ME_phi: 'MELA #Phi' - ME_phi1: 'MELA #Phi_{1}' + ME_D: "MELA D^{VBF}_{Z + 2 Jets}" + ME_vbf_vs_Z: "MELA D^{VBF}_{Z + 2 Jets}" + ME_ggh_vs_Z: "MELA D^{ggH}_{Z + 2 Jets}" + ME_vbf_vs_ggh: "MELA D^{VBF}_{ggH}" + ME_ggh: "MELA ^{}P(ggH)" + ME_vbf: "MELA ^{}P(VBF)" + ME_z2j_1: "MELA ^{}P_{1}(Z + 2 Jets)" + ME_z2j_2: "MELA ^{}P_{2}(Z + 2 Jets)" + ME_q2v1: "MELA Q^{2}(^{}V_{1}) / GeV^{2}" + ME_q2v2: "MELA Q^{2}(^{}V_{2}) / GeV^{2}" + ME_costheta1: "MELA cos(#Theta_{1})" + ME_costheta2: "MELA cos(#Theta_{2})" + ME_costhetastar: "MELA cos(#Theta*)" + ME_phi: "MELA #Phi" + ME_phi1: "MELA #Phi_{1}" et: # Dilepton Quantities - m_vis: 'Visible di-#tau mass / GeV' - ptvis: 'Visible di-#tau p_{T} / GeV' - DiTauDeltaR: '#DeltaR(e, ^{}#tau_{h})' - m_sv: 'SVFit di-#tau mass (PF) / GeV' - pt_sv: 'SVFit di-#tau p_{T} (PF) / GeV' - eta_sv: 'SVFit di-#tau #eta (PF)' - m_fastmtt: 'fastMTT di-#tau mass (PF) / GeV' - pt_fastmtt: 'fastMTT di-#tau p_{T} (PF) / GeV' - eta_fastmtt: 'fastMTT di-#tau #eta (PF)' - m_sv_puppi: 'SVFit di-#tau mass (Puppi) / GeV' - pt_sv_puppi: 'SVFit di-#tau p_{T} (Puppi) / GeV' - eta_sv_puppi: 'SVFit di-#tau #eta (Puppi)' - m_fastmtt_puppi: 'fastMTT di-#tau mass (Puppi) / GeV' - pt_fastmtt_puppi: 'fastMTT di-#tau p_{T} (Puppi) / GeV' - eta_fastmtt_puppi: 'fastMTT di-#tau #eta (Puppi)' - pt_tt: 'p_{T}(#tau#tau) (PF) / GeV' - pt_tt_puppi: 'p_{T}(#tau#tau) (Puppi) / GeV' + m_vis: "Visible di-#tau mass / GeV" + ptvis: "Visible di-#tau p_{T} / GeV" + DiTauDeltaR: "#DeltaR(e, ^{}#tau_{h})" + m_sv: "SVFit di-#tau mass (PF) / GeV" + pt_sv: "SVFit di-#tau p_{T} (PF) / GeV" + eta_sv: "SVFit di-#tau #eta (PF)" + m_fastmtt: "fastMTT di-#tau mass (PF) / GeV" + pt_fastmtt: "fastMTT di-#tau p_{T} (PF) / GeV" + eta_fastmtt: "fastMTT di-#tau #eta (PF)" + m_sv_puppi: "SVFit di-#tau mass (Puppi) / GeV" + pt_sv_puppi: "SVFit di-#tau p_{T} (Puppi) / GeV" + eta_sv_puppi: "SVFit di-#tau #eta (Puppi)" + m_fastmtt_puppi: "fastMTT di-#tau mass (Puppi) / GeV" + pt_fastmtt_puppi: "fastMTT di-#tau p_{T} (Puppi) / GeV" + eta_fastmtt_puppi: "fastMTT di-#tau #eta (Puppi)" + pt_tt: "p_{T}(#tau#tau) (PF) / GeV" + pt_tt_puppi: "p_{T}(#tau#tau) (Puppi) / GeV" # Lepton quantities - pt_1: 'Electron p_{T} / GeV' - pt_2: 'Hadronic Tau p_{T} / GeV' - eta_1: 'Electron #eta' - eta_2: 'Hadronic Tau #eta' + pt_1: "Electron p_{T} / GeV" + pt_2: "Hadronic Tau p_{T} / GeV" + eta_1: "Electron #eta" + eta_2: "Hadronic Tau #eta" # Jet quantities - jpt_1: 'Leading Jet p_{T} / GeV' - jpt_2: 'Trailing Jet p_{T} / GeV' - jeta_1: 'Leading Jet #eta' - jeta_2: 'Trailing Jet #eta' - jdeta: '#Delta #eta_{jj}' - jphi_1: 'Leading Jet #varphi' - jphi_2: 'Trailing Jet #varphi' - mjj: 'Di-Jet mass m_{jj} / GeV' - dijetpt: 'Di-Jet p_{T} / GeV' - pt_ttjj: 'p_{T}(#tau#tau + di-Jet) (PF) / GeV' - pt_ttjj_puppi: 'p_{T}(#tau#tau + di-Jet) (Puppi) / GeV' - njets: 'Number of Jets' + jpt_1: "Leading Jet p_{T} / GeV" + jpt_2: "Trailing Jet p_{T} / GeV" + jeta_1: "Leading Jet #eta" + jeta_2: "Trailing Jet #eta" + jdeta: "#Delta #eta_{jj}" + jphi_1: "Leading Jet #varphi" + jphi_2: "Trailing Jet #varphi" + mjj: "Di-Jet mass m_{jj} / GeV" + dijetpt: "Di-Jet p_{T} / GeV" + pt_ttjj: "p_{T}(#tau#tau + di-Jet) (PF) / GeV" + pt_ttjj_puppi: "p_{T}(#tau#tau + di-Jet) (Puppi) / GeV" + njets: "Number of Jets" # B-jet quantities - nbtag: 'Number of b-tagged Jets' - bpt_1: 'Leading b-Jet p_{T} / GeV' - bpt_2: 'Trailing b-Jet p_{T} / GeV' - beta_1: 'Leading b-Jet #eta' - beta_2: 'Trailing b-Jet #eta' + nbtag: "Number of b-tagged Jets" + bpt_1: "Leading b-Jet p_{T} / GeV" + bpt_2: "Trailing b-Jet p_{T} / GeV" + beta_1: "Leading b-Jet #eta" + beta_2: "Trailing b-Jet #eta" # MET quantities - met: 'Missing transverse Energy (PF) / GeV' - metphi: 'Missing transverse Energy (PF) #varphi' - puppimet: 'Missing transverse Energy (Puppi) / GeV' - puppimetphi: 'Missing transverse Energy (Puppi) #varphi' + met: "Missing transverse Energy (Puppi) / GeV" + metphi: "Missing transverse Energy (Puppi) #varphi" + puppimet: "Missing transverse Energy (Puppi) / GeV" + puppimetphi: "Missing transverse Energy (Puppi) #varphi" + pfmet: "Missing transverse Energy (PF) / GeV" + pfmetphi: "Missing transverse Energy (PF) #varphi" # Lepton-MET quantities - mt_1: 'Transverse mass m_{T}(e, #slash{E}_{T}) (PF) / GeV' - mt_2: 'Transverse mass m_{T}(^{}#tau_{h}, #slash{E}_{T}) (PF) / GeV' - mt_tot: 'Total transverse mass m_{T}^{tot} (PF) / GeV' - mTdileptonMET: 'Transverse mass m_{T}(e+^{}#tau_{h}, #slash{E}_{T}) (PF) / GeV' - pZetaMissVis: 'p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (PF) / GeV' - mt_1_puppi: 'Transverse mass m_{T}(e, #slash{E}_{T}) (Puppi) / GeV' - mt_2_puppi: 'Transverse mass m_{T}(^{}#tau_{h}, #slash{E}_{T}) (Puppi) / GeV' - mt_tot_puppi: 'Total transverse mass m_{T}^{tot} (Puppi) / GeV' - mTdileptonMET_puppi: 'Transverse mass m_{T}(e+^{}#tau_{h}, #slash{E}_{T}) (Puppi) / GeV' - pZetaPuppiMissVis: 'p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (Puppi) / GeV' + mt_1: "Transverse mass m_{T}(e, #slash{E}_{T}) (PF) / GeV" + mt_2: "Transverse mass m_{T}(^{}#tau_{h}, #slash{E}_{T}) (PF) / GeV" + mt_tot: "Total transverse mass m_{T}^{tot} (PF) / GeV" + mTdileptonMET: "Transverse mass m_{T}(e+^{}#tau_{h}, #slash{E}_{T}) (PF) / GeV" + pZetaMissVis: "p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (PF) / GeV" + mt_1_puppi: "Transverse mass m_{T}(e, #slash{E}_{T}) (Puppi) / GeV" + mt_2_puppi: "Transverse mass m_{T}(^{}#tau_{h}, #slash{E}_{T}) (Puppi) / GeV" + mt_tot_puppi: "Total transverse mass m_{T}^{tot} (Puppi) / GeV" + mTdileptonMET_puppi: "Transverse mass m_{T}(e+^{}#tau_{h}, #slash{E}_{T}) (Puppi) / GeV" + pZetaPuppiMissVis: "p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (Puppi) / GeV" # MELA quantities - ME_D: 'MELA D^{VBF}_{Z + 2 Jets}' - ME_vbf_vs_Z: 'MELA D^{VBF}_{Z + 2 Jets}' - ME_ggh_vs_Z: 'MELA D^{ggH}_{Z + 2 Jets}' - ME_vbf_vs_ggh: 'MELA D^{VBF}_{ggH}' - ME_ggh: 'MELA ^{}P(ggH)' - ME_vbf: 'MELA ^{}P(VBF)' - ME_z2j_1: 'MELA ^{}P_{1}(Z + 2 Jets)' - ME_z2j_2: 'MELA ^{}P_{2}(Z + 2 Jets)' - ME_q2v1: 'MELA Q^{2}(^{}V_{1}) / GeV^{2}' - ME_q2v2: 'MELA Q^{2}(^{}V_{2}) / GeV^{2}' - ME_costheta1: 'MELA cos(#Theta_{1})' - ME_costheta2: 'MELA cos(#Theta_{2})' - ME_costhetastar: 'MELA cos(#Theta*)' - ME_phi: 'MELA #Phi' - ME_phi1: 'MELA #Phi_{1}' + ME_D: "MELA D^{VBF}_{Z + 2 Jets}" + ME_vbf_vs_Z: "MELA D^{VBF}_{Z + 2 Jets}" + ME_ggh_vs_Z: "MELA D^{ggH}_{Z + 2 Jets}" + ME_vbf_vs_ggh: "MELA D^{VBF}_{ggH}" + ME_ggh: "MELA ^{}P(ggH)" + ME_vbf: "MELA ^{}P(VBF)" + ME_z2j_1: "MELA ^{}P_{1}(Z + 2 Jets)" + ME_z2j_2: "MELA ^{}P_{2}(Z + 2 Jets)" + ME_q2v1: "MELA Q^{2}(^{}V_{1}) / GeV^{2}" + ME_q2v2: "MELA Q^{2}(^{}V_{2}) / GeV^{2}" + ME_costheta1: "MELA cos(#Theta_{1})" + ME_costheta2: "MELA cos(#Theta_{2})" + ME_costhetastar: "MELA cos(#Theta*)" + ME_phi: "MELA #Phi" + ME_phi1: "MELA #Phi_{1}" tt: # Dilepton Quantities - m_vis: 'Visible di-#tau mass / GeV' - ptvis: 'Visible di-#tau p_{T} / GeV' - DiTauDeltaR: '#DeltaR(^{}#tau_{h,1}, ^{}#tau_{h,2})' - m_sv: 'SVFit di-#tau mass (PF) / GeV' - pt_sv: 'SVFit di-#tau p_{T} (PF) / GeV' - eta_sv: 'SVFit di-#tau #eta (PF)' - m_fastmtt: 'fastMTT di-#tau mass (PF) / GeV' - pt_fastmtt: 'fastMTT di-#tau p_{T} (PF) / GeV' - eta_fastmtt: 'fastMTT di-#tau #eta (PF)' - m_sv_puppi: 'SVFit di-#tau mass (Puppi) / GeV' - pt_sv_puppi: 'SVFit di-#tau p_{T} (Puppi) / GeV' - eta_sv_puppi: 'SVFit di-#tau #eta (Puppi)' - m_fastmtt_puppi: 'fastMTT di-#tau mass (Puppi) / GeV' - pt_fastmtt_puppi: 'fastMTT di-#tau p_{T} (Puppi) / GeV' - eta_fastmtt_puppi: 'fastMTT di-#tau #eta (Puppi)' - pt_tt: 'p_{T}(#tau#tau) (PF) / GeV' - pt_tt_puppi: 'p_{T}(#tau#tau) (Puppi) / GeV' + m_vis: "Visible di-#tau mass / GeV" + ptvis: "Visible di-#tau p_{T} / GeV" + DiTauDeltaR: "#DeltaR(^{}#tau_{h,1}, ^{}#tau_{h,2})" + m_sv: "SVFit di-#tau mass (PF) / GeV" + pt_sv: "SVFit di-#tau p_{T} (PF) / GeV" + eta_sv: "SVFit di-#tau #eta (PF)" + m_fastmtt: "fastMTT di-#tau mass (PF) / GeV" + pt_fastmtt: "fastMTT di-#tau p_{T} (PF) / GeV" + eta_fastmtt: "fastMTT di-#tau #eta (PF)" + m_sv_puppi: "SVFit di-#tau mass (Puppi) / GeV" + pt_sv_puppi: "SVFit di-#tau p_{T} (Puppi) / GeV" + eta_sv_puppi: "SVFit di-#tau #eta (Puppi)" + m_fastmtt_puppi: "fastMTT di-#tau mass (Puppi) / GeV" + pt_fastmtt_puppi: "fastMTT di-#tau p_{T} (Puppi) / GeV" + eta_fastmtt_puppi: "fastMTT di-#tau #eta (Puppi)" + pt_tt: "p_{T}(#tau#tau) (PF) / GeV" + pt_tt_puppi: "p_{T}(#tau#tau) (Puppi) / GeV" # Lepton quantities - pt_1: 'Leading hadronic Tau p_{T} / GeV' - pt_2: 'Trailing hadronic Tau p_{T} / GeV' - eta_1: 'Leading hadronic Tau #eta' - eta_2: 'Trailing hadronic Tau #eta' + pt_1: "Leading hadronic Tau p_{T} / GeV" + pt_2: "Trailing hadronic Tau p_{T} / GeV" + eta_1: "Leading hadronic Tau #eta" + eta_2: "Trailing hadronic Tau #eta" # Jet quantities - jpt_1: 'Leading Jet p_{T} / GeV' - jpt_2: 'Trailing Jet p_{T} / GeV' - jeta_1: 'Leading Jet #eta' - jeta_2: 'Trailing Jet #eta' - jdeta: '#Delta #eta_{jj}' - jphi_1: 'Leading Jet #varphi' - jphi_2: 'Trailing Jet #varphi' - mjj: 'Di-Jet mass m_{jj} / GeV' - dijetpt: 'Di-Jet p_{T} / GeV' - pt_ttjj: 'p_{T}(#tau#tau + di-Jet) (PF) / GeV' - pt_ttjj_puppi: 'p_{T}(#tau#tau + di-Jet) (Puppi) / GeV' - njets: 'Number of Jets' + jpt_1: "Leading Jet p_{T} / GeV" + jpt_2: "Trailing Jet p_{T} / GeV" + jeta_1: "Leading Jet #eta" + jeta_2: "Trailing Jet #eta" + jdeta: "#Delta #eta_{jj}" + jphi_1: "Leading Jet #varphi" + jphi_2: "Trailing Jet #varphi" + mjj: "Di-Jet mass m_{jj} / GeV" + dijetpt: "Di-Jet p_{T} / GeV" + pt_ttjj: "p_{T}(#tau#tau + di-Jet) (PF) / GeV" + pt_ttjj_puppi: "p_{T}(#tau#tau + di-Jet) (Puppi) / GeV" + njets: "Number of Jets" # B-jet quantities - nbtag: 'Number of b-tagged Jets' - bpt_1: 'Leading b-Jet p_{T} / GeV' - bpt_2: 'Trailing b-Jet p_{T} / GeV' - beta_1: 'Leading b-Jet #eta' - beta_2: 'Trailing b-Jet #eta' + nbtag: "Number of b-tagged Jets" + bpt_1: "Leading b-Jet p_{T} / GeV" + bpt_2: "Trailing b-Jet p_{T} / GeV" + beta_1: "Leading b-Jet #eta" + beta_2: "Trailing b-Jet #eta" # MET quantities - met: 'Missing transverse Energy (PF) / GeV' - metphi: 'Missing transverse Energy (PF) #varphi' - puppimet: 'Missing transverse Energy (Puppi) / GeV' - puppimetphi: 'Missing transverse Energy (Puppi) #varphi' + met: "Missing transverse Energy (Puppi) / GeV" + metphi: "Missing transverse Energy (Puppi) #varphi" + puppimet: "Missing transverse Energy (Puppi) / GeV" + puppimetphi: "Missing transverse Energy (Puppi) #varphi" + pfmet: "Missing transverse Energy (PF) / GeV" + pfmetphi: "Missing transverse Energy (PF) #varphi" # Lepton-MET quantities - mt_1: 'Transverse mass m_{T}(^{}#tau_{h,1}, #slash{E}_{T}) (PF) / GeV' - mt_2: 'Transverse mass m_{T}(^{}#tau_{h,2}, #slash{E}_{T}) (PF) / GeV' - mt_tot: 'Total transverse mass m_{T}^{tot} (PF) / GeV' - mTdileptonMET: 'Transverse mass m_{T}(^{}#tau_{h,1}+^{}#tau_{h,2}, #slash{E}_{T}) (PF) / GeV' - pZetaMissVis: 'p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (PF) / GeV' - mt_1_puppi: 'Transverse mass m_{T}(^{}#tau_{h,1}, #slash{E}_{T}) (Puppi) / GeV' - mt_2_puppi: 'Transverse mass m_{T}(^{}#tau_{h,2}, #slash{E}_{T}) (Puppi) / GeV' - mt_tot_puppi: 'Total transverse mass m_{T}^{tot} (Puppi) / GeV' - mTdileptonMET_puppi: 'Transverse mass m_{T}(^{}#tau_{h,1}+^{}#tau_{h,2}, #slash{E}_{T}) (Puppi) / GeV' - pZetaPuppiMissVis: 'p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (Puppi) / GeV' + mt_1: "Transverse mass m_{T}(^{}#tau_{h,1}, #slash{E}_{T}) (PF) / GeV" + mt_2: "Transverse mass m_{T}(^{}#tau_{h,2}, #slash{E}_{T}) (PF) / GeV" + mt_tot: "Total transverse mass m_{T}^{tot} (PF) / GeV" + mTdileptonMET: "Transverse mass m_{T}(^{}#tau_{h,1}+^{}#tau_{h,2}, #slash{E}_{T}) (PF) / GeV" + pZetaMissVis: "p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (PF) / GeV" + mt_1_puppi: "Transverse mass m_{T}(^{}#tau_{h,1}, #slash{E}_{T}) (Puppi) / GeV" + mt_2_puppi: "Transverse mass m_{T}(^{}#tau_{h,2}, #slash{E}_{T}) (Puppi) / GeV" + mt_tot_puppi: "Total transverse mass m_{T}^{tot} (Puppi) / GeV" + mTdileptonMET_puppi: "Transverse mass m_{T}(^{}#tau_{h,1}+^{}#tau_{h,2}, #slash{E}_{T}) (Puppi) / GeV" + pZetaPuppiMissVis: "p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (Puppi) / GeV" # MELA quantities - ME_D: 'MELA D^{VBF}_{Z + 2 Jets}' - ME_vbf_vs_Z: 'MELA D^{VBF}_{Z + 2 Jets}' - ME_ggh_vs_Z: 'MELA D^{ggH}_{Z + 2 Jets}' - ME_vbf_vs_ggh: 'MELA D^{VBF}_{ggH}' - ME_ggh: 'MELA ^{}P(ggH)' - ME_vbf: 'MELA ^{}P(VBF)' - ME_z2j_1: 'MELA ^{}P_{1}(Z + 2 Jets)' - ME_z2j_2: 'MELA ^{}P_{2}(Z + 2 Jets)' - ME_q2v1: 'MELA Q^{2}(^{}V_{1}) / GeV^{2}' - ME_q2v2: 'MELA Q^{2}(^{}V_{2}) / GeV^{2}' - ME_costheta1: 'MELA cos(#Theta_{1})' - ME_costheta2: 'MELA cos(#Theta_{2})' - ME_costhetastar: 'MELA cos(#Theta*)' - ME_phi: 'MELA #Phi' - ME_phi1: 'MELA #Phi_{1}' + ME_D: "MELA D^{VBF}_{Z + 2 Jets}" + ME_vbf_vs_Z: "MELA D^{VBF}_{Z + 2 Jets}" + ME_ggh_vs_Z: "MELA D^{ggH}_{Z + 2 Jets}" + ME_vbf_vs_ggh: "MELA D^{VBF}_{ggH}" + ME_ggh: "MELA ^{}P(ggH)" + ME_vbf: "MELA ^{}P(VBF)" + ME_z2j_1: "MELA ^{}P_{1}(Z + 2 Jets)" + ME_z2j_2: "MELA ^{}P_{2}(Z + 2 Jets)" + ME_q2v1: "MELA Q^{2}(^{}V_{1}) / GeV^{2}" + ME_q2v2: "MELA Q^{2}(^{}V_{2}) / GeV^{2}" + ME_costheta1: "MELA cos(#Theta_{1})" + ME_costheta2: "MELA cos(#Theta_{2})" + ME_costhetastar: "MELA cos(#Theta*)" + ME_phi: "MELA #Phi" + ME_phi1: "MELA #Phi_{1}" + ee: + # Dilepton Quantities + m_vis: "Di-e mass / GeV" + ptvis: "Di-e p_{T} / GeV" + DiTauDeltaR: "#DeltaR(e_{1}, e_{2})" + m_sv: "SVFit di-#tau mass (Puppi) / GeV" + pt_sv: "SVFit di-#tau p_{T} (Puppi) / GeV" + eta_sv: "SVFit di-#tau #eta (Puppi)" + m_fastmtt: "fastMTT di-#tau mass (Puppi) / GeV" + pt_fastmtt: "fastMTT di-#tau p_{T} (Puppi) / GeV" + eta_fastmtt: "fastMTT di-#tau #eta (Puppi)" + pt_tt: "p_{T}(#tau#tau) (Puppi) / GeV" + + m_sv_puppi: "SVFit di-#tau mass (Puppi) / GeV" + pt_sv_puppi: "SVFit di-#tau p_{T} (Puppi) / GeV" + eta_sv_puppi: "SVFit di-#tau #eta (Puppi)" + m_fastmtt_puppi: "fastMTT di-#tau mass (Puppi) / GeV" + pt_fastmtt_puppi: "fastMTT di-#tau p_{T} (Puppi) / GeV" + eta_fastmtt_puppi: "fastMTT di-#tau #eta (Puppi)" + pt_tt_puppi: "p_{T}(#tau#tau) (Puppi) / GeV" + + m_sv_pf: "SVFit di-#tau mass (PF) / GeV" + pt_sv_pf: "SVFit di-#tau p_{T} (PF) / GeV" + eta_sv_pf: "SVFit di-#tau #eta (PF)" + m_fastmtt_pf: "fastMTT di-#tau mass (PF) / GeV" + pt_fastmtt_pf: "fastMTT di-#tau p_{T} (PF) / GeV" + eta_fastmtt_pf: "fastMTT di-#tau #eta (PF)" + pt_tt_pf: "p_{T}(#tau#tau) (PF) / GeV" + + # Lepton quantities + pt_1: "Leading Electron p_{T} / GeV" + pt_2: "Trailing Electron p_{T} / GeV" + eta_1: "Leading Electron #eta" + eta_2: "Trailing Electron #eta" + + # Jet quantities + jpt_1: "Leading Jet p_{T} / GeV" + jpt_2: "Trailing Jet p_{T} / GeV" + jeta_1: "Leading Jet #eta" + jeta_2: "Trailing Jet #eta" + jdeta: "#Delta #eta_{jj}" + jphi_1: "Leading Jet #varphi" + jphi_2: "Trailing Jet #varphi" + mjj: "Di-Jet mass m_{jj} / GeV" + dijetpt: "Di-Jet p_{T} / GeV" + pt_ttjj: "p_{T}(#tau#tau + di-Jet) (Puppi) / GeV" + pt_ttjj_puppi: "p_{T}(#tau#tau + di-Jet) (Puppi) / GeV" + pt_ttjj_pf: "p_{T}(#tau#tau + di-Jet) (PF) / GeV" + njets: "Number of Jets" + + # B-jet quantities + nbtag: "Number of b-tagged Jets" + bpt_1: "Leading b-Jet p_{T} / GeV" + bpt_2: "Trailing b-Jet p_{T} / GeV" + beta_1: "Leading b-Jet #eta" + beta_2: "Trailing b-Jet #eta" emt: # Dilepton Quantitieshttps://mattermost.web.cern.ch/cms-htt/messages/@rwolf m_vis: 'Visible di-#tau mass / GeV' @@ -1055,6 +1147,48 @@ emt: ME_phi: 'MELA #Phi' ME_phi1: 'MELA #Phi_{1}' + + # MET quantities + met: "Missing transverse Energy (Puppi) / GeV" + metphi: "Missing transverse Energy (Puppi) #varphi" + puppimet: "Missing transverse Energy (Puppi) / GeV" + puppimetphi: "Missing transverse Energy (Puppi) #varphi" + pfmet: "Missing transverse Energy (PF) / GeV" + pfmetphi: "Missing transverse Energy (PF) #varphi" + + # Lepton-MET quantities + mt_1: "Transverse mass m_{T}(e_{1}, #slash{E}_{T}) (Puppi) / GeV" + mt_2: "Transverse mass m_{T}(e_{2}, #slash{E}_{T}) (Puppi) / GeV" + mt_tot: "Total transverse mass m_{T}^{tot} (Puppi) / GeV" + mTdileptonMET: "Transverse mass m_{T}(e_{1}+e_{2}, #slash{E}_{T}) (Puppi) / GeV" + pZetaMissVis: "p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (Puppi) / GeV" + mt_1_puppi: "Transverse mass m_{T}(e_{1}, #slash{E}_{T}) (Puppi) / GeV" + mt_2_puppi: "Transverse mass m_{T}(e_{2}, #slash{E}_{T}) (Puppi) / GeV" + mt_tot_puppi: "Total transverse mass m_{T}^{tot} (Puppi) / GeV" + mTdileptonMET_puppi: "Transverse mass m_{T}(e_{1}+e_{2}, #slash{E}_{T}) (Puppi) / GeV" + pZetaPuppiMissVis: "p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (Puppi) / GeV" + mt_1_pf: "Transverse mass m_{T}(e_{1}, #slash{E}_{T}) (PF) / GeV" + mt_2_pf: "Transverse mass m_{T}(e_{2}, #slash{E}_{T}) (PF) / GeV" + mt_tot_pf: "Total transverse mass m_{T}^{tot} (PF) / GeV" + mTdileptonMET_pf: "Transverse mass m_{T}(e_{1}+e_{2}, #slash{E}_{T}) (PF) / GeV" + pZetaMissVis_pf: "p_{#zeta}^{miss} - 0.85 #upoint p_{#zeta}^{vis} (PF) / GeV" + + # MELA quantities + ME_D: "MELA D^{VBF}_{Z + 2 Jets}" + ME_vbf_vs_Z: "MELA D^{VBF}_{Z + 2 Jets}" + ME_ggh_vs_Z: "MELA D^{ggH}_{Z + 2 Jets}" + ME_vbf_vs_ggh: "MELA D^{VBF}_{ggH}" + ME_ggh: "MELA ^{}P(ggH)" + ME_vbf: "MELA ^{}P(VBF)" + ME_z2j_1: "MELA ^{}P_{1}(Z + 2 Jets)" + ME_z2j_2: "MELA ^{}P_{2}(Z + 2 Jets)" + ME_q2v1: "MELA Q^{2}(^{}V_{1}) / GeV^{2}" + ME_q2v2: "MELA Q^{2}(^{}V_{2}) / GeV^{2}" + ME_costheta1: "MELA cos(#Theta_{1})" + ME_costheta2: "MELA cos(#Theta_{2})" + ME_costhetastar: "MELA cos(#Theta*)" + ME_phi: "MELA #Phi" + ME_phi1: "MELA #Phi_{1}" legend_label: VHWW: 'VH#rightarrowWW' rem_VH: 'VH#rightarrowWW' @@ -1079,6 +1213,57 @@ legend_label: ZH: 'qq#rightarrowZH' ZTT: 'Z#rightarrow#tau#tau' EMB: '#tau embedded' + embminus2p5: "#tau embedded es -2.5%" + embminus2p4: "#tau embedded es -2.4%" + embminus2p3: "#tau embedded es -2.3%" + embminus2p2: "#tau embedded es -2.2%" + embminus2p1: "#tau embedded es -2.1%" + embminus2p0: "#tau embedded es -2.0%" + embminus1p9: "#tau embedded es -1.9%" + embminus1p8: "#tau embedded es -1.8%" + embminus1p7: "#tau embedded es -1.7%" + embminus1p6: "#tau embedded es -1.6%" + embminus1p5: "#tau embedded es -1.5%" + embminus1p4: "#tau embedded es -1.4%" + embminus1p3: "#tau embedded es -1.3%" + embminus1p2: "#tau embedded es -1.2%" + embminus1p1: "#tau embedded es -1.1%" + embminus1p0: "#tau embedded es -1.0%" + embminus0p9: "#tau embedded es -0.9%" + embminus0p8: "#tau embedded es -0.8%" + embminus0p7: "#tau embedded es -0.7%" + embminus0p6: "#tau embedded es -0.6%" + embminus0p5: "#tau embedded es -0.5%" + embminus0p4: "#tau embedded es -0.4%" + embminus0p3: "#tau embedded es -0.3%" + embminus0p2: "#tau embedded es -0.2%" + embminus0p1: "#tau embedded es -0.1%" + emb0p0: "#tau embedded es 0.0%" + emb0p1: "#tau embedded es 0.1%" + emb0p2: "#tau embedded es 0.2%" + emb0p3: "#tau embedded es 0.3%" + emb0p4: "#tau embedded es 0.4%" + emb0p5: "#tau embedded es 0.5%" + emb0p6: "#tau embedded es 0.6%" + emb0p7: "#tau embedded es 0.7%" + emb0p8: "#tau embedded es 0.8%" + emb0p9: "#tau embedded es 0.9%" + emb1p0: "#tau embedded es 1.0%" + emb1p1: "#tau embedded es 1.1%" + emb1p2: "#tau embedded es 1.2%" + emb1p3: "#tau embedded es 1.3%" + emb1p4: "#tau embedded es 1.4%" + emb1p5: "#tau embedded es 1.5%" + emb1p6: "#tau embedded es 1.6%" + emb1p7: "#tau embedded es 1.7%" + emb1p8: "#tau embedded es 1.8%" + emb1p9: "#tau embedded es 1.9%" + emb2p0: "#tau embedded es 2.0%" + emb2p1: "#tau embedded es 2.1%" + emb2p2: "#tau embedded es 2.2%" + emb2p3: "#tau embedded es 2.3%" + emb2p4: "#tau embedded es 2.4%" + emb2p5: "#tau embedded es 2.5%" EMBCMB: 'Z/t#bar{t}/VV#rightarrow#tau#tau' TotalBkg: 'Background' REST: 'Sim. Bkg.' @@ -1113,3 +1298,4 @@ legend_label: jetFakesTT: 'Jet#rightarrow^{}#tau_{h} (TT)' jetFakesEMB: 'Jet#rightarrow^{}#tau_{h}' data_obs: 'Data' + diff --git a/Dumbledraw/rootfile_parser.py b/Dumbledraw/rootfile_parser.py index 1237933..f543928 100644 --- a/Dumbledraw/rootfile_parser.py +++ b/Dumbledraw/rootfile_parser.py @@ -4,11 +4,12 @@ import logging import ROOT import copy + logger = logging.getLogger(__name__) class Rootfile_parser(object): - def __init__(self, inputrootfilename, mode="CombineHarvester"): + def __init__(self, inputrootfilename, mode="CombineHarvester", prefit=False): self._rootfilename = inputrootfilename self._rootfile = ROOT.TFile(self._rootfilename, "READ") self._type = "control" @@ -16,11 +17,13 @@ def __init__(self, inputrootfilename, mode="CombineHarvester"): for entry in content: if entry.endswith("prefit"): self._type = "prefit" - for entry in content: - if entry.endswith("postfit"): - self._type = "postfit" - logger.debug("Identified rootfile %s as %s shapes" % - (inputrootfilename, self._type)) + if not prefit: + for entry in content: + if entry.endswith("postfit"): + self._type = "postfit" + logger.debug( + "Identified rootfile %s as %s shapes" % (inputrootfilename, self._type) + ) if mode == "standard": self._hist_hash = "{channel}_{category}{plottype}/{process}{unc}" elif mode == "CombineHarvester": @@ -36,8 +39,7 @@ def rootfile(self): def get(self, era, channel, category, process, syst=None): if syst != None and self._type != "control": - logger.fatal( - "Uncertainty shapes are only available in control plots!") + logger.fatal("Uncertainty shapes are only available in control plots!") raise Exception hist_hash = self._hist_hash.format( era=era, @@ -45,32 +47,41 @@ def get(self, era, channel, category, process, syst=None): category=category, process=process, plottype="{plottype}", - unc="{unc}") + unc="{unc}", + ) if self._type == "control": syst = "" if syst == None else "_" + syst hist_hash = hist_hash.format(plottype="", unc=syst) else: hist_hash = hist_hash.format(plottype="_" + self._type, unc="") - logger.debug( - "Try to access %s in %s" % (hist_hash, self._rootfilename)) + logger.debug("Try to access %s in %s" % (hist_hash, self._rootfilename)) # perform check if file is available and otherwise return some dummy TH1F - available_processes = [entry.GetName() for entry in self._rootfile.Get(hist_hash.split('/')[0]).GetListOfKeys()] - if hist_hash.split('/')[1] in available_processes: + available_processes = [ + entry.GetName() + for entry in self._rootfile.Get(hist_hash.split("/")[0]).GetListOfKeys() + ] + if hist_hash.split("/")[1] in available_processes: return self._rootfile.Get(hist_hash) elif len(available_processes) != 0: - logger.warning("%s in %s does not exist !" % (hist_hash, self._rootfilename)) + logger.warning( + "%s in %s does not exist !" % (hist_hash, self._rootfilename) + ) logger.debug(" Available Histograms are: %s" % available_processes) logger.debug(" Returning a dummy histogram ") - dummy = self._rootfile.Get('{}/{}'.format(hist_hash.split('/')[0],available_processes[0])) + dummy = self._rootfile.Get( + "{}/{}".format(hist_hash.split("/")[0], available_processes[0]) + ) dummy.Reset() dummy.SetTitle(process) dummy.SetName(hist_hash) return dummy else: - logger.fatal(" None of the requested Histograms are available in %s. Aborting." % hist_hash.split('/')[0]) + logger.fatal( + " None of the requested Histograms are available in %s. Aborting." + % hist_hash.split("/")[0] + ) raise Exception - def get_bins(self, era, channel, category, process, syst=None): hist = self.get(era, channel, category, process, syst) nbins = hist.GetNbinsX() diff --git a/Dumbledraw/rootfile_parser_inputshapes.py b/Dumbledraw/rootfile_parser_inputshapes.py index e631889..f370a19 100644 --- a/Dumbledraw/rootfile_parser_inputshapes.py +++ b/Dumbledraw/rootfile_parser_inputshapes.py @@ -4,6 +4,7 @@ import logging import ROOT import copy + logger = logging.getLogger(__name__) @@ -29,10 +30,10 @@ def get(self, channel, category, process): analysis=self._analysis, epoch=self._epoch, variable=self._variable, - mass=self._mass) - logger.debug("Try to access %s in %s" % (hist_hash, - self._rootfilename)) - print "rootfile: " , self._rootfile.Get(hist_hash), " hash: ", hist_hash + mass=self._mass, + ) + logger.debug("Try to access %s in %s" % (hist_hash, self._rootfilename)) + print("rootfile: ", self._rootfile.Get(hist_hash), " hash: ", hist_hash) return self._rootfile.Get(hist_hash) diff --git a/Dumbledraw/rootfile_parser_ntuple_processor_inputshapes.py b/Dumbledraw/rootfile_parser_ntuple_processor_inputshapes.py new file mode 100644 index 0000000..c693bfb --- /dev/null +++ b/Dumbledraw/rootfile_parser_ntuple_processor_inputshapes.py @@ -0,0 +1,213 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +from __future__ import print_function + +import logging +import ROOT +import copy + +logger = logging.getLogger(__name__) + + +class Rootfile_parser(object): + + _dataset_map = { + "data": "data", + "ZTT": "DY", + "ZL": "DY", + "ZJ": "DY", + "TTT": "TT", + "TTL": "TT", + "TTJ": "TT", + "VVT": "VV", + "VVL": "VV", + "VVJ": "VV", + "W": "W", + "EMB": "EMB", + "QCDEMB": "QCD", + "QCD": "QCDMC", + "jetFakesEMB": "jetFakes", + "jetFakes": "jetFakesMC", + "ggH125": "ggH", + "qqH125": "qqH", + "wFakes": "wFakes", + "embminus2p5": "embminus2p5", + "embminus2p4": "embminus2p4", + "embminus2p3": "embminus2p3", + "embminus2p2": "embminus2p2", + "embminus2p1": "embminus2p1", + "embminus2p0": "embminus2p0", + "embminus1p9": "embminus1p9", + "embminus1p8": "embminus1p8", + "embminus1p7": "embminus1p7", + "embminus1p6": "embminus1p6", + "embminus1p5": "embminus1p5", + "embminus1p4": "embminus1p4", + "embminus1p3": "embminus1p3", + "embminus1p2": "embminus1p2", + "embminus1p1": "embminus1p1", + "embminus1p0": "embminus1p0", + "embminus0p9": "embminus0p9", + "embminus0p8": "embminus0p8", + "embminus0p7": "embminus0p7", + "embminus0p6": "embminus0p6", + "embminus0p5": "embminus0p5", + "embminus0p4": "embminus0p4", + "embminus0p3": "embminus0p3", + "embminus0p2": "embminus0p2", + "embminus0p1": "embminus0p1", + "emb0p0": "emb0p0", + "emb0p1": "emb0p1", + "emb0p2": "emb0p2", + "emb0p3": "emb0p3", + "emb0p4": "emb0p4", + "emb0p5": "emb0p5", + "emb0p6": "emb0p6", + "emb0p7": "emb0p7", + "emb0p8": "emb0p8", + "emb0p9": "emb0p9", + "emb1p0": "emb1p0", + "emb1p1": "emb1p1", + "emb1p2": "emb1p2", + "emb1p3": "emb1p3", + "emb1p4": "emb1p4", + "emb1p5": "emb1p5", + "emb1p6": "emb1p6", + "emb1p7": "emb1p7", + "emb1p8": "emb1p8", + "emb1p9": "emb1p9", + "emb2p0": "emb2p0", + "emb2p1": "emb2p1", + "emb2p2": "emb2p2", + "emb2p3": "emb2p3", + "emb2p4": "emb2p4", + "emb2p5": "emb2p5", + } + + _process_map = { + "data": "data", + "ZTT": "DY-ZTT", + "ZL": "DY-ZL", + "ZJ": "DY-ZJ", + "TTT": "TT-TTT", + "TTL": "TT-TTL", + "TTJ": "TT-TTJ", + "VVT": "VV-VVT", + "VVL": "VV-VVL", + "VVJ": "VV-VVJ", + "W": "W", + "EMB": "Embedded", + "QCDEMB": "QCD", + "QCD": "QCDMC", + "jetFakesEMB": "jetFakes", + "jetFakes": "jetFakesMC", + "ggH125": "ggH125", + "qqH125": "qqH125", + "wFakes": "wFakes", + "embminus2p5": "Embedded", + "embminus2p4": "Embedded", + "embminus2p3": "Embedded", + "embminus2p2": "Embedded", + "embminus2p1": "Embedded", + "embminus2p0": "Embedded", + "embminus1p9": "Embedded", + "embminus1p8": "Embedded", + "embminus1p7": "Embedded", + "embminus1p6": "Embedded", + "embminus1p5": "Embedded", + "embminus1p4": "Embedded", + "embminus1p3": "Embedded", + "embminus1p2": "Embedded", + "embminus1p1": "Embedded", + "embminus1p0": "Embedded", + "embminus0p9": "Embedded", + "embminus0p8": "Embedded", + "embminus0p7": "Embedded", + "embminus0p6": "Embedded", + "embminus0p5": "Embedded", + "embminus0p4": "Embedded", + "embminus0p3": "Embedded", + "embminus0p2": "Embedded", + "embminus0p1": "Embedded", + "emb0p0": "Embedded", + "emb0p1": "Embedded", + "emb0p2": "Embedded", + "emb0p3": "Embedded", + "emb0p4": "Embedded", + "emb0p5": "Embedded", + "emb0p6": "Embedded", + "emb0p7": "Embedded", + "emb0p8": "Embedded", + "emb0p9": "Embedded", + "emb1p0": "Embedded", + "emb1p1": "Embedded", + "emb1p2": "Embedded", + "emb1p3": "Embedded", + "emb1p4": "Embedded", + "emb1p5": "Embedded", + "emb1p6": "Embedded", + "emb1p7": "Embedded", + "emb1p8": "Embedded", + "emb1p9": "Embedded", + "emb2p0": "Embedded", + "emb2p1": "Embedded", + "emb2p2": "Embedded", + "emb2p3": "Embedded", + "emb2p4": "Embedded", + "emb2p5": "Embedded", + } + + def __init__(self, inputrootfilename, variable): + self._rootfilename = inputrootfilename + self._rootfile = ROOT.TFile(self._rootfilename, "READ") + self._variable = variable + + @property + def rootfile(self): + return self._rootfile + + def get(self, channel, process, category=None, shape_type="Nominal"): + dataset = self._dataset_map[process] + if category is None: + category = "" if "data" in process else "-" + self._process_map[process] + else: + category = ( + "-" + category + if "data" in process + else "-" + "-".join([self._process_map[process], category]) + ) + hist_hash = "{dataset}#{channel}{category}#{shape_type}#{variable}".format( + dataset=dataset, + channel=channel, + category=category, + shape_type=shape_type, + variable=self._variable, + ) + logger.debug("Try to access %s in %s" % (hist_hash, self._rootfilename)) + print("rootfile: ", self._rootfile.Get(hist_hash), " hash: ", hist_hash) + + return self._rootfile.Get(hist_hash) + + def list_contents(self): + return [key.GetTitle() for key in self._rootfile.GetListOfKeys()] + + def get_bins(self, channel, category): + hist = self.get(channel, category) + nbins = hist.GetNbinsX() + bins = [] + for i in range(nbins): + bins.append(hist.GetBinLowEdge(i + 1)) + bins.append(hist.GetBinLowEdge(i + 1) + hist.GetBinWidth(i + 1)) + return bins + + def get_values(self, channel, category): + hist = self.get(channel, category) + nbins = hist.GetNbinsX() + values = [] + for i in range(nbins): + values.append(hist.GetBinContent(i + 1)) + return values + + def __del__(self): + logger.debug("Closing rootfile %s" % (self._rootfilename)) + self._rootfile.Close() diff --git a/Dumbledraw/sf_rootfile_parser.py b/Dumbledraw/sf_rootfile_parser.py index 05794cf..64c538e 100644 --- a/Dumbledraw/sf_rootfile_parser.py +++ b/Dumbledraw/sf_rootfile_parser.py @@ -4,6 +4,7 @@ import logging import ROOT import copy + logger = logging.getLogger(__name__) @@ -13,24 +14,22 @@ def __init__(self, inputrootfilename): self._rootfile = ROOT.TFile(self._rootfilename, "READ") content = [entry.GetName() for entry in self._rootfile.GetListOfKeys()] self.Nbins = len(content) - logger.debug("Identified {} histograms in rootfile {} ".format(len(content), inputrootfilename)) + logger.debug( + "Identified {} histograms in rootfile {} ".format( + len(content), inputrootfilename + ) + ) self._hist_hash = "{variable}_projx_{etabin}" @property def rootfile(self): return self._rootfile - - def get(self, variable, etabin): - hist_hash = self._hist_hash.format( - variable=variable, - etabin=etabin) - logger.debug( - "Try to access %s in %s" % (hist_hash, self._rootfilename)) + hist_hash = self._hist_hash.format(variable=variable, etabin=etabin) + logger.debug("Try to access %s in %s" % (hist_hash, self._rootfilename)) return self._rootfile.Get(hist_hash) - def get_bins(self, variable, etabin): hist = self.get(self, variable, etabin) nbins = hist.GetNbinsX() @@ -50,8 +49,8 @@ def get_values(self, variable, etabin): def get_values_up(self, variable, etabin): hist = self.get(self, variable, etabin) - nbins=hist.GetNbinsX() - values=[] + nbins = hist.GetNbinsX() + values = [] for i in range(nbins): values.append(hist.GetBinErrDown(i + 1)) return values diff --git a/Dumbledraw/styles.py b/Dumbledraw/styles.py index 0fb8039..e98dd69 100644 --- a/Dumbledraw/styles.py +++ b/Dumbledraw/styles.py @@ -19,8 +19,9 @@ 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"] +legend_label_dict = yaml.safe_load(open(labels_path))["legend_label"] +x_label_dict = yaml.safe_load(open(labels_path))["x_label"] + color_dict = { "rem_VV": R.TColor.GetColor("#6F2D35"), @@ -50,6 +51,58 @@ def CreateTransparentColor(color, alpha): "inclusive": R.TColor.GetColor(254, 74, 73), "ZTT": R.TColor.GetColor(248, 206, 104), "EMB": R.TColor.GetColor(248, 206, 104), + "embminus2p5": R.TColor.GetColor(248, 206, 104), + "embminus2p4": R.TColor.GetColor(248, 206, 104), + "embminus2p3": R.TColor.GetColor(248, 206, 104), + "embminus2p2": R.TColor.GetColor(248, 206, 104), + "embminus2p1": R.TColor.GetColor(248, 206, 104), + "embminus2p0": R.TColor.GetColor(248, 206, 104), + "embminus1p9": R.TColor.GetColor(248, 206, 104), + "embminus1p8": R.TColor.GetColor(248, 206, 104), + "embminus1p7": R.TColor.GetColor(248, 206, 104), + "embminus1p6": R.TColor.GetColor(248, 206, 104), + "embminus1p5": R.TColor.GetColor(248, 206, 104), + "embminus1p4": R.TColor.GetColor(248, 206, 104), + "embminus1p3": R.TColor.GetColor(248, 206, 104), + "embminus1p2": R.TColor.GetColor(248, 206, 104), + "embminus1p1": R.TColor.GetColor(248, 206, 104), + "embminus1p0": R.TColor.GetColor(248, 206, 104), + "embminus0p9": R.TColor.GetColor(248, 206, 104), + "embminus0p8": R.TColor.GetColor(248, 206, 104), + "embminus0p7": R.TColor.GetColor(248, 206, 104), + "embminus0p6": R.TColor.GetColor(248, 206, 104), + "embminus0p5": R.TColor.GetColor(248, 206, 104), + "embminus0p4": R.TColor.GetColor(248, 206, 104), + "embminus0p3": R.TColor.GetColor(248, 206, 104), + "embminus0p2": R.TColor.GetColor(248, 206, 104), + "embminus0p1": R.TColor.GetColor(248, 206, 104), + "emb0p0": R.TColor.GetColor(248, 206, 104), + "emb0p1": R.TColor.GetColor(248, 206, 104), + "emb0p2": R.TColor.GetColor(248, 206, 104), + "emb0p3": R.TColor.GetColor(248, 206, 104), + "emb0p4": R.TColor.GetColor(248, 206, 104), + "emb0p5": R.TColor.GetColor(248, 206, 104), + "emb0p6": R.TColor.GetColor(248, 206, 104), + "emb0p7": R.TColor.GetColor(248, 206, 104), + "emb0p8": R.TColor.GetColor(248, 206, 104), + "emb0p9": R.TColor.GetColor(248, 206, 104), + "emb1p0": R.TColor.GetColor(248, 206, 104), + "emb1p1": R.TColor.GetColor(248, 206, 104), + "emb1p2": R.TColor.GetColor(248, 206, 104), + "emb1p3": R.TColor.GetColor(248, 206, 104), + "emb1p4": R.TColor.GetColor(248, 206, 104), + "emb1p5": R.TColor.GetColor(248, 206, 104), + "emb1p6": R.TColor.GetColor(248, 206, 104), + "emb1p7": R.TColor.GetColor(248, 206, 104), + "emb1p8": R.TColor.GetColor(248, 206, 104), + "emb1p9": R.TColor.GetColor(248, 206, 104), + "emb2p0": R.TColor.GetColor(248, 206, 104), + "emb2p1": R.TColor.GetColor(248, 206, 104), + "emb2p2": R.TColor.GetColor(248, 206, 104), + "emb2p3": R.TColor.GetColor(248, 206, 104), + "emb2p4": R.TColor.GetColor(248, 206, 104), + "emb2p5": R.TColor.GetColor(248, 206, 104), + "MUEMB": R.TColor.GetColor(100, 192, 232), "ZLL": R.TColor.GetColor(100, 192, 232), "ZL": R.TColor.GetColor(100, 192, 232), "ZJ": R.TColor.GetColor("#64DE6A"), @@ -89,7 +142,7 @@ def CreateTransparentColor(color, alpha): def SetStyle(name, **kwargs): styles = {"none": none, "TDR": SetTDRStyle, "ModTDR": ModTDRStyle} - if not name in styles.keys(): + if not name in list(styles.keys()): logger.fatal("%s style not available!" % name) logger.info("Set plotting style to %s" % name) styles[name](**kwargs) diff --git a/plot_variable.py b/plot_variable.py index b255569..6909934 100755 --- a/plot_variable.py +++ b/plot_variable.py @@ -70,7 +70,7 @@ def main(args): #print rootfile.list_contents() name = "_".join([channel, category]) out_name = "_".join([channel, category, variable]) - print name + 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.