def __init__(self, subprocesses, tree, label, line_color=1, fill_color=0, marker_style=None, metadata=None): """Initializes a new instance of the Process class. Args: subporocesses: An iterable of processes label: The ROOT TLatex label string to use when rendering the process line_color: The ROOT TColor number or hex string (#rrggbb) to use as the line color when rendering the process fill_color: The ROOT TColor number or hex string (#rrggbb) to use as the fill color when rendering the process marker_style: The ROOT TMarker number to use as the marker style when rendering the process metadata: A (pickleable) object containing optional metadata """ # Store parameters self._subprocesses = subprocesses self._label = label self._line_color = line_color self._fill_color = fill_color self._marker_style = marker_style self._metadata = metadata # Translate hex colors if necessary if isinstance(self._line_color, string_types): self._line_color = TColor.GetColor(self._line_color) if isinstance(self._fill_color, string_types): self._fill_color = TColor.GetColor(self._fill_color)
def __init__(self): self.p_n = [ 0, ] * 100 self.e_n = [ 0, ] * 100 self.stored_parameters = [ 0, ] * 100 self.num_bins = 0 self.xmins = [] self.xmaxes = [] self.data = [] self.errors = [] self.data_fits = [] self.model_scale_values = [] self.final = False self.exclude_regions = ((0, 0), ) self.col1 = 1 self.col2 = TColor.GetColor(27, 158, 119) self.col3 = TColor.GetColor(217, 95, 2) self.col4 = TColor.GetColor(117, 112, 179)
def getColor(color, transparency = None): from ROOT import TColor try: color = TColor.GetColor( *color ) except: if type(color) is not int: color = TColor.GetColor( color ) if transparency is not None: color = TColor.GetColorTransparent( color, transparency ) return color
def add_2P2F_hist(self, estimateZX_Data_file): file2p2f = ROOT.TFile(estimateZX_Data_file, "READ") histname = f"h1D_m4l_Add_{self.get_cr_fs_str()}" histPlot2p2f = file2p2f.Get(histname) print(f"2P2F contribution = {histPlot2p2f.Integral()}") print("Adding ZZ and WZ to the 2P2F CR in 3P1F") histPlot2p2f.Add(self.hist_ls[1]) # This is sloppy. Fix later. histPlot2p2f.Add(self.hist_ls[2]) histPlot2p2f.SetFillColor(TColor.GetColor("#ffffff")) # White. histPlot2p2f.SetLineColor(TColor.GetColor("#ff00ff")) # Pink. histPlot2p2f.SetLineWidth(2) histPlot2p2f.SetFillStyle(4000) histPlot2p2f.Smooth() histPlot2p2f.Draw("hist E1 same goff")
def add_palette(palette): tcolor_list = [] for rgb_triplet in palette: root_index = TColor.GetColor(rgb_triplet[0], rgb_triplet[1], rgb_triplet[2]) tcolor_list.append(root_index) return tcolor_list
def main(input_files, tags, show=True): g = [] for i, j in enumerate(input_files): t = tags[i] # print(i, j, t) g.append(make_reso(j, t, show)) can = TCanvas("all", "all") can.DrawFrame( 0, 0, 1, 200, f";{g[0].GetXaxis().GetTitle()};Resolution {g[0].GetYaxis().GetTitle()};", ) cols = ["#e41a1c", "#377eb8", "#4daf4a", "#984ea3"] leg = TLegend(0.9, 0.1, 1, 0.9) for j, i in enumerate(g): print("Drawing", i) c = TColor.GetColor(cols[j]) i.SetLineColor(c) i.SetLineWidth(2) leg.AddEntry(i, "", "l") i.Draw("sameL") leg.Draw() can.Update() input("press enter to continue")
def make_hstack(self): """Return a THStack with a TH1 already set to it.""" h_stack = ROOT.THStack(self.get_cr_fs_str(), self.get_cr_fs_str()) h_addtostack = ROOT.TH1F( f"h_addtostack_{self.get_cr_fs_str()}", # Internal name. self.get_cr_fs_str(title_friendly=True), # Title. 100, 0, 2000) h_addtostack.SetMinimum(-5.608576) h_addtostack.SetMaximum(51.10072) h_addtostack.SetDirectory(0) h_addtostack.SetStats(0) h_addtostack.SetLineColor(TColor.GetColor("#000099")) h_addtostack.SetLineStyle(0) h_addtostack.SetMarkerStyle(20) # Black data points. h_addtostack.GetXaxis().SetLabelFont(42) h_addtostack.GetXaxis().SetLabelOffset(0.007) h_addtostack.GetXaxis().SetLabelSize(0.05) h_addtostack.GetXaxis().SetTitleSize(0.06) h_addtostack.GetXaxis().SetTitleOffset(0.9) h_addtostack.GetXaxis().SetTitleFont(42) h_addtostack.GetYaxis().SetLabelFont(42) h_addtostack.GetYaxis().SetLabelOffset(0.007) h_addtostack.GetYaxis().SetLabelSize(0.05) h_addtostack.GetYaxis().SetTitleSize(0.06) h_addtostack.GetYaxis().SetTitleOffset(1.25) h_addtostack.GetYaxis().SetTitleFont(42) h_addtostack.GetZaxis().SetLabelFont(42) h_addtostack.GetZaxis().SetLabelOffset(0.007) h_addtostack.GetZaxis().SetLabelSize(0.05) h_addtostack.GetZaxis().SetTitleSize(0.06) h_addtostack.GetZaxis().SetTitleFont(42) h_stack.SetHistogram(h_addtostack) return h_stack
def main(filename, canvases): f = TFile(filename, "READ") f.ls() cols = ["#e41a1c", "#377eb8", "#4daf4a"] cols = [TColor.GetColor(i) for i in cols] print("Canvases", canvases) canname = canvases[0] canname.split("_folder_")[-1] can = f.Get(canname) lcan = can.GetListOfPrimitives() lcan.FindObject("TPave").SetHeader("") can.Draw() print(can) # leg = TLegend(0.7, 0.7, 0.9, 0.9) for i in canvases[1:]: print("Getting", i) c = f.Get(i) lp = c.GetListOfPrimitives() # lp.ls() for j in lp: if "TH1" not in j.ClassName(): continue print(j) can.cd() j.Draw("sameHIST") can.Update() return can
def efficiencyPalette(): from ROOT import TColor pcol = [] for iBin in range(0, 100): rgb = [] if iBin < 70: rgb = [0.70 + 0.007 * iBin, 0.00 + 0.0069 * iBin, 0.00] elif iBin < 90: rgb = [ 0.70 + 0.007 * iBin, 0.00 + 0.0069 * iBin + 0.10 + 0.01 * (iBin - 70), 0.00 ] else: rgb = [0.98 - 0.098 * (iBin - 90), 0.80, 0.00] pcol.append(TColor.GetColor(rgb[0], rgb[1], rgb[2])) return pcol
def get_hist(self, sample_dct, Nickname): """Return hist from infile. If hist is MC, make it pretty.""" # infile = sample_dct[Nickname]["filepath"] # isData = sample_dct[Nickname]["isData"] f = ROOT.TFile(infile, "READ") histname = f"h1D_mass4l_{self.get_cr_fs_str()}" if len(self.finalstate) == 0: histname += "_inclus" hist = f.Get(histname).Clone() hist.SetDirectory(0) lastbin = hist.GetNbinsX() lowedgelastbin = hist.GetBinLowEdge(lastbin) highedge = lowedgelastbin + hist.GetBinWidth(lastbin) print(f"Low_xbin={hist.GetBinLowEdge(1)}, High_xbin={highedge}") if not isData: fillcolor = sample_dct[Nickname]["fillcolor"] linecolor = sample_dct[Nickname]["linecolor"] hist.SetFillColor(TColor.GetColor(fillcolor)) hist.SetLineColor(TColor.GetColor(linecolor)) hist.SetFillStyle(1001) hist.SetLineStyle(0) hist.SetMarkerStyle(20) # x axis. hist.GetXaxis().SetLabelFont(42) hist.GetXaxis().SetLabelOffset(0.007) hist.GetXaxis().SetLabelSize(0.05) hist.GetXaxis().SetTitleSize(0.06) hist.GetXaxis().SetTitleOffset(0.9) hist.GetXaxis().SetTitleFont(42) # y axis. hist.GetYaxis().SetLabelFont(42) hist.GetYaxis().SetLabelOffset(0.007) hist.GetYaxis().SetLabelSize(0.05) hist.GetYaxis().SetTitleSize(0.06) hist.GetYaxis().SetTitleOffset(1.25) hist.GetYaxis().SetTitleFont(42) # z axis. hist.GetZaxis().SetLabelFont(42) hist.GetZaxis().SetLabelOffset(0.007) hist.GetZaxis().SetLabelSize(0.05) hist.GetZaxis().SetTitleSize(0.06) hist.GetZaxis().SetTitleFont(42) f.Close() return hist
def __init__(self, files, tree, label, sample_type='undef', friends=(), line_color=1, fill_color=0, marker_style=None, metadata={}): """Initializes a new instance of the Process class. Args: files: An iterable of ROOT file paths for files representing the process tree: The ROOT TTree path within the files to use label: The ROOT TLatex label string to use when rendering the process line_color: The ROOT TColor number or hex string (#rrggbb) to use as the line color when rendering the process fill_color: The ROOT TColor number or hex string (#rrggbb) to use as the fill color when rendering the process marker_style: The ROOT TMarker number to use as the marker style when rendering the process metadata: A (pickleable) object containing optional metadata """ # Store parameters self._files = tuple(files) self._files_size_time = None self._tree = tree self._label = label self._sample_type = sample_type self._friends = friends self._line_color = line_color self._fill_color = fill_color self._marker_style = marker_style self._metadata = metadata # Translate hex colors if necessary if isinstance(self._line_color, string_types): self._line_color = TColor.GetColor(self._line_color) if isinstance(self._fill_color, string_types): self._fill_color = TColor.GetColor(self._fill_color) # Create initial patches container self._patches = ()
def getHistColor(index): if index == 0: return TColor.GetColor("#000075") if index == 1: return TColor.GetColor("#800000") if index == 2: return TColor.GetColor("#f58231") if index == 3: return TColor.GetColor("#3cb44d") if index == 4: return TColor.GetColor("#ffe119") if index == 5: return TColor.GetColor("#87F1FF") if index == 6: return TColor.GetColor("#F4F1BB")
def rgb(r, g, b): '''rgb(r, g, b): from: http://webhome.phy.duke.edu/~dmb60/the-guide/ TColor* color = gROOT->GetColor(TColor::GetColor(red,green,blue));//Use ints from 0 to 255 color->SetAlpha(0.5);//0 is fully transparent, 1 fully opaque hist->SetFillColor(color->GetNumber()); ''' return TColor.GetColor(r, g, b)
def getStackColor(index): if index == 0: return TColor.GetColor("#4C5760") if index == 1: return TColor.GetColor("#93A8AC") if index == 2: return TColor.GetColor("#D7CEB2") if index == 3: return TColor.GetColor("#F4FDD9") if index == 4: return TColor.GetColor("#AA767C") if index == 5: return TColor.GetColor("#D6A184")
def getLineColor(index): if index == 3: return TColor.GetColor("#000000") if index == 4: return TColor.GetColor("#e6194B") if index == 5: return TColor.GetColor("#4363d8") if index == 0: return TColor.GetColor("#B9BAA3") if index == 1: return TColor.GetColor("#685762") if index == 2: return TColor.GetColor("#E8C547")
def style_histogram(drawable, line_color, fill_color, marker_style, fill_style=1001, marker_size=2, line_size=2): """Applies a style to a drawable object. Args: drawable: The object to style line_color, fill_color, marker_style: The style to apply """ # Translate hex colors if necessary if isinstance(line_color, string_types): line_color = TColor.GetColor(line_color) if isinstance(fill_color, string_types): fill_color = TColor.GetColor(fill_color) # Set line color and width drawable.SetLineColor(line_color) drawable.SetLineWidth(line_size) # Set fill style and color drawable.SetFillStyle(fill_style) drawable.SetFillColor(fill_color) # Set marker style if marker_style is not None: drawable.SetMarkerStyle(marker_style) drawable.SetMarkerSize(marker_size) drawable.SetMarkerColor(line_color) else: # HACK: Set marker style to an invalid value if not specified, # because we need some way to differentiate rendering in the legend drawable.SetMarkerStyle(0)
def style_line(drawable, line_color, line_style, line_size=1): """Applies a style to a drawable with TAttLine capabilities. Args: drawable: The object to style line_color, line_style, line_size: The style to apply """ # Translate hex colors if necessary if isinstance(line_color, string_types): line_color = TColor.GetColor(line_color) # Set line style, color, and width drawable.SetLineColor(line_color) drawable.SetLineStyle(line_style) drawable.SetLineWidth(line_size)
def GetCustomColor(x): # r,g,b in [0,255] omega_r = 2 * 0.12 phi_r = -3.1415 omega_g = 2 * 0.08 phi_g = 1.57 omega_b = 1.5 * 0.16 phi_b = -3.1415 / 2. theta_r = 3.1415 * omega_r * x + phi_r theta_g = 3.1415 * omega_g * x + phi_g theta_b = 3.1415 * omega_b * x + phi_b r = 128 + round(127. * TMath.Cos(theta_r)) g = 128 + round(127. * TMath.Cos(theta_g)) b = 128 + round(127. * TMath.Cos(theta_b)) # printf("r,g,b = (%d,%d,%d)\n",r,g,b); return TColor.GetColor(r, g, b)
def load_palette(self, name, palette_dir=""): if name in self._palettes: print "[SeabornColors::load_palette] ERROR : Palette " + name + " already exists" sys.exit(1) import pickle if palette_dir == "": palette_path = self._default_palette_dir + "/" + name + ".pkl" else: palette_path = palette_dir + "/" + name + ".pkl" print "[SeabornColors::load_palette] Loading palette from " + palette_path self._palettes[name] = pickle.load(open(palette_path, 'r')) self._root_palettes[name] = [] for rgb_triplet in self._palettes[name]: root_index = TColor.GetColor(rgb_triplet[0], rgb_triplet[1], rgb_triplet[2]) self._root_palettes[name].append(root_index)
def DrawHist(hist, xlabel, ylabel, legendNames, destination, year, ylog=False): GeneralSettings() #Create Canvas Canv = TCanvas("Canv" + destination, "Canv" + destination, 1000, 1000) tdr.setTDRStyle() #Set Histogram Styles for h in hist: h.SetLineColor(TColor.GetColor(GetHistColor(hist.index(h)))) title = " ;" + xlabel + " ; " + ylabel + " / " + str( hist[0].GetBinWidth(1)) + " GeV" hist[0].SetTitle(title) OverallMax = GetOverallMaximum(hist) OverallMin = GetOverallMinimum(hist) if ylog: Canv.SetLogy() hist[0].GetYaxis().SetRangeUser(0.3 * OverallMin, 30 * OverallMax) else: hist[0].GetYaxis().SetRangeUser(0.7 * OverallMin, 1.3 * OverallMax) #Start Drawing for h in hist: if (hist.index(h) == 0): h.Draw("HIST") else: h.Draw("HISTSAME") #Create Legend if legendNames: legend = TLegend(0.7, .7, .9, .9) for h, n in zip(hist, legendNames): legend.AddEntry(h, n) legend.SetFillStyle(0) legend.SetBorderSize(0) legend.Draw() #CMS lumi cl.CMS_lumi(Canv, 4, 11, year, 'Simulation', False) #Save everything savePlots(Canv, destination)
def compare(objs, add_leg_title=True, normalize=True): print("Comparing") cols = ['#e41a1c', '#377eb8', '#4daf4a'] colors = {} drawn = {} for i in objs: print("Entry", len(colors), i) colors[i] = TColor.GetColor(cols[len(colors)]) # Drawing objects for i in objs: for j in objs[i]: obj = objs[i][j] opt = "" if drawn.setdefault(j, None) is None: drawn[j] = [TCanvas(j, j)] else: opt += "same" drawn[j][0].cd() print("Drawing", obj, "with opt", opt, "on canvas", gPad.GetName()) obj.SetLineColor(colors[i]) obj.SetBit(TH1.kNoTitle) obj.SetBit(TH1.kNoStats) obj.SetTitle(i) if normalize: drawn[j].append(obj.DrawNormalized(opt)) else: drawn[j].append(obj.DrawClone(opt)) for i in drawn: d = drawn[i] can = d[0] can.cd() gPad.SetLogy() leg = TLegend(.1, .9, .9, .99, can.GetName()) leg.SetNColumns(2) d.append(leg) for j in can.GetListOfPrimitives(): leg.AddEntry(j) leg.Draw() return drawn
def MakeGradient(nsteps, start, end): from ROOT import TColor r1, g1, b1 = start r2, g2, b2 = end # print start, "to", end gradient = [] rstep = float(r2 - r1) / float(nsteps - 1) gstep = float(g2 - g1) / float(nsteps - 1) bstep = float(b2 - b1) / float(nsteps - 1) # print "steps", rstep, gstep, bstep for i in range(nsteps): r = r1 + rstep * i g = g1 + gstep * i b = b1 + bstep * i color = TColor.GetColor(r, g, b) # print "(%.2f, %.2f, %.2f) = %i" %(r,g,b, color) gradient.append(color) return gradient
def calcAndDrawSignificance(SignalHist, BkgrHist, xtitle, legendNames, DataName, destination, year, ylog=False, customLabels=None, extraText=None, scaleSignalToBkgr=False, DivideByLine=None): GeneralSettings() #Make sure the code works for single backgrounds if not isinstance(BkgrHist, (list, )): BkgrHist = [BkgrHist] if not isinstance(SignalHist, (list, )): SignalHist = [SignalHist] BkgrHist, legendNames = orderHist(BkgrHist, legendNames, True) #Add all backgrounds totBkgr = BkgrHist[0].Clone("TotBkgr") for h in BkgrHist[1:]: totBkgr.Add(h) #Normalize signal to background if needed if scaleSignalToBkgr: for h in SignalHist: h.scale(totBkgr.GetSumOfWeights() / h.GetSumOfWeights) #Define a canvas Canv = TCanvas("Canv" + destination, "Canv" + destination, 1500, 1000) #Set Histogram Styles for h, n in zip(BkgrHist, legendNames): h.SetFillColor(TColor.GetColor(GetStackColorTauPOGbyName(n))) h.SetLineColor(TColor.GetColor(GetStackColorTauPOGbyName(n))) for i, h in enumerate(SignalHist): h.SetMarkerColor(TColor.GetColor(GetLineColor(i))) h.SetLineColor(TColor.GetColor(GetLineColor(i))) h.SetMarkerStyle(GetMarker(i)) list_of_significance_hists = [] for i, sh in enumerate(SignalHist): #Calculate significance total = totBkgr.Clone("Total") total.Add(sh) sqrt_total = total.Clone('Sqrt_Total') for xbin in xrange( 1, total.GetSize() - 1 ): #GetSize returns nbins + 2 (for overflow and underflow bin) sqrt_x = np.sqrt(total.GetBinContent(xbin)) sqrt_total.SetBinContent(xbin, sqrt_x) sqrt_total.SetBinError(xbin, 0.5 * total.GetBinError(xbin) / sqrt_x) significance = sh.Clone('Signal' + str(i)) significance.Divide(sqrt_total) list_of_significance_hists.append(significance) #First pad plotpad = TPad("plotpad", "plotpad", 0, .3, 1, 0.98) plotpad.SetBottomMargin(0.025) plotpad.Draw() plotpad.cd() #Create Stack (Change with most logical ordering) hs = THStack("hs", "hs") for h in BkgrHist: hs.Add(h) hs.Draw( "EHist" ) #Draw before using GetHistogram, see https://root-forum.cern.ch/t/thstack-gethistogram-null-pointer-error/12892/4 title = " ; ; Events" hs.SetTitle(title) # hs.GetHistogram().GetXaxis().SetTickLength(0) hs.GetHistogram().GetXaxis().SetLabelOffset(9999999) #hs.GetHistogram().SetMaximum(1) #Set range overallMin = GetOverallMinimum(BkgrHist + SignalHist, True) overallMax = GetOverallMaximum([totBkgr] + SignalHist) if ylog: if overallMin == 0.: overallMin = 0.1 ymin = 0.3 * overallMin ymax = 30 * overallMax plotpad.SetLogy() else: ymin = 0.7 * overallMin ymax = 1.3 * overallMax hs.SetMinimum(ymin) hs.SetMaximum(ymax) for h in SignalHist: h.Draw("EPSame") #Create Legend legend = TLegend(0.7, .7, .9, .9) for h, n in zip(BkgrHist, legendNames): legend.AddEntry(h, n) for h, n in zip(SignalHist, DataName): legend.AddEntry(h, n) legend.SetFillStyle(0) legend.SetBorderSize(0) legend.Draw() #Draw lines if needed if DivideByLine is not None: tdrStyle_Left_Margin = 0.16 tdrStyle_Right_Margin = 0.02 plot_size_hor = 1 - tdrStyle_Left_Margin - tdrStyle_Right_Margin #Option one, user provides the number of divisions and we divide equally if isinstance(DivideByLine[0], int): x_pos = np.linspace(totBkgr.GetXaxis().GetXmin(), totBkgr.GetXaxis().GetXmax(), DivideByLine[0] + 1) #Option two, user provides the specific boundaries if isinstance(DivideByLine[0], (list, )): x_pos = DivideByLine[0] #Draw the lines lines = [] for i, x in enumerate(x_pos[1:-1]): lines.append(TLine(x, ymin, x, ymax)) lines[i].SetLineColor(ROOT.kRed) lines[i].SetLineStyle(10) for line in lines: line.Draw('same') #Add extra text for i, name in enumerate(DivideByLine[1]): x = ((x_pos[i + 1] + x_pos[i]) / (2 * (x_pos[-1] - x_pos[0]) / plot_size_hor)) + tdrStyle_Left_Margin extraText.append(extraTextFormat(name, x, 0.1, None, 22)) #Draw extra text if needed if extraText is not None: DrawExtraText(plotpad, extraText) #Return to canvas Canv.cd() #Second pad ratiopad = TPad("ratiopad", "ratiopad", 0, 0.05, 1, .3) ratiopad.SetTopMargin(0.05) ratiopad.SetBottomMargin(0.25) ratiopad.Draw() ratiopad.cd() #print list_of_significance_hists[0].GetMaximum(), list_of_significance_hists[1].GetMaximum(), list_of_significance_hists[2].GetMaximum() overallMin = GetOverallMinimum(list_of_significance_hists) overallMax = GetOverallMaximum(list_of_significance_hists) significance = list_of_significance_hists[0] #Prepare lines before changing maximum lines_bottom = [] for i, sig in enumerate(list_of_significance_hists): lines_bottom.append( TLine(sig.GetXaxis().GetXmin(), sig.GetMaximum(), sig.GetXaxis().GetXmax(), sig.GetMaximum())) lines_bottom[i].SetLineColor(TColor.GetColor(GetLineColor(i))) lines_bottom[i].SetLineStyle(3) #Set Style for bottom plot significance.SetTitle(";" + xtitle + "; S/#sqrt{S+B}") significance.GetXaxis().SetTitleSize(.12) significance.GetYaxis().SetTitleSize(.12) significance.GetYaxis().SetTitleOffset(.6) significance.GetXaxis().SetLabelSize(.12) significance.GetYaxis().SetLabelSize(.12) significance.SetMinimum(0.) significance.SetMaximum(1.3 * overallMax) significance.Draw("EP") for sig in list_of_significance_hists[1:]: sig.Draw('EPSame') for line in lines_bottom: line.Draw("same") #Set custom x labels xaxis = significance.GetXaxis() if customLabels != None: number_of_bins = significance.GetNbinsX() if number_of_bins != len(customLabels): if DivideByLine is not None: for i in range(number_of_bins): xaxis.SetBinLabel( i + 1, customLabels[i % len(customLabels)] ) #Only works when DivideByLine[0] is an integer else: print 'Please provide ' + str( number_of_bins) + ' labels instead of ' + str( len(customLabels)) return else: for i, label in zip(range(number_of_bins), customLabels): xaxis.SetBinLabel(i + 1, label) #Throw CMs lumi at it cl.CMS_lumi(Canv, 4, 11, year, 'Simulation Preliminary', True) #Save everything savePlots(Canv, destination) ROOT.SetOwnership( Canv, False ) #https://root-forum.cern.ch/t/tlatex-crashing-in-pyroot-after-many-uses/21638/4 return
def plotROCfromgraph(graphs, xlabel, ylabel, legendNames, destination, year, xlog=False, ylog=False, additionalInformation=None): GeneralSettings() #Make sure single curves also pass try: len(graphs) except: graphs = [graphs] #Create Canvas Canv = TCanvas("Canv" + destination, "Canv" + destination, 1000, 1000) tdr.setTDRStyle() #Create TGraph mgraph = TMultiGraph() for i, graph in enumerate(graphs): graph.SetMarkerSize(1.5) graph.SetLineColor(TColor.GetColor(GetLineColor(graphs.index(graph)))) graph.SetMarkerColor(TColor.GetColor(GetLineColor( graphs.index(graph)))) graph.SetMarkerStyle(GetMarker(graphs.index(graph))) mgraph.Add(graph) mgraph.Draw("APLine") mgraph.SetTitle(";" + xlabel + ";" + ylabel) cl.CMS_lumi(Canv, 4, 11, year, 'Simulation', False) xmax = GetXMax(graphs) xmin = GetXMin(graphs) ymax = GetYMax(graphs) ymin = GetYMin(graphs) if xlog: Canv.SetLogx() mgraph.GetXaxis().SetRangeUser(0.3 * xmin, 30 * xmax) else: mgraph.GetXaxis().SetRangeUser(0.7 * xmin, 1.3 * xmax) if ylog: Canv.SetLogy() mgraph.GetYaxis().SetRangeUser(0.3 * ymin, 10 * ymax) else: mgraph.GetYaxis().SetRangeUser(0.5 * ymin, 1.2 * ymax) #Write extra text if additionalInformation is not None: lastYpos = 0.8 lastCorrectedYpos = None extraText = TLatex() for info in additionalInformation: try: extraTextString = info[0] extraTextXpos = info[1] extraTextYpos = info[2] extraTextSize = info[3] except: print("Wrong Format for additionalInformation. Stopping") pass if extraTextSize is None: extraTextSize = 0.03 if extraTextXpos is None: extraTextXpos = 0.2 if extraTextYpos is None: if lastYpos is None: extraTextYpos = lastCorrectedYpos - 0.05 else: extraTextYpos = 0.8 extraText.SetNDC() extraText.SetTextAlign(12) extraText.SetTextSize(extraTextSize) extraText.DrawLatex(extraTextXpos, extraTextYpos, extraTextString) lastYpos = info[2] lastCorrectedYpos = extraTextYpos if legendNames: legend = TLegend(0.7, .7, .9, .9) for g, n in zip(graphs, legendNames): legend.AddEntry(g, n) legend.SetFillStyle(0) legend.SetBorderSize(0) legend.Draw() #Save everything savePlots(Canv, destination)
def plotROC(xdata, ydata, xlabel, ylabel, legendNames, destination, year, xerror=None, yerror=None, xlog=False, ylog=False, additionalInformation=None): GeneralSettings() #Make sure single curves also pass try: len(xdata[0]) except: xdata = [xdata] ydata = [ydata] legendNames = [legendNames] xerror = [xerror] yerror = [yerror] #Create Canvas Canv = TCanvas("Canv" + destination, "Canv" + destination, 1000, 1000) tdr.setTDRStyle() #Create TGraph graphs = [] for x, y, xe, ye in zip(xdata, ydata, xerror, yerror): tmpgraph = None if xe is None and ye is None: tmpgraph = TGraph(len(x), x, y) elif xe is None or ye is None: NullErrors = np.zeros(len(x)) if xe is not None: tmpgraph = TGraphErrors(len(x), x, y, xe, NullErrors) if ye is not None: tmpgraph = TGraphErrors(len(x), x, y, NullErrors, ye) else: tmpgraph = TGraphErrors(len(x), x, y, xe, ye) graphs.append(tmpgraph) mgraph = TMultiGraph() for i, graph in enumerate(graphs): graph.SetMarkerSize(1.5) graph.SetLineColor(TColor.GetColor(GetLineColor(graphs.index(graph)))) graph.SetMarkerColor(TColor.GetColor(GetLineColor( graphs.index(graph)))) graph.SetMarkerStyle(GetMarker(graphs.index(graph))) mgraph.Add(graph) mgraph.Draw("APLine") mgraph.SetTitle(";" + xlabel + ";" + ylabel) cl.CMS_lumi(Canv, 4, 11, 'Simulation', False) if xlog: Canv.SetLogx() mgraph.GetXaxis().SetRangeUser(0.3 * GetNestedMin(xdata), 30 * GetNestedMax(xdata)) else: mgraph.GetXaxis().SetRangeUser(0.7 * GetNestedMin(xdata[0]), 1.3 * GetNestedMax(xdata)) if ylog: Canv.SetLogy() mgraph.GetYaxis().SetRangeUser(0.3 * GetNestedMin(ydata), 10 * GetNestedMax(ydata)) else: mgraph.GetYaxis().SetRangeUser(0.5 * GetNestedMin(ydata), 1.2 * GetNestedMax(ydata)) #Write extra text if additionalInformation is not None: lastYpos = 0.8 lastCorrectedYpos = None extraText = TLatex() for info in additionalInformation: try: extraTextString = info[0] extraTextXpos = info[1] extraTextYpos = info[2] extraTextSize = info[3] except: print("Wrong Format for additionalInformation. Stopping") pass if extraTextSize is None: extraTextSize = 0.03 if extraTextXpos is None: extraTextXpos = 0.2 if extraTextYpos is None: if lastYpos is None: extraTextYpos = lastCorrectedYpos - 0.05 else: extraTextYpos = 0.8 extraText.SetNDC() extraText.SetTextAlign(12) extraText.SetTextSize(extraTextSize) extraText.DrawLatex(extraTextXpos, extraTextYpos, extraTextString) lastYpos = info[2] lastCorrectedYpos = extraTextYpos if legendNames: legend = TLegend(0.7, .7, .9, .9) for g, n in zip(graphs, legendNames): legend.AddEntry(g, n) legend.SetFillStyle(0) legend.SetBorderSize(0) legend.Draw() #Save everything savePlots(Canv, destination)
def plotClosure(observed, predicted, xtitle, ytitle, DataName, additionalInfo, destination, year, yLog=False): GeneralSettings() Canv = TCanvas("Canv" + destination, "Canv" + destination, 1000, 1000) observed.SetMarkerColor(ROOT.kBlack) observed.SetLineColor(ROOT.kBlack) observed.SetMarkerStyle(20) predicted.SetFillColor(TColor.GetColor('#3399ff')) predicted.SetLineColor(TColor.GetColor('#3399ff')) #First pad plotpad = TPad("plotpad", "plotpad", 0, .3, 1, 0.98) plotpad.SetBottomMargin(0.025) plotpad.Draw() plotpad.cd() predicted.Draw( "Hist" ) #Draw before using GetHistogram, see https://root-forum.cern.ch/t/thstack-gethistogram-null-pointer-error/12892/4 title = " ; ; " + ytitle + " / " + str( predicted.GetBinWidth(1)) + ' ' + getUnit(xtitle) predicted.SetTitle(title) predicted.GetXaxis().SetLabelOffset(9999999) predStatError = predicted.Clone("PredictedStatError") predSystError = predicted.Clone("PredictedSystError") predTotError = predicted.Clone("PredictedTotalError") for b in xrange(predSystError.GetNbinsX() + 1): predSystError.SetBinError(b, 0.3 * predicted.GetBinContent(b)) syst = predSystError.GetBinError(b) stat = predStatError.GetBinError(b) # print syst, stat, np.sqrt(stat*stat+syst*syst) predTotError.SetBinError(b, np.sqrt(stat * stat + syst * syst)) predTotError.SetFillStyle(3013) predTotError.SetFillColor(ROOT.kGray + 2) predTotError.SetMarkerStyle(0) predTotError.Draw("E2 Same") #Set range overallMin = GetOverallMinimum([observed, predicted], yLog) overallMax = GetOverallMaximum([observed, predicted]) if yLog: plotpad.SetLogy() predicted.SetMinimum(0.3 * overallMin) predicted.SetMaximum(10 * overallMax) else: predicted.SetMinimum(0.5 * overallMin) predicted.SetMaximum(1.7 * overallMax) observed.Draw("EPSame") #Create Legend legend = TLegend(0.7, .7, .9, .9) legend.AddEntry(observed, DataName + ' (observed)') legend.AddEntry(predicted, DataName + ' (predicted)') legend.SetFillStyle(0) legend.SetBorderSize(0) legend.Draw() #Draw extra text DrawExtraText(plotpad, additionalInfo) #Return to canvas Canv.cd() #Second pad ratiopad = TPad("ratiopad", "ratiopad", 0, 0.05, 1, .3) ratiopad.SetTopMargin(0.05) ratiopad.SetBottomMargin(0.25) ratiopad.Draw() ratiopad.cd() ratio = observed.Clone('ratio') ratio.Divide(predicted) StatErrorRatio = predStatError.Clone("StatErrorRatio") StatErrorRatio.SetFillStyle(1001) StatErrorRatio.SetFillColor(TColor.GetColor('#6EF9F5')) TotErrorRatio = predTotError.Clone("SystErrorRatio") TotErrorRatio.SetFillColor(TColor.GetColor('#63E2C6')) TotErrorRatio.SetFillStyle(1001) for b in xrange(StatErrorRatio.GetNbinsX() + 1): if (StatErrorRatio.GetBinContent(b) != 0): StatErrorRatio.SetBinError( b, StatErrorRatio.GetBinError(b) / StatErrorRatio.GetBinContent(b)) TotErrorRatio.SetBinError( b, TotErrorRatio.GetBinError(b) / TotErrorRatio.GetBinContent(b)) StatErrorRatio.SetBinContent(b, 1.) TotErrorRatio.SetBinContent(b, 1.) else: StatErrorRatio.SetBinContent(b, 0) TotErrorRatio.SetBinContent(b, 0) #Set Style for bottom plot ratio.SetTitle(";" + xtitle + "; Obs./pred.") ratio.GetXaxis().SetTitleSize(.12) ratio.GetYaxis().SetTitleSize(.12) ratio.GetYaxis().SetTitleOffset(.6) ratio.GetXaxis().SetLabelSize(.12) ratio.GetYaxis().SetLabelSize(.12) ratio.SetMinimum(0.3) ratio.SetMaximum(1.7) ratio.Draw("EP") TotErrorRatio.Draw("E2 same") StatErrorRatio.Draw("E2 same") ratio.Draw("EPsame") #Create Legend legend_bottom = TLegend(0.2, .8, .9, .9) legend_bottom.SetNColumns(3) legend_bottom.AddEntry(ratio, "Obs./Pred.") legend_bottom.AddEntry(StatErrorRatio, "Stat. Unc.") legend_bottom.AddEntry(TotErrorRatio, "Tot. Unc.") legend_bottom.SetFillStyle(0) legend_bottom.SetBorderSize(0) legend_bottom.Draw() #Draw a guide for the eye line = TLine(ratio.GetXaxis().GetXmin(), 1, ratio.GetXaxis().GetXmax(), 1) line.SetLineColor(ROOT.kRed) line.SetLineWidth(1) line.SetLineStyle(1) line.Draw("Same") #Throw CMs lumi at it cl.CMS_lumi(Canv, 4, 11, year, 'Preliminary', True) #Save everything savePlots(Canv, destination)
def plotDataVSMC(DataHist, MCHist, xtitle, legendNames, DataName, destination, year, ytitle_bottom='Data/MC', ylog=False): GeneralSettings() Canv = TCanvas("Canv" + destination, "Canv" + destination, 1000, 1000) #Set Histogram Styles for i, h in enumerate(MCHist): h.SetFillColor( TColor.GetColor(GetStackColorTauPOGbyName(legendNames[i]))) h.SetLineColor( TColor.GetColor(GetStackColorTauPOGbyName(legendNames[i]))) DataHist.SetMarkerColor(ROOT.kBlack) DataHist.SetLineColor(ROOT.kBlack) DataHist.SetMarkerStyle(20) #Add all MC samples to use in ratios totBkgr = MCHist[0].Clone("totBkgr") for h in MCHist[1:]: totBkgr.Add(h) DataOverMC = DataHist.Clone("DataOverMC") DataOverMC.Divide(totBkgr) #Errors predStatError = totBkgr.Clone("PredictedStatError") predSystError = totBkgr.Clone("PredictedSystError") predTotError = totBkgr.Clone("PredictedTotalError") for b in xrange(predSystError.GetNbinsX() + 1): predSystError.SetBinError(b, 0.3 * totBkgr.GetBinContent(b)) syst = predSystError.GetBinError(b) stat = predStatError.GetBinError(b) predTotError.SetBinError(b, np.sqrt(stat * stat + syst * syst)) #predTotError.SetFillStyle(3013) #predTotError.SetFillColor(ROOT.kGray+2) #predTotError.SetMarkerStyle(0) #predTotError.Draw("E2 Same") #First pad plotpad = TPad("plotpad", "plotpad", 0, .3, 1, 0.98) plotpad.SetBottomMargin(0.025) plotpad.Draw() plotpad.cd() #Create Stack (Change with most logical ordering) hs = THStack("hs", "hs") for h in MCHist: hs.Add(h) hs.Draw( "EHist" ) #Draw before using GetHistogram, see https://root-forum.cern.ch/t/thstack-gethistogram-null-pointer-error/12892/4 title = " ; ; Events / " + str(MCHist[0].GetBinWidth(1)) + " GeV" hs.SetTitle(title) # hs.GetHistogram().GetXaxis().SetTickLength(0) hs.GetHistogram().GetXaxis().SetLabelOffset(9999999) hs.GetHistogram().SetMaximum(1) #Set range overallMin = GetOverallMinimum(MCHist + [DataHist]) overallMax = GetOverallMaximum([totBkgr] + [DataHist]) if ylog: plotpad.SetLogy() hs.SetMinimum(0.3 * overallMin) hs.SetMaximum(10 * overallMax) else: hs.SetMinimum(0.5 * overallMin) hs.SetMaximum(1.7 * overallMax) DataHist.Draw("EPSame") predTotError.SetFillStyle(3013) predTotError.SetFillColor(ROOT.kGray + 2) predTotError.SetMarkerStyle(0) predTotError.Draw("E2 Same") #Create Legend legend = TLegend(0.7, .7, .9, .9) for h, n in zip(MCHist, legendNames): legend.AddEntry(h, n) legend.AddEntry(DataHist, DataName) legend.SetFillStyle(0) legend.SetBorderSize(0) legend.Draw() #Return to canvas Canv.cd() #Second pad ratiopad = TPad("ratiopad", "ratiopad", 0, 0.05, 1, .3) ratiopad.SetTopMargin(0.05) ratiopad.SetBottomMargin(0.25) ratiopad.Draw() ratiopad.cd() #Errors StatErrorRatio = predStatError.Clone("StatErrorRatio") StatErrorRatio.SetFillStyle(1001) StatErrorRatio.SetFillColor(TColor.GetColor('#6EF9F5')) TotErrorRatio = predTotError.Clone("SystErrorRatio") TotErrorRatio.SetFillColor(TColor.GetColor('#63E2C6')) TotErrorRatio.SetFillStyle(1001) for b in xrange(StatErrorRatio.GetNbinsX() + 1): if (StatErrorRatio.GetBinContent(b) != 0): StatErrorRatio.SetBinError( b, StatErrorRatio.GetBinError(b) / StatErrorRatio.GetBinContent(b)) TotErrorRatio.SetBinError( b, TotErrorRatio.GetBinError(b) / TotErrorRatio.GetBinContent(b)) StatErrorRatio.SetBinContent(b, 1.) TotErrorRatio.SetBinContent(b, 1.) else: StatErrorRatio.SetBinContent(b, 0) TotErrorRatio.SetBinContent(b, 0) #Set Style for bottom plot DataOverMC.SetTitle(";" + xtitle + "; " + ytitle_bottom) DataOverMC.GetXaxis().SetTitleSize(.12) DataOverMC.GetYaxis().SetTitleSize(.12) DataOverMC.GetYaxis().SetTitleOffset(.6) DataOverMC.GetXaxis().SetLabelSize(.12) DataOverMC.GetYaxis().SetLabelSize(.12) DataOverMC.SetMinimum(0.3) DataOverMC.SetMaximum(1.7) DataOverMC.Draw("EP") TotErrorRatio.Draw("E2 same") StatErrorRatio.Draw("E2 same") DataOverMC.Draw("EPsame") #Draw a guide for the eye line = TLine(DataOverMC.GetXaxis().GetXmin(), 1, DataOverMC.GetXaxis().GetXmax(), 1) line.SetLineColor(ROOT.kRed) line.SetLineWidth(1) line.SetLineStyle(1) line.Draw("Same") #Create Legend legend_bottom = TLegend(0.2, .8, .9, .9) legend_bottom.SetNColumns(3) legend_bottom.AddEntry(DataOverMC, "Obs./Pred.") legend_bottom.AddEntry(StatErrorRatio, "Stat. Unc.") legend_bottom.AddEntry(TotErrorRatio, "Tot. Unc.") legend_bottom.SetFillStyle(0) legend_bottom.SetBorderSize(0) legend_bottom.Draw() #Throw CMs lumi at it cl.CMS_lumi(Canv, 4, 11, year, 'Preliminary', True) print 'save' #Save everything savePlots(Canv, destination) print 'saved'
frame.GetXaxis().SetRangeUser(0.75, 2.55) xmin, xmax = frame.GetXaxis().GetXmin(), frame.GetXaxis().GetXmax() tline.DrawLine(xmin, 1.0, xmax, 1.0) h1a_eff.Draw("same") h1b_eff.Draw("same") draw_cms_lumi() gPad.Print("figures_perf/" + hname + "_omtf" + ".png") gPad.Print("figures_perf/" + hname + "_omtf" + ".pdf") donotdelete.append([frame, h1a_eff, h1b_eff]) # ____________________________________________________________________________ # emtf_eff_vs_genpt_l1pt99 palette = ("#333333", "#377eb8", "#e41a1c", "#984ea3", "#ff7f00", "#4daf4a") palette = map(lambda x: TColor.GetColor(x), palette) hname = "emtf_eff_vs_genpt_l1pt%i" i = 0 effs = [] for l in (0, 10, 20, 30, 40, 50): denom = tfile.Get((hname % (l)) + "_denom") numer = tfile.Get((hname % (l)) + "_numer") eff = TEfficiency(numer, denom) eff.SetStatisticOption(0) # kFCP eff.SetConfidenceLevel(0.682689492137) # one sigma eff.SetMarkerColor(palette[i]) # kRed eff.SetLineColor(palette[i]) # kRed eff.SetLineWidth(2) effs.append(eff)
def configure_samples(): # ------------------------------------- # # Custom colours (in hexadecimal RGB) # Taken from http://colorbrewer2.org/ # # ------------------------------------- # Blues myLighterBlue = TColor.GetColor('#deebf7') myLightBlue = TColor.GetColor('#9ecae1') myMediumBlue = TColor.GetColor('#0868ac') myDarkBlue = TColor.GetColor('#08306b') # Greens myLighterGreen = TColor.GetColor('#e5f5e0') myLightGreen = TColor.GetColor('#a1d99b') myMediumGreen = TColor.GetColor('#41ab5d') myDarkGreen = TColor.GetColor('#006d2c') # Oranges myLighterOrange = TColor.GetColor('#ffeda0') myLightOrange = TColor.GetColor('#fec49f') myMediumOrange = TColor.GetColor('#fe9929') myDarkOrange = TColor.GetColor('#ec7014') myDarkerOrange = TColor.GetColor('#cc4c02') # Greys myLightestGrey = TColor.GetColor('#f0f0f0') myLighterGrey = TColor.GetColor('#e3e3e3') myLightGrey = TColor.GetColor('#969696') # Pinks myLightPink = TColor.GetColor('#fde0dd') myMediumPink = TColor.GetColor('#fcc5c0') myDarkPink = TColor.GetColor('#dd3497') # Purples myLightPurple = TColor.GetColor('#dadaeb') myMediumPurple = TColor.GetColor('#9e9ac8') myDarkPurple = TColor.GetColor('#6a51a3') # ------------------------------------- # # Samples dictionary # # 'TTree name for sample' : # { 'type' : set as data, background or signal # 'leg' : label that appears in the plot legend # 'f_color' : fill colour of background sample # 'l_color' : line colour of signal sample # } # # ------------------------------------- d_samp = { #------------------------------------ # Loose analysis #------------------------------------ 'loose_noGenFilt_signal_hh_loop_sm_trackJetBTag': { 'type': 'sig', 'leg': 'HH', 'l_color': kRed + 3 }, 'loose_noGenFilt_zz': { 'type': 'bkg', 'leg': 'ZZ', 'f_color': myMediumOrange }, 'loose_noGenFilt_zh': { 'type': 'bkg', 'leg': 'Zh', 'f_color': myLightOrange }, 'loose_noGenFilt_wh': { 'type': 'bkg', 'leg': 'Wh', 'f_color': myLighterOrange }, 'loose_noGenFilt_ttbar': { 'type': 'bkg', 'leg': 't#bar{t}', 'f_color': myDarkPurple }, 'loose_noGenFilt_ttbb': { 'type': 'bkg', 'leg': 't#bar{t}+b#bar{b}', 'f_color': myMediumPurple }, 'loose_noGenFilt_tth': { 'type': 'bkg', 'leg': 't#bar{t}h', 'f_color': myLightPurple }, 'loose_noGenFilt_bbh': { 'type': 'bkg', 'leg': 'b#bar{b}h', 'f_color': myLightPink }, 'loose_ptj1_20_to_200_2b2j': { 'type': 'bkg', 'leg': '2b2j 20-200', 'f_color': myDarkGreen }, 'loose_ptj1_200_to_500_2b2j': { 'type': 'bkg', 'leg': '2b2j 200-500', 'f_color': myMediumGreen }, 'loose_ptj1_500_to_1000_2b2j': { 'type': 'bkg', 'leg': '2b2j 500-1000', 'f_color': myLightGreen }, 'loose_ptj1_1000_to_infty_2b2j': { 'type': 'bkg', 'leg': '2b2j 1000-#infty', 'f_color': myLighterGreen }, 'loose_ptj1_20_to_200_4b': { 'type': 'bkg', 'leg': '4b 20-200', 'f_color': myDarkBlue }, 'loose_ptj1_200_to_500_4b': { 'type': 'bkg', 'leg': '4b 200-500', 'f_color': myMediumBlue }, 'loose_ptj1_500_to_1000_4b': { 'type': 'bkg', 'leg': '4b 500-1000', 'f_color': myLightBlue }, 'loose_ptj1_1000_to_infty_4b': { 'type': 'bkg', 'leg': '4b 1000-#infty', 'f_color': myLighterBlue }, # Colour merging of samples 'loose_noGenFilt_ttbar': { 'type': 'bkg', 'leg': 't#bar{t}+t#bar{t}b#bar{b}', 'f_color': myMediumGreen }, 'loose_noGenFilt_ttbb': { 'type': 'bkg', 'leg': 't#bar{t}+b#bar{b}', 'f_color': myMediumGreen }, 'loose_noGenFilt_tth': { 'type': 'bkg', 'leg': 't#bar{t}h+b#bar{b}h', 'f_color': myMediumOrange }, 'loose_noGenFilt_bbh': { 'type': 'bkg', 'leg': 'b#bar{b}h', 'f_color': myMediumOrange }, 'loose_noGenFilt_zz': { 'type': 'bkg', 'leg': 'ZZ', 'f_color': myLightOrange }, 'loose_noGenFilt_zh': { 'type': 'bkg', 'leg': 'Zh+Wh', 'f_color': myLighterOrange }, 'loose_noGenFilt_wh': { 'type': 'bkg', 'leg': 'Wh', 'f_color': myLighterOrange }, 'loose_ptj1_20_to_200_2b2j': { 'type': 'bkg', 'leg': '2b2j', 'f_color': myLightBlue }, 'loose_ptj1_200_to_500_2b2j': { 'type': 'bkg', 'leg': '2b2j 200-500', 'f_color': myLightBlue }, 'loose_ptj1_500_to_1000_2b2j': { 'type': 'bkg', 'leg': '2b2j 500-1000', 'f_color': myLightBlue }, 'loose_ptj1_1000_to_infty_2b2j': { 'type': 'bkg', 'leg': '2b2j 1000-#infty', 'f_color': myLightBlue }, 'loose_ptj1_20_to_200_4b': { 'type': 'bkg', 'leg': '4b', 'f_color': myMediumBlue }, 'loose_ptj1_200_to_500_4b': { 'type': 'bkg', 'leg': '4b 200-500', 'f_color': myMediumBlue }, 'loose_ptj1_500_to_1000_4b': { 'type': 'bkg', 'leg': '4b 500-1000', 'f_color': myMediumBlue }, 'loose_ptj1_1000_to_infty_4b': { 'type': 'bkg', 'leg': '4b 1000-#infty', 'f_color': myMediumBlue }, 'loose_noGenFilt_signal_hh_TopYuk_1.0_SlfCoup_0.5': { 'type': 'sig', 'leg': 'HH kl = 0', 'l_color': kBlue }, 'loose_noGenFilt_signal_hh_TopYuk_1.0_SlfCoup_1.0': { 'type': 'sig', 'leg': '#kappa_{#lambda} = 1', 'l_color': kRed + 2 }, 'loose_noGenFilt_signal_hh_TopYuk_1.0_SlfCoup_2.0': { 'type': 'sig', 'leg': '#kappa_{#lambda} = 2', 'l_color': kAzure + 1 }, 'loose_noGenFilt_signal_hh_TopYuk_1.0_SlfCoup_3.0': { 'type': 'sig', 'leg': '#kappa_{#lambda} = 3', 'l_color': myLightBlue }, 'loose_noGenFilt_signal_hh_TopYuk_1.0_SlfCoup_5.0': { 'type': 'sig', 'leg': '#kappa_{#lambda} = 5', 'l_color': kBlue + 2 }, 'loose_noGenFilt_signal_hh_TopYuk_1.0_SlfCoup_7.0': { 'type': 'sig', 'leg': '#kappa_{#lambda} = 7', 'l_color': myLightPink }, 'loose_noGenFilt_signal_hh_TopYuk_1.0_SlfCoup_10.0': { 'type': 'sig', 'leg': '#kappa_{#lambda} = 10', 'l_color': myLightPink }, 'loose_noGenFilt_signal_hh_TopYuk_1.0_SlfCoup_m1.0': { 'type': 'sig', 'leg': '#kappa_{#lambda} = #minus1', 'l_color': myMediumBlue }, 'loose_noGenFilt_signal_hh_TopYuk_1.0_SlfCoup_m2.0': { 'type': 'sig', 'leg': '#kappa_{#lambda} = #minus2', 'l_color': myMediumGreen }, 'loose_noGenFilt_signal_hh_TopYuk_1.0_SlfCoup_m3.0': { 'type': 'sig', 'leg': '#kappa_{#lambda} = #minus3', 'l_color': myMediumOrange }, 'loose_noGenFilt_signal_hh_TopYuk_1.0_SlfCoup_m5.0': { 'type': 'sig', 'leg': '#kappa_{#lambda} = #minus5', 'l_color': kGreen }, 'loose_noGenFilt_signal_hh_TopYuk_1.0_SlfCoup_m7.0': { 'type': 'sig', 'leg': '#kappa_{#lambda} = #minus7', 'l_color': myMediumPurple }, 'loose_noGenFilt_signal_hh_TopYuk_1.0_SlfCoup_m10.0': { 'type': 'sig', 'leg': '#kappa_{#lambda} = #minus10', 'l_color': myDarkBlue }, 'loose_noGenFilt_signal_hh_TopYuk_0.8_SlfCoup_1.0': { 'type': 'sig', 'leg': 'HH kt = 0.8', 'l_color': kBlue }, 'loose_noGenFilt_signal_hh_TopYuk_1.1_SlfCoup_1.0': { 'type': 'sig', 'leg': 'HH kt = 1.1', 'l_color': kRed }, 'loose_noGenFilt_signal_hh_TopYuk_1.2_SlfCoup_1.0': { 'type': 'sig', 'leg': 'HH kt = 1.2', 'l_color': myLightGreen }, } return d_samp
def configure_samples(): # Blues #myLighterBlue=TColor.GetColor('#deebf7') myLighterBlue = kAzure - 2 myLightBlue = TColor.GetColor('#9ecae1') myMediumBlue = TColor.GetColor('#0868ac') myDarkBlue = TColor.GetColor('#08306b') # Greens myLightGreen = TColor.GetColor('#c7e9c0') myMediumGreen = TColor.GetColor('#41ab5d') myDarkGreen = TColor.GetColor('#006d2c') # Oranges myLighterOrange = TColor.GetColor('#ffeda0') myLightOrange = TColor.GetColor('#fec49f') myMediumOrange = TColor.GetColor('#fe9929') # Greys myLightestGrey = TColor.GetColor('#f0f0f0') myLighterGrey = TColor.GetColor('#e3e3e3') myLightGrey = TColor.GetColor('#969696') # Pinks myLightPink = TColor.GetColor('#fde0dd') myMediumPink = TColor.GetColor('#fcc5c0') myDarkPink = TColor.GetColor('#dd3497') # background path bkg_suffix # Joey's configuration #bkg_suffix='_SusySkimHiggsino_v1.9_SUSY16_tree_LOOSE_NOMINAL.root' #sig_suffix='_SusySkimHiggsino_v1.9_SUSY16_tree_LOOSE_NOMINAL.root' # Jesse's configuration #bkg_suffix='_SusySkimHiggsino_v1.9_SUSY16_tree_NoSys.root' bkg_suffix = '_SusySkimHiggsino_v1.9_hadded_tree.root' #sig_suffix='_SusySkimHiggsino_v1.9_SUSY16_tree_NoSys.root' #sig_suffix='_SusySkimHiggsino_v1.9b_SUSY16_tree_NoSys.root' sig_suffix = '_SusySkimHiggsino_v1.8b_SUSY16_tree_NoSys.root' d_samp = { 'data': { 'type': 'data', 'leg': 'Data', 'f_color': 0, 'l_color': 0, 'path': 'data' + bkg_suffix }, #'fakes' :{'type':'bkg','leg':'Fake leptons', 'f_color':myLighterGrey, 'path':'fakes'+bkg_suffix}, 'fakes2Lb_DijetFFs': { 'type': 'bkg', 'leg': 'Fake leptons', 'f_color': myLighterGrey, 'path': 'fakes2Lb_DijetFFs_SusySkimHiggsino_v1.9_SUSY16_tree_NoSys.root' }, #'top' :{'type':'bkg', 'leg':'t#bar{t} & Single top', 'f_color':myLightBlue, 'path':'top'+bkg_suffix}, 'top': { 'type': 'bkg', 'leg': 't#bar{t} & Single top', 'f_color': myLightBlue, 'path': 'top_SusySkimHiggsino_v1.9_hadded_tree.root' }, #'Zttjets' :{'type':'bkg', 'leg':'Z(#rightarrow#tau#tau)+jets', 'f_color':myMediumGreen, 'path':'Zttjets'+bkg_suffix}, 'Zttjets': { 'type': 'bkg', 'leg': 'Z(#rightarrow#tau#tau)+jets', 'f_color': myMediumGreen, 'path': 'Zttjets_SusySkimHiggsino_v1.9_hadded_tree.root' }, #'diboson' :{'type':'bkg', 'leg':'Diboson', 'f_color':myMediumOrange, 'path':'diboson'+bkg_suffix}, 'diboson': { 'type': 'bkg', 'leg': 'Diboson', 'f_color': myMediumOrange, 'path': 'diboson_SusySkimHiggsino_v1.9_hadded_tree.root' }, #'other' :{'type':'bkg', 'leg':'Others', 'f_color':myLighterOrange,'path':'other'+bkg_suffix}, 'other': { 'type': 'bkg', 'leg': 'Others', 'f_color': myLighterOrange, 'path': 'other_SusySkimHiggsino_v1.9_hadded_tree.root' }, # Signals 'MGPy8EG_A14N23LO_SlepSlep_direct_100p0_90p0_MET50': { 'type': 'sig', 'leg': '#tilde{#font[12]{l}} [100, 90]', 'l_color': kOrange + 3, 'path': 'MGPy8EG_A14N23LO_SlepSlep_direct_100p0_90p0_MET50' + sig_suffix }, 'MGPy8EG_A14N23LO_SlepSlep_direct_110p0_90p0_MET50': { 'type': 'sig', 'leg': '#tilde{#font[12]{l}} [110, 90]', 'l_color': kRed + 3, 'path': 'MGPy8EG_A14N23LO_SlepSlep_direct_110p0_90p0_MET50' + sig_suffix }, 'MGPy8EG_A14N23LO_SlepSlep_direct_102p0_100p0_MET50': { 'type': 'sig', 'leg': '#tilde{#font[12]{l}} [102, 100]', 'l_color': kAzure + 4, 'path': 'MGPy8EG_A14N23LO_SlepSlep_direct_102p0_100p0_MET50' + sig_suffix }, 'MGPy8EG_A14N23LO_SlepSlep_direct_105p0_100p0_MET50': { 'type': 'sig', 'leg': '#tilde{#font[12]{l}} [105, 100]', 'l_color': kCyan + 2, 'path': 'MGPy8EG_A14N23LO_SlepSlep_direct_105p0_100p0_MET50' + sig_suffix }, 'MGPy8EG_A14N23LO_SlepSlep_direct_110p0_100p0_MET50': { 'type': 'sig', 'leg': '#tilde{#font[12]{l}} [110, 100]', 'l_color': kViolet + 2, 'path': 'MGPy8EG_A14N23LO_SlepSlep_direct_110p0_100p0_MET50' + sig_suffix }, 'MGPy8EG_A14N23LO_SlepSlep_direct_120p0_100p0_MET50': { 'type': 'sig', 'leg': '#tilde{#font[12]{l}} [120, 100]', 'l_color': kMagenta - 9, 'path': 'MGPy8EG_A14N23LO_SlepSlep_direct_120p0_100p0_MET50' + sig_suffix }, 'MGPy8EG_A14N23LO_SlepSlep_direct_140p0_100p0_MET50': { 'type': 'sig', 'leg': '#tilde{#font[12]{l}} [140, 100]', 'l_color': kOrange + 2, 'path': 'MGPy8EG_A14N23LO_SlepSlep_direct_140p0_100p0_MET50' + sig_suffix }, 'MGPy8EG_A14N23LO_SlepSlep_direct_100p0_90p0_MET50': { 'type': 'sig', 'leg': '#tilde{#font[12]{l}} [100, 90]', 'l_color': kAzure + 4, 'path': 'MGPy8EG_A14N23LO_SlepSlep_direct_100p0_90p0_MET50' + sig_suffix }, 'MGPy8EG_A14N23LO_SlepSlep_direct_130p0_120p0_MET50': { 'type': 'sig', 'leg': '#tilde{#font[12]{l}} [130, 120]', 'l_color': kCyan - 3, 'path': 'MGPy8EG_A14N23LO_SlepSlep_direct_130p0_120p0_MET50' + sig_suffix }, 'MGPy8EG_A14N23LO_SlepSlep_direct_150p0_140p0_MET50': { 'type': 'sig', 'leg': '#tilde{#font[12]{l}} [150, 140]', 'l_color': kGray + 1, 'path': 'MGPy8EG_A14N23LO_SlepSlep_direct_150p0_140p0_MET50' + sig_suffix }, 'MGPy8EG_A14N23LO_SlepSlep_direct_190p0_180p0_MET50': { 'type': 'sig', 'leg': '#tilde{#font[12]{l}} [190, 180]', 'l_color': kMagenta - 9, 'path': 'MGPy8EG_A14N23LO_SlepSlep_direct_190p0_180p0_MET50' + sig_suffix }, 'MGPy8EG_A14N23LO_SM_Higgsino_90_80_2LMET50_MadSpin': { 'type': 'sig', 'leg': '#tilde{H} [90, 80]', 'l_color': kBlue + 3, 'path': 'MGPy8EG_A14N23LO_SM_Higgsino_90_80_2LMET50_MadSpin' + sig_suffix }, 'MGPy8EG_A14N23LO_SM_Higgsino_100_80_2LMET50_MadSpin': { 'type': 'sig', 'leg': '#tilde{H} [100, 80]', 'l_color': kMagenta - 3, 'path': 'MGPy8EG_A14N23LO_SM_Higgsino_100_80_2LMET50_MadSpin' + sig_suffix }, 'MGPy8EG_A14N23LO_SM_Higgsino_103_100_2LMET50_MadSpin': { 'type': 'sig', 'leg': '#tilde{H} [103, 100]', 'l_color': kAzure + 4, 'path': 'MGPy8EG_A14N23LO_SM_Higgsino_103_100_2LMET50_MadSpin' + sig_suffix }, 'MGPy8EG_A14N23LO_SM_Higgsino_105_100_2LMET50_MadSpin': { 'type': 'sig', 'leg': '#tilde{H} [105, 100]', 'l_color': kCyan + 2, 'path': 'MGPy8EG_A14N23LO_SM_Higgsino_105_100_2LMET50_MadSpin' + sig_suffix }, 'MGPy8EG_A14N23LO_SM_Higgsino_110_100_2LMET50_MadSpin': { 'type': 'sig', 'leg': '#tilde{H} [110, 100]', 'l_color': kRed + 2, 'path': 'MGPy8EG_A14N23LO_SM_Higgsino_110_100_2LMET50_MadSpin' + sig_suffix }, 'MGPy8EG_A14N23LO_SM_Higgsino_120_100_2LMET50_MadSpin': { 'type': 'sig', 'leg': '#tilde{H} [120, 100]', 'l_color': kViolet + 5, 'path': 'MGPy8EG_A14N23LO_SM_Higgsino_120_100_2LMET50_MadSpin' + sig_suffix }, 'MGPy8EG_A14N23LO_SM_Higgsino_140_100_2LMET50_MadSpin': { 'type': 'sig', 'leg': '#tilde{H} [140, 100]', 'l_color': kAzure + 3, 'path': 'MGPy8EG_A14N23LO_SM_Higgsino_140_100_2LMET50_MadSpin' + sig_suffix }, 'MGPy8EG_A14N23LO_SM_Higgsino_220_200_2LMET50_MadSpin': { 'type': 'sig', 'leg': '#tilde{H} [220, 200]', 'l_color': kAzure + 3, 'path': 'MGPy8EG_A14N23LO_SM_Higgsino_220_200_2LMET50_MadSpin' + sig_suffix }, # 'MGPy8EG_A14N23LO_SM_Higgsino_160_100_2LMET50_MadSpin':{'type':'sig','leg':'#tilde{H} [160, 100]','l_color':kViolet+1,'path':'MGPy8EG_A14N23LO_SM_Higgsino_160_100_2LMET50_MadSpin'+sig_suffix}, # 'MGPy8EG_A14N23LO_SM_Higgsino_160_150_2LMET50_MadSpin':{'type':'sig','leg':'#tilde{H} [160, 150]','l_color':kViolet+2,'path':'MGPy8EG_A14N23LO_SM_Higgsino_160_150_2LMET50_MadSpin'+sig_suffix}, # 'MGPy8EG_A14N23LO_SM_Higgsino_170_150_2LMET50_MadSpin':{'type':'sig','leg':'#tilde{H} [170, 150]','l_color':kViolet+3,'path':'MGPy8EG_A14N23LO_SM_Higgsino_170_150_2LMET50_MadSpin'+sig_suffix}, # 'MGPy8EG_A14N23LO_SM_Higgsino_190_150_2LMET50_MadSpin':{'type':'sig','leg':'#tilde{H} [190, 150]','l_color':kViolet+4,'path':'MGPy8EG_A14N23LO_SM_Higgsino_190_150_2LMET50_MadSpin'+sig_suffix}, # # 'MGPy8EG_A14N23LO_NUHM2_m12_300_weak_2LMET50_MadSpin':{'type':'sig','leg':'NUHM2 m12=300','l_color':kRed,'path':'MGPy8EG_A14N23LO_NUHM2_m12_300_weak_2LMET50_MadSpin'+sig_suffix}, # 'MGPy8EG_A14N23LO_NUHM2_m12_350_weak_2LMET50_MadSpin':{'type':'sig','leg':'NUHM2 m12=350','l_color':kRed-1,'path':'MGPy8EG_A14N23LO_NUHM2_m12_350_weak_2LMET50_MadSpin'+sig_suffix}, # 'MGPy8EG_A14N23LO_NUHM2_m12_400_weak_2LMET50_MadSpin':{'type':'sig','leg':'NUHM2 m12=400','l_color':kRed-2,'path':'MGPy8EG_A14N23LO_NUHM2_m12_400_weak_2LMET50_MadSpin'+sig_suffix}, # 'MGPy8EG_A14N23LO_NUHM2_m12_500_weak_2LMET50_MadSpin':{'type':'sig','leg':'NUHM2 m12=500','l_color':kRed-3,'path':'MGPy8EG_A14N23LO_NUHM2_m12_500_weak_2LMET50_MadSpin'+sig_suffix}, # 'MGPy8EG_A14N23LO_NUHM2_m12_600_weak_2LMET50_MadSpin':{'type':'sig','leg':'NUHM2 m12=600','l_color':kRed-4,'path':'MGPy8EG_A14N23LO_NUHM2_m12_600_weak_2LMET50_MadSpin'+sig_suffix}, # 'MGPy8EG_A14N23LO_NUHM2_m12_700_weak_2LMET50_MadSpin':{'type':'sig','leg':'NUHM2 m12=700','l_color':kRed-5,'path':'MGPy8EG_A14N23LO_NUHM2_m12_700_weak_2LMET50_MadSpin'+sig_suffix}, # 'MGPy8EG_A14N23LO_NUHM2_m12_800_weak_2LMET50_MadSpin':{'type':'sig','leg':'NUHM2 m12=800','l_color':kRed-6,'path':'MGPy8EG_A14N23LO_NUHM2_m12_800_weak_2LMET50_MadSpin'+sig_suffix}, 'MGPy8EG_A14N23LO_SM_Higgsino_160_100_2LMET50_MadSpin': { 'type': 'sig', 'leg': '#tilde{H} [160, 100]', 'l_color': kViolet + 1, 'path': 'AllSignals_SusySkimHiggsino_v1.9b_SUSY16_tree_AllSys.root' }, 'MGPy8EG_A14N23LO_SM_Higgsino_160_150_2LMET50_MadSpin': { 'type': 'sig', 'leg': '#tilde{H} [160, 150]', 'l_color': kViolet + 2, 'path': 'AllSignals_SusySkimHiggsino_v1.9b_SUSY16_tree_AllSys.root' }, 'MGPy8EG_A14N23LO_SM_Higgsino_170_150_2LMET50_MadSpin': { 'type': 'sig', 'leg': '#tilde{H} [170, 150]', 'l_color': kViolet + 3, 'path': 'AllSignals_SusySkimHiggsino_v1.9b_SUSY16_tree_AllSys.root' }, 'MGPy8EG_A14N23LO_SM_Higgsino_190_150_2LMET50_MadSpin': { 'type': 'sig', 'leg': '#tilde{H} [190, 150]', 'l_color': kViolet + 4, 'path': 'AllSignals_SusySkimHiggsino_v1.9b_SUSY16_tree_AllSys.root' }, 'MGPy8EG_A14N23LO_NUHM2_m12_300_weak': { 'type': 'sig', 'leg': 'NUHM2 m12=300', 'l_color': kRed, 'path': 'AllSignals_SusySkimHiggsino_v1.9b_SUSY16_tree_AllSys.root' }, 'MGPy8EG_A14N23LO_NUHM2_m12_350_weak': { 'type': 'sig', 'leg': 'NUHM2 m12=350', 'l_color': kRed - 1, 'path': 'AllSignals_SusySkimHiggsino_v1.9b_SUSY16_tree_AllSys.root' }, 'MGPy8EG_A14N23LO_NUHM2_m12_400_weak': { 'type': 'sig', 'leg': 'NUHM2 m12=400', 'l_color': kRed - 2, 'path': 'AllSignals_SusySkimHiggsino_v1.9b_SUSY16_tree_AllSys.root' }, 'MGPy8EG_A14N23LO_NUHM2_m12_500_weak': { 'type': 'sig', 'leg': 'NUHM2 m12=500', 'l_color': kRed - 3, 'path': 'AllSignals_SusySkimHiggsino_v1.9b_SUSY16_tree_AllSys.root' }, 'MGPy8EG_A14N23LO_NUHM2_m12_600_weak': { 'type': 'sig', 'leg': 'NUHM2 m12=600', 'l_color': kRed - 4, 'path': 'AllSignals_SusySkimHiggsino_v1.9b_SUSY16_tree_AllSys.root' }, 'MGPy8EG_A14N23LO_NUHM2_m12_700_weak': { 'type': 'sig', 'leg': 'NUHM2 m12=700', 'l_color': kRed - 5, 'path': 'AllSignals_SusySkimHiggsino_v1.9b_SUSY16_tree_AllSys.root' }, 'MGPy8EG_A14N23LO_NUHM2_m12_800_weak': { 'type': 'sig', 'leg': 'NUHM2 m12=800', 'l_color': kRed - 6, 'path': 'AllSignals_SusySkimHiggsino_v1.9b_SUSY16_tree_AllSys.root' }, } return d_samp