ratio_err = ratio * math.sqrt(1 / lo + 1 / hi) h_hori.Fill(h.yedges(i), ratio) h_hori.SetBinError(int(i / nbins_per_slice) + 1, ratio_err) return h_vert, h_hori, ybound_val, xbound_val h = f.ch4mu.data.dphiIso2Dinit print('[4mu VR] dphiIsoinit - correlation factor: ', h.get_correlation_factor()) h.Draw('colz') h.GetListOfFunctions().FindObject("palette").SetX2NDC(0.92) title = TitleAsLatex('[4#mu VR] ' + h.title) title.Draw() canvas.SaveAs('{}/ch4mu_vr_dphiisopre.pdf'.format(outdir)) canvas.Clear() h.Draw('colz') h.GetListOfFunctions().FindObject("palette").SetX2NDC(0.92) title.Draw() dphi_bounds = [0.7 * math.pi, 0.8 * math.pi, 0.9 * math.pi] vlines = [] for i, b in enumerate(dphi_bounds): vline = Line(b, h.yaxis.GetXmin(), b, h.yaxis.GetXmax()) vline.color = COLORS[i] vline.linewidth = 2 vlines.append(vline) for l in vlines: l.Draw() canvas.SaveAs('{}/ch4mu_vr_dphiisopre_vline.pdf'.format(outdir)) canvas.Clear()
gr.SetLineColor(ROOT.kRed + 2) gr.SetMarkerColor(ROOT.kRed + 2) gr.SetMarkerStyle(20) gr.SetTitle("QQ with CL") gr.GetXaxis().SetTitle(h1.GetTitle()) gr.GetYaxis().SetTitle(h2.GetTitle()) gr.SetFillColor(17) gr.SetFillStyle(1001) c = Canvas(name="c", title="QQ with CL", width=600, height=450) gr.Draw("ap") x_min = gr.GetXaxis().GetXmin() x_max = gr.GetXaxis().GetXmax() y_min = gr.GetXaxis().GetXmin() y_max = gr.GetXaxis().GetXmax() c.Clear() gr.Draw('a3') gr.Draw('Xp same') # a straight line y=x to be a reference f_dia = ROOT.TF1("f_dia", "x", h1.GetXaxis().GetXmin(), h1.GetXaxis().GetXmax()) f_dia.SetLineColor(9) f_dia.SetLineWidth(2) f_dia.SetLineStyle(2) f_dia.Draw("same") leg = ROOT.TLegend(0.52, 0.15, 0.87, 0.35) leg.SetFillColor(0) leg.SetShadowColor(17)
def routine(chandir, bkgh, optm_region, outdir): canvas = Canvas() ROOT.gPad.SetGrid() for massKey in chandir.keys(): mboundstate = int(massKey.name.split('_')[0].replace('mXX-', '')) NORM_FACTOR_SIGNAL = 30./genxsec[mboundstate] # norm to 30/fb massDir = getattr(chandir, massKey.name) _outdir = os.path.join(outdir, massKey.name) if not os.path.isdir(_outdir): os.makedirs(_outdir) boundary_edges = {} for lifetimeKey in massDir.keys(): lifetimeDir = getattr(massDir, lifetimeKey.name) sigh = lifetimeDir.dphiIso2D_nominal sigh.scale( NORM_FACTOR_SIGNAL ) ###### ZA map ###### zah = create_za_map(sigh, bkgh, optm_region=optm_region) zah.Draw('colz') zah.GetListOfFunctions().FindObject("palette").SetX2NDC(0.92) mkh, xedge, yedge, maxval = mark_maximum_bin(zah) boundary_edges[lifetimeKey.name] = (xedge, yedge, maxval) # bookkeeping for overlap plot label = '(|#Delta#phi|, iso): {:.2f}, {:.2f} '.format(xedge, yedge)+'Z_{A}: '+'{:.3f}'.format(maxval) mkh.Draw('p same') if outdir.endswith('ch4mu'): title = TitleAsLatex('[4#mu {}] '.format(massKey.name)+'proxy significance Z_{A}') if outdir.endswith('ch2mu2e'): title = TitleAsLatex('[2#mu2e {}] '.format(massKey.name)+'proxy significance Z_{A}') title.Draw() leg = Legend(1, margin=0.25, leftmargin=0.05, rightmargin=0.5, topmargin=0.05, entrysep=0.01, entryheight=0.02, textsize=15, header=lifetimeKey.name) leg.AddEntry(mkh, label=label) leg.Draw() canvas.SaveAs('{}/ZA__{}.png'.format(_outdir, lifetimeKey.name)) canvas.SaveAs('{}/ZA__{}.pdf'.format(_outdir, lifetimeKey.name)) canvas.Clear() ###### signal distribution ###### sigc = sigh.clone() sigc.Draw('colz') if sigc.integral(): sigc.GetListOfFunctions().FindObject("palette").SetX2NDC(0.92) if outdir.endswith('ch4mu'): title = TitleAsLatex('[4#mu SR {}] '.format(massKey.name)+'|#Delta#phi| vs. maxIso') if outdir.endswith('ch2mu2e'): title = TitleAsLatex('[2#mu2e SR {}] '.format(massKey.name)+'|#Delta#phi| vs. Iso') sigc.yaxis.title='egm lepton-jet iso' title.Draw() decorate_axis_pi(sigc.xaxis) hline = Line(sigc.xaxis.GetXmin(), yedge, sigc.xaxis.GetXmax(), yedge) vline = Line(xedge, sigc.yaxis.GetXmin(), xedge, sigc.yaxis.GetXmax()) for l in [hline, vline]: l.linewidth=2 l.color='red' l.Draw() canvas.SaveAs('{}/IsoDphi_{}.png'.format(_outdir, lifetimeKey.name)) canvas.SaveAs('{}/IsoDphi_{}.pdf'.format(_outdir, lifetimeKey.name)) canvas.Clear() ###### optimal boundaries ###### boundsh = sigh.clone() boundsh.Reset() boundsh.Draw('col') decorate_axis_pi(boundsh.xaxis) leg = Legend(len(boundary_edges), margin=0.25, leftmargin=0.05, rightmargin=0.5, topmargin=0.05, entrysep=0.01, entryheight=0.02, textsize=12) get_lxy = lambda t : float(t.split('_')[0].split('-')[-1].replace('p', '.')) for i, k in enumerate(sorted(boundary_edges, key=get_lxy)): bx, by, za = boundary_edges[k] hline = Line(boundsh.xaxis.GetXmin(), by, boundsh.xaxis.GetXmax(), by) vline = Line(bx, boundsh.yaxis.GetXmin(), bx, boundsh.yaxis.GetXmax()) label = '{:20}'.format(k) label+='({:.2f}, {:.2f})'.format(bx, by) label+=' Z_{A}: %.3f'%za leg.AddEntry(hline, label=label, style='L') for l in (hline, vline): l.linewidth=2 l.color=sigCOLORS[i] if i%2==0: l.linestyle='dashed' l.Draw() leg.Draw() if outdir.endswith('ch4mu'): title = TitleAsLatex('[4#mu {}] '.format(massKey.name)+'optimial boundaries') if outdir.endswith('ch2mu2e'): title = TitleAsLatex('[2#mu2e SR {}] '.format(massKey.name)+'optimal boundaries') title.Draw() canvas.SaveAs('{}/boundaries.png'.format(_outdir)) canvas.SaveAs('{}/boundaries.pdf'.format(_outdir)) canvas.Clear()