def make1DLimitPlot(xtitle, xvals, obs, exp, exp1plus, exp1minus, exp2plus, exp2minus, theory): gStyle.SetOptTitle(0) axisTitleSize = 0.041 axisTitleOffset = 1.2 axisTitleSizeRatioX = 0.18 axisLabelSizeRatioX = 0.12 axisTitleOffsetRatioX = 0.94 axisTitleSizeRatioY = 0.15 axisLabelSizeRatioY = 0.108 axisTitleOffsetRatioY = 0.32 leftMargin = 0.15 rightMargin = 0.12 topMargin = 0.05 bottomMargin = 0.14 bottomMargin2 = 0.22 #c1 = TCanvas() #'c1', '', 200, 10, 700, 500 ) c1 = TCanvas( "c1", "c2", 200, 10, 700, 600 ) c1.SetHighLightColor(2) c1.SetFillColor(0) c1.SetBorderMode(0) c1.SetBorderSize(2) c1.SetLeftMargin(leftMargin) c1.SetRightMargin(rightMargin) c1.SetTopMargin(topMargin) c1.SetBottomMargin(bottomMargin) c1.SetFrameBorderMode(0) c1.SetFrameBorderMode(0) c1.SetLogy(1) #c1.SetLogx(1) c1.SetTickx(1) c1.SetTicky(1) #c1.SetGridx(True); #c1.SetGridy(True); if "c#tau" in xtitle: c1.SetLogx(1); exp2sigma_xsec = TGraphAsymmErrors(len(xvals), array('d', xvals), array('d', exp), \ array('d', [0]), array('d', [0]), array('d', exp2minus), array('d', exp2plus)) exp2sigma_xsec.Sort() exp2sigma_xsec.Draw('A3') exp2sigma_xsec.SetFillStyle(1001); exp2sigma_xsec.SetFillColor(kOrange); exp2sigma_xsec.SetLineColor(kOrange); exp2sigma_xsec.GetYaxis().SetRangeUser(0.001,100); exp2sigma_xsec.GetXaxis().SetLimits(0.8*min(xvals),1.1*max(xvals)); #exp2sigma_xsec.GetXaxis().SetTitle('m_{1} [GeV]') #exp2sigma_xsec.GetXaxis().SetTitle('c#tau [cm]') exp2sigma_xsec.GetXaxis().SetTitle(xtitle) exp2sigma_xsec.GetXaxis().SetTitleOffset(axisTitleOffset) exp2sigma_xsec.GetYaxis().SetTitle('95% C.L. #sigma(pp #rightarrow #chi_{1} #chi_{1} #mu^{+} #mu^{-}) [pb]') exp2sigma_xsec.GetYaxis().SetTitleOffset(axisTitleOffset+0.1) exp1sigma_xsec = TGraphAsymmErrors(len(xvals), array('d', xvals), array('d', exp), \ array('d', [0]), array('d', [0]), array('d', exp1minus), array('d', exp1plus)) exp1sigma_xsec.Sort() exp1sigma_xsec.SetFillStyle(1001); exp1sigma_xsec.SetFillColor(kGreen+1); exp1sigma_xsec.SetLineColor(kGreen+1); exp1sigma_xsec.Draw('3 SAME') exp_xsec = TGraph(len(xvals), array('d', xvals), array('d', exp)) exp_xsec.Sort() exp_xsec.SetLineWidth(2) exp_xsec.SetLineStyle(1) exp_xsec.SetLineColor(kRed) exp_xsec.Draw('C SAME') obs_xsec = TGraph(len(xvals), array('d', xvals), array('d', obs)) obs_xsec.Sort() obs_xsec.SetLineWidth(3) obs_xsec.SetLineColor(kBlack) obs_xsec.SetMarkerColor(kBlack) obs_xsec.SetMarkerStyle(20) obs_xsec.SetMarkerSize(1) obs_xsec.Draw('PC SAME') theory_xsec = TGraph(len(xvals), array('d', xvals), array('d', theory)) theory_xsec.Sort() theory_xsec.SetLineWidth(2) theory_xsec.SetLineStyle(8) theory_xsec.SetLineColor(kBlue) theory_xsec.Draw('C SAME') leg = TLegend(0.50,0.70,0.8,0.90); leg.SetBorderSize(0); leg.SetFillStyle(0); leg.AddEntry(theory_xsec, "Theory", "l"); leg.AddEntry(obs_xsec, "Observed Limit", "pl"); leg.AddEntry(exp_xsec, "Expected Limit", "l"); leg.AddEntry(exp1sigma_xsec, "#pm 1 std. dev.", "f"); leg.AddEntry(exp2sigma_xsec, "#pm 2 std. dev.", "f"); leg.Draw() drawCMSLogo(c1, 13, 122450) # TCanvas.Update() draws the frame, after which one can change it # c1.Update() # c1.Modified() # c1.Update() c1.RedrawAxis() c1.Draw() wait(True)
def make1DLimitPlot(xtitle, xvals, obs, exp, exp1plus, exp1minus, exp2plus, exp2minus, theory, alphaD, xvar): gStyle.SetOptTitle(0) axisTitleSize = 0.041 axisTitleOffset = 1.2 axisTitleSizeRatioX = 0.18 axisLabelSizeRatioX = 0.12 axisTitleOffsetRatioX = 0.94 axisTitleSizeRatioY = 0.15 axisLabelSizeRatioY = 0.108 axisTitleOffsetRatioY = 0.32 leftMargin = 0.15 rightMargin = 0.12 topMargin = 0.05 bottomMargin = 0.14 bottomMargin2 = 0.22 #c1 = TCanvas() #'c1', '', 200, 10, 700, 500 ) c1 = TCanvas("c1", "c2", 200, 10, 700, 600) c1.SetHighLightColor(2) c1.SetFillColor(0) c1.SetBorderMode(0) c1.SetBorderSize(2) c1.SetLeftMargin(leftMargin) c1.SetRightMargin(rightMargin) c1.SetTopMargin(topMargin) c1.SetBottomMargin(bottomMargin) c1.SetFrameBorderMode(0) c1.SetFrameBorderMode(0) c1.SetLogy(1) #c1.SetLogx(1) c1.SetTickx(1) c1.SetTicky(1) #c1.SetGridx(True); #c1.SetGridy(True); if "c#tau" in xtitle: c1.SetLogx(1) exp2sigma_xsec = TGraphAsymmErrors(len(xvals), array('d', xvals), array('d', exp), \ array('d', [0]), array('d', [0]), array('d', exp2minus), array('d', exp2plus)) exp2sigma_xsec.Sort() exp2sigma_xsec.Draw('A3') exp2sigma_xsec.SetFillStyle(1001) exp2sigma_xsec.SetFillColor(kOrange) exp2sigma_xsec.SetLineColor(kOrange) exp2sigma_xsec.GetYaxis().SetRangeUser(1e-4, 1e3) if xvar == 'mass': exp2sigma_xsec.GetXaxis().SetLimits(1, 80) elif xvar == 'ctau': exp2sigma_xsec.GetXaxis().SetLimits(0.1, 100) else: exp2sigma_xsec.GetXaxis().SetLimits(0.8 * min(xvals), 1.1 * max(xvals)) #exp2sigma_xsec.GetXaxis().SetTitle('m_{1} [GeV]') #exp2sigma_xsec.GetXaxis().SetTitle('c#tau [cm]') exp2sigma_xsec.GetXaxis().SetTitle(xtitle) exp2sigma_xsec.GetXaxis().SetTitleOffset(axisTitleOffset) exp2sigma_xsec.GetYaxis().SetTitle( "#sigma_{95% CL} Br(A' #rightarrow #mu#mu) [pb]") exp2sigma_xsec.GetYaxis().SetTitleOffset(axisTitleOffset + 0.1) exp1sigma_xsec = TGraphAsymmErrors(len(xvals), array('d', xvals), array('d', exp), \ array('d', [0]), array('d', [0]), array('d', exp1minus), array('d', exp1plus)) exp1sigma_xsec.Sort() exp1sigma_xsec.SetFillStyle(1001) exp1sigma_xsec.SetFillColor(kGreen + 1) exp1sigma_xsec.SetLineColor(kGreen + 1) exp1sigma_xsec.Draw('3 SAME') exp_xsec = TGraph(len(xvals), array('d', xvals), array('d', exp)) exp_xsec.Sort() exp_xsec.SetLineWidth(2) exp_xsec.SetLineStyle(1) exp_xsec.SetLineColor(kRed) exp_xsec.Draw('C SAME') obs_xsec = TGraph(len(xvals), array('d', xvals), array('d', obs)) obs_xsec.Sort() obs_xsec.SetLineWidth(3) obs_xsec.SetLineColor(kBlack) obs_xsec.SetMarkerColor(kBlack) obs_xsec.SetMarkerStyle(20) obs_xsec.SetMarkerSize(1) obs_xsec.Draw('PC SAME') theory_xsec = TGraph(len(xvals), array('d', xvals), array('d', theory)) theory_xsec.Sort() theory_xsec.SetLineWidth(2) theory_xsec.SetLineStyle(8) theory_xsec.SetLineColor(kBlue) theory_xsec.Draw('C SAME') leg = TLegend(0.50, 0.70, 0.8, 0.90) leg.SetBorderSize(0) leg.SetFillStyle(0) leg.AddEntry(theory_xsec, "Theory", "l") leg.AddEntry(obs_xsec, "Observed Limit", "pl") leg.AddEntry(exp_xsec, "Expected Limit", "l") leg.AddEntry(exp1sigma_xsec, "#pm 1 std. dev.", "f") leg.AddEntry(exp2sigma_xsec, "#pm 2 std. dev.", "f") leg.Draw() drawCMSLogo(c1, 13, 122450) if alphaD != '': aDtext = TLatex() #baseSize = 25 aDtext.SetNDC() aDtext.SetTextAngle(0) aDtext.SetTextColor(1) #aDtext.SetTextFont(61) #aDtext.SetTextAlign(11) aDtext.SetTextSize(0.0375) aDtext.DrawLatex(0.7, 0.9, "#alpha_{D} = " + alphaD) # TCanvas.Update() draws the frame, after which one can change it # c1.Update() # c1.Modified() # c1.Update() c1.RedrawAxis() c1.Draw() wait(True)