largest_cont = 0 for (m3, mu), (mgl, mn1) in grid_m3_mu.iteritems(): name = 'GGM_M3_mu_%i_%i' % (m3, mu) sig = get_events(name, selection=selection, lumi='data').mean contamination = round(sig/(sig+total_bkg) * 100, 2) if contamination > largest_cont: largest_cont = contamination hmap.Fill(mgl, mn1, contamination) frame = draw_grid_frame() frame.SetRightMargin(0.15) hmap.SetContour(999) hmap.GetZaxis().SetRangeUser(0, 100) hmap.SetMarkerStyle(21) hmap.SetMarkerSize(100) hmap.Draw('pcolzsame') l = ROOT.TLatex() l.SetNDC() l.SetTextSize(0.035) l.DrawLatex(0.17, 0.85, 'Signal Contamination [%]') l.DrawLatex(0.17, 0.78, region.replace('_L', '_{L}').replace('_H', '_{H}')) frame.RedrawAxis()
def plot_exclusion(path, region, outdir): #set_default_style() set_atlas_style() ROOT.gStyle.SetLegendFont(42) # input files if sig_xs_syst: file_name = path + '/Output_fixSigXSecNominal_hypotest__1_harvest_list.root' file_name_high = path + '/Output_fixSigXSecUp_hypotest__1_harvest_list.root' file_name_low = path + '/Output_fixSigXSecDown_hypotest__1_harvest_list.root' else: file_name = path + '/Output_hypotest__1_harvest_list.root' # Get histograms ## obs CLs (Nominal, Low, High) sigp1clsf = return_contour95('sigp1clsf', file_name) if sig_xs_syst: sigp1clsfLow = return_contour95('sigp1clsf', file_name_low) sigp1clsfHigh = return_contour95('sigp1clsf', file_name_high) sigp1clsfLow.SetName('sigp1clsfLow') sigp1clsfLow.SetTitle('sigp1clsfLow') sigp1clsfHigh.SetName('sigp1clsfHigh') sigp1clsfHigh.SetTitle('sigp1clsfHigh') sigp1expclsf = return_contour95('sigp1expclsf', file_name) sigclsu1s = return_contour95('sigclsu1s', file_name) sigclsd1s = return_contour95('sigclsd1s', file_name) graph_sigp1clsf = convert_hist_to_graph(sigp1clsf) if sig_xs_syst: graph_sigp1clsfLow = convert_hist_to_graph(sigp1clsfLow) graph_sigp1clsfHigh = convert_hist_to_graph(sigp1clsfHigh) graph_sigp1expclsf = convert_hist_to_graph(sigp1expclsf) graph_sigclsu1s = convert_hist_to_graph(sigclsu1s) graph_sigclsd1s = convert_hist_to_graph(sigclsd1s) # Colours c_yellow = ROOT.TColor.GetColor('#ffe938') c_red = ROOT.TColor.GetColor('#aa0000') c_blue = ROOT.TColor.GetColor('#28373c') frame = draw_grid_frame(xmin=1146, xmax=2550, ymin=147, ymax=2550) # Create the text in the plot # DATA info leg1 = ROOT.TLatex() leg1.SetNDC() leg1.SetTextSize(0.035) leg1.SetTextColor(1) if args.datalabel is not None: leg1.DrawLatex(0.15, 0.7, args.datalabel) else: leg1.DrawLatex(0.15, 0.7, style.data_label) # if style.atlas_label: # leg1.SetTextSize(0.04) # leg1.DrawLatex(1810, 230, style.atlas_label) # Signal Regions label leg3 = ROOT.TLatex() leg3.SetNDC() leg3.SetTextSize(0.035) leg3.SetTextColor(1) leg3.SetTextFont(42) region_text = region if 'SRL,SRH' in region_text or 'SRiL,SRiH' in region_text: region_text = region_text = 'SR_{L} and SR_{H}' elif 'SRL' in region_text or 'SRiL' in region_text: region_text = 'SR_{L}' elif 'SRH' in region_text or 'SRiH' in region_text: region_text = 'SR_{H}' leg3.DrawLatex(0.15, 0.63, region_text) # Legend leg = ROOT.TLegend(0.15, 0.77, 0.49, 0.92) leg.SetFillColor(0) leg.SetBorderSize(0) # extra text leg4 = ROOT.TLatex() leg4.SetNDC() leg4.SetTextSize(0.03) leg4.SetTextColor(1) leg4.SetTextAngle(90) if (args.obscls or args.expcls or args.bestsr): leg4.SetTextColor(ROOT.kGray+2) textx = 0.98 texty = 0.12 if args.obscls: leg4.DrawLatex(textx, texty, 'Numbers give observed CL_{s} values') elif args.expcls: leg4.DrawLatex(textx, texty, 'Numbers give expected CL_{s} values') elif args.bestsr: leg4.DrawLatex(textx, texty, 'Labels indicate best-expected SR') # leg2 = ROOT.TLatex() # leg2.SetNDC() # leg2.SetTextSize(0.03) # leg2.SetTextColor(1) # leg2.DrawLatex(0.17, 0.75, "All limits at 95% CL") graph_sigp1clsf.SetFillColor(ROOT.kWhite) graph_sigp1clsf.SetFillStyle(3003) graph_sigp1clsf.SetLineColor(c_red) graph_sigp1clsf.SetLineStyle(1) graph_sigp1clsf.SetLineWidth(3) if sig_xs_syst: graph_sigp1clsfHigh.SetFillColor(ROOT.kWhite) graph_sigp1clsfHigh.SetFillStyle(3003) graph_sigp1clsfHigh.SetLineColor(c_red) graph_sigp1clsfHigh.SetLineStyle(3) graph_sigp1clsfHigh.SetLineWidth(2) graph_sigp1clsfLow.SetFillColor(ROOT.kWhite) graph_sigp1clsfLow.SetFillStyle(3003) graph_sigp1clsfLow.SetLineColor(c_red) graph_sigp1clsfLow.SetLineStyle(3) graph_sigp1clsfLow.SetLineWidth(2) sigp1expclsf.SetLineColor(c_blue) sigp1expclsf.SetLineStyle(1) sigp1expclsf.SetLineWidth(2) sigp1clsf.SetLineWidth(3) sigclsu1s.SetFillColor(ROOT.kWhite) sigclsd1s.SetFillColor(c_yellow) graph_sigp1expclsf.SetFillColor(c_yellow) graph_sigp1expclsf.SetFillStyle(1001) graph_sigp1expclsf.SetLineColor(c_blue) graph_sigp1expclsf.SetLineStyle(7) graph_sigp1expclsf.SetLineWidth(2) # Load run 1 limit # if ',' in region: # f = ROOT.TFile.Open(os.environ['SUSY_ANALYSIS'] + '/results/limit_run1_gln1.root') # limit_run1 = f.Get('clsf_obs') # leg.AddEntry(limit_run1, 'ATLAS 8 TeV, 20.3 fb^{-1}', 'F') if not args.onlyexp: obs_entry = leg.AddEntry(graph_sigp1clsf, "Observed limit (#pm1 #sigma^{SUSY}_{theory})", "LF") leg.AddEntry(graph_sigp1expclsf, "Expected limit (#pm1 #sigma_{exp})", "LF") leg.Draw() if not args.onlyexp and sig_xs_syst: ROOT.gPad.Update() n_rows = leg.GetNRows() x1 = 0.15 y1 = 0.77 x2 = 0.49 y2 = 0.92 margin = leg.GetMargin() * (x2-x1) boxw = margin*0.35 yspace = (y2-y1) / n_rows xsym = x1 + margin/2. ysym = y2 - 0.5*yspace - yspace * (n_rows-2) dy = 0.015 line = ROOT.TLine() ROOT.SetOwnership(line, False) line.SetLineColor(obs_entry.GetLineColor()) line.SetLineWidth(2) line.SetLineStyle(3) line.DrawLineNDC(xsym-boxw, ysym+dy, xsym+boxw, ysym+dy) line.DrawLineNDC(xsym-boxw, ysym-dy, xsym+boxw, ysym-dy) # Plot sigclsd1s.Draw("same cont0") sigclsu1s.Draw("same cont0") graph_sigp1expclsf.Draw("same l") if not args.onlyexp: graph_sigp1clsf.Draw('same l') if sig_xs_syst: graph_sigp1clsfHigh.Draw("same l") graph_sigp1clsfLow.Draw("same l") # plot Run 1 limit # if ',' in region: # limit_run1.SetLineWidth(2) # limit_run1.SetLineColor(get_color('#b9b7b7')) # limit_run1.SetFillColor(get_color('#c6c4c4')) # limit_run1.Draw('f same') # limit_run1.Draw('l same') # Redraw axis and update frame frame.RedrawAxis() ROOT.gPad.Update() output_tag = '' if args.obscls or args.expcls: # if sig_xs_syst: # file_name = '%s/Output_fixSigXSecNominal_hypotest__1_harvest_list.root' % path # else: # file_name = '%s/Output_hypotest__1_harvest_list.root' % path l_region = ROOT.TLatex() l_region.SetTextSize(0.014) l_region.SetTextColor(ROOT.kGray+2) if sig_xs_syst: tree_file = '%s/Output_fixSigXSecNominal_hypotest__1_harvest_list_hack.root' % path else: tree_file = '%s/Output_hypotest__1_harvest_list_hack.root' % path if args.obscls: cls_dict = get_cls_values(tree_file, False) output_tag = '_obscls' if args.expcls: cls_dict = get_cls_values(tree_file, True) output_tag = '_expcls' for (mgl, mn1), cls in cls_dict.iteritems(): l_region.DrawLatex(mgl, mn1, "%.3f" % cls) elif args.bestsr: output_tag = '_bestsr' region_events = dict() dict_events = dict() for sel in region.split(','): if sig_xs_syst: tree_file = '%s/Output_%s_fixSigXSecNominal_hypotest__1_harvest_list_hack.root' % (path, sel) else: tree_file = '%s/Output_%s_hypotest__1_harvest_list_hack.root' % (path, sel) dict_events = get_cls_values(tree_file, exp=True) region_events[sel] = dict_events l_tot = ROOT.TLatex() l_tot.SetTextSize(0.016) l_tot.SetTextColor(ROOT.kGray+3) for mgl, mn1 in dict_events.iterkeys(): binCLs = 100. best_region_string = '' for r in region_events.iterkeys(): if region_events[r][(mgl, mn1)] < binCLs: binCLs = region_events[r][(mgl, mn1)] best_region_string = r print mgl, mn1, r, binCLs l_tot.DrawLatex(mgl, mn1, "%s" % best_region_string[-1]) elif args.points: lp = ROOT.TLatex() lp.SetTextSize(0.016) lp.SetTextColor(ROOT.kGray+3) for (m3, mu), (mgl, mn1) in grid_m3_mu.iteritems(): if m3 > 2000: lp.SetTextColor(ROOT.kRed-4) lp.DrawLatex(mgl, mn1, "#times") else: lp.SetTextColor(ROOT.kGray+3) lp.DrawLatex(mgl, mn1, "#bullet") frame.SaveAs(path+'/limitPlot_%s%s.pdf' % (region.replace(',', '_'), output_tag)) # Save contours outname = path + '/limit_contour_%s' % region.replace(',', '_') + '.root' outfile = ROOT.TFile(outname, 'recreate') outfile.cd() ## observed graph_sigp1clsf.Write('clsf_obs') if sig_xs_syst: graph_sigp1clsfHigh.Write("clsf_obs_up") graph_sigp1clsfLow.Write("clsf_obs_dn") ## expected graph_sigp1expclsf.Write('clsf_exp') if sig_xs_syst: graph_sigclsd1s = convert_hist_to_graph(sigclsd1s) graph_sigclsu1s = convert_hist_to_graph(sigclsu1s) graph_sigclsd1s.Write('clsf_exp_dn') graph_sigclsu1s.Write('clsf_exp_up') outfile.Close()
h_srl200.SetDirectory(f) h_srl300.SetDirectory(f) h_srh.SetDirectory(f) h_srl200.Write('h_srl200') h_srl300.Write('h_srl300') h_srh.Write('h_srh') f.Close() sys.exit(1) # plot set_atlas_style() # SRL200 frame_srl200 = draw_grid_frame() frame_srl200.SetRightMargin(0.15) h_srl200.SetContour(999) h_srl200.GetZaxis().SetRangeUser(0, 0.4) h_srl200.SetMarkerStyle(21) h_srl200.SetMarkerSize(100) h_srl200.Draw('pcolzsame') l = ROOT.TLatex() l.SetNDC() l.SetTextSize(0.035) l.DrawLatex(0.17, 0.85, 'Acceptance #times efficiency') l.DrawLatex(0.17, 0.78, 'SRL200') frame_srl200.RedrawAxis()
for (m3, mu), (mgl, mn1) in mg_gg_grid.iteritems(): name = 'GGM_GG_bhmix_%i_%i' % (m3, mu) sig = get_events(name, selection=selection, lumi='data').mean contamination = round(sig / (sig + total_bkg) * 100, 2) if contamination > largest_cont: largest_cont = contamination if contamination < 0.001: contamination = 0.001 hmap.Fill(mgl, mn1, contamination) frame = draw_grid_frame(800, 800, gl_min, gl_max, n1_min, n1_max) frame.SetRightMargin(0.12) hmap.SetContour(999) hmap.GetZaxis().SetRangeUser(0, 100) hmap.GetZaxis().SetLabelSize(0.03) hmap.SetMarkerStyle(21) hmap.SetMarkerSize(200) hmap.Draw('pcolzsame') l = ROOT.TLatex() l.SetNDC() l.SetTextSize(0.035) l.DrawLatex(0.17, 0.85, 'Signal Contamination [%]') l.DrawLatex(0.17, 0.78, region.replace('_L', '_{L}').replace('_H', '_{H}'))
sril_acceff = round(sril_events/total_events, 2) srih_acceff = round(srih_events/total_events, 2) h_srl.Fill(mgl, mn1, srl_acceff) h_srh.Fill(mgl, mn1, srh_acceff) h_sril.Fill(mgl, mn1, sril_acceff) h_srih.Fill(mgl, mn1, srih_acceff) # plot set_atlas_style() set_palette() # SRL frame_srl = draw_grid_frame() frame_srl.SetRightMargin(0.15) h_srl.SetContour(999) h_srl.GetZaxis().SetRangeUser(0, 0.4) h_srl.SetMarkerStyle(21) h_srl.SetMarkerSize(100) h_srl.Draw('pcolzsame') l = ROOT.TLatex() l.SetNDC() l.SetTextSize(0.035) l.DrawLatex(0.17, 0.85, 'Acceptance #times efficiency') l.DrawLatex(0.17, 0.78, 'SR_{L}') frame_srl.RedrawAxis()