def draw_limits_per_category(nchannels, xmin, xmax, obs, expect, upper1sig, lower1sig, upper2sig, lower2sig): channel = np.array( [3. * nchannels - 1.5 - 3. * i for i in range(0, nchannels)]) ey = np.array([0.8 for i in range(0, nchannels)]) zero = np.zeros(nchannels) gexpect1sig = TGraphAsymmErrors(nchannels, expect, channel, lower1sig, upper1sig, ey, ey) gexpect1sig.SetFillColor(kGreen) gexpect1sig.SetLineWidth(2) gexpect1sig.SetLineStyle(2) gexpect2sig = TGraphAsymmErrors(nchannels, expect, channel, lower2sig, upper2sig, ey, ey) gexpect2sig.SetFillColor(kYellow) gexpect2sig.SetLineWidth(2) gexpect2sig.SetLineStyle(2) gexpect2sig.Draw("2") gexpect1sig.Draw("2") gobs = TGraphErrors(nchannels, obs, channel, zero, ey) gobs.SetMarkerStyle(21) gobs.SetMarkerSize(1.5) gobs.SetLineWidth(2) gobs.Draw("pz") # dashed line at median expected limits l = TLine() l.SetLineStyle(2) l.SetLineWidth(2) for bin in range(nchannels): l.DrawLine(expect[bin], channel[bin] - ey[bin], expect[bin], channel[bin] + ey[bin]) # line to separate individual and combined limits l.SetLineStyle(1) l.SetLineWidth(1) l.DrawLine(xmin, 0, xmax, 0) # legend x1 = gStyle.GetPadLeftMargin() + 0.01 y2 = 1 - gStyle.GetPadTopMargin() - 0.01 leg = TLegend(x1, y2 - 0.17, x1 + 0.25, y2) leg.SetFillColor(4000) leg.AddEntry(gexpect1sig, "Expected #pm1#sigma", "FL") leg.AddEntry(gexpect2sig, "Expected #pm2#sigma", "FL") leg.AddEntry(gobs, "Observed", "pl") leg.Draw() return gobs, gexpect1sig, gexpect2sig, leg
def draw_limits_per_category(nchannels, xmin, xmax, obs, expect, upper1sig, lower1sig, upper2sig, lower2sig): channel = np.array( [nchannels - 1.5 - float(i) for i in range(0, nchannels)]) ey = np.full(nchannels, 0.494) zero = np.zeros(nchannels) gexpect1sig = TGraphAsymmErrors(nchannels, expect, channel, lower1sig, upper1sig, ey, ey) gexpect1sig.SetFillColor(kGreen) gexpect1sig.SetLineWidth(2) gexpect1sig.SetLineStyle(2) gexpect2sig = TGraphAsymmErrors(nchannels, expect, channel, lower2sig, upper2sig, ey, ey) gexpect2sig.SetFillColor(kYellow) gexpect2sig.SetLineWidth(2) gexpect2sig.SetLineStyle(2) gexpect2sig.Draw("2") gexpect1sig.Draw("2") gobs = TGraphErrors(nchannels, obs, channel, zero, ey) gobs.SetMarkerStyle(21) gobs.SetMarkerSize(1.5) gobs.SetLineWidth(2) #gobs.Draw("pz") # dashed line at median expected limits l = TLine() l.SetLineStyle(2) l.SetLineWidth(2) for bin in range(nchannels): l.DrawLine(expect[bin], channel[bin] - ey[bin], expect[bin], channel[bin] + ey[bin]) # line to separate individual and combined limits l.SetLineStyle(1) l.SetLineWidth(1) l.DrawLine(xmin, 0, xmax, 0) # legend leg = TLegend(0.75, 0.75, 0.95, 0.9) leg.SetFillColor(4000) leg.AddEntry(gexpect1sig, "Expected #pm1#sigma", "FL") leg.AddEntry(gexpect2sig, "Expected #pm2#sigma", "FL") #leg.AddEntry( gobs, "Observed", "pl" ) leg.Draw() return gobs, gexpect1sig, gexpect2sig, leg
def makeResidHist(data, bkg): pulls = TGraphAsymmErrors(data.GetN()) pulls.SetName("Pulls") pulls.SetLineWidth(data.GetLineWidth()) pulls.SetLineStyle(data.GetLineStyle()) pulls.SetLineColor(data.GetLineColor()) pulls.SetMarkerSize(data.GetMarkerSize()) pulls.SetMarkerStyle(data.GetMarkerStyle()) pulls.SetMarkerColor(data.GetMarkerColor()) pulls.SetFillStyle(data.GetFillStyle()) pulls.SetFillColor(data.GetFillColor()) # Add histograms, calculate Poisson confidence interval on sum value for i in range(data.GetN()): x = data.GetX()[i] dyl = data.GetErrorYlow(i) dyh = data.GetErrorYhigh(i) yy = data.GetY()[i] - bkg.Interpolate(x) #bkg.GetBinContent(i+1) norm = dyl if yy > 0. else dyh if norm == 0.: yy, dyh, dyl = 0., 0., 0. else: yy /= norm dyh /= norm dyl /= norm pulls.SetPoint(i, x, yy) pulls.SetPointEYhigh(i, dyh) pulls.SetPointEYlow(i, dyl) return pulls
def convertHistToGraph(hist, useGarwood=False): alpha = 1 - 0.6827 graph = TGraphAsymmErrors(hist.GetNbinsX()) if useGarwood: lastEvent = False for i in reversed(range(hist.GetNbinsX())): N = hist.GetBinContent(i + 1) if not lastEvent and N > 0: lastEvent = True if lastEvent and N <= 0.: N = 1.e-6 L = 0 if N == 0 else ROOT.Math.gamma_quantile(alpha / 2, N, 1.) U = ROOT.Math.gamma_quantile_c(alpha / 2, N + 1, 1) graph.SetPoint(i, hist.GetXaxis().GetBinCenter(i + 1), N if not N == 0 else -1.e99) graph.SetPointError(i, 0., 0., N - L, U - N) else: for i in range(hist.GetNbinsX()): graph.SetPoint(i, hist.GetXaxis().GetBinCenter(i + 1), hist.GetBinContent(i + 1)) graph.SetPointError(i, hist.GetXaxis().GetBinWidth(i + 1) / 2., hist.GetXaxis().GetBinWidth(i + 1) / 2., hist.GetBinError(i + 1), hist.GetBinError(i + 1)) graph.SetLineWidth(hist.GetLineWidth()) graph.SetLineStyle(hist.GetLineStyle()) graph.SetLineColor(hist.GetLineColor()) graph.SetMarkerSize(hist.GetMarkerSize()) graph.SetMarkerStyle(hist.GetMarkerStyle()) graph.SetMarkerColor(hist.GetMarkerColor()) graph.SetFillStyle(hist.GetFillStyle()) graph.SetFillColor(hist.GetFillColor()) return graph
def getDataPoissonErrors(hist, kPoisson=False, drawZeroBins=False, drawXbars=False, centerBin=True): '''Make data poisson errors for a histogram with two different methods: - TH1.kPoisson - chi-squared quantile ''' # https://github.com/DESY-CMS-SUS/cmgtools-lite/blob/8_0_25/TTHAnalysis/python/plotter/mcPlots.py#L70-L102 # https://github.com/DESY-CMS-SUS/cmgtools-lite/blob/8_0_25/TTHAnalysis/python/plotter/susy-1lep/RcsDevel/plotDataPredictWithSyst.py#L12-L21 if kPoisson: hist.SetBinErrorOption(TH1D.kPoisson) Nbins = hist.GetNbinsX() xaxis = hist.GetXaxis() alpha = (1 - 0.6827) / 2. graph = TGraphAsymmErrors(Nbins) graph.SetName(hist.GetName() + "_graph") graph.SetTitle(hist.GetTitle()) for i in xrange(1, Nbins + 1): N = hist.GetBinContent(i) if N <= 0 and not drawZeroBins: continue dN = hist.GetBinError(i) yscale = 1 if centerBin: x = xaxis.GetBinCenter(i) else: x = xaxis.GetBinLowEdge(i) if N > 0 and dN > 0 and abs(dN**2 / N - 1) > 1e-4: # check is error is Poisson yscale = (dN**2 / N) N = (N / dN)**2 if kPoisson: EYlow = hist.GetBinErrorLow(i) EYup = hist.GetBinErrorUp(i) else: EYlow = (N - Math.chisquared_quantile_c(1 - alpha, 2 * N) / 2.) if N > 0 else 0 EYup = Math.chisquared_quantile_c(alpha, 2 * (N + 1)) / 2. - N y = yscale * N EXup = xaxis.GetBinUpEdge(i) - x if drawXbars else 0 EXlow = x - xaxis.GetBinLowEdge(i) if drawXbars else 0 graph.SetPoint(i - 1, x, y) graph.SetPointError(i - 1, EXlow, EXup, EYlow, EYup) #print ">>> getDataPoissonErrors - bin %2d: (x,y) = ( %3.1f - %4.2f + %4.2f, %4.2f - %4.2f + %4.2f )"%(i,x,EXlow,EXup,y,EYlow,EYup) graph.SetLineWidth(hist.GetLineWidth()) graph.SetLineColor(hist.GetLineColor()) graph.SetLineStyle(hist.GetLineStyle()) graph.SetMarkerSize(hist.GetMarkerSize()) graph.SetMarkerColor(hist.GetMarkerColor()) graph.SetMarkerStyle(hist.GetMarkerStyle()) return graph
def convertHistToGraph(hist): graph = TGraphAsymmErrors(hist.GetNbinsX()) for i in range(hist.GetNbinsX()): graph.SetPoint(i, hist.GetXaxis().GetBinCenter(i), hist.GetBinContent(i)) graph.SetPointError(i, hist.GetXaxis().GetBinWidth(i) / 2., hist.GetXaxis().GetBinWidth(i) / 2., hist.GetBinError(i), hist.GetBinError(i)) graph.SetLineWidth(hist.GetLineWidth()) graph.SetLineStyle(hist.GetLineStyle()) graph.SetLineColor(hist.GetLineColor()) graph.SetMarkerSize(hist.GetMarkerSize()) graph.SetMarkerStyle(hist.GetMarkerStyle()) graph.SetMarkerColor(hist.GetMarkerColor()) graph.SetFillStyle(hist.GetFillStyle()) graph.SetFillColor(hist.GetFillColor()) return graph
def histToGraph(hist, name='', keepErrors=True, poissonErrors=True): ## Helper method to convert a histogram to a corresponding graph # @hist TH1 object # @name name of the graph (default is name of histogram) # @keepErrors decide if the y-errors should be propagated to the graph # @poissonErrors decide if the y-errors should be calculated as Poisson errors # @return graph if not name: name = 'g%s' % (hist.GetName()) from ROOT import TGraphAsymmErrors nBins = hist.GetNbinsX() graph = TGraphAsymmErrors(nBins) graph.SetNameTitle(name, hist.GetTitle()) xAxis = hist.GetXaxis() for i in xrange(nBins): xVal = xAxis.GetBinCenter(i + 1) yVal = hist.GetBinContent(i + 1) graph.SetPoint(i, xVal, yVal) graph.SetPointEXlow(i, abs(xVal - xAxis.GetBinLowEdge(i + 1))) graph.SetPointEXhigh(i, abs(xVal - xAxis.GetBinUpEdge(i + 1))) if keepErrors: if poissonErrors: lo, hi = calculatePoissonErrors(yVal) graph.SetPointEYlow(i, lo) graph.SetPointEYhigh(i, hi) else: graph.SetPointEYlow(i, hist.GetBinErrorLow(i + 1)) graph.SetPointEYhigh(i, hist.GetBinErrorUp(i + 1)) # copy the style graph.SetMarkerStyle(hist.GetMarkerStyle()) graph.SetMarkerColor(hist.GetMarkerColor()) graph.SetMarkerSize(hist.GetMarkerSize()) graph.SetLineStyle(hist.GetLineStyle()) graph.SetLineColor(hist.GetLineColor()) graph.SetLineWidth(hist.GetLineWidth()) graph.SetFillColor(hist.GetFillColor()) graph.SetFillStyle(hist.GetFillStyle()) return graph
def limits(): # put real limits here: lepton+jets, dilepton, combined obs = np.array([1, 1, 1]) expect = np.array([1, 1, 1]) upper1sig = np.array([1.352, 0.736390352249, 0.636]) lower1sig = np.array([0.9153, 0.500572919846, 0.439]) upper2sig = np.array([3.125, 1.66185164452, 1.455]) lower2sig = np.array([1.4717, 0.805953979492, 0.715]) channel = np.array([1.5, 0.5, -0.5]) ey = np.array([0.495, 0.495, 0.495]) zero = np.zeros(nchannels) xmin = 0.7 xmax = 30 c, h = draw_canvas_histo( xmin, xmax, "95% CL limit on #mu = #sigma/#sigma_{SM} at m_{H} = 125 GeV") c.SetLogx() gexpect1sig = TGraphAsymmErrors(nchannels, expect, channel, lower1sig, upper1sig, ey, ey) gexpect1sig.SetFillColor(kGreen) gexpect1sig.SetLineWidth(2) gexpect1sig.SetLineStyle(2) gexpect2sig = TGraphAsymmErrors(nchannels, expect, channel, lower2sig, upper2sig, ey, ey) gexpect2sig.SetFillColor(kYellow) gexpect2sig.SetLineWidth(2) gexpect2sig.SetLineStyle(2) gexpect2sig.Draw("2") gexpect1sig.Draw("2") gobs = TGraphErrors(nchannels, obs, channel, zero, ey) gobs.SetMarkerStyle(21) gobs.SetMarkerSize(1.5) gobs.SetLineWidth(2) #gobs.Draw("pz") # dashed line at median expected limits l = TLine() l.SetLineStyle(2) l.SetLineWidth(2) for bin in range(nchannels): l.DrawLine(expect[bin], channel[bin] - ey[bin], expect[bin], channel[bin] + ey[bin]) # line to separate individual and combined limits l.SetLineStyle(1) l.SetLineWidth(1) l.DrawLine(xmin, 0, xmax, 0) # legend leg = TLegend(0.67, 0.75, 0.95, 0.9) leg.SetFillColor(4000) leg.AddEntry(gexpect1sig, "Expected #pm1#sigma", "FL") leg.AddEntry(gexpect2sig, "Expected #pm2#sigma", "FL") #leg.AddEntry( gobs, "Observed", "pl" ) leg.Draw() #draw_disclaimer() c.RedrawAxis() c.Modified() c.Update() c.SaveAs("limits.pdf")
def limit(): method = '' channel = "bb" particleP = "Z'" particle = channel multF = ZPTOBB THEORY = ['A1', 'B3'] suffix = "_" + BTAGGING if ISMC: suffix += "_MC" if SY: suffix += "_comb" #if method=="cls": suffix="_CLs" if SY: filename = "./combine/limits/MANtag_study/" + BTAGGING + "/combined_run2/" + YEAR + "_M%d.txt" else: filename = "./combine/limits/MANtag_study/" + BTAGGING + "/" + YEAR + "_M%d.txt" if CATEGORY != "": filename = filename.replace( BTAGGING + "/", BTAGGING + "/single_category/" + CATEGORY + "_") suffix += "_" + CATEGORY if ISMC: filename = filename.replace(".txt", "_MC.txt") mass, val = fillValues(filename) #print "mass =",mass #print "val =", val Obs0s = TGraph() Exp0s = TGraph() Exp1s = TGraphAsymmErrors() Exp2s = TGraphAsymmErrors() Sign = TGraph() pVal = TGraph() Best = TGraphAsymmErrors() Theory = {} for i, m in enumerate(mass): if not m in val: print "Key Error:", m, "not in value map" continue n = Exp0s.GetN() Obs0s.SetPoint(n, m, val[m][0] * multF) Exp0s.SetPoint(n, m, val[m][3] * multF) Exp1s.SetPoint(n, m, val[m][3] * multF) Exp1s.SetPointError(n, 0., 0., val[m][3] * multF - val[m][2] * multF, val[m][4] * multF - val[m][3] * multF) Exp2s.SetPoint(n, m, val[m][3] * multF) Exp2s.SetPointError(n, 0., 0., val[m][3] * multF - val[m][1] * multF, val[m][5] * multF - val[m][3] * multF) if len(val[m]) > 6: Sign.SetPoint(n, m, val[m][6]) if len(val[m]) > 7: pVal.SetPoint(n, m, val[m][7]) if len(val[m]) > 8: Best.SetPoint(n, m, val[m][8]) if len(val[m]) > 10: Best.SetPointError(n, 0., 0., abs(val[m][9]), val[m][10]) for t in THEORY: Theory[t] = TGraphAsymmErrors() addXZH = True for m in sorted(HVT[t]['W']['XS'].keys()): if m < mass[0] or m > mass[-1]: continue if m > 4500: continue ## for now because I don't have the higher mass xs FIXME XsZ, XsZ_Up, XsZ_Down = 0., 0., 0. if addXZH: XsZ = 1000. * HVT[t]['Z']['XS'][ m] * 0.12 #temporary BR value set to 0.12 FIXME XsZ_Up = XsZ * (1. + math.hypot(HVT[t]['Z']['QCD'][m][0] - 1., HVT[t]['Z']['PDF'][m][0] - 1.)) XsZ_Down = XsZ * (1. - math.hypot(1. - HVT[t]['Z']['QCD'][m][0], 1. - HVT[t]['Z']['PDF'][m][0])) n = Theory[t].GetN() Theory[t].SetPoint(n, m, XsZ) Theory[t].SetPointError(n, 0., 0., (XsZ - XsZ_Down), (XsZ_Up - XsZ)) Theory[t].SetLineColor(theoryLineColor[t]) Theory[t].SetFillColor(theoryFillColor[t]) Theory[t].SetFillStyle(theoryFillStyle[t]) Theory[t].SetLineWidth(2) #Theory[t].SetLineStyle(7) Exp2s.SetLineWidth(2) Exp2s.SetLineStyle(1) Obs0s.SetLineWidth(3) Obs0s.SetMarkerStyle(0) Obs0s.SetLineColor(1) Exp0s.SetLineStyle(2) Exp0s.SetLineWidth(3) Exp1s.SetFillColor(417) #kGreen+1 Exp1s.SetLineColor(417) #kGreen+1 Exp2s.SetFillColor(800) #kOrange Exp2s.SetLineColor(800) #kOrange Exp2s.GetXaxis().SetTitle("m_{" + particleP + "} (GeV)") Exp2s.GetXaxis().SetTitleSize(Exp2s.GetXaxis().GetTitleSize() * 1.25) Exp2s.GetXaxis().SetNoExponent(True) Exp2s.GetXaxis().SetMoreLogLabels(True) Exp2s.GetYaxis().SetTitle("#sigma(" + particleP + ") #bf{#it{#Beta}}(" + particleP + " #rightarrow " + particle + ") (fb)") Exp2s.GetYaxis().SetTitleOffset(1.5) Exp2s.GetYaxis().SetNoExponent(True) Exp2s.GetYaxis().SetMoreLogLabels() Sign.SetLineWidth(2) Sign.SetLineColor(629) Sign.GetXaxis().SetTitle("m_{" + particleP + "} (GeV)") Sign.GetXaxis().SetTitleSize(Sign.GetXaxis().GetTitleSize() * 1.1) Sign.GetYaxis().SetTitle("Significance") pVal.SetLineWidth(2) pVal.SetLineColor(629) pVal.GetXaxis().SetTitle("m_{" + particleP + "} (GeV)") pVal.GetXaxis().SetTitleSize(pVal.GetXaxis().GetTitleSize() * 1.1) pVal.GetYaxis().SetTitle("local p-Value") Best.SetLineWidth(2) Best.SetLineColor(629) Best.SetFillColor(629) Best.SetFillStyle(3003) Best.GetXaxis().SetTitle("m_{" + particleP + "} (GeV)") Best.GetXaxis().SetTitleSize(Best.GetXaxis().GetTitleSize() * 1.1) Best.GetYaxis().SetTitle("Best Fit (pb)") c1 = TCanvas("c1", "Exclusion Limits", 800, 600) c1.cd() #SetPad(c1.GetPad(0)) c1.GetPad(0).SetTopMargin(0.06) c1.GetPad(0).SetRightMargin(0.05) c1.GetPad(0).SetLeftMargin(0.12) c1.GetPad(0).SetTicks(1, 1) #c1.GetPad(0).SetGridx() #c1.GetPad(0).SetGridy() c1.GetPad(0).SetLogy() Exp2s.Draw("A3") Exp1s.Draw("SAME, 3") for t in THEORY: Theory[t].Draw("SAME, L3") Theory[t].Draw("SAME, L3X0Y0") Exp0s.Draw("SAME, L") if not options.blind: Obs0s.Draw("SAME, L") #setHistStyle(Exp2s) Exp2s.GetXaxis().SetTitleSize(0.050) Exp2s.GetYaxis().SetTitleSize(0.050) Exp2s.GetXaxis().SetLabelSize(0.045) Exp2s.GetYaxis().SetLabelSize(0.045) Exp2s.GetXaxis().SetTitleOffset(0.90) Exp2s.GetYaxis().SetTitleOffset(1.25) Exp2s.GetYaxis().SetMoreLogLabels(True) Exp2s.GetYaxis().SetNoExponent(True) Exp2s.GetYaxis().SetRangeUser(0.1, 5.e3) #else: Exp2s.GetYaxis().SetRangeUser(0.1, 1.e2) #Exp2s.GetXaxis().SetRangeUser(mass[0], min(mass[-1], MAXIMUM[channel] if channel in MAXIMUM else 1.e6)) Exp2s.GetXaxis().SetRangeUser(SIGNALS[0], SIGNALS[-1]) #drawAnalysis(channel) drawAnalysis("") #drawRegion(channel, True) drawRegion("", True) #drawCMS(LUMI, "Simulation Preliminary") #Preliminary drawCMS(LUMI, "Work in Progress", suppressCMS=True) # legend top = 0.9 nitems = 4 + len(THEORY) leg = TLegend(0.55, top - nitems * 0.3 / 5., 0.98, top) #leg = TLegend(0.45, top-nitems*0.3/5., 0.98, top) leg.SetBorderSize(0) leg.SetFillStyle(0) #1001 leg.SetFillColor(0) leg.SetHeader("95% CL upper limits") leg.AddEntry(Obs0s, "Observed", "l") leg.AddEntry(Exp0s, "Expected", "l") leg.AddEntry(Exp1s, "#pm 1 std. deviation", "f") leg.AddEntry(Exp2s, "#pm 2 std. deviation", "f") for t in THEORY: leg.AddEntry(Theory[t], theoryLabel[t], "fl") leg.Draw() latex = TLatex() latex.SetNDC() latex.SetTextSize(0.045) latex.SetTextFont(42) #latex.DrawLatex(0.66, leg.GetY1()-0.045, particleP+" #rightarrow "+particle+"h") leg2 = TLegend(0.12, 0.225 - 2 * 0.25 / 5., 0.65, 0.225) leg2.SetBorderSize(0) leg2.SetFillStyle(0) #1001 leg2.SetFillColor(0) c1.GetPad(0).RedrawAxis() leg2.Draw() if not options.blind: Obs0s.Draw("SAME, L") c1.GetPad(0).Update() if not gROOT.IsBatch(): raw_input("Press Enter to continue...") c1.Print("combine/plotsLimit/ExclusionLimits/MANtag_study/" + YEAR + suffix + ".png") c1.Print("combine/plotsLimit/ExclusionLimits/MANtag_study/" + YEAR + suffix + ".pdf") if 'ah' in channel or 'sl' in channel: c1.Print("combine/plotsLimit/ExclusionLimits/MANtag_study/" + YEAR + suffix + ".C") c1.Print("combine/plotsLimit/ExclusionLimits/MANtag_study/" + YEAR + suffix + ".root") for t in THEORY: print "Model", t, ":", for m in range(mass[0], mass[-1], 1): if not (Theory[t].Eval(m) > Obs0s.Eval(m)) == ( Theory[t].Eval(m + 1) > Obs0s.Eval(m + 1)): print m, print "" return
def limit2HDM(): global signals signals = range(800, 2000 + 1, 50) multF = HTOBB THEORY = ['T1', 'T2'] mass, val = fillValues("./combine/AZh/AZh_M%d.txt") Obs0s = TGraph() Exp0s = TGraph() Exp1s = TGraphAsymmErrors() Exp2s = TGraphAsymmErrors() massB, valB = fillValues("./combine/BBAZh/BBAZh_M%d.txt") Obs0sB = TGraph() Exp0sB = TGraph() Exp1sB = TGraphAsymmErrors() Exp2sB = TGraphAsymmErrors() for i, m in enumerate(mass): if not m in val: print "Key Error:", m, "not in value map" continue n = Exp0s.GetN() Obs0s.SetPoint(n, m, val[m][0] * multF) Exp0s.SetPoint(n, m, val[m][3] * multF) Exp1s.SetPoint(n, m, val[m][3] * multF) Exp1s.SetPointError(n, 0., 0., val[m][3] * multF - val[m][2] * multF, val[m][4] * multF - val[m][3] * multF) Exp2s.SetPoint(n, m, val[m][3] * multF) Exp2s.SetPointError(n, 0., 0., val[m][3] * multF - val[m][1] * multF, val[m][5] * multF - val[m][3] * multF) Obs0sB.SetPoint(n, m, valB[m][0] * multF) Exp0sB.SetPoint(n, m, valB[m][3] * multF) Exp1sB.SetPoint(n, m, valB[m][3] * multF) Exp1sB.SetPointError(n, 0., 0., valB[m][3] * multF - valB[m][2] * multF, valB[m][4] * multF - valB[m][3] * multF) Exp2sB.SetPoint(n, m, valB[m][3] * multF) Exp2sB.SetPointError(n, 0., 0., valB[m][3] * multF - valB[m][1] * multF, valB[m][5] * multF - valB[m][3] * multF) col = 629 Exp2s.SetLineWidth(2) Exp2s.SetLineStyle(1) Obs0s.SetLineWidth(3) Obs0s.SetMarkerStyle(0) Obs0s.SetLineColor(1) Exp0s.SetLineStyle(2) Exp0s.SetLineWidth(3) Exp0s.SetLineColor(1) # Exp1s.SetFillColorAlpha(col, 0.4) #kGreen+1 # Exp1s.SetLineColorAlpha(col, 0.4) # Exp2s.SetFillColorAlpha(col, 0.2) #kOrange # Exp2s.SetLineColorAlpha(col, 0.2) Exp1s.SetFillColor(417) Exp1s.SetLineColor(417) Exp2s.SetFillColor(800) Exp2s.SetLineColor(800) colB = 922 Exp2sB.SetLineWidth(2) Obs0sB.SetLineStyle(9) Obs0sB.SetLineWidth(3) Obs0sB.SetMarkerStyle(0) Obs0sB.SetLineColor(colB) Exp0sB.SetLineStyle(8) Exp0sB.SetLineWidth(3) Exp0sB.SetLineColor(colB) Exp1sB.SetFillColorAlpha(colB, 0.4) #kGreen+1 Exp1sB.SetLineColorAlpha(colB, 0.4) Exp2sB.SetFillColorAlpha(colB, 0.2) #kOrange Exp2sB.SetLineColorAlpha(colB, 0.2) Exp2s.GetXaxis().SetTitle("m_{A} (GeV)") Exp2s.GetXaxis().SetTitleSize(Exp2s.GetXaxis().GetTitleSize() * 1.25) Exp2s.GetXaxis().SetNoExponent(True) Exp2s.GetXaxis().SetMoreLogLabels(True) Exp2s.GetYaxis().SetTitle( "#sigma(A) #bf{#it{#Beta}}(A #rightarrow Zh) #bf{#it{#Beta}}(h #rightarrow bb) (fb)" ) Exp2s.GetYaxis().SetTitleOffset(1.5) Exp2s.GetYaxis().SetNoExponent(True) Exp2s.GetYaxis().SetMoreLogLabels() Theory = {} #for t in THEORY: # Theory[t] = TGraphAsymmErrors() # for m in sorted(THDM[t]['ggA'].keys()): # if m < mass[0] or m > mass[-1]: continue # Xs, Xs_Up, Xs_Down = 0., 0., 0. # Xs = THDM[t]['ggA'][m] # Xs_Up = Xs*(1.+math.sqrt((THDM['PDF']['ggA'][m][0]-1.)**2 + (THDM['QCD']['ggA'][m][0]-1.)**2)) # Xs_Down = Xs*(1.-math.sqrt((1.-THDM['PDF']['ggA'][m][1])**2 + (1.-THDM['QCD']['ggA'][m][1])**2)) # n = Theory[t].GetN() # Theory[t].SetPoint(n, m, Xs) # Theory[t].SetPointError(n, 0., 0., (Xs-Xs_Down), (Xs_Up-Xs)) # Theory[t].SetLineColor(theoryLineColor[t]) # Theory[t].SetFillColor(theoryFillColor[t]) # Theory[t].SetFillStyle(theoryFillStyle[t]) # Theory[t].SetLineWidth(2) # #Theory[t].SetLineStyle(7) c1 = TCanvas("c1", "Exclusion Limits", 800, 600) c1.cd() #SetPad(c1.GetPad(0)) c1.GetPad(0).SetTopMargin(0.06) c1.GetPad(0).SetRightMargin(0.05) c1.GetPad(0).SetLeftMargin(0.12) c1.GetPad(0).SetTicks(1, 1) c1.GetPad(0).SetLogy() Exp2s.Draw("A3") Exp1s.Draw("SAME, 3") Exp0s.Draw("SAME, L") # Exp2sB.Draw("SAME, 3") # Exp1sB.Draw("SAME, 3") Exp0sB.Draw("SAME, L") if not options.blind: Obs0s.Draw("SAME, L") Obs0sB.Draw("SAME, L") for t in THEORY: Theory[t].Draw("SAME, L3") Theory[t].Draw("SAME, L3X0Y0") #setHistStyle(Exp2s) # Exp2s.GetXaxis().SetTitleSize(0.045) # Exp2s.GetYaxis().SetTitleSize(0.04) # Exp2s.GetXaxis().SetLabelSize(0.04) # Exp2s.GetYaxis().SetLabelSize(0.04) # Exp2s.GetXaxis().SetTitleOffset(1) # Exp2s.GetYaxis().SetTitleOffset(1.25) Exp2s.GetXaxis().SetTitleSize(0.050) Exp2s.GetYaxis().SetTitleSize(0.050) Exp2s.GetXaxis().SetLabelSize(0.045) Exp2s.GetYaxis().SetLabelSize(0.045) Exp2s.GetXaxis().SetTitleOffset(0.90) Exp2s.GetYaxis().SetTitleOffset(1.25) Exp2s.GetYaxis().SetMoreLogLabels(True) Exp2s.GetYaxis().SetNoExponent(True) Exp2s.GetYaxis().SetRangeUser(0.5, 1.e3) Exp2s.GetXaxis().SetRangeUser(mass[0], mass[-1]) drawAnalysis('AZh') drawRegion('AZHsl', True) drawCMS(LUMI, "") #Preliminary #drawCMS(LUMI, "Work in Progress", suppressCMS=True) # legend leg = TLegend(0.6, 0.90, 0.99, 0.90) leg.SetBorderSize(0) leg.SetFillStyle(0) #1001 leg.SetFillColor(0) leg.SetHeader("95% CL upper limits") leg.AddEntry(None, "gg #rightarrow A #rightarrow Zh", "") #"95% CL upper limits" leg.AddEntry(Obs0s, "Observed", "l") leg.AddEntry(Exp0s, "Expected", "l") leg.AddEntry(Exp1s, "#pm 1 std. deviation", "f") leg.AddEntry(Exp2s, "#pm 2 std. deviation", "f") leg.AddEntry(None, "", "") leg.AddEntry(None, "bbA #rightarrow Zh", "") leg.AddEntry(Obs0sB, "Observed", "l") leg.AddEntry(Exp0sB, "Expected", "l") leg.SetY1(leg.GetY2() - leg.GetNRows() * 0.045) leg.Draw() # latex = TLatex() # latex.SetNDC() # latex.SetTextSize(0.040) # latex.SetTextFont(42) # latex.DrawLatex(0.65, leg.GetY1()-0.045, "cos(#beta-#alpha)=0.25, tan(#beta)=1") # legB = TLegend(0.12, 0.4-4*0.3/5., 0.65, 0.4) legB = TLegend(0.15, 0.27, 0.68, 0.27) legB.SetBorderSize(0) legB.SetFillStyle(0) #1001 legB.SetFillColor(0) for t in THEORY: legB.AddEntry(Theory[t], theoryLabel[t], "fl") legB.AddEntry(None, "cos(#beta-#alpha)=0.25, tan(#beta)=1", "") legB.SetY1(legB.GetY2() - legB.GetNRows() * 0.045) legB.Draw() c1.GetPad(0).RedrawAxis() leg.Draw() c1.Update() if not gROOT.IsBatch(): raw_input("Press Enter to continue...") c1.Print("plotsLimit/Exclusion/THDM.png") c1.Print("plotsLimit/Exclusion/THDM.pdf")
theory_v = TVectorD(7, theory_a) mass_a = array("d", [1500, 1750, 2000, 2250, 2500, 3000, 3250, 3500]) mass_v = TVectorD(7, mass_a) err_a = array("d", [0, 0, 0, 0, 0, 0, 0, 0]) err_v = TVectorD(7, err_a) ## theory_a = array("d",[0.0006434760289,0.0005751010031,0.0005231099785,0.0005344069796,0.0005340549978]) ## theory_v = TVectorD(5,theory_a) ## mass_a = array("d",[1750,2000,2500,2750,3000]) ## mass_v = TVectorD(5,mass_a) ## err_a = array("d",[0,0,0,0,0,0]) ## err_v = TVectorD(5,err_a) theory = TGraphAsymmErrors(mass_v, theory_v, err_v, err_v, err_v, err_v) theory.SetLineColor(4) theory.SetLineStyle(9) theory.SetLineWidth(3) observed_p = TGraphAsymmErrors(massv, obsv, masserrv, masserrv, obserrv, obserrv) observed_p.SetLineColor(ROOT.kBlack) observed_p.SetLineWidth(2) observed_p.SetMarkerStyle(20) expected_p = TGraphAsymmErrors(massv, expv, masserrv, masserrv, experrv, experrv) expected_p.SetLineColor(ROOT.kBlack) expected_p.SetLineWidth(2) expected_p.SetLineStyle(2) expected68 = TGraphAsymmErrors(massv, expv, masserrv, masserrv, exp68Lv, exp68Hv)
def makePlot1D(filepath, foutname, plottitle='', masstitle=''): br = 1 if 'Resonant' in plottitle else 0.68 limits = parseLimitFiles2D(filepath, br) xaxis = [] xseclist = [] xsecerr = [] cent = [] obs = [] up1 = [] up2 = [] down1 = [] down2 = [] maxval = 0 minval = 999 for m in sorted(limits): l = limits[m] xaxis.append(m) xseclist.append(l.xsec) xsecerr.append(l.xsec * .2) cent.append(l.cent) up1.append(l.up1 - l.cent) up2.append(l.up2 - l.cent) down1.append(l.cent - l.down1) down2.append(l.cent - l.down2) obs.append(l.obs) maxval = max(maxval, l.up2) minval = min(minval, l.down2) N = len(xaxis) up1Sigma = array('f', up1) up2Sigma = array('f', up2) down1Sigma = array('f', down1) down2Sigma = array('f', down2) cent = array('f', cent) obs = array('f', obs) xarray = array('f', xaxis) xsecarray = array('f', xseclist) xsecerrarray = array('f', xsecerr) zeros = array('f', [0 for i in xrange(N)]) graphXsec = TGraphErrors(N, xarray, xsecarray, zeros, xsecerrarray) graphCent = TGraph(N, xarray, cent) graphObs = TGraph(N, xarray, obs) graph1Sigma = TGraphAsymmErrors(N, xarray, cent, zeros, zeros, down1Sigma, up1Sigma) graph2Sigma = TGraphAsymmErrors(N, xarray, cent, zeros, zeros, down2Sigma, up2Sigma) c = TCanvas('c', 'c', 700, 600) c.SetLogy() c.SetLeftMargin(.15) graph2Sigma.GetXaxis().SetTitle(masstitle + ' [GeV]') graph2Sigma.GetYaxis().SetTitle( '95% C.L. upper limit [#sigma/#sigma_{theory}]') c2 = root.kOrange c1 = root.kGreen + 1 graph2Sigma.SetLineColor(c2) graph1Sigma.SetLineColor(c1) graph2Sigma.SetFillColor(c2) graph1Sigma.SetFillColor(c1) graph2Sigma.SetMinimum(0.5 * minval) graph2Sigma.SetMaximum(10 * maxval) graphCent.SetLineWidth(2) graphCent.SetLineStyle(2) graphObs.SetLineColor(1) graphObs.SetLineWidth(3) graphObs.SetMarkerStyle(20) graphObs.SetMarkerSize(1) graphObs.SetMarkerColor(1) graph1Sigma.SetLineStyle(0) graph2Sigma.SetLineStyle(0) leg = TLegend(0.55, 0.7, 0.9, 0.9) leg.AddEntry(graphCent, 'Expected', 'L') if not BLIND: leg.AddEntry(graphObs, 'Observed', 'Lp') leg.AddEntry(graph1Sigma, '1 std. dev.', 'F') leg.AddEntry(graph2Sigma, '2 std. dev.', 'F') leg.SetFillStyle(0) leg.SetBorderSize(0) graph2Sigma.Draw('A3') graph1Sigma.Draw('3 same') graphCent.Draw('same L') if not BLIND: graphObs.Draw('same Lp') subscript = 'SR' if 'Resonant' in plottitle else 'FC' coupling = '0.1' if 'Resonant' in plottitle else '0.25' graphXsec.SetLineColor(2) graphXsec.SetLineWidth(2) graphXsec.SetLineStyle(2) graphXsec.SetFillColor(2) graphXsec.SetFillStyle(3005) graphXsec.Draw('same L3') ''' if not scale: if 'Resonant' in plottitle: leg.AddEntry(graphXsec,'Theory #splitline{a_{%s}=b_{%s}=%s}{m_{#chi}=100 GeV}'%(subscript,subscript,coupling),'l') else: leg.AddEntry(graphXsec,'Theory #splitline{a_{%s}=b_{%s}=%s}{m_{#chi}=10 GeV}'%(subscript,subscript,coupling),'l') ''' if not BLIND: findIntersect1D(graphObs, graphXsec, xaxis[0], xaxis[-1]) findIntersect1D(graphCent, graphXsec, xaxis[0], xaxis[-1]) leg.Draw() label = TLatex() label.SetNDC() label.SetTextSize(0.8 * c.GetTopMargin()) label.SetTextFont(62) label.SetTextAlign(11) label.DrawLatex(0.15, 0.94, "CMS") label.SetTextFont(52) label.SetTextSize(0.6 * c.GetTopMargin()) # label.DrawLatex(0.25,0.94,"Preliminary") label.SetTextFont(42) label.SetTextSize(0.7 * c.GetTopMargin()) label.DrawLatex(0.19, 0.83, plottitle) if 'Resonant' in plottitle: label.DrawLatex(0.19, 0.75, "a_{SR} = b_{SR} = %s" % coupling) label.DrawLatex(0.19, 0.68, "m_{#chi}=100 GeV") else: label.DrawLatex(0.19, 0.75, "g_{DM}^{V}=1,g_{q}^{V}=0.25") label.DrawLatex(0.19, 0.68, "m_{#chi}=1 GeV") label.SetTextSize(0.6 * c.GetTopMargin()) label.SetTextFont(42) label.SetTextAlign(31) # align right label.DrawLatex(0.95, 0.94, "%.1f fb^{-1} (13 TeV)" % (plotConfig.lumi)) c.SaveAs(foutname + '.pdf') c.SaveAs(foutname + '.png')
ey_hi_ratio = 0.0 else: ey_hi_ratio = y_ratio * math.hypot(ey_hi_mu / y_mu, ey_hi_ele / y_ele) grRatio.SetPoint(i, x, y_ratio) grRatio.SetPointEXlow(i, ex_lo) grRatio.SetPointEXhigh(i, ex_hi) grRatio.SetPointEYlow(i, ey_lo_ratio) grRatio.SetPointEYhigh(i, ey_hi_ratio) if True: grRatio.SetMarkerStyle(20) grRatio.SetMarkerSize(1.5) grRatio.SetMarkerColor(1) grRatio.SetLineStyle(1) grRatio.SetLineColor(1) grRatio.SetLineWidth(1) grRatio.GetXaxis().SetLabelSize(0.04) grRatio.GetXaxis().SetTitleSize(0.04) grRatio.GetXaxis().SetTitleOffset(1.25) grRatio.GetYaxis().SetLabelSize(0.04) grRatio.GetYaxis().SetTitleSize(0.04) grRatio.GetYaxis().SetTitleOffset(1.5) # grRatio.GetYaxis().SetRangeUser(ylo, yhi) grRatio.Draw("ALP") fOutput = TFile('durp.root', 'recreate')
extrapol_rate /= 1000 gr_extrapol.SetPoint(i, pu, extrapol_rate) gr_denom.SetMarkerStyle(20) gr_denom.SetMarkerSize(1.4) gr_denom.SetMarkerColor(632) # kRed gr_denom.SetLineWidth(2) gr_denom.SetLineColor(632) # kRed gr_numer.SetMarkerStyle(20) gr_numer.SetMarkerSize(1.4) gr_numer.SetMarkerColor(600) # kBlue gr_numer.SetLineWidth(2) gr_numer.SetLineColor(600) # kBlue gr_extrapol.SetLineStyle(7) gr_extrapol.SetLineWidth(1) gr_extrapol.SetLineColor(920) # kGray frame = TH1F("frame", "; PU; Trigger rate [kHz]", 100, 0, 350) frame.SetMinimum(0) frame.SetMaximum(100) frame.Draw() gr_denom.Draw("P") gr_numer.Draw("P") gr_extrapol.Draw("C") for i, x in enumerate(rates): pu, emtf_rate, emtf_rate_err, emtf2026_rate, emtf2026_rate_err = x tlatex.DrawLatex(pu - 3, emtf_rate + 4, "%.1f" % emtf_rate)
def limit(): method = '' channel = "bb" if INCLUDEACC: particleP = "X" else: particleP = "Z'" particle = 'b#bar{b}' multF = ZPTOBB THEORY = ['A1', 'B3'] if INCLUDEACC: THEORY.append('SSM') suffix = "_"+BTAGGING if ISMC: suffix += "_MC" if SY: suffix += "_comb" #if method=="cls": suffix="_CLs" if INCLUDEACC: suffix+="_acc" if SY: filename = "./combine/limits/" + BTAGGING + "/combined_run2/"+ YEAR + "_M%d.txt" else: filename = "./combine/limits/" + BTAGGING + "/"+ YEAR + "_M%d.txt" if CATEGORY!="": if SY: filename = filename.replace(BTAGGING + "/combined_run2/", BTAGGING + "/single_category/combined_run2/"+CATEGORY+"_") else: filename = filename.replace(BTAGGING + "/", BTAGGING + "/single_category/"+CATEGORY+"_") suffix += "_"+CATEGORY if ISMC: filename = filename.replace(".txt", "_MC.txt") mass, val = fillValues(filename) #print "mass =",mass #print "val =", val Obs0s = TGraph() Exp0s = TGraph() Exp1s = TGraphAsymmErrors() Exp2s = TGraphAsymmErrors() Sign = TGraph() pVal = TGraph() Best = TGraphAsymmErrors() Theory = {} for i, m in enumerate(mass): if not m in val: print "Key Error:", m, "not in value map" continue if INCLUDEACC: acc_factor = ACCEPTANCE[m] else: acc_factor = 1. n = Exp0s.GetN() Obs0s.SetPoint(n, m, val[m][0]*multF*acc_factor) Exp0s.SetPoint(n, m, val[m][3]*multF*acc_factor) Exp1s.SetPoint(n, m, val[m][3]*multF*acc_factor) Exp1s.SetPointError(n, 0., 0., (val[m][3]-val[m][2])*multF*acc_factor, (val[m][4]-val[m][3])*multF*acc_factor) Exp2s.SetPoint(n, m, val[m][3]*multF*acc_factor) Exp2s.SetPointError(n, 0., 0., (val[m][3]-val[m][1])*multF*acc_factor, (val[m][5]-val[m][3])*multF*acc_factor) if len(val[m]) > 6: Sign.SetPoint(n, m, val[m][6]) if len(val[m]) > 7: pVal.SetPoint(n, m, val[m][7]) if len(val[m]) > 8: Best.SetPoint(n, m, val[m][8]) if len(val[m]) > 10: Best.SetPointError(n, 0., 0., abs(val[m][9]), val[m][10]) for t in THEORY: Theory[t] = TGraphAsymmErrors() Xs_dict = HVT[t]['Z']['XS'] if t!='SSM' else SSM['Z'] for m in sorted(Xs_dict.keys()): if INCLUDEACC and t!='SSM': acc_factor = ACCEPTANCE[m] else: acc_factor = 1. if m < SIGNALS[0] or m > SIGNALS[-1]: continue #if m < mass[0] or m > mass[-1]: continue #if t!= 'SSM' and m>4500: continue ## I don't have the higher mass xs if m>4500: continue XsZ, XsZ_Up, XsZ_Down = 0., 0., 0. if t!='SSM': XsZ = 1000.*HVT[t]['Z']['XS'][m]*SSM["BrZ"][m] #assuming the same BR as the SSM Z' one XsZ_Up = XsZ*(1.+math.hypot(HVT[t]['Z']['QCD'][m][0]-1., HVT[t]['Z']['PDF'][m][0]-1.)) XsZ_Down = XsZ*(1.-math.hypot(1.-HVT[t]['Z']['QCD'][m][0], 1.-HVT[t]['Z']['PDF'][m][0])) else: XsZ = 1000.*SSM['Z'][m]*SSM["BrZ"][m] XsZ_Up = XsZ*(1.+math.hypot(HVT['A1']['Z']['QCD'][m][0]-1., HVT['A1']['Z']['PDF'][m][0]-1.)) XsZ_Down = XsZ*(1.-math.hypot(1.-HVT['A1']['Z']['QCD'][m][0], 1.-HVT['A1']['Z']['PDF'][m][0])) n = Theory[t].GetN() Theory[t].SetPoint(n, m, XsZ*acc_factor) Theory[t].SetPointError(n, 0., 0., (XsZ-XsZ_Down)*acc_factor, (XsZ_Up-XsZ)*acc_factor) Theory[t].SetLineColor(theoryLineColor[t]) Theory[t].SetFillColor(theoryFillColor[t]) Theory[t].SetFillStyle(theoryFillStyle[t]) Theory[t].SetLineWidth(2) #Theory[t].SetLineStyle(7) Exp2s.SetLineWidth(2) Exp2s.SetLineStyle(1) Obs0s.SetLineWidth(3) Obs0s.SetMarkerStyle(0) Obs0s.SetLineColor(1) Exp0s.SetLineStyle(2) Exp0s.SetLineWidth(3) Exp1s.SetFillColor(417) #kGreen+1 Exp1s.SetLineColor(417) #kGreen+1 Exp2s.SetFillColor(800) #kOrange Exp2s.SetLineColor(800) #kOrange Exp2s.GetXaxis().SetTitle("m_{"+particleP+"} (GeV)") Exp2s.GetXaxis().SetTitleSize(Exp2s.GetXaxis().GetTitleSize()*1.25) Exp2s.GetXaxis().SetNoExponent(True) Exp2s.GetXaxis().SetMoreLogLabels(True) Exp2s.GetYaxis().SetTitle("#sigma("+particleP+") #bf{#it{#Beta}}("+particleP+" #rightarrow "+particle+"){} (fb)".format(" #times #Alpha" if INCLUDEACC else "")) Exp2s.GetYaxis().SetTitleOffset(1.5) Exp2s.GetYaxis().SetNoExponent(True) Exp2s.GetYaxis().SetMoreLogLabels() Sign.SetLineWidth(2) Sign.SetLineColor(629) Sign.GetXaxis().SetTitle("m_{"+particleP+"} (GeV)") Sign.GetXaxis().SetTitleSize(Sign.GetXaxis().GetTitleSize()*1.1) Sign.GetYaxis().SetTitle("Significance") pVal.SetLineWidth(2) pVal.SetLineColor(629) pVal.GetXaxis().SetTitle("m_{"+particleP+"} (GeV)") pVal.GetXaxis().SetTitleSize(pVal.GetXaxis().GetTitleSize()*1.1) pVal.GetYaxis().SetTitle("local p-Value") Best.SetLineWidth(2) Best.SetLineColor(629) Best.SetFillColor(629) Best.SetFillStyle(3003) Best.GetXaxis().SetTitle("m_{"+particleP+"} (GeV)") Best.GetXaxis().SetTitleSize(Best.GetXaxis().GetTitleSize()*1.1) Best.GetYaxis().SetTitle("Best Fit (pb)") c1 = TCanvas("c1", "Exclusion Limits", 800, 600) c1.cd() #SetPad(c1.GetPad(0)) c1.GetPad(0).SetTopMargin(0.06) c1.GetPad(0).SetRightMargin(0.05) c1.GetPad(0).SetLeftMargin(0.12) c1.GetPad(0).SetTicks(1, 1) #c1.GetPad(0).SetGridx() #c1.GetPad(0).SetGridy() c1.GetPad(0).SetLogy() Exp2s.Draw("A3") Exp1s.Draw("SAME, 3") for t in THEORY: Theory[t].Draw("SAME, L3") Theory[t].Draw("SAME, L3X0Y0") Exp0s.Draw("SAME, L") if not options.blind: Obs0s.Draw("SAME, L") #setHistStyle(Exp2s) Exp2s.GetXaxis().SetTitleSize(0.050) Exp2s.GetYaxis().SetTitleSize(0.050) Exp2s.GetXaxis().SetLabelSize(0.045) Exp2s.GetYaxis().SetLabelSize(0.045) Exp2s.GetXaxis().SetTitleOffset(0.90) Exp2s.GetYaxis().SetTitleOffset(1.25) Exp2s.GetYaxis().SetMoreLogLabels(True) Exp2s.GetYaxis().SetNoExponent(True) if INCLUDEACC: Exp2s.GetYaxis().SetRangeUser(0.05, 5.e3) else: Exp2s.GetYaxis().SetRangeUser(0.1, 5.e3) #else: Exp2s.GetYaxis().SetRangeUser(0.1, 1.e2) #Exp2s.GetXaxis().SetRangeUser(mass[0], min(mass[-1], MAXIMUM[channel] if channel in MAXIMUM else 1.e6)) Exp2s.GetXaxis().SetRangeUser(SIGNALS[0], SIGNALS[-1]) #drawAnalysis(channel) drawAnalysis("") #drawRegion(channel, True) drawRegion("", True) #drawCMS(LUMI, "Simulation Preliminary") #Preliminary if CATEGORY=="": #drawCMS(LUMI, "Work in Progress", suppressCMS=True) drawCMS(LUMI, "", suppressCMS=True) else: #drawCMS(LUMI, "Work in Progress, "+CAT_LABELS[CATEGORY], suppressCMS=True) drawCMS(LUMI, CAT_LABELS[CATEGORY], suppressCMS=True) # legend top = 0.9 nitems = 4 + len(THEORY) leg = TLegend(0.55, top-nitems*0.3/5., 0.98, top) #leg = TLegend(0.45, top-nitems*0.3/5., 0.98, top) leg.SetBorderSize(0) leg.SetFillStyle(0) #1001 leg.SetFillColor(0) leg.SetHeader("95% CL upper limits") leg.AddEntry(Obs0s, "Observed", "l") leg.AddEntry(Exp0s, "Expected", "l") leg.AddEntry(Exp1s, "#pm 1 std. deviation", "f") leg.AddEntry(Exp2s, "#pm 2 std. deviation", "f") for t in THEORY: leg.AddEntry(Theory[t], theoryLabel[t], "fl") leg.Draw() latex = TLatex() latex.SetNDC() latex.SetTextSize(0.045) latex.SetTextFont(42) #latex.DrawLatex(0.66, leg.GetY1()-0.045, particleP+" #rightarrow "+particle+"h") leg2 = TLegend(0.12, 0.225-2*0.25/5., 0.65, 0.225) leg2.SetBorderSize(0) leg2.SetFillStyle(0) #1001 leg2.SetFillColor(0) c1.GetPad(0).RedrawAxis() leg2.Draw() if not options.blind: Obs0s.Draw("SAME, L") c1.GetPad(0).Update() if not gROOT.IsBatch(): raw_input("Press Enter to continue...") c1.Print("combine/plotsLimit/ExclusionLimits/"+YEAR+suffix+".png") c1.Print("combine/plotsLimit/ExclusionLimits/"+YEAR+suffix+".pdf") if 'ah' in channel or 'sl' in channel: c1.Print("combine/plotsLimit/ExclusionLimits/"+YEAR+suffix+".C") c1.Print("combine/plotsLimit/ExclusionLimits/"+YEAR+suffix+".root") for t in THEORY: print "Model", t, ":", for m in range(mass[0], mass[-1], 1): if not (Theory[t].Eval(m) > Obs0s.Eval(m)) == (Theory[t].Eval(m+1) > Obs0s.Eval(m+1)): print m, print "" return ##FIXME # ---------- Significance ---------- c2 = TCanvas("c2", "Significance", 800, 600) c2.cd() c2.GetPad(0).SetTopMargin(0.06) c2.GetPad(0).SetRightMargin(0.05) c2.GetPad(0).SetTicks(1, 1) c2.GetPad(0).SetGridx() c2.GetPad(0).SetGridy() Sign.GetYaxis().SetRangeUser(0., 5.) Sign.Draw("AL3") #drawCMS(LUMI, "Preliminary") drawCMS(LUMI, "Work in Progress", suppressCMS=True) drawAnalysis(channel[1:3]) c2.Print("combine/plotsLimit/Significance/"+YEAR+suffix+".png") c2.Print("combine/plotsLimit/Significance/"+YEAR+suffix+".pdf") # c2.Print("plotsLimit/Significance/"+YEAR+suffix+".root") # c2.Print("plotsLimit/Significance/"+YEAR+suffix+".C") # ---------- p-Value ---------- c3 = TCanvas("c3", "p-Value", 800, 600) c3.cd() c3.GetPad(0).SetTopMargin(0.06) c3.GetPad(0).SetRightMargin(0.05) c3.GetPad(0).SetTicks(1, 1) c3.GetPad(0).SetGridx() c3.GetPad(0).SetGridy() c3.GetPad(0).SetLogy() pVal.Draw("AL3") pVal.GetYaxis().SetRangeUser(2.e-7, 0.5) ci = [1., 0.317310508, 0.045500264, 0.002699796, 0.00006334, 0.000000573303, 0.000000001973] line = TLine() line.SetLineColor(922) line.SetLineStyle(7) text = TLatex() text.SetTextColor(922) text.SetTextSize(0.025) text.SetTextAlign(12) for i in range(1, len(ci)-1): line.DrawLine(pVal.GetXaxis().GetXmin(), ci[i]/2, pVal.GetXaxis().GetXmax(), ci[i]/2); text.DrawLatex(pVal.GetXaxis().GetXmax()*1.01, ci[i]/2, "%d #sigma" % i); #drawCMS(LUMI, "Preliminary") drawCMS(LUMI, "Work in Progress", suppressCMS=True) drawAnalysis(channel[1:3]) c3.Print("combine/plotsLimit/pValue/"+YEAR+suffix+".png") c3.Print("combine/plotsLimit/pValue/"+YEAR+suffix+".pdf") # c3.Print("plotsLimit/pValue/"+YEAR+suffix+".root") # c3.Print("plotsLimit/pValue/"+YEAR+suffix+".C") # --------- Best Fit ---------- c4 = TCanvas("c4", "Best Fit", 800, 600) c4.cd() c4.GetPad(0).SetTopMargin(0.06) c4.GetPad(0).SetRightMargin(0.05) c4.GetPad(0).SetTicks(1, 1) c4.GetPad(0).SetGridx() c4.GetPad(0).SetGridy() Best.Draw("AL3") #drawCMS(LUMI, "Preliminary") drawCMS(LUMI, "Work in Progress", suppressCMS=True) drawAnalysis(channel[1:3]) c4.Print("combine/plotsLimit/BestFit/"+YEAR+suffix+".png") c4.Print("combine/plotsLimit/BestFit/"+YEAR+suffix+".pdf") # c4.Print("plotsLimit/BestFit/"+YEAR+suffix+".root") # c4.Print("plotsLimit/BestFit/"+YEAR+suffix+".C") if not gROOT.IsBatch(): raw_input("Press Enter to continue...") if 'ah' in channel: outFile = TFile("bands.root", "RECREATE") outFile.cd() pVal.Write("graph") Best.Write("best") outFile.Close()
def main(): # usage description usage = "Example: ./scripts/plotSignificance.py -l logs -f qq --massrange 1200 6000 100" # input parameters parser = ArgumentParser(description='Script that plots significance for specified mass points',epilog=usage) parser.add_argument("-M", "--method", dest="method", choices=['MaxLikelihoodFit'], default='MaxLikelihoodFit', help="Method to calculate upper limits", metavar="METHOD") results_group = parser.add_mutually_exclusive_group(required=True) results_group.add_argument("-l", "--logs_path", dest="logs_path", help="Path to log files", metavar="LOGS_PATH") results_group.add_argument("-r", "--results_file", dest="results_file", help="Path to a file containing results", metavar="RESULTS_FILE") parser.add_argument("-f", "--final_state", dest="final_state", required=True, help="Final state (e.g. qq, qg, gg)", metavar="FINAL_STATE") parser.add_argument("--postfix", dest="postfix", default='', help="Postfix for the output plot name (default: %(default)s)") parser.add_argument("--fileFormat", dest="fileFormat", default='pdf', help="Format of the output plot (default: %(default)s)") parser.add_argument("--extraText", dest="extraText", default='Simulation Preliminary', help="Extra text on the plot (default: %(default)s)") parser.add_argument("--lumi_sqrtS", dest="lumi_sqrtS", default='1 fb^{-1} (13 TeV)', help="Integrated luminosity and center-of-mass energy (default: %(default)s)") parser.add_argument("--printResults", dest="printResults", default=False, action="store_true", help="Print results to the screen") mass_group = parser.add_mutually_exclusive_group(required=True) mass_group.add_argument("--mass", type=int, nargs = '*', default = 1000, help="Mass can be specified as a single value or a whitespace separated list (default: %(default)i)" ) mass_group.add_argument("--massrange", type=int, nargs = 3, help="Define a range of masses to be produced. Format: min max step", metavar = ('MIN', 'MAX', 'STEP') ) mass_group.add_argument("--masslist", help = "List containing mass information" ) args = parser.parse_args() # mass points for which resonance shapes will be produced input_masses = [] if args.massrange != None: MIN, MAX, STEP = args.massrange input_masses = range(MIN, MAX+STEP, STEP) elif args.masslist != None: # A mass list was provided print "Will create mass list according to", args.masslist masslist = __import__(args.masslist.replace(".py","")) input_masses = masslist.masses else: input_masses = args.mass # sort masses input_masses.sort() # arrays holding results masses = array('d') sig = array('d') sig_ex = array('d') sig_eyl = array('d') sig_eyh = array('d') if args.logs_path != None: logs_path = os.path.join(os.getcwd(),args.logs_path) for mass in input_masses: print ">> Reading results for %s resonance with m = %i GeV..."%(args.final_state, int(mass)) masses.append(mass) logName = 'signal_xs_%s_%s_m%i.log'%(args.method,args.final_state,int(mass)) log_file = open(os.path.join(logs_path,logName),'r') # read the log file for line in log_file: if re.search("^Best fit r:", line): sig.append(float(line.split()[3])) sig_eyl.append(float(line.split()[4].split('/')[0].lstrip('-'))) sig_eyh.append(float(line.split()[4].split('/')[1].lstrip('+'))) sig_ex.append(0.) if len(masses) != len(sig): print "** WARNING: ** Fit failed for m =", int(mass), "GeV. Setting signal cross section to 0." sig.append(0.) sig_eyl.append(0.) sig_eyh.append(0.) else: print ">> Importing results..." sys.path.insert(0, os.path.dirname(args.results_file)) results = __import__(os.path.basename(args.results_file).replace(".py","")) all_masses = np.array(results.masses) indices = [] # search for indices of input_masses for mass in input_masses: where = np.where(all_masses==mass)[0] if len(where) == 0: print "** WARNING: ** Cannot find results for m =", int(mass), "GeV in the provided results file. Skipping this mass point." indices.extend( where ) # sort indices indices.sort() for i in indices: masses.append( results.masses[i] ) sig.append( results.sig[i] ) sig_ex.append( results.sig_ex[i] ) sig_eyl.append( results.sig_eyl[i] ) sig_eyh.append( results.sig_eyh[i] ) if args.printResults: print "masses =", masses.tolist() print "sig =", sig.tolist() print "sig_ex =", sig_ex.tolist() print "sig_eyl =", sig_eyl.tolist() print "sig_eyh =", sig_eyh.tolist() # create final arrays sig_pos = array('d') sig_exl = array('d') sig_exh = array('d') # fill final arrays for i in range(0,len(masses)): sig_pos.append(sig[i] if sig[i]>0. else 0.) sig_exl.append(sig_ex[i]) sig_exh.append(sig_ex[i]) sig_eyl.append(sig_eyl[i] if sig[i]>0. else 0.) sig_eyh.append(sig_eyh[i]) # import ROOT stuff from ROOT import kTRUE, kFALSE, gROOT, gStyle, gPad, TGraphAsymmErrors, TCanvas, TLegend from ROOT import kGreen, kYellow, kWhite, kRed, kBlue gROOT.SetBatch(kTRUE); gStyle.SetOptStat(0) gStyle.SetOptTitle(0) gStyle.SetTitleFont(42, "XYZ") gStyle.SetTitleSize(0.06, "XYZ") gStyle.SetLabelFont(42, "XYZ") gStyle.SetLabelSize(0.05, "XYZ") gStyle.SetCanvasBorderMode(0) gStyle.SetFrameBorderMode(0) gStyle.SetCanvasColor(kWhite) gStyle.SetPadTickX(1) gStyle.SetPadTickY(1) gStyle.SetPadLeftMargin(0.15) gStyle.SetPadRightMargin(0.05) gStyle.SetPadTopMargin(0.05) gStyle.SetPadBottomMargin(0.15) gROOT.ForceStyle() graph_sig = TGraphAsymmErrors(len(masses),masses,sig_pos,sig_exl,sig_exh,sig_eyl,sig_eyh) graph_sig.GetXaxis().SetTitle("%s resonance mass [GeV]"%(args.final_state)) graph_sig.GetYaxis().SetTitle("Signal cross section [pb]") graph_sig.GetYaxis().SetTitleOffset(1.2) graph_sig.GetYaxis().SetRangeUser(1e-4,2e2) graph_sig.SetMarkerStyle(20) graph_sig.SetMarkerColor(1) graph_sig.SetLineWidth(2) graph_sig.SetLineStyle(1) graph_sig.SetLineColor(1) c = TCanvas("c", "",800,800) c.cd() graph_sig.Draw("AP") # draw the lumi text on the canvas CMS_lumi.extraText = args.extraText CMS_lumi.lumi_sqrtS = args.lumi_sqrtS # used with iPeriod = 0 (free form) iPos = 11 iPeriod = 0 CMS_lumi.CMS_lumi(c, iPeriod, iPos) gPad.RedrawAxis() c.SetLogy() c.SetGridx() c.SetGridy() fileName = 'signal_xs_%s_%s.%s'%(args.method,args.final_state + ( ('_' + args.postfix) if args.postfix != '' else '' ), args.fileFormat.lower()) c.SaveAs(fileName) print "Plot saved to '%s'"%(fileName)
def plotMCEffs(input_list, plot_name='fakerate.pdf'): '''input_list expects tuples with structure: (hist tight, hist loose, legend line, colour) ''' graphs = [] for (hist_tight, hist_loose, legend, colour, style) in input_list: g = TGraphAsymmErrors(hist_tight) g.Divide(hist_tight, hist_loose) g.GetYaxis().SetTitle('Misidentification rate') g.GetXaxis().SetTitle(hist_tight.GetXaxis().GetTitle()) g.GetYaxis().SetTitleOffset(1.2) g.GetYaxis().SetTitleOffset(1.3) g.SetLineColor(colour) g.SetLineStyle(style) g.SetMarkerColor(colour) g.SetMarkerStyle(19+style) g.legend = legend graphs.append(g) ratio_graphs = [] base_graph = graphs[0] for graph in graphs[1:]: g_vals = base_graph.GetY() g_data_vals = graph.GetY() g_ratio = graph.Clone('ratio') for i in xrange(graph.GetN()): ratio = g_data_vals[i]/g_vals[i] if g_vals[i] else 0. g_ratio.SetPoint(i, base_graph.GetX()[i], ratio) rel_y_low = math.sqrt((graph.GetErrorYlow(i)/g_data_vals[i])**2 + (base_graph.GetErrorYlow(i)/g_vals[i])**2) if g_data_vals[i] > 0.0000001 and g_vals[i] > 0.0000001 else 0. g_ratio.SetPointEYlow(i, rel_y_low * ratio) rel_y_high = math.sqrt((graph.GetErrorYhigh(i)/g_data_vals[i])**2 + (base_graph.GetErrorYhigh(i)/g_vals[i])**2) if g_data_vals[i] > 0.0000001 and g_vals[i] > 0.0000001 else 0. g_ratio.SetPointEYhigh(i, rel_y_high * ratio) ratio_graphs.append(g_ratio) # Gymnastics to get same label sizes etc in ratio and main plot ytp_ratio = 2. xtp_ratio = 2. # hr.GetYaxis().SetNdivisions(4) for g_ratio in ratio_graphs: g_ratio.GetYaxis().SetTitleSize(g.GetYaxis().GetTitleSize() * xtp_ratio) g_ratio.GetXaxis().SetTitleSize(g.GetXaxis().GetTitleSize() * ytp_ratio) g_ratio.GetYaxis().SetTitleOffset(g.GetYaxis().GetTitleOffset() / xtp_ratio) g_ratio.GetXaxis().SetTitleOffset(g.GetXaxis().GetTitleOffset()) # / ytp_ratio) g_ratio.GetYaxis().SetLabelSize(g.GetYaxis().GetLabelSize() * xtp_ratio) g_ratio.GetXaxis().SetLabelSize(g.GetXaxis().GetLabelSize() * ytp_ratio) g_ratio.GetXaxis().SetTitle(base_graph.GetXaxis().GetTitle()) for graph in graphs: graph.GetXaxis().SetLabelColor(0) graph.GetXaxis().SetLabelSize(0) maxy = 1.3 * max([gr.GetMaximum() for gr in graphs] + [1./1.25]) for g in graphs: g.GetYaxis().SetRangeUser(0.0011, maxy) cv, pad, padr = HistDrawer.buildCanvas() pad.cd() base_graph.Draw('AP') for graph in graphs[1:]: graph.Draw('P') legend = TLegend(0.63, 0.63, 0.93, 0.91) legend.SetFillColor(0) legend.SetFillStyle(0) legend.SetLineColor(0) legend.SetLineWidth(0) legend2 = TLegend(0.78, 0.63, 0.93, 0.91) legend2.SetFillColor(0) legend2.SetFillStyle(0) legend2.SetLineColor(0) legend2.SetLineWidth(0) for graph in graphs: if 'opp' in graph.legend: legend2.AddEntry(graph.GetName(), graph.legend, 'lep') else: legend.AddEntry(graph.GetName(), graph.legend, 'lep') legend.Draw() legend2.Draw() padr.cd() for g_ratio in ratio_graphs: g_ratio.GetYaxis().SetRangeUser(0.01, 1.99) g_ratio.GetYaxis().SetTitle('Ratio to '+base_graph.legend) g_ratio.Draw('AP' if g_ratio == ratio_graphs[0] else 'P') drawRatioLines(g_ratio) cv.Print(plot_name) g.GetYaxis().SetRangeUser(0.0001, 1) pad.SetLogy(True) cv.Print(plot_name.replace('.', '_log.')) f = ROOT.TFile(plot_name.replace('.', '_log.').replace('.pdf', '.root'), 'RECREATE') g.Write() # g_data.Write() cv.Write() f.Close()
graph_HV_L1 = TGraphAsymmErrors() n = 0 for a in sorted(HV_scan_L1): #for a in sorted(run_parameters): ##Fill the TGraph with threshold (x-axis) and rate (y-axis) #######graph.SetPoint(n,int(run_parameters[a]['VTHR']),float(run_parameters[a]['RATE_SL1_L1'])) graph_HV_L1.SetPoint(n, int(a), float(HV_scan_L1[a])) n = n + 1 graph_HV_L1.SetMarkerSize(1.) graph_HV_L1.SetMarkerStyle(21) graph_HV_L1.SetMarkerColor(418) graph_HV_L1.SetFillColor(868) graph_HV_L1.SetFillStyle(3844) graph_HV_L1.SetLineColor(418 - 1) graph_HV_L1.SetLineWidth(2) graph_HV_L1.SetLineStyle(2) graph_HV_L1.GetXaxis().SetTitle("HV [V]") graph_HV_L1.GetYaxis().SetTitleOffset(1.2) graph_HV_L1.GetYaxis().SetTitle("efficiency") graph_HV_L1.GetYaxis().SetRangeUser(0, 1.01) graph_HV_L1.Draw("APL") latex = TLatex() latex.SetNDC() latex.SetTextSize(0.04) latex.SetTextColor(1) latex.SetTextFont(42) latex.SetTextAlign(33) latex.SetTextSize(0.04) latex.SetTextFont(62) latex.DrawLatex(0.30, 0.96, "GIF++") etichetta = TLatex()
def PlotLimits(Type): theory_x = array('d', [ 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1900, 2100, 2300, 2500 ]) if Type == 'Right': theory_y = array('d', [ 1.2 * 1.6997, 1.2 * 0.97609, 1.2 * 0.58782, 1.2 * 0.36266, 1.2 * 0.22815, 1.2 * 0.14584, 1.2 * 0.09445, 1.2 * 0.06195, 1.2 * 0.04102, 1.2 * 0.027453, 1.2 * 0.012585, 1.2 * 0.005984, 1.2 * 0.0029719, 1.2 * 0.0015585 ]) theory_xv = TVectorD(len(theory_x), theory_x) theory_yv = TVectorD(len(theory_y), theory_y) theory = TGraph(theory_xv, theory_yv) theory.SetLineColor(2) theory.SetLineWidth(2) Nentries = Trees[Type].GetEntriesFast() mass = array('d', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) exp = array('d', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) obs = array('d', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) exp68H = array('d', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) exp68L = array('d', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) exp95H = array('d', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) exp95L = array('d', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) masserr = array('d', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) obserr = array('d', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) experr = array('d', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) m = 0 for entry in xrange(Nentries): Trees[Type].GetEntry(entry) thismass = Trees[Type].mh thisquantile = Trees[Type].quantileExpected thislimit = Trees[Type].limit thislimiterr = Trees[Type].limitErr if thismass == 800.0: i = 0 elif thismass == 900.0: i = 1 elif thismass == 1000.0: i = 2 elif thismass == 1100.0: i = 3 elif thismass == 1200.0: i = 4 elif thismass == 1300.0: i = 5 elif thismass == 1400.0: i = 6 elif thismass == 1500.0: i = 7 elif thismass == 1600.0: i = 8 elif thismass == 1700.0: i = 9 elif thismass == 1900.0: i = 10 elif thismass == 2100.0: i = 11 elif thismass == 2300.0: i = 12 elif thismass == 2500.0: i = 13 #if thismass < 1000: continue if (abs(thisquantile + 1.000) < 0.01): mass[i] = thismass obs[i] = thislimit obserr[i] = 0 masserr[i] = 0 elif (abs(thisquantile - 0.025) < 0.01): exp95L[i] = thislimit print '95L ', thislimit elif (abs(thisquantile - 0.160) < 0.01): exp68L[i] = thislimit elif (abs(thisquantile - 0.500) < 0.01): exp[i] = thislimit experr[i] = thislimiterr elif (abs(thisquantile - 0.840) < 0.01): exp68H[i] = thislimit elif (abs(thisquantile - 0.975) < 0.01): exp95H[i] = thislimit print str(thismass) + ' ' + str(thisquantile) + ' ' + str(thislimit) print 'exp95L', exp95L print 'exp95H', exp95H print 'exp68L', exp68L print 'exp68H', exp68H massv = TVectorD(len(mass), mass) expv = TVectorD(len(mass), exp) obsv = TVectorD(len(mass), obs) exp68Hv = TVectorD(len(mass), exp68H) exp68Lv = TVectorD(len(mass), exp68L) exp95Hv = TVectorD(len(mass), exp95H) exp95Lv = TVectorD(len(mass), exp95L) #exp95Lv = TVectorD(len(mass),exp68L) masserrv = TVectorD(len(mass), masserr) obserrv = TVectorD(len(mass), obserr) experrv = TVectorD(len(mass), experr) observed = TGraphAsymmErrors(massv, obsv, masserrv, masserrv, obserrv, obserrv) observed.SetLineColor(ROOT.kBlack) observed.SetLineWidth(2) observed.SetMarkerStyle(20) expected = TGraphAsymmErrors(massv, expv, masserrv, masserrv, experrv, experrv) expected.SetLineColor(ROOT.kBlack) expected.SetLineWidth(2) expected.SetLineStyle(2) ## I'm confused, somehow this is the way that works expected68 = TGraphAsymmErrors(massv, expv, masserrv, masserrv, exp95Lv, exp68Hv) #expected68 = TGraphAsymmErrors(massv,expv,masserrv,masserrv,exp68Lv,exp68Hv) expected68.SetFillColor(ROOT.kGreen) expected95 = TGraphAsymmErrors(massv, expv, masserrv, masserrv, exp68Lv, exp95Hv) #expected95 = TGraphAsymmErrors(massv,expv,masserrv,masserrv,exp95Lv,exp95Hv) expected95.SetFillColor(ROOT.kYellow) c4 = TCanvas("c4", "W' tb Limits", 1000, 800) c4.SetBottomMargin(0.15) c4.SetRightMargin(0.06) expected95.Draw("a3") expected95.GetXaxis().SetTitle("W'_{" + Type + "} mass [GeV/c^{2}]") expected95.GetYaxis().SetTitle("#sigma(pp#rightarrowW/W'_{" + str(Type) + "}#rightarrowtb) [pb]") expected68.Draw("3same") expected.Draw("csame") observed.Draw("cpsame") theory.Draw("csame") latex = TLatex() latex.SetNDC() latex.SetTextSize(0.04) latex.SetTextAlign(31) # align right latex.DrawLatex(0.45, 0.95, "CMS Preliminary") latex2 = TLatex() latex2.SetNDC() latex2.SetTextSize(0.04) latex2.SetTextAlign(31) # align right latex2.DrawLatex(0.87, 0.95, str(lumiPlot) + " fb^{-1} at #sqrt{s} = 7 TeV") latex4 = TLatex() latex4.SetNDC() latex4.SetTextSize(0.04) latex4.SetTextAlign(31) # align right latex4.DrawLatex(0.80, 0.87, "e+jets N_{b tags} #geq 1 ") legend = TLegend(.566, .684, .84, .84) legend.AddEntry(observed, '95% C.L. Observed', "lp") legend.AddEntry(expected, '95% C.L. Expected', "l") legend.AddEntry(expected68, '#pm 1#sigma Expected', "f") legend.AddEntry(expected95, '#pm 2#sigma Expected', "f") legend.SetShadowColor(0) legend.SetFillColor(0) legend.SetLineColor(0) legend.Draw() c4.SaveAs('Wprime_' + Type + '_Limits.root') c4.SaveAs('Wprime_' + Type + '_Limits.png')
def limit(method, channel): particle = channel[1:2] particleP = particle + "'" if channel.startswith('X') else channel[0] THEORY = ['A1', 'B3'] if channel.startswith('X') else [] suffix = "" if method == "hvt": suffix = "_HVT" if method == "cls": suffix = "_CLs" if method == "monoH": suffix = "_monoH" filename = "./combine/" + method + "/" + channel + "_M%d.txt" mass, val = fillValues(filename) Obs0s = TGraph() Exp0s = TGraph() Exp1s = TGraphAsymmErrors() Exp2s = TGraphAsymmErrors() Sign = TGraph() pVal = TGraph() Best = TGraphAsymmErrors() Theory = {} for i, m in enumerate(mass): if not m in val: print "Key Error:", m, "not in value map" continue n = Exp0s.GetN() Obs0s.SetPoint(n, m, val[m][0]) Exp0s.SetPoint(n, m, val[m][3]) Exp1s.SetPoint(n, m, val[m][3]) Exp1s.SetPointError(n, 0., 0., val[m][3] - val[m][2], val[m][4] - val[m][3]) Exp2s.SetPoint(n, m, val[m][3]) Exp2s.SetPointError(n, 0., 0., val[m][3] - val[m][1], val[m][5] - val[m][3]) if len(val[m]) > 6: Sign.SetPoint(n, m, val[m][6]) if len(val[m]) > 7: pVal.SetPoint(n, m, val[m][7]) if len(val[m]) > 8: Best.SetPoint(n, m, val[m][8]) if len(val[m]) > 10: Best.SetPointError(n, 0., 0., abs(val[m][9]), val[m][10]) for t in THEORY: Theory[t] = TGraphAsymmErrors() for m in sorted(HVT[t]['Z']['XS'].keys()): if m < mass[0] or m > mass[-1]: continue XsW, XsW_Up, XsW_Down, XsZ, XsZ_Up, XsZ_Down = 0., 0., 0., 0., 0., 0. XsZ = 1000. * HVT[t]['Z']['XS'][m] * HVT[t]['Z']['BR'][m] XsZ_Up = XsZ * (1. + math.hypot(HVT[t]['Z']['QCD'][m][0] - 1., HVT[t]['Z']['PDF'][m][0] - 1.)) XsZ_Down = XsZ * (1. - math.hypot(1. - HVT[t]['Z']['QCD'][m][0], 1. - HVT[t]['Z']['PDF'][m][0])) n = Theory[t].GetN() Theory[t].SetPoint(n, m, XsW + XsZ) Theory[t].SetPointError(n, 0., 0., (XsW - XsW_Down) + (XsZ - XsZ_Down), (XsW_Up - XsW) + (XsZ_Up - XsZ)) Theory[t].SetLineColor(theoryLineColor[t]) Theory[t].SetFillColor(theoryFillColor[t]) Theory[t].SetFillStyle(theoryFillStyle[t]) Theory[t].SetLineWidth(2) #Theory[t].SetLineStyle(7) Exp2s.SetLineWidth(2) Exp2s.SetLineStyle(1) Obs0s.SetLineWidth(3) Obs0s.SetMarkerStyle(0) Obs0s.SetLineColor(1) Exp0s.SetLineStyle(2) Exp0s.SetLineWidth(3) Exp1s.SetFillColor(417) #kGreen+1 Exp1s.SetLineColor(417) #kGreen+1 Exp2s.SetFillColor(800) #kOrange Exp2s.SetLineColor(800) #kOrange Exp2s.GetXaxis().SetTitle("m_{" + particleP + "} (GeV)") Exp2s.GetXaxis().SetTitleSize(Exp2s.GetXaxis().GetTitleSize() * 1.25) Exp2s.GetXaxis().SetNoExponent(True) Exp2s.GetXaxis().SetMoreLogLabels(True) Exp2s.GetYaxis().SetTitle("#sigma(" + particleP + ") #bf{#it{#Beta}}(" + particleP + " #rightarrow " + particle + "h) (fb)") Exp2s.GetYaxis().SetTitleOffset(1.5) Exp2s.GetYaxis().SetNoExponent(True) Exp2s.GetYaxis().SetMoreLogLabels() Sign.SetLineWidth(2) Sign.SetLineColor(629) Sign.GetXaxis().SetTitle("m_{" + particleP + "} (GeV)") Sign.GetXaxis().SetTitleSize(Sign.GetXaxis().GetTitleSize() * 1.1) Sign.GetYaxis().SetTitle("Significance") pVal.SetLineWidth(2) pVal.SetLineColor(629) pVal.GetXaxis().SetTitle("m_{" + particleP + "} (GeV)") pVal.GetXaxis().SetTitleSize(pVal.GetXaxis().GetTitleSize() * 1.1) pVal.GetYaxis().SetTitle("local p-Value") Best.SetLineWidth(2) Best.SetLineColor(629) Best.SetFillColor(629) Best.SetFillStyle(3003) Best.GetXaxis().SetTitle("m_{" + particleP + "} (GeV)") Best.GetXaxis().SetTitleSize(Best.GetXaxis().GetTitleSize() * 1.1) Best.GetYaxis().SetTitle("Best Fit (pb)") c1 = TCanvas("c1", "Exclusion Limits", 800, 600) c1.cd() #SetPad(c1.GetPad(0)) c1.GetPad(0).SetTopMargin(0.06) c1.GetPad(0).SetRightMargin(0.05) c1.GetPad(0).SetLeftMargin(0.12) c1.GetPad(0).SetTicks(1, 1) #c1.GetPad(0).SetGridx() #c1.GetPad(0).SetGridy() c1.GetPad(0).SetLogy() Exp2s.Draw("A3") Exp1s.Draw("SAME, 3") for t in THEORY: Theory[t].Draw("SAME, L3") Theory[t].Draw("SAME, L3X0Y0") Exp0s.Draw("SAME, L") if not options.blind: Obs0s.Draw("SAME, L") #setHistStyle(Exp2s) Exp2s.GetXaxis().SetTitleSize(0.050) Exp2s.GetYaxis().SetTitleSize(0.050) Exp2s.GetXaxis().SetLabelSize(0.045) Exp2s.GetYaxis().SetLabelSize(0.045) Exp2s.GetXaxis().SetTitleOffset(0.90) Exp2s.GetYaxis().SetTitleOffset(1.25) Exp2s.GetYaxis().SetMoreLogLabels(True) Exp2s.GetYaxis().SetNoExponent(True) Exp2s.GetYaxis().SetRangeUser(0.01, 5.e3) #else: Exp2s.GetYaxis().SetRangeUser(0.1, 1.e2) Exp2s.GetXaxis().SetRangeUser( mass[0], min(mass[-1], MAXIMUM[channel] if channel in MAXIMUM else 1.e6)) drawAnalysis(channel) drawRegion(channel, True) drawCMS(LUMI, YEAR, "Preliminary") #Preliminary # legend top = 0.9 nitems = 4 + len(THEORY) leg = TLegend(0.55, top - nitems * 0.3 / 5., 0.98, top) leg.SetBorderSize(0) leg.SetFillStyle(0) #1001 leg.SetFillColor(0) leg.SetHeader("95% CL upper limits") leg.AddEntry(Obs0s, "Observed", "l") leg.AddEntry(Exp0s, "Expected", "l") leg.AddEntry(Exp1s, "#pm 1 std. deviation", "f") leg.AddEntry(Exp2s, "#pm 2 std. deviation", "f") for t in THEORY: leg.AddEntry(Theory[t], theoryLabel[t], "fl") leg.Draw() latex = TLatex() latex.SetNDC() latex.SetTextSize(0.045) latex.SetTextFont(42) #latex.DrawLatex(0.66, leg.GetY1()-0.045, particleP+" #rightarrow "+particle+"h") leg2 = TLegend(0.12, 0.225 - 2 * 0.25 / 5., 0.65, 0.225) leg2.SetBorderSize(0) leg2.SetFillStyle(0) #1001 leg2.SetFillColor(0) c1.GetPad(0).RedrawAxis() """ if True and channel.endswith('sl'): mass, val = fillValues("./combine/alpha/X"+particle+"Hbonly_M%d.txt") Exp, Obs = TGraphAsymmErrors(), TGraphAsymmErrors() for i, m in enumerate(mass): if not m in val: continue Exp.SetPoint(Exp.GetN(), m, val[m][3]) Obs.SetPoint(Obs.GetN(), m, val[m][0]) Exp.SetLineWidth(3) Exp.SetLineColor(602) #602 Exp.SetLineStyle(5) Obs.SetLineWidth(3) Obs.SetLineColor(602) Exp.Draw("SAME, L") Obs.Draw("SAME, L") mass15, val15 = fillValues("./combine/Vh_2015/X"+particle+"h_M%d.txt") Exp15, Obs15 = TGraphAsymmErrors(), TGraphAsymmErrors() for i, m in enumerate(mass15): if not m in val: continue Exp15.SetPoint(Exp15.GetN(), m, val15[m][3]*multF*Theory['B3'].GetY()[i]*(0.625 if particle=='V' and m>3000 else 1.)) Obs15.SetPoint(Obs15.GetN(), m, val15[m][0]*multF*Theory['B3'].GetY()[i]*(0.625 if particle=='V' and m>3000 else 1.)) Exp15.SetLineWidth(3) Exp15.SetLineColor(856) #602 Exp15.SetLineStyle(6) Obs15.SetLineWidth(3) Obs15.SetLineColor(856) Exp15.Draw("SAME, L") #Obs15.Draw("SAME, L") leg2.AddEntry(Exp, "1+2 b-tag", "l") """ if True and channel == 'AZh': massLL, valLL = fillValues("./combine/AZh/AZhll_M%d.txt") ExpLL, ObsLL = TGraphAsymmErrors(), TGraphAsymmErrors() for i, m in enumerate(massLL): if not m in val: continue ExpLL.SetPoint(ExpLL.GetN(), m, valLL[m][3] * multF) ObsLL.SetPoint(ObsLL.GetN(), m, valLL[m][0] * multF) ExpLL.SetLineWidth(3) ExpLL.SetLineColor(833) #602 ExpLL.SetLineStyle(5) ObsLL.SetLineWidth(3) ObsLL.SetLineColor(833) ExpLL.Draw("SAME, L") #ObsLL.Draw("SAME, L") massNN, valNN = fillValues("./combine/AZh/AZhnn_M%d.txt") ExpNN, ObsNN = TGraphAsymmErrors(), TGraphAsymmErrors() for i, m in enumerate(massNN): if not m in val: continue ExpNN.SetPoint(ExpNN.GetN(), m, valNN[m][3] * multF) ObsNN.SetPoint(ObsNN.GetN(), m, valNN[m][0] * multF) ExpNN.SetLineWidth(3) ExpNN.SetLineColor(855) #602 ExpNN.SetLineStyle(6) ObsNN.SetLineWidth(3) ObsNN.SetLineColor(855) ExpNN.Draw("SAME, L") #ObsNN.Draw("SAME, L") leg2.AddEntry(ExpLL, "Expected, A #rightarrow Zh #rightarrow llb#bar{b}", "l") leg2.AddEntry(ExpNN, "Expected, A #rightarrow Zh #rightarrow #nu#nub#bar{b}", "l") if method == 'combo': massAH, valAH = fillValues("./combine/dijet/X" + particle + "Hah_M%d.txt") ExpAH = TGraphAsymmErrors() for i, m in enumerate(massAH): if not m in val: continue ExpAH.SetPoint(ExpAH.GetN(), m, valAH[m][3] * multF) ExpAH.SetLineWidth(2) ExpAH.SetLineColor(602) #602 ExpAH.SetLineStyle(4) ExpAH.Draw("SAME, L") massSL, valSL = fillValues("./combine/alpha/X" + particle + "Hsl_M%d.txt") ExpSL = TGraphAsymmErrors() for i, m in enumerate(massSL): if not m in val: continue ExpSL.SetPoint(ExpSL.GetN(), m, valSL[m][3] * multF) ExpSL.SetLineWidth(3) ExpSL.SetLineColor(860 - 9) #602 ExpSL.SetLineStyle(7) ExpSL.Draw("SAME, L") leg2.AddEntry(ExpAH, "B2G-17-002", "l") leg2.AddEntry(ExpSL, "B2G-17-004", "l") leg2.Draw() if not options.blind: Obs0s.Draw("SAME, L") c1.GetPad(0).Update() if not gROOT.IsBatch(): raw_input("Press Enter to continue...") c1.Print("plotsLimit/Exclusion/" + channel + suffix + ".png") c1.Print("plotsLimit/Exclusion/" + channel + suffix + ".pdf") if 'ah' in channel or 'sl' in channel: c1.Print("plotsLimit/Exclusion/" + channel + suffix + ".C") c1.Print("plotsLimit/Exclusion/" + channel + suffix + ".root") for t in THEORY: print "Model", t, ":", for m in range(mass[0], mass[-1], 1): if not (Theory[t].Eval(m) > Obs0s.Eval(m)) == ( Theory[t].Eval(m + 1) > Obs0s.Eval(m + 1)): print m, print "" print "p1s[", for i in range(Exp0s.GetN()): print Exp0s.GetY()[i] + Exp1s.GetErrorYhigh(i), ",", print "]," print "m1s[", for i in range(Exp0s.GetN()): print Exp0s.GetY()[i] - Exp1s.GetErrorYlow(i), ",", print "]," print "[", for i in range(Exp0s.GetN()): print Exp0s.GetY()[i], ",", print "]" #if not 'ah' in channel and not 'sl' in channel: return # ---------- Significance ---------- c2 = TCanvas("c2", "Significance", 800, 600) c2.cd() c2.GetPad(0).SetTopMargin(0.06) c2.GetPad(0).SetRightMargin(0.05) c2.GetPad(0).SetTicks(1, 1) c2.GetPad(0).SetGridx() c2.GetPad(0).SetGridy() Sign.GetYaxis().SetRangeUser(0., 5.) Sign.Draw("AL3") drawCMS(LUMI, YEAR, "Preliminary") drawAnalysis(channel[1:3]) c2.Print("plotsLimit/Significance/" + channel + suffix + ".png") c2.Print("plotsLimit/Significance/" + channel + suffix + ".pdf") # c2.Print("plotsLimit/Significance/"+channel+suffix+".root") # c2.Print("plotsLimit/Significance/"+channel+suffix+".C") # ---------- p-Value ---------- c3 = TCanvas("c3", "p-Value", 800, 600) c3.cd() c3.GetPad(0).SetTopMargin(0.06) c3.GetPad(0).SetRightMargin(0.05) c3.GetPad(0).SetTicks(1, 1) c3.GetPad(0).SetGridx() c3.GetPad(0).SetGridy() c3.GetPad(0).SetLogy() pVal.Draw("AL3") pVal.GetYaxis().SetRangeUser(2.e-7, 0.5) ci = [ 1., 0.317310508, 0.045500264, 0.002699796, 0.00006334, 0.000000573303, 0.000000001973 ] line = TLine() line.SetLineColor(922) line.SetLineStyle(7) text = TLatex() text.SetTextColor(922) text.SetTextSize(0.025) text.SetTextAlign(12) for i in range(1, len(ci) - 1): line.DrawLine(pVal.GetXaxis().GetXmin(), ci[i] / 2, pVal.GetXaxis().GetXmax(), ci[i] / 2) text.DrawLatex(pVal.GetXaxis().GetXmax() * 1.01, ci[i] / 2, "%d #sigma" % i) drawCMS(LUMI, YEAR, "Preliminary") drawAnalysis(channel[1:3]) c3.Print("plotsLimit/pValue/" + channel + suffix + ".png") c3.Print("plotsLimit/pValue/" + channel + suffix + ".pdf") # c3.Print("plotsLimit/pValue/"+channel+suffix+".root") # c3.Print("plotsLimit/pValue/"+channel+suffix+".C") # --------- Best Fit ---------- c4 = TCanvas("c4", "Best Fit", 800, 600) c4.cd() c4.GetPad(0).SetTopMargin(0.06) c4.GetPad(0).SetRightMargin(0.05) c4.GetPad(0).SetTicks(1, 1) c4.GetPad(0).SetGridx() c4.GetPad(0).SetGridy() Best.Draw("AL3") drawCMS(LUMI, YEAR, "Preliminary") drawAnalysis(channel[1:3]) c4.Print("plotsLimit/BestFit/" + channel + suffix + ".png") c4.Print("plotsLimit/BestFit/" + channel + suffix + ".pdf") # c4.Print("plotsLimit/BestFit/"+channel+suffix+".root") # c4.Print("plotsLimit/BestFit/"+channel+suffix+".C") if not gROOT.IsBatch(): raw_input("Press Enter to continue...") if 'ah' in channel: outFile = TFile("bands.root", "RECREATE") outFile.cd() pVal.Write("graph") Best.Write("best") outFile.Close()
def makePlot(finname,foutname,plottitle='',masstitle='',scale=False): xsecs = resonantXsecs if 'resonant' in finname else fcncXsecs points = {} if BLIND: cls = [2.5, 16, 50, 84, 97.5] else: cls = [2.5, 16, 50, 84, 97.5,'Observed'] xaxis = [] for cl in cls: points[cl] = [] xsec=1 for l in open(finname): try: if l.strip()[0]=='#': continue if 'MASS' in l: if scale: xsec = xsecs[int(l.split()[1])] if VERBOSE: print '' stdout.write('$%6s$ & $%7.3g$'%(l.split()[1],xsec/(0.667))) xaxis.append(float(l.split()[1])) else: cl,val = parseLine(l) points[cl].append(val/xsec) if VERBOSE and (cl==50 or cl=='Observed'): stdout.write(' & $%10.4g$'%(val/xsec)) except: pass if VERBOSE: print '' N = len(xaxis) up1Sigma=[]; up2Sigma=[] down1Sigma=[]; down2Sigma=[] for iM in xrange(N): up1Sigma.append(points[84][iM]-points[50][iM]) up2Sigma.append(points[97.5][iM]-points[50][iM]) down1Sigma.append(-points[16][iM]+points[50][iM]) down2Sigma.append(-points[2.5][iM]+points[50][iM]) up1Sigma = array('f',up1Sigma) up2Sigma = array('f',up2Sigma) down1Sigma = array('f',down1Sigma) down2Sigma = array('f',down2Sigma) cent = array('f',points[50]) if not BLIND: obs = array('f',points['Observed']) xarray = array('f',xaxis) xsecarray = array('f',[xsecs[xx] for xx in xaxis]) xsecarrayLow = array('f',[0.0625*xsecs[xx] for xx in xaxis]) onearray = array('f',[1 for xx in xaxis]) graphXsec = TGraph(N,xarray,xsecarray) graphXsecLow = TGraph(N,xarray,xsecarrayLow) graphOne = TGraph(N,xarray,onearray) zeros = array('f',[0 for i in xrange(N)]) graphCent = TGraph(N,xarray,cent) if not BLIND: graphObs = TGraph(N,xarray,obs) graph1Sigma = TGraphAsymmErrors(N,xarray,cent,zeros,zeros,down1Sigma,up1Sigma) graph2Sigma = TGraphAsymmErrors(N,xarray,cent,zeros,zeros,down2Sigma,up2Sigma) c = TCanvas('c','c',700,600) c.SetLogy() c.SetLeftMargin(.15) graph2Sigma.GetXaxis().SetTitle(masstitle+' [GeV]') if scale: graph2Sigma.GetYaxis().SetTitle('Upper limit [#sigma/#sigma_{theory}]') else: graph2Sigma.GetYaxis().SetTitle("Upper limit [#sigma] [pb]") graph2Sigma.SetLineColor(5) graph1Sigma.SetLineColor(3) graph2Sigma.SetFillColor(5) graph1Sigma.SetFillColor(3) graph2Sigma.SetMinimum(0.5*min(points[2.5])) if scale: graph2Sigma.SetMaximum(10*max(max(points[97.5]),max(xsecarray),4)) else: graph2Sigma.SetMaximum(10*max(max(points[97.5]),max(xsecarray))) graphCent.SetLineWidth(2) graphCent.SetLineStyle(2) if not BLIND: graphObs.SetLineColor(1) graphObs.SetLineWidth(3) graph1Sigma.SetLineStyle(0) graph2Sigma.SetLineStyle(0) leg = TLegend(0.55,0.7,0.9,0.9) leg.AddEntry(graphCent,'Expected','L') if not BLIND: leg.AddEntry(graphObs,'Observed','L') leg.AddEntry(graph1Sigma,'1 #sigma','F') leg.AddEntry(graph2Sigma,'2 #sigma','F') leg.SetFillStyle(0) leg.SetBorderSize(0) graph2Sigma.Draw('A3') graph1Sigma.Draw('3 same') graphCent.Draw('same L') if not BLIND: graphObs.Draw('same L') if scale: graphOne.SetLineColor(2) graphOne.SetLineWidth(2) graphOne.SetLineStyle(2) graphOne.Draw('same L') else: graphXsec.SetLineColor(2) graphXsecLow.SetLineColor(4) subscript = 'SR' if 'Resonant' in plottitle else 'FC' if 'Resonant' in plottitle: leg.AddEntry(graphXsec,'Theory #splitline{a_{%s}=b_{%s}=0.1}{m_{#chi}=100 GeV}'%(subscript,subscript),'l') else: leg.AddEntry(graphXsec,'Theory a_{%s}=b_{%s}=0.1'%(subscript,subscript),'l') # leg.AddEntry(graphXsecLow,'Theory a_{%s}=b_{%s}=0.025'%(subscript,subscript),'l') for g in [graphXsec]: g.SetLineWidth(2) g.SetLineStyle(2) g.Draw('same L') leg.Draw() label = TLatex() label.SetNDC() label.SetTextFont(62) label.SetTextAlign(11) label.DrawLatex(0.19,0.85,"CMS") label.SetTextFont(52) label.DrawLatex(0.28,0.85,"Preliminary") label.SetTextFont(42) label.SetTextSize(0.6*c.GetTopMargin()) label.DrawLatex(0.19,0.77,plottitle) if scale: if 'Resonant' in plottitle: label.DrawLatex(0.19,0.7,"a_{SR} = b_{SR} = 0.1") label.DrawLatex(0.19,0.64,"m_{#chi}=100 GeV") else: label.DrawLatex(0.19,0.7,"a_{FC} = b_{FC} = 0.1") label.SetTextSize(0.5*c.GetTopMargin()) label.SetTextFont(42) label.SetTextAlign(31) # align right label.DrawLatex(0.9, 0.94,"%.1f fb^{-1} (13 TeV)"%(plotConfig.lumi)) c.SaveAs(foutname+'.pdf') c.SaveAs(foutname+'.png')
def nuisance_plot(input_file_, orien_, sticker_, oname_): pars = get_parameters_from_file(input_file_) #adjust_parameters(pars) N = len(pars) g68 = TGraph(2 * N + 7) g95 = TGraph(2 * N + 7) gPR = TGraphAsymmErrors(N) for i in range(0, N): x = pars[i].value y = i + 1.5 xerr = pars[i].error yerr = 0. if orien_ == 'h': x, y = y, x xerr, yerr = yerr, xerr gPR.SetPoint(i, x, y) gPR.SetPointEXlow(i, xerr) gPR.SetPointEYlow(i, yerr) gPR.SetPointEXhigh(i, xerr) gPR.SetPointEYhigh(i, yerr) for a in range(0, N + 3): if orien_ == 'h': g68.SetPoint(a, a, -1) g95.SetPoint(a, a, -2) g68.SetPoint(a + 1 + N + 2, N + 2 - a, 1) g95.SetPoint(a + 1 + N + 2, N + 2 - a, 2) else: g68.SetPoint(a, -1, a) g95.SetPoint(a, -2, a) g68.SetPoint(a + 1 + N + 2, 1, N + 2 - a) g95.SetPoint(a + 1 + N + 2, 2, N + 2 - a) gPR.SetLineStyle(1) gPR.SetLineWidth(1) gPR.SetLineColor(1) gPR.SetMarkerStyle(21) gPR.SetMarkerSize(1.25) g68.SetFillColor(kGreen) g95.SetFillColor(kYellow) if orien_ == 'h': text_TL = TPaveText(0.100, 0.925, 0.440, 0.995, 'NDC') text_TR = TPaveText(0.587, 0.925, 0.999, 0.993, 'NDC') else: text_TL = TPaveText(0.370, 0.945, 0.590, 0.995, 'NDC') text_TR = TPaveText(0.600, 0.945, 0.995, 0.993, 'NDC') text_TL.AddText(label_TL) text_TL.SetFillColor(0) text_TL.SetTextAlign(12) text_TL.SetTextSize(0.06) text_TL.SetTextFont(42) text_TR.AddText(sticker_) text_TR.SetFillColor(0) text_TR.SetTextAlign(32) text_TR.SetTextSize(0.05) text_TR.SetTextFont(42) if orien_ == 'h': c = TCanvas('c', 'c', 1000, 700) c.SetTopMargin(0.08) c.SetRightMargin(0.02) c.SetBottomMargin(0.16) c.SetLeftMargin(0.11) else: c = TCanvas('c', 'c', 700, 1000) c.SetTopMargin(0.06) c.SetRightMargin(0.02) c.SetBottomMargin(0.12) c.SetLeftMargin(0.35 * 700 / 650) c.SetTickx() c.SetTicky() c.Update() g95.Draw('AF') g68.Draw('F') gPR.Draw('P') text_TL.Draw('same') text_TR.Draw('same') ax_1 = g95.GetHistogram().GetYaxis() ax_2 = g95.GetHistogram().GetXaxis() if orien_ == 'h': ax_1, ax_2 = ax_2, ax_1 ax_1.Set(N + 2, 0, N + 2) ax_1.SetNdivisions(-414) for i in range(0, N): ax_1.SetBinLabel(i + 2, pars[i].name) g95.SetTitle('') ax_2.SetTitle('post-fit nuisance parameters values') #ax_2.SetTitle('deviation in units of #sigma') ax_1.SetTitleSize(0.050) ax_2.SetTitleSize(0.050) ax_1.SetTitleOffset(1.4) ax_2.SetTitleOffset(1.0) ax_1.SetLabelSize(0.05) #ax_2.SetLabelSize(0.05) ax_1.SetRangeUser(0, N + 2) ax_2.SetRangeUser(-2.4, 2.4) g95.GetHistogram().Draw('axis,same') c.SaveAs(oname_ + '.pdf') c.Close()
def limit(channel, signal): multF = 1. # in fb filename = "./limitOutput_" + options.name + "/" + signal + "_MChi1_MPhi%d_scalar" + options.bjets + "_" + channel + "_AsymptoticLimits_grepOutput.txt" if (options.mediator == 'SC'): filename = "./limitOutput_" + options.name + "/" + signal + "_MChi1_MPhi%d_scalar" + options.bjets + "_" + channel + "_AsymptoticLimits_grepOutput.txt" elif (options.mediator == 'PS'): filename = "./limitOutput_" + options.name + "/" + signal + "_MChi1_MPhi%d_pseudo" + options.bjets + "_" + channel + "_AsymptoticLimits_grepOutput.txt" else: print 'WRONG mediator type' mass, val = fillValues(filename) Obs0s = TGraph() Exp0s = TGraph() Exp1s = TGraphAsymmErrors() Exp2s = TGraphAsymmErrors() Sign = TGraph() pVal = TGraph() Best = TGraphAsymmErrors() for i, m in enumerate(mass): if not m in val: print "Key Error:", m, "not in value map" continue n = Exp0s.GetN() Obs0s.SetPoint(n, m, val[m][0] * multF) Exp0s.SetPoint(n, m, val[m][3] * multF) Exp1s.SetPoint(n, m, val[m][3] * multF) Exp1s.SetPointError(n, 0., 0., val[m][3] * multF - val[m][2] * multF, val[m][4] * multF - val[m][3] * multF) Exp2s.SetPoint(n, m, val[m][3] * multF) Exp2s.SetPointError(n, 0., 0., val[m][3] * multF - val[m][1] * multF, val[m][5] * multF - val[m][3] * multF) #Sign.SetPoint(n, m, val[m][6]) #pVal.SetPoint(n, m, val[m][7]) #Best.SetPoint(n, m, val[m][8]) #Best.SetPointError(m, 0., 0., abs(val[m][9]), abs(val[m][10])) Exp2s.SetLineWidth(2) Exp2s.SetLineStyle(1) Obs0s.SetLineWidth(3) Obs0s.SetMarkerStyle(0) Obs0s.SetLineColor(1) Exp0s.SetLineStyle(2) Exp0s.SetLineWidth(3) Exp1s.SetFillColor(417) #kGreen+1 Exp1s.SetLineColor(417) #kGreen+1 Exp2s.SetFillColor(800) #kOrange Exp2s.SetLineColor(800) #kOrange Exp2s.GetXaxis().SetTitle("m_{#phi} (GeV)") Exp2s.GetXaxis().SetTitleSize(Exp2s.GetXaxis().GetTitleSize() * 1.25) Exp2s.GetXaxis().SetNoExponent(True) Exp2s.GetXaxis().SetMoreLogLabels(True) Exp2s.GetYaxis().SetTitle("#sigma/#sigma_{th}") Exp2s.GetYaxis().SetTitleOffset(1.5) Exp2s.GetYaxis().SetNoExponent(True) Exp2s.GetYaxis().SetMoreLogLabels() Sign.SetLineWidth(2) Sign.SetLineColor(629) Sign.GetXaxis().SetTitle("m_{#phi} (GeV)") Sign.GetXaxis().SetTitleSize(Sign.GetXaxis().GetTitleSize() * 1.1) Sign.GetYaxis().SetTitle("Significance") pVal.SetLineWidth(2) pVal.SetLineColor(629) pVal.GetXaxis().SetTitle("m_{#phi} (GeV)") pVal.GetXaxis().SetTitleSize(pVal.GetXaxis().GetTitleSize() * 1.1) pVal.GetYaxis().SetTitle("local p-Value") Best.SetLineWidth(2) Best.SetLineColor(629) Best.SetFillColor(629) Best.SetFillStyle(3003) Best.GetXaxis().SetTitle("m_{#phi} (GeV)") Best.GetXaxis().SetTitleSize(Best.GetXaxis().GetTitleSize() * 1.1) Best.GetYaxis().SetTitle("Best Fit (pb)") c1 = TCanvas("c1", "Exclusion Limits", 800, 600) c1.cd() #SetPad(c1.GetPad(0)) c1.GetPad(0).SetTopMargin(0.06) c1.GetPad(0).SetRightMargin(0.05) c1.GetPad(0).SetTicks(1, 1) #c1.GetPad(0).SetGridx() #c1.GetPad(0).SetGridy() c1.GetPad(0).SetLogx() c1.GetPad(0).SetLogy() Exp2s.Draw("A3") Exp1s.Draw("SAME, 3") Exp0s.Draw("SAME, L") if not options.blind: Obs0s.Draw("SAME, L") #Theory[0].Draw("SAME, L") #Theory[1].Draw("SAME, L") #setHistStyle(Exp2s) Exp2s.GetXaxis().SetTitleSize(0.045) Exp2s.GetXaxis().SetMoreLogLabels(True) Exp2s.GetXaxis().SetNoExponent(True) Exp2s.GetYaxis().SetTitleSize(0.04) Exp2s.GetXaxis().SetLabelSize(0.04) Exp2s.GetYaxis().SetLabelSize(0.04) Exp2s.GetXaxis().SetTitleOffset(1) Exp2s.GetYaxis().SetTitleOffset(1.25) Exp2s.GetYaxis().SetMoreLogLabels(True) Exp2s.GetYaxis().SetNoExponent(True) Exp2s.GetYaxis().SetRangeUser(0.1, 1000.) #else: Exp2s.GetYaxis().SetRangeUser(0.1, 1.e2) Exp2s.GetXaxis().SetRangeUser(mass[0], mass[-1]) drawAnalysis("tDM") drawRegion(channel, True) drawCMS(LUMI, "Preliminary") if True: if (options.mediator == 'SC'): massT, valT = fillValues("./limitOutput_" + options.name + "/" + signal.replace('tttDM', 'tDM') + "_MChi1_MPhi%d_scalar" + options.bjets + "_" + channel + "_AsymptoticLimits_grepOutput.txt") elif (options.mediator == 'PS'): massT, valT = fillValues("./limitOutput_" + options.name + "/" + signal.replace('tttDM', 'tDM') + "_MChi1_MPhi%d_pseudo" + options.bjets + "_" + channel + "_AsymptoticLimits_grepOutput.txt") ExpT, ObsT = TGraphAsymmErrors(), TGraphAsymmErrors() for i, m in enumerate(massT): if not m in val: continue ExpT.SetPoint(ExpT.GetN(), m, valT[m][3] * multF) ObsT.SetPoint(ObsT.GetN(), m, valT[m][0] * multF) ExpT.SetLineWidth(3) ExpT.SetLineColor(602) #602 ExpT.SetLineStyle(5) ObsT.SetLineWidth(3) ObsT.SetLineColor(602) ExpT.SetMarkerStyle(21) ObsT.SetMarkerStyle(22) ExpT.SetMarkerColor(602) ObsT.SetMarkerColor(602) ExpT.Draw("SAME, PC") #if not options.blind: ObsT.Draw("SAME, P") if (options.mediator == 'SC'): massTTT, valTTT = fillValues("./limitOutput_" + options.name + "/" + signal.replace('tttDM', 'ttDM') + "_MChi1_MPhi%d_scalar" + options.bjets + "_" + channel + "_AsymptoticLimits_grepOutput.txt") elif (options.mediator == 'PS'): massTTT, valTTT = fillValues("./limitOutput_" + options.name + "/" + signal.replace('tttDM', 'ttDM') + "_MChi1_MPhi%d_pseudo" + options.bjets + "_" + channel + "_AsymptoticLimits_grepOutput.txt") ExpTTT, ObsTTT = TGraphAsymmErrors(), TGraphAsymmErrors() for i, m in enumerate(massTTT): if not m in val: continue ExpTTT.SetPoint(ExpTTT.GetN(), m, valTTT[m][3] * multF) ObsTTT.SetPoint(ObsTTT.GetN(), m, valTTT[m][0] * multF) ExpTTT.SetLineWidth(3) ExpTTT.SetLineColor(634) #602 ExpTTT.SetLineStyle(5) ObsTTT.SetLineWidth(3) ObsTTT.SetLineColor(634) ExpTTT.SetMarkerStyle(21) ObsTTT.SetMarkerStyle(22) ExpTTT.SetMarkerColor(634) ObsTTT.SetMarkerColor(634) ExpTTT.Draw("SAME, PC") #if not options.blind: ObsTTT.Draw("SAME, P") # legend top = 0.9 nitems = 4 + 2 leg = TLegend(0.55, top - nitems * 0.3 / 5., 0.95, top) leg.SetBorderSize(0) leg.SetFillStyle(0) #1001 leg.SetFillColor(0) leg.SetHeader("95% CL limits") leg.AddEntry(Obs0s, "Observed", "l") leg.AddEntry(Exp0s, "Expected (t+DM, tt+DM)", "l") leg.AddEntry(Exp1s, "#pm 1 s. d.", "f") leg.AddEntry(Exp2s, "#pm 2 s. d.", "f") if True: leg.AddEntry(ExpT, "Expected (t+DM)", "p") leg.AddEntry(ExpTTT, "Expected (tt+DM)", "p") leg.Draw() c1.GetPad(0).RedrawAxis() c1.GetPad(0).Update() if gROOT.IsBatch(): c1.Print("plotsLimit_" + options.name + "/Exclusion_" + channel + "_" + options.mediator + "_" + options.bjets + ".png") c1.Print("plotsLimit_" + options.name + "/Exclusion_" + channel + "_" + options.mediator + "_" + options.bjets + ".pdf") if not gROOT.IsBatch(): raw_input("Press Enter to continue...") # print "p1s[", # for i in range(Exp0s.GetN()): # print Exp0s.GetY()[i]+Exp1s.GetErrorYhigh(i), ",", # print "]," # print "m1s[", # for i in range(Exp0s.GetN()): # print Exp0s.GetY()[i]-Exp1s.GetErrorYlow(i), ",", # print "]," # print "[", # for i in range(Exp0s.GetN()): # print Exp0s.GetY()[i], ",", # print "]" return # ---------- Significance ---------- c2 = TCanvas("c2", "Significance", 800, 600) c2.cd() c2.GetPad(0).SetTopMargin(0.06) c2.GetPad(0).SetRightMargin(0.05) c2.GetPad(0).SetTicks(1, 1) c2.GetPad(0).SetGridx() c2.GetPad(0).SetGridy() Sign.GetYaxis().SetRangeUser(0., 5.) Sign.Draw("AL3") drawCMS(LUMI, "Preliminary") drawAnalysis(channel[1:3]) if gROOT.IsBatch(): c2.Print("plotsLimit_" + options.name + "/Significance/" + channel + "_" + options.mediator + "_" + options.bjets + ".png") c2.Print("plotsLimit_" + options.name + "/Significance/" + channel + "_" + options.mediator + "_" + options.bjets + ".pdf") # c2.Print("plotsLimit/Significance/"+channel+suffix+".root") # c2.Print("plotsLimit/Significance/"+channel+suffix+".C") # ---------- p-Value ---------- c3 = TCanvas("c3", "p-Value", 800, 600) c3.cd() c3.GetPad(0).SetTopMargin(0.06) c3.GetPad(0).SetRightMargin(0.05) c3.GetPad(0).SetTicks(1, 1) c3.GetPad(0).SetGridx() c3.GetPad(0).SetGridy() c3.GetPad(0).SetLogy() pVal.Draw("AL3") pVal.GetYaxis().SetRangeUser(2.e-7, 0.5) ci = [ 1., 0.317310508, 0.045500264, 0.002699796, 0.00006334, 0.000000573303, 0.000000001973 ] line = TLine() line.SetLineColor(922) line.SetLineStyle(7) text = TLatex() text.SetTextColor(922) text.SetTextSize(0.025) text.SetTextAlign(12) for i in range(1, len(ci) - 1): line.DrawLine(pVal.GetXaxis().GetXmin(), ci[i] / 2, pVal.GetXaxis().GetXmax(), ci[i] / 2) text.DrawLatex(pVal.GetXaxis().GetXmax() * 1.01, ci[i] / 2, "%d #sigma" % i) drawCMS(LUMI, "Preliminary") drawAnalysis(channel[1:3]) if gROOT.IsBatch(): c3.Print("plotsLimit_" + options.name + "/pValue/" + channel + suffix + "_" + options.mediator + "_" + options.bjets + ".png") c3.Print("plotsLimit_" + options.name + "/pValue/" + channel + suffix + "_" + options.mediator + "_" + options.bjets + ".pdf") # c3.Print("plotsLimit/pValue/"+channel+suffix+".root") # c3.Print("plotsLimit/pValue/"+channel+suffix+".C") # --------- Best Fit ---------- c4 = TCanvas("c4", "Best Fit", 800, 600) c4.cd() c4.GetPad(0).SetTopMargin(0.06) c4.GetPad(0).SetRightMargin(0.05) c4.GetPad(0).SetTicks(1, 1) c4.GetPad(0).SetGridx() c4.GetPad(0).SetGridy() Best.Draw("AL3") drawCMS(LUMI, "Preliminary") drawAnalysis(channel[1:3]) if gROOT.IsBatch(): c4.Print("plotsLimit_" + options.name + "/BestFit/" + channel + suffix + "_" + options.mediator + "_" + options.bjets + ".png") c4.Print("plotsLimit_" + options.name + "/BestFit/" + channel + suffix + "_" + options.mediator + "_" + options.bjets + ".pdf") # c4.Print("plotsLimit/BestFit/"+channel+suffix+".root") # c4.Print("plotsLimit/BestFit/"+channel+suffix+".C") if not gROOT.IsBatch(): raw_input("Press Enter to continue...")
g_th_166.SetPoint(bin-1, scales[bin-1], th_xsec_166[bin-1]) g_th_166.SetPointError(bin-1,scales[bin-1]-bins[bin-1], bins[bin]-scales[bin-1], 0, 0) xsec_err = getXsec(bin) g_exp.SetPoint(bin-1, scales[bin-1], xsec_err[0]) g_exp.SetPointError(bin-1, 0, 0, xsec_err[2], xsec_err[1]) g_th_164.SetMarkerStyle(0) g_th_164.SetMarkerColor(ROOT.kRed) g_th_164.SetLineColor(ROOT.kRed) g_th_162.SetMarkerStyle(0) g_th_162.SetMarkerColor(ROOT.kBlue) g_th_162.SetLineColor(ROOT.kBlue) g_th_162.SetLineStyle(2) g_th_166.SetMarkerStyle(0) g_th_166.SetMarkerColor(ROOT.kGreen+2) g_th_166.SetLineColor(ROOT.kGreen+2) g_th_166.SetLineStyle(3) g_exp.SetMarkerStyle(8) g_exp.SetLineWidth(1) latexLabel1 = ROOT.TLatex() latexLabel1.SetTextSize(0.06) latexLabel1.SetNDC() latexLabel2 = ROOT.TLatex()
def pullsVertical(fileName): content = filterPullFile(fileName) nbins, off = len(content), 0.10 b_pulls = TH1F("b_pulls", ";;Pulls", nbins, 0. - off, nbins - off) s_pulls = TH1F("s_pulls", ";;Pulls", nbins, 0. + off, nbins + off) # for i, s in enumerate(content): l = s.split() b_pulls.GetXaxis().SetBinLabel(i + 1, l[0]) s_pulls.GetXaxis().SetBinLabel(i + 1, l[0]) b_pulls.SetBinContent(i + 1, float(l[1])) b_pulls.SetBinError(i + 1, float(l[2])) s_pulls.SetBinContent(i + 1, float(l[3])) s_pulls.SetBinError(i + 1, float(l[4])) b_pulls.SetFillStyle(3005) b_pulls.SetFillColor(923) b_pulls.SetLineColor(923) b_pulls.SetLineWidth(1) b_pulls.SetMarkerStyle(20) b_pulls.SetMarkerSize(1.25) s_pulls.SetLineColor(602) s_pulls.SetMarkerColor(602) s_pulls.SetMarkerStyle(24) #24 s_pulls.SetLineWidth(1) b_pulls.GetYaxis().SetRangeUser(-2.5, 2.5) # Graphs h_pulls = TH2F("pulls", "", 6, -3., 3., nbins, 0, nbins) B_pulls = TGraphAsymmErrors(nbins) S_pulls = TGraphAsymmErrors(nbins) boxes = [] canvas = TCanvas("canvas", "Pulls", 600, 150 + nbins * 10) #nbins*20) canvas.cd() canvas.SetGrid(0, 1) canvas.GetPad(0).SetTopMargin(0.01) canvas.GetPad(0).SetRightMargin(0.01) canvas.GetPad(0).SetBottomMargin(0.05) canvas.GetPad(0).SetLeftMargin(0.25) #(0.25)#(0.065) canvas.GetPad(0).SetTicks(1, 1) for i, s in enumerate(content): l = s.split() if "1034h" in l[0]: l[0] = "CMS_PDF_13TeV" h_pulls.GetYaxis().SetBinLabel(i + 1, l[0].replace('CMS2016_', '')) #C #y1 = gStyle.GetPadBottomMargin() #y2 = 1. - gStyle.GetPadTopMargin() #h = (y2 - y1) / float(nbins) #y1 = y1 + float(i) * h #y2 = y1 + h #box = TPaveText(0, y1, 1, y2, 'NDC') #box.SetFillColor(0) #box.SetTextSize(0.02) #box.SetBorderSize(0) #box.SetTextAlign(12) #box.SetMargin(0.005) #if i % 2 == 0: # box.SetFillColor(18) #box.Draw() #boxes.append(box) B_pulls.SetPoint(i + 1, float(l[1]), float(i + 1) - 0.3) #C B_pulls.SetPointError(i + 1, float(l[2]), float(l[2]), 0., 0.) #C for i, s in enumerate(content): l = s.split() S_pulls.SetPoint(i + 1, float(l[3]), float(i + 1) - 0.7) #C S_pulls.SetPointError(i + 1, float(l[4]), float(l[4]), 0., 0.) #C h_pulls.GetXaxis().SetTitle("(#hat{#theta} - #theta_{0}) / #Delta#theta") h_pulls.GetXaxis().SetLabelOffset(-0.01) h_pulls.GetXaxis().SetTitleOffset(.6) h_pulls.GetYaxis().SetNdivisions(nbins, 0, 0) B_pulls.SetFillColor(1) B_pulls.SetLineColor(1) B_pulls.SetLineStyle(1) B_pulls.SetLineWidth(2) B_pulls.SetMarkerColor(1) B_pulls.SetMarkerStyle(20) B_pulls.SetMarkerSize(1) #(0.75) S_pulls.SetFillColor(629) S_pulls.SetLineColor(629) S_pulls.SetMarkerColor(629) S_pulls.SetLineWidth(2) S_pulls.SetMarkerStyle(20) S_pulls.SetMarkerSize(1) box1 = TBox(-1., 0., 1., nbins) box1.SetFillStyle(3001) #box1.SetFillStyle(0) box1.SetFillColor(417) box1.SetLineWidth(2) box1.SetLineStyle(2) box1.SetLineColor(417) box2 = TBox(-2., 0., 2., nbins) box2.SetFillStyle(3001) #box2.SetFillStyle(0) box2.SetFillColor(800) box2.SetLineWidth(2) box2.SetLineStyle(2) box2.SetLineColor(800) leg = TLegend(0.1, -0.05, 0.7, 0.08) leg.SetBorderSize(0) leg.SetFillStyle(0) leg.SetFillColor(0) leg.SetNColumns(2) leg.AddEntry(B_pulls, "B-only fit", "lp") leg.AddEntry(S_pulls, "S+B fit", "lp") if text: leg.AddEntry(0, text, "") h_pulls.Draw("") box2.Draw() box1.Draw() B_pulls.Draw("P6SAME") S_pulls.Draw("P6SAME") leg.Draw() # drawCMS(35867, "Preliminary") # drawAnalysis("VH") # drawRegion(outName) canvas.Print(outName + ".png") canvas.Print(outName + ".pdf") if not gROOT.IsBatch(): raw_input("Press Enter to continue...")
graph = TGraphAsymmErrors() n=0 for a in sorted(threshold_scan): #for a in sorted(run_parameters): ##Fill the TGraph with threshold (x-axis) and rate (y-axis) #######graph.SetPoint(n,int(run_parameters[a]['VTHR']),float(run_parameters[a]['RATE_SL1_L1'])) graph.SetPoint(n,int(a),float(threshold_scan[a])) n = n+1 graph.SetMarkerSize(1.) graph.SetMarkerStyle(21) graph.SetMarkerColor(862) graph.SetFillColor(868) graph.SetFillStyle(3844) graph.SetLineColor(868) graph.SetLineWidth(2) graph.SetLineStyle(2) graph.GetXaxis().SetTitle("threshold [mV]") graph.GetYaxis().SetTitleOffset(1.2) graph.GetYaxis().SetTitle("rate [kHz]") graph.Draw("APL") latex = TLatex() latex.SetNDC() latex.SetTextSize(0.04) latex.SetTextColor(1) latex.SetTextFont(42) latex.SetTextAlign(33) latex.SetTextSize(0.04) latex.SetTextFont(62) latex.DrawLatex(0.30, 0.96, "GIF++") etichetta = TLatex() etichetta.SetNDC()