def main(): ROOT.gROOT.SetBatch() line_width = 3 limits = [ ('res_NWA_ggF.root', utils.ggfs, 'ggF production'), ('res_NWA_VBF.root', utils.vbfs, 'VBF production'), ('llvv_LWA_wH1.root', utils.ggfs, 'LWA, #it{#Gamma_{H}} = 0.01 #times #it{m_{H}}'), ('llvv_LWA_wH5.root', utils.ggfs, 'LWA, #it{#Gamma_{H}} = 0.05 #times #it{m_{H}}'), ('llvv_LWA_wH10.root', utils.ggfs, 'LWA, #it{#Gamma_{H}} = 0.1 #times #it{m_{H}}'), ] for file_name, y_axis_title, prod_mode in limits: file = ROOT.TFile('inputs/' + file_name) exp_4l = file.Get('canvas2').GetPrimitive('Graph4') exp_4l.SetLineStyle(7) exp_4l.SetLineWidth(line_width) exp_4l.SetLineColor(ROOT.kAzure + 2) exp_4l.SetMarkerColor(ROOT.kAzure + 2) exp_2l2v = file.Get('canvas2').GetPrimitive('Graph6') exp_2l2v.SetLineStyle(3) exp_2l2v.SetLineWidth(line_width + 1) exp_2l2v.SetLineColor(ROOT.kOrange + 10) exp_2l2v.SetMarkerColor(ROOT.kOrange + 10) exp_comb = file.Get('canvas2').GetPrimitive('Graph2') exp_comb.SetLineStyle(2) exp_comb.SetLineWidth(line_width) exp_comb.SetLineColor(ROOT.kBlack) exp_comb.SetMarkerColor(ROOT.kBlack) obs_comb = file.Get('canvas2').GetPrimitive('Graph3') obs_comb.SetLineStyle(1) obs_comb.SetLineWidth(line_width) obs_comb.SetLineColor(ROOT.kBlack) obs_comb.SetMarkerColor(ROOT.kBlack) obs_comb.SetMarkerSize(1) band_1 = file.Get('canvas2').GetPrimitive('Graph1') band_1.SetFillColor(3) band_2 = file.Get('canvas2').GetPrimitive('Graph0') band_2.SetFillColor(5) canvas = ROOT.TCanvas('plot_' + file_name.replace('.root', ''), '', 800, 600) band_2.Draw('a3') if 'LWA' in prod_mode: band_2.GetXaxis().SetRangeUser(400, 1000) band_2.GetYaxis().SetRangeUser(0.005, 1.5) else: band_2.GetXaxis().SetRangeUser(200, 1200) band_2.GetYaxis().SetRangeUser(0.005, 10) band_2.GetXaxis().SetTitle('#it{m_{H}} [GeV]') band_2.GetYaxis().SetTitle('95% C.L. limit on ' + y_axis_title + ' [pb]') band_2 = utils.re_style(band_2) band_1.Draw('3') exp_4l.Draw('l') exp_2l2v.Draw('l') exp_comb.Draw('l') obs_comb.Draw('pl') x_l1, y_l1, latex1 = utils.draw_latex(utils.lumi, False) latex1.DrawLatex( x_l1, y_l1 - 0.105, utils.h_to_zz_to + utils.lepp + utils.lepm + utils.lepp + utils.lepm + ' + ' + utils.lepp + utils.lepm + utils.nu + utils.nubar) latex1.DrawLatex(x_l1, y_l1 - 0.16, prod_mode) xLeg = 0.62 yLeg = 0.89 leg = utils.create_legend_limit(6) utils.print_details(obs_comb) leg.AddEntry(obs_comb, 'Observed ' + utils.cls + ' limit', 'pl') leg.AddEntry(exp_comb, 'Expected ' + utils.cls + ' limit', 'l') leg.AddEntry(band_1, 'Expected #pm 1#sigma', 'f') leg.AddEntry(band_2, 'Expected #pm 2#sigma', 'f') leg.AddEntry( exp_4l, 'Expected ' + utils.cls + ' limit (' + utils.lepp + utils.lepm + utils.lepp + utils.lepm + ')', 'l') leg.AddEntry( exp_2l2v, 'Expected ' + utils.cls + ' limit (' + utils.lepp + utils.lepm + utils.nu + utils.nubar + ')', 'l') #leg.AddEntry( exp_4l, 'Expected ' + utils.cls + ' limit', 'l' ) #leg.AddEntry( exp_2l2v, 'Expected ' + utils.cls + ' limit', 'l' ) leg.Draw() ROOT.gPad.RedrawAxis() #utils.patch_bar( 292. / 566., 298. / 566., 327. / 407., 327. / 407., True ) canvas.SetLogy() utils.save(canvas)
def main(): ### Main definitions ROOT.gROOT.SetBatch() ### canvas, c_top, c_bottom = utils.create_double_pad('plot_3lcr_2l2v') ### root_file = ROOT.TFile('inputs/MTW_all_met_tst.root') stack = utils.re_style_top( root_file.Get('c1').GetPrimitive('pad1').GetPrimitive('hs1')) stack.GetXaxis().SetTitle('#it{E}_{T}^{miss} [GeV]') stack.GetYaxis().SetTitle('Events / 30 GeV') hists = {} merging_scheme = utils.complex_merging full_stack = stack.GetStack().Last() for hist in stack.GetHists(): prev_color = hist.GetFillColor() sample_name = None for key, vals in utils.original_colors_2l2v.iteritems(): if prev_color in vals: sample_name = key if not sample_name: 'Sample Name Not Found' else: ''' for merging_key, merging_list in merging_scheme.iteritems(): if sample_name in merging_list: print sample_name, ' is supposed to be merged into ', merging_key ''' hists[sample_name] = utils.re_shape_tail(hist) ''' a = hist.GetXaxis() print print a.GetNbins() print a.GetXmin() print a.GetXmax() ''' ### Getting complicated here... loop_over_this = hists.keys() to_be_removed = utils.wjets_removal for key in loop_over_this: for merging_key, merging_list in merging_scheme.iteritems(): if key in merging_list: to_be_removed.add(key) if merging_key in hists: hists[merging_key].Add(hists[key]) else: hists[merging_key] = hists[key].Clone('another_clone_' + hists[key].GetName()) to_be_used = [] for k in hists: hist = hists[k] hist.SetFillColor(utils.get_colors(k)) hist.SetLineColor(ROOT.kBlack) hist.SetLineWidth(1) hist.SetTitle(utils.titles[k]) if not k in to_be_removed: to_be_used.append((k, hist.Integral())) sample_list = sorted(to_be_used, key=lambda x: x[1]) sample_list_r = sorted(to_be_used, key=lambda x: x[1], reverse=True) new_stack = ROOT.THStack(stack.GetName() + '_clone', '') for name, integral in sample_list: new_stack.Add(hists[name]) ### data = utils.re_style_top( utils.th1_to_tgraph( root_file.Get('c1').GetPrimitive('pad1').GetPrimitive( 'met_tst_MTW_all_Nominal'), True)) prev_error, last_bin_ratio = utils.re_shape_tail( root_file.Get('c1').GetPrimitive('pad1').GetPrimitive('h0'), True) error = utils.re_style_top(utils.th1_to_tgraph(prev_error)) error.SetMarkerStyle(1) error.SetFillColor(ROOT.kBlack) error.SetFillStyle(3345) ### ratio_axis = utils.re_style_bot( root_file.Get('c1').GetPrimitive('pad2').GetPrimitive('h3')) ratio = utils.re_style_bot( utils.th1_to_tgraph( root_file.Get('c1').GetPrimitive('pad2').GetPrimitive('h3'), True)) ratio_axis.GetXaxis().SetTitle('#it{E}_{T}^{miss} [GeV]') ratio_axis.GetYaxis().SetTitle('#frac{Data}{Prediction}') syst_band = utils.re_style_bot( utils.th1_to_tgraph( utils.change_last_bin( root_file.Get('c1').GetPrimitive('pad2').GetPrimitive('h0'), last_bin_ratio))) #ratio = utils.re_style_bot( root_file.Get( 'c1' ).GetPrimitive( 'pad2' ).GetPrimitive( 'h3' ) ) #ratio.GetXaxis().SetTitle( '#it{E}_{T}^{miss} [GeV]' ) #ratio.GetYaxis().SetTitle( '#frac{Data}{Prediction}' ) ##syst_band = utils.re_style_bot( utils.re_shape_tail( root_file.Get( 'c1' ).GetPrimitive( 'pad2' ).GetPrimitive( 'h0' ), full_stack ) ) #syst_band = utils.re_style_bot( utils.change_last_bin( root_file.Get( 'c1' ).GetPrimitive( 'pad2' ).GetPrimitive( 'h0' ), last_bin_ratio ) ) syst_band.SetMarkerStyle(1) syst_band.SetFillColor(ROOT.kBlack) syst_band.SetFillStyle(3345) ### c_top.cd() new_stack.SetMaximum(1000000) new_stack.SetMinimum(0.001) new_stack.Draw('hist') new_stack = utils.re_style_top(new_stack) new_stack.Draw('hist') new_stack.GetXaxis().SetTitle('#it{E}_{T}^{miss} [GeV]') new_stack.GetYaxis().SetTitle('Events / 30 GeV') new_stack.GetXaxis().SetRangeUser(0, 600) error.Draw('e2 same') data.Draw('pe') x_l1, y_l1, latex1 = utils.draw_latex(utils.lumi, True) latex1.DrawLatex( x_l1, y_l1 - 0.12, utils.h_to_zz_to + utils.lepp + utils.lepm + utils.nu + utils.nubar + utils.void_char + utils.inv_prime) latex1.DrawLatex(x_l1, y_l1 - 0.18, '3#it{l} Control Region') leg = utils.create_legend(len(sample_list_r), 0.3, 1) leg.AddEntry(data, 'Data', 'pe') for name, integral in sample_list_r: leg.AddEntry(hists[name], hists[name].GetTitle(), 'f') leg.AddEntry(error, 'Uncertainty', 'f') leg.Draw() #utils.patch_bar( 229. / 566., 234. / 566., 322. / 407., 322. / 407., True ) c_top.SetLogy() c_bottom.cd() ratio_axis.Draw('axis') ratio_axis.GetXaxis().SetRangeUser(0, 600) syst_band.Draw('e2 same') ratio.Draw('pe0 same') c_bottom.Update() for arrow in utils.get_arrows(ROOT.gPad.GetUymin(), ROOT.gPad.GetUymax(), ratio): arrow.Draw() Line = ROOT.TLine(ROOT.gPad.GetUxmin(), 1, ROOT.gPad.GetUxmax(), 1) Line.SetLineColor(ROOT.kBlack) Line.SetLineWidth(2) Line.SetLineStyle(2) Line.Draw() #canvas.SaveAs( canvas.GetName() + '.pdf' ) utils.save(canvas)
def main(): ROOT.gROOT.SetBatch() line_width = 2 file = ROOT.TFile('inputs/p0_NWA_graphs.root') p0_4l = file.Get('p0_4l') p0_4l.SetLineStyle(7) p0_4l.SetLineWidth(line_width) p0_4l.SetLineColor(ROOT.kAzure + 2) p0_4l.SetMarkerColor(ROOT.kAzure + 2) p0_2l2v = file.Get('p0_llvv') p0_2l2v.SetLineStyle(3) p0_2l2v.SetLineWidth(line_width) p0_2l2v.SetLineColor(ROOT.kOrange + 10) p0_2l2v.SetMarkerColor(ROOT.kOrange + 10) p0_comb = file.Get('p0_comb') p0_comb.SetLineStyle(1) p0_comb.SetLineWidth(line_width) p0_comb.SetLineColor(ROOT.kBlack) p0_comb.SetMarkerColor(ROOT.kBlack) canvas = ROOT.TCanvas('plot_p0', '', 800, 600) p0_4l.Draw('ac') minX, maxX = 200, 1200 p0_4l.GetXaxis().SetRangeUser(minX, maxX) p0_4l.GetYaxis().SetRangeUser(0.000001, 1.5) p0_4l.GetXaxis().SetTitle('#it{m_{H}} [GeV]') p0_4l.GetYaxis().SetTitle('Local #it{p}_{0}') p0_4l = utils.re_style(p0_4l) #lines_y = [ 0.5, 0.1586553, 0.02275013, 0.001349898 ] lines_y = [0.1586553, 0.02275013, 0.001349898, 0.000063342484 * .5] loc_line = {} loc_tex = {} for index, line_y in enumerate(lines_y): loc_line[index] = ROOT.TLine(minX, line_y, maxX, line_y) loc_line[index].SetLineColor(15) loc_line[index].SetLineStyle(5) loc_line[index].SetLineWidth(2) loc_line[index].Draw() loc_tex[index] = ROOT.TLatex(maxX * 1.01, line_y, '%d#sigma' % (index + 1)) loc_tex[index].SetTextColor(15) loc_tex[index].SetTextFont(42) loc_tex[index].SetTextSize(0.03) loc_tex[index].SetTextAlign(12) loc_tex[index].Draw() p0_2l2v.Draw('c') p0_comb.Draw('c') x_l1, y_l1, latex1 = utils.draw_latex(utils.lumi, False, 0.05, -0.46) latex1.DrawLatex( x_l1, y_l1 - 0.115, utils.h_to_zz_to + utils.lepp + utils.lepm + utils.lepp + utils.lepm + ' + ' + utils.lepp + utils.lepm + utils.nu + utils.nubar) latex1.DrawLatex(x_l1, y_l1 - 0.17, 'NWA') latex1.SetTextSize(17) latex1.DrawLatex(0.6, 0.68, 'Global significance for') latex1.DrawLatex( 0.6, 0.63, 'largest excess (' + utils.lepp + utils.lepm + utils.lepp + utils.lepm + '): 2.2#sigma') xLeg = 0.62 yLeg = 0.89 leg = utils.create_legend_limit(3, 0.1, -0.48) leg.AddEntry(p0_4l, utils.lepp + utils.lepm + utils.lepp + utils.lepm, 'l') leg.AddEntry(p0_2l2v, utils.lepp + utils.lepm + utils.nu + utils.nubar, 'l') leg.AddEntry(p0_comb, 'Combined', 'l') leg.Draw() #utils.patch_bar( 321. / 566., 326. / 566., 140. / 407., 140. / 407., True ) #utils.patch_bar( 443. / 566., 448. / 566., 137. / 407., 137. / 407., True ) canvas.SetLogy() utils.save(canvas)
def make_plot( file_name, cat, title, maxYtop, minY = 0.02, maxY = 1.98 ): #def make_plot( file_name, cat, title, maxYtop, minY = 0.18, maxY = 1.82 ): #def make_plot( file_name, cat, title, maxYtop, minY = 0., maxY = 3.4 ): ### canvas, c_top, c_bottom = utils.create_double_pad( 'plot_%s' % file_name.replace( '.root', '' ) ) ### root_file = ROOT.TFile( 'inputs/' + file_name ) stack = utils.re_style_top( root_file.Get( 'ratio' ).GetPrimitive( 'p1_ratio' ).GetPrimitive( 'combined' ) ) hists = {} merging_scheme = {} #utils.complex_merging for hist in stack.GetHists(): prev_color = hist.GetFillColor() sample_name = None for key, vals in utils.original_colors_4l.iteritems(): if prev_color in vals: sample_name = key ''' if not sample_name: 'Sample Name Not Found' else: hist.SetFillColor( utils.get_colors( sample_name ) ) #hist.SetLineColor( utils.colors[ sample_name ] ) hist.SetLineColor( ROOT.kBlack ) hist.SetLineWidth( 1 ) hist.SetTitle( utils.titles[ sample_name ] ) ''' hists[ sample_name ] = hist ### Getting complicated here... loop_over_this = hists.keys() to_be_removed = set() for key in loop_over_this: for merging_key, merging_list in merging_scheme.iteritems(): if key in merging_list: to_be_removed.add( key ) if merging_key in hists: hists[ merging_key ].Add( hists[ key ] ) else: hists[ merging_key ] = hists[ key ].Clone( 'another_clone_' + hists[ key ].GetName() ) to_be_used = [] for k in hists: hist = hists[ k ] hist.SetFillColor( utils.get_colors( k ) ) hist.SetLineColor( ROOT.kBlack ) hist.SetLineWidth( 1 ) hist.SetTitle( utils.titles[ k ] ) if not k in to_be_removed: penalty = 0 if k == 'Red': penalty = -1 to_be_used.append( ( k, hist.Integral() + penalty ) ) sample_list = sorted( to_be_used, key = lambda x: x[ 1 ] ) sample_list_r = sorted( to_be_used, key = lambda x: x[ 1 ], reverse = True ) new_stack = ROOT.THStack( stack.GetName() + '_clone', '' ) for name, integral in sample_list: new_stack.Add( hists[ name ] ) data, error = None, None for element in root_file.Get( 'ratio' ).GetPrimitive( 'p1_ratio' ).GetListOfPrimitives(): if element.GetName() == 'Graph': if not utils.is_data( element ): error = utils.re_style_top( element ) error.SetMarkerStyle( 1 ) error.SetFillColor( ROOT.kBlack ) error.SetFillStyle( 3345 ) else: data = utils.re_style_top( element ) ### ratio = utils.re_style_bot( root_file.Get( 'ratio' ).GetPrimitive( 'p2_ratio' ).GetPrimitive( 'dataRatio' ) ) syst_band = utils.re_style_bot( root_file.Get( 'ratio' ).GetPrimitive( 'p2_ratio' ).GetPrimitive( 'sysGraphRatio' ), minY, maxY ) syst_band.SetMarkerStyle( 1 ) syst_band.SetFillColor( ROOT.kBlack ) syst_band.SetFillStyle( 3345 ) syst_band.GetXaxis().SetTitle( utils.m4l ) #'#it{m}_{4l} [GeV]' ) syst_band.GetYaxis().SetTitle( '#frac{Data}{Prediction}' ) ### c_top.cd() new_stack.SetMinimum( 0.003 ) new_stack.Draw( 'hist' ) new_stack = utils.re_style_top( new_stack ) new_stack.Draw( 'hist' ) #new_stack.GetXaxis().SetRangeUser( 250, 1500 ) new_stack.GetXaxis().SetTitle( utils.m4l ) #'#it{m}_{4l} [GeV]' ) new_stack.GetYaxis().SetTitle( 'Events / %d GeV' % int( stack.GetXaxis().GetBinWidth( 1 ) ) ) new_stack.SetMaximum( maxYtop ) error.Draw( 'e2' ) data.Draw( 'p same' ) x_l1, y_l1, latex1 = utils.draw_latex( utils.lumi, True ) latex1.DrawLatex( x_l1, y_l1 - 0.12, title + utils.void_char ) latex1.DrawLatex( x_l1, y_l1 - 0.18, cat + utils.void_char ) leg = utils.create_legend( len( sample_list_r ), 0.3, 1 ) leg.AddEntry( data, 'Data', 'pe' ) for name, integral in sample_list_r: leg.AddEntry( hists[ name ], hists[ name ].GetTitle(), 'f' ) leg.AddEntry( error, 'Uncertainty', 'f' ) #leg.AddEntry( None, '', '' ) #leg.AddEntry( None, '#color[0]{' + utils.titles[ 'emu' ] + '}', '' ) leg.Draw() c_top.Update() minX, maxX = ROOT.gPad.GetUxmin(), ROOT.gPad.GetUxmax() c_top.SetLogy() c_bottom.cd() syst_band.Draw( 'ae2' ) syst_band.GetXaxis().SetRangeUser( minX, maxX ) ratio.Draw( 'pe0 same' ) c_bottom.Update() for arrow in utils.get_arrows( ROOT.gPad.GetUymin(), ROOT.gPad.GetUymax(), ratio ): arrow.Draw() Line = ROOT.TLine( ROOT.gPad.GetUxmin(), 1, ROOT.gPad.GetUxmax(), 1 ) Line.SetLineColor( ROOT.kBlack ) Line.SetLineWidth( 2 ) Line.SetLineStyle( 2 ) Line.Draw() utils.save( canvas )
def main(): ROOT.gROOT.SetBatch() limits = [ ( 'ExclusionContours_2HDMTypeI_tanb_vs_cba.root', '#bf{2HDM Type I, #it{m_{H}} = 200 GeV}', 1, 10, 26, -0.9, 0.9, 'cos(#beta-#alpha)', utils.h_to_zz_to + utils.lepp + utils.lepm + utils.lepp + utils.lepm, None ), ( 'ExclusionContours_2HDMTypeII_tanb_vs_cba.root', '#bf{2HDM Type II, #it{m_{H}} = 200 GeV}', 1, 10, 26, -0.9, 0.9, 'cos(#beta-#alpha)', utils.h_to_zz_to + utils.lepp + utils.lepm + utils.lepp + utils.lepm, None ), ( 'ExclusionContours_2HDMTypeI_tanb_vs_mH.root', '#bf{2HDM Type I, cos(#beta-#alpha) = -0.1}', 0.5, 18, 80, 200, 400, '#it{m_{H}} [GeV]', utils.h_to_zz_to + utils.lepp + utils.lepm + utils.lepp + utils.lepm + ' + ' + utils.lepp + utils.lepm + utils.nu + utils.nubar, ( 320, 324, 31 ) ), ( 'ExclusionContours_2HDMTypeII_tanb_vs_mH.root', '#bf{2HDM Type II, cos(#beta-#alpha) = -0.1}', 0.5, 10, 35, 200, 400, '#it{m_{H}} [GeV]', utils.h_to_zz_to + utils.lepp + utils.lepm + utils.lepp + utils.lepm + ' + ' + utils.lepp + utils.lepm + utils.nu + utils.nubar, ( 320, 324, 15.6 ) ), ] for file_name, mod_type, minY, maxY, max_maxY, minX, maxX, x_title, channel, patch_vals in limits: file = ROOT.TFile( 'inputs/' + file_name ) first_base_hist = file.Get( 'h_med' ) base_hist = ROOT.TH2F( first_base_hist.GetName() + '_extended', ';%s;tan#beta' % x_title, first_base_hist.GetXaxis().GetNbins(), first_base_hist.GetXaxis().GetXmin(), first_base_hist.GetXaxis().GetXmax(), 100 * first_base_hist.GetYaxis().GetNbins(), first_base_hist.GetYaxis().GetXmin(), 1000 ) obs_name = 'obs' if 'tanb_vs_mH' in file_name: obs_name = 'obsc' types = [ utils.graph_info( 'n2sig', file, 5, 1, 1001 ), utils.graph_info( 'n1sig', file, 3, 1, 1001 ), utils.graph_info( 'p1sig', file, 5, 1, 1001 ), utils.graph_info( 'p2sig', file, ROOT.kWhite, 1, 1001 ), #utils.graph_info( 'med', file, ROOT.kWhite, 1001 ), utils.graph_info( 'medc', file, ROOT.kAzure + 2, 2 ), utils.graph_info( 'obsf', file, ROOT.kOrange + 10, 1, 3844 ), utils.graph_info( obs_name, file, ROOT.kBlack, 1 ), ] graphs = {} single_graphs = {} for item in types: for index in range( item.number ): full_name = 'h_%s_contour_%d' % ( item.name, index ) graphs[ full_name ] = ( utils.add_points( file.Get( full_name ), [] ), item ) single_graphs[ item.name ] = graphs[ full_name ] canvas = ROOT.TCanvas( 'plot_' + file_name.replace( '.root', '' ), '', 600, 600 ) base_hist.Draw( 'axis' ) order = [ 'n2sig', 'n1sig', 'p1sig', 'p2sig', 'med', 'medc', 'obsf', obs_name ] for key1 in order: for key2, ( g, g_info ) in graphs.iteritems(): if key1 in key2: g.SetLineColor( g_info.color ) g.SetLineStyle( g_info.line ) g.SetLineWidth( 2 ) option = 'c' if g_info.fill: g.SetFillColor( g_info.color ) g.SetFillStyle( g_info.fill ) g.SetLineStyle( 1 ) g.SetLineColor( ROOT.kBlack ) option = 'fc' #if 'sig' in g_info.name: # option = '3' g.Draw( option ) base_hist.GetXaxis().SetRangeUser( minX, maxX ) base_hist.GetYaxis().SetRangeUser( minY, max_maxY ) #utils.get_bound( minY, maxY ) ) canvas.Update() the_box = utils.get_box( ROOT.gPad.GetUxmin(), ROOT.gPad.GetUxmax(), maxY, ROOT.gPad.GetUymax() ) base_hist.Draw( 'axis same' ) the_box.Draw( 'l' ) x_l1, y_l1, latex1 = utils.draw_latex( utils.lumi, False ) latex1.DrawLatex( x_l1, y_l1 - 0.105, channel ) latex1.SetTextSize( 20 ) #latex1.DrawLatex( x_l1, y_l1 - 0.16, '2HDM Type I, #it{m_{H}}=200 GeV' ) latex1.SetTextAlign( 22 ) latex1.DrawLatex( 0.535, y_l1 - 0.16, mod_type ) xLeg = 0.62 yLeg = 0.89 leg = utils.create_legend_2hdm( 3 ) leg.AddEntry( single_graphs[ obs_name ][ 0 ], 'Observed', 'l' ) leg.AddEntry( single_graphs[ 'n1sig' ][ 0 ], '#pm1#sigma band', 'f' ) leg.AddEntry( single_graphs[ 'medc' ][ 0 ], 'Expected', 'l' ) leg.AddEntry( single_graphs[ 'n2sig' ][ 0 ], '#pm2#sigma band', 'f' ) leg.AddEntry( None, '', '' ) leg.AddEntry( single_graphs[ 'obsf' ][ 0 ], 'Excluded', 'f' ) leg.Draw() #if patch_vals: # p_x1, p_x2, p_y = patch_vals # utils.patch_bar( p_x1, p_x2, p_y, p_y ) canvas.SetLogy() utils.save( canvas )
def make_plot( file_name, cat, title, maxYtop, minY = 0.18, maxY = 1.82 ): ### canvas, c_top, c_bottom = utils.create_double_pad( 'plot_sr_' + cat + 'vv' ) ### root_file = ROOT.TFile( 'inputs/' + file_name ) stack = utils.re_style_top( root_file.Get( 'c1' ).GetPrimitive( 'pad1' ).GetPrimitive( 'hs1' ) ) hists = {} merging_scheme = utils.complex_merging for hist in stack.GetHists(): prev_color = hist.GetFillColor() sample_name = None for key, vals in utils.original_colors_2l2v.iteritems(): if prev_color in vals: sample_name = key ''' if not sample_name: 'Sample Name Not Found' else: hist.SetFillColor( utils.get_colors( sample_name ) ) #hist.SetLineColor( utils.colors[ sample_name ] ) hist.SetLineColor( ROOT.kBlack ) hist.SetLineWidth( 1 ) hist.SetTitle( utils.titles[ sample_name ] ) ''' hists[ sample_name ] = hist ### Getting complicated here... loop_over_this = hists.keys() to_be_removed = set()#utils.wjets_removal for key in loop_over_this: for merging_key, merging_list in merging_scheme.iteritems(): if key in merging_list: to_be_removed.add( key ) if merging_key in hists: hists[ merging_key ].Add( hists[ key ] ) else: hists[ merging_key ] = hists[ key ].Clone( 'another_clone_' + hists[ key ].GetName() ) to_be_used = [] for k in hists: hist = hists[ k ] hist.SetFillColor( utils.get_colors( k ) ) hist.SetLineColor( ROOT.kBlack ) hist.SetLineWidth( 1 ) hist.SetTitle( utils.titles[ k ] ) if not k in to_be_removed: penalty = 0 if k == 'Wjets': penalty = -1 to_be_used.append( ( k, hist.Integral() + penalty ) ) sample_list = sorted( to_be_used, key = lambda x: x[ 1 ] ) sample_list_r = sorted( to_be_used, key = lambda x: x[ 1 ], reverse = True ) new_stack = ROOT.THStack( stack.GetName() + '_clone', '' ) for name, integral in sample_list: new_stack.Add( hists[ name ] ) data = utils.re_style_top( utils.th1_to_tgraph( root_file.Get( 'c1' ).GetPrimitive( 'pad1' ).GetPrimitive( 'mT_' + cat + '_Nominal' ), True ) ) utils.print_contents( root_file.Get( 'c1' ).GetPrimitive( 'pad1' ).GetPrimitive( 'mT_' + cat + '_Nominal' ) ) error = utils.re_style_top( utils.th1_to_tgraph( root_file.Get( 'c1' ).GetPrimitive( 'pad1' ).GetPrimitive( 'h0' ) ) ) error.SetMarkerStyle( 1 ) error.SetFillColor( ROOT.kBlack ) error.SetFillStyle( 3345 ) ### ratio_axis = utils.re_style_bot( root_file.Get( 'c1' ).GetPrimitive( 'pad2' ).GetPrimitive( 'h3' ), minY, maxY ) ratio = utils.re_style_bot( utils.th1_to_tgraph( root_file.Get( 'c1' ).GetPrimitive( 'pad2' ).GetPrimitive( 'h3' ), True ), minY, maxY ) ratio_axis.GetXaxis().SetTitle( '#it{m}_{T}^{' + utils.zz + '} [GeV]' ) ratio_axis.GetYaxis().SetTitle( '#frac{Data}{Prediction}' ) syst_band = utils.re_style_bot( utils.th1_to_tgraph( root_file.Get( 'c1' ).GetPrimitive( 'pad2' ).GetPrimitive( 'h0' ) ) ) for index in range( syst_band.GetN() ): X, Y = ROOT.Double( 0. ), ROOT.Double( 0. ) syst_band.GetPoint( index, X, Y ) syst_band.SetMarkerStyle( 1 ) syst_band.SetFillColor( ROOT.kBlack ) syst_band.SetFillStyle( 3345 ) syst_band.GetXaxis().SetTitle( '#it{m}_{T}^{' + utils.zz + '} [GeV]' ) syst_band.GetYaxis().SetTitle( '#frac{Data}{Prediction}' ) ### c_top.cd() new_stack.SetMinimum( 0.002 ) new_stack.Draw( 'hist' ) new_stack = utils.re_style_top( new_stack ) new_stack.Draw( 'hist' ) new_stack.GetXaxis().SetTitle( '#it{m}_{T}^{' + utils.zz + '} [GeV]' ) new_stack.GetYaxis().SetTitle( 'Events / %d GeV' % int( stack.GetXaxis().GetBinWidth( 1 ) ) ) new_stack.SetMaximum( maxYtop ) new_stack.GetXaxis().SetRangeUser( 250, 1500 ) error.Draw( '2 same' ) data.Draw( 'pe' ) x_l1, y_l1, latex1 = utils.draw_latex( utils.lumi, True ) latex1.DrawLatex( x_l1, y_l1 - 0.12, title + utils.void_char ) latex1.DrawLatex( x_l1, y_l1 - 0.18, '' ) leg = utils.create_legend( len( sample_list_r ), 0.3, 1 ) leg.AddEntry( data, 'Data', 'pe' ) for name, integral in sample_list_r: leg.AddEntry( hists[ name ], hists[ name ].GetTitle(), 'f' ) leg.AddEntry( error, 'Uncertainty', 'f' ) leg.Draw() mod_x, mod_y = 0, 0 if cat == 'ee': mod_x, mod_y = 4, -2 #utils.patch_bar( ( 228. + mod_x ) / 566., ( 233. + mod_x ) / 566., ( 324. + mod_y ) / 407., ( 324. + mod_y ) / 407., True ) c_top.SetLogy() c_bottom.cd() ratio_axis.Draw( 'axis' ) ratio_axis.GetXaxis().SetRangeUser( 250, 1500 ) syst_band.Draw( 'e2 same' ) ratio.Draw( 'pe0 same' ) c_bottom.Update() for arrow in utils.get_arrows( ROOT.gPad.GetUymin(), ROOT.gPad.GetUymax(), ratio ): arrow.Draw() Line = ROOT.TLine( ROOT.gPad.GetUxmin(), 1, ROOT.gPad.GetUxmax(), 1 ) Line.SetLineColor( ROOT.kBlack ) Line.SetLineWidth( 2 ) Line.SetLineStyle( 2 ) Line.Draw() utils.save( canvas )
def make_plot(file_name, cat, title, minX=-999., maxX=-1., minY=0.02, maxY=1.98, isLog=1): print "isLog:", isLog ### canvas, c_top, c_bottom = utils.create_double_pad( 'plot_%s' % file_name.replace('.root', '')) ### root_file = ROOT.TFile('input_offshell/' + file_name) ch_file = file_name.split('_')[1] val_file = file_name.split('_')[2] + '_' + file_name.split('_')[3] stack = utils.re_style_top( root_file.Get('c1').GetPrimitive('pad1').GetPrimitive('hs1')) hists = {} merging_scheme = {} #utils.complex_merging for hist in stack.GetHists(): prev_color = hist.GetFillColor() #print hist, prev_color sample_name = None for key, vals in utils.original_colors_2l2v.iteritems(): #print key, vals if prev_color in vals: sample_name = key ''' if not sample_name: 'Sample Name Not Found' else: hist.SetFillColor( utils.get_colors( sample_name ) ) #hist.SetLineColor( utils.colors[ sample_name ] ) hist.SetLineColor( ROOT.kBlack ) hist.SetLineWidth( 1 ) hist.SetTitle( utils.titles[ sample_name ] ) ''' hists[sample_name] = hist ### get those no stack histograms in pad1 data, error, sbi, sbi5 = None, None, None, None for element in root_file.Get('c1').GetPrimitive( 'pad1').GetListOfPrimitives(): #print element if element.GetName( ) == 'stat_sys_band_' + val_file + '_BJETVETO_' + ch_file: error = utils.re_style_top(element) error.SetMarkerStyle(1) error.SetFillColor(ROOT.kBlack) error.SetFillStyle(3345) elif element.GetName( ) == 'data_' + val_file + '_BJETVETO_' + ch_file + '_Nominal': data = utils.re_style_top(element) elif element.GetName( ) == 'SBI5_' + val_file + '_NLOIBJETVETO_' + ch_file + '_Nominal': sbi5 = utils.re_style_top(element) sbi5.SetMarkerColor(0) sbi5.SetMarkerStyle(0) sbi5.SetMarkerSize(0) sbi5.SetLineColor(616) sbi5.SetLineStyle(2) elif element.GetName( ) == 'SBI_' + val_file + '_NLOIBJETVETO_' + ch_file + '_Nominal': sbi = element prev_color = sbi.GetFillColor() #print sbi, prev_color sample_name = None for key, vals in utils.original_colors_2l2v.iteritems(): if prev_color in vals: sample_name = key for k in hists: hist = hists[k] sbi.Add(hist, -1) hists[sample_name] = sbi ### Getting complicated here... loop_over_this = hists.keys() to_be_removed = set() for key in loop_over_this: for merging_key, merging_list in merging_scheme.iteritems(): if key in merging_list: to_be_removed.add(key) if merging_key in hists: hists[merging_key].Add(hists[key]) else: hists[merging_key] = hists[key].Clone('another_clone_' + hists[key].GetName()) to_be_used = [('ZZ', 3), ('Others', 1), ('WZ', 2), ('SBI', 4)] for k in hists: hist = hists[k] hist.SetFillColor(utils.get_colors(k)) if k == 'SBI': hist.SetLineColor(ROOT.kBlue) else: hist.SetLineColor(ROOT.kBlack) hist.SetLineWidth(1) hist.SetTitle(utils.titles[k]) # if not k in to_be_removed: # penalty = 0 # to_be_used.append( ( k, hist.Integral() + penalty ) ) print "to_be_used:", to_be_used sample_list = sorted(to_be_used, key=lambda x: x[1]) sample_list_r = sorted(to_be_used, key=lambda x: x[1], reverse=True) new_stack = ROOT.THStack(stack.GetName() + '_clone', '') for name, integral in sample_list: #print name, integral new_stack.Add(hists[name]) ### ratio = utils.re_style_bot( root_file.Get('c1').GetPrimitive( 'pad2').GetPrimitive('ratio_bkg_data_' + val_file + '_BJETVETO_' + ch_file + '_Nominal')) syst_band = utils.re_style_bot( root_file.Get('c1').GetPrimitive('pad2').GetPrimitive( 'ratio_sys_band_' + val_file + '_BJETVETO_' + ch_file), minY, maxY) syst_band.SetMarkerStyle(1) syst_band.SetFillColor(ROOT.kBlack) syst_band.SetFillStyle(3345) if val_file == 'met_tst': syst_band.GetXaxis().SetTitle(utils.met) elif val_file == 'mT_ZZ': syst_band.GetXaxis().SetTitle(utils.mTZZ) syst_band.GetYaxis().SetTitle('#frac{Data}{Prediction}') ### if minX == -999. or maxX == -1.: minX, maxX = ROOT.gPad.GetUxmin(), ROOT.gPad.GetUxmax() print "minX =", minX, "maxX =", maxX c_top.cd() new_stack.SetMinimum(0.003) new_stack.Draw('hist') new_stack = utils.re_style_top(new_stack) new_stack.Draw('hist') new_stack.GetXaxis().SetRangeUser(minX, maxX) #new_stack.GetXaxis().SetTitle( utils.m4l ) new_stack.GetYaxis().SetTitle('Events / %d GeV' % stack.GetXaxis().GetBinWidth(1)) #new_stack.GetYaxis().SetTitle( 'Events / %s' % stack.GetXaxis().GetBinWidth( 1 ) ) if isLog == 1: Yscale = 1000 else: Yscale = 1.6 new_stack.SetMaximum(data.GetMaximum() * Yscale) error.Draw('e2 same') sbi5.Draw('hist same') data.Draw('p same') x_l1, y_l1, latex1 = utils.draw_latex(utils.lumi, True) latex1.DrawLatex(x_l1, y_l1 - 0.12, title + utils.void_char) latex1.DrawLatex(x_l1, y_l1 - 0.18, cat + utils.void_char) leg = utils.create_legend(len(sample_list_r), 0.3, 1) leg.AddEntry(data, 'Data', 'pe') leg.AddEntry(sbi5, 'gg+VBF#rightarrow(H*#rightarrow)ZZ(#mu_{off-shell}=5)', 'l') for name, integral in sample_list_r: leg.AddEntry(hists[name], hists[name].GetTitle(), 'f') leg.AddEntry(error, 'Uncertainty', 'f') #leg.AddEntry( None, '', '' ) #leg.AddEntry( None, '#color[0]{' + utils.titles[ 'emu' ] + '}', '' ) leg.Draw() c_top.Update() if isLog == 1: c_top.SetLogy() c_bottom.cd() syst_band.Draw('e2') syst_band.GetXaxis().SetRangeUser(minX, maxX) ratio.Draw('pe0 same') c_bottom.Update() #for arrow in utils.get_arrows( ROOT.gPad.GetUymin(), ROOT.gPad.GetUymax(), ratio ): arrow.Draw() Line = ROOT.TLine(ROOT.gPad.GetUxmin(), 1, ROOT.gPad.GetUxmax(), 1) Line.SetLineColor(ROOT.kBlack) Line.SetLineWidth(2) Line.SetLineStyle(2) Line.Draw() print "isLog:", isLog utils.save(canvas, isLog)
def main(): ROOT.gSystem.Load('libRooFit') ROOT.gROOT.SetBatch() ROOT.gErrorIgnoreLevel = 0 ROOT.RooMsgService.instance().setGlobalKillBelow(ROOT.RooFit.ERROR) mass_files = { 200: 'inputs/mc15_13TeV.341274.PowhegPythia8EvtGen_CT10_AZNLOCTEQ6L1_ggH200NW_ZZ4lep.root', 300: 'inputs/mc15_13TeV.341275.PowhegPythia8EvtGen_CT10_AZNLOCTEQ6L1_ggH300NW_ZZ4lep.root', 400: 'inputs/mc15_13TeV.341276.PowhegPythia8EvtGen_CT10_AZNLOCTEQ6L1_ggH400NW_ZZ4lep.root', 500: 'inputs/mc15_13TeV.341277.PowhegPythia8EvtGen_CT10_AZNLOCTEQ6L1_ggH500NW_ZZ4lep.root', 600: 'inputs/mc15_13TeV.341278.PowhegPythia8EvtGen_CT10_AZNLOCTEQ6L1_ggH600NW_ZZ4lep.root', 700: 'inputs/mc15_13TeV.341279.PowhegPythia8EvtGen_CT10_AZNLOCTEQ6L1_ggH700NW_ZZ4lep.root', 800: 'inputs/mc15_13TeV.341280.PowhegPythia8EvtGen_CT10_AZNLOCTEQ6L1_ggH800NW_ZZ4lep.root', 900: 'inputs/mc15_13TeV.341281.PowhegPythia8EvtGen_CT10_AZNLOCTEQ6L1_ggH900NW_ZZ4lep.root', 1000: 'inputs/mc15_13TeV.341282.PowhegPythia8EvtGen_CT10_AZNLOCTEQ6L1_ggH1000NW_ZZ4lep.root', 1200: 'inputs/mc15_13TeV.341283.PowhegPythia8EvtGen_CT10_AZNLOCTEQ6L1_ggH1200NW_ZZ4lep.root', 1400: 'inputs/mc15_13TeV.341284.PowhegPythia8EvtGen_CT10_AZNLOCTEQ6L1_ggH1400NW_ZZ4lep.root', #1600: '/eos/atlas/atlascerngroupdisk/phys-higgs/HSG2/H4l/2016/MiniTrees/Prod_v10/mc/Nominal/mc15_13TeV.341285.PowhegPythia8EvtGen_CT10_AZNLOCTEQ6L1_ggH1600NW_ZZ4lep.root', } f = ROOT.TFile('inputs/workspace_36fb_NWA_WithVBF.root') w = f.Get('combined') my_mass = w.var('m4l') higgs_mass = w.var('mH') channels = ['4mu', '2mu2e', '4e'] colors = { '4mu': ROOT.kAzure + 6, '2mu2e': ROOT.kAzure + 3, '4e': ROOT.kSpring - 5 } cuts = {'4mu': (0, 0), '2mu2e': (2, 3), '4e': (1, 1)} lines = {'4mu': 1, '2mu2e': 2, '4e': 4} markers = {'4mu': 20, '2mu2e': 21, '4e': 22} titles = { '4mu': utils.mup + utils.mum + utils.mup + utils.mum, '2mu2e': utils.mup + utils.mum + utils.ep + utils.em + ' + ' + utils.ep + utils.em + utils.mup + utils.mum, '4e': utils.ep + utils.em + utils.ep + utils.em } all_hists = {} graphs = {} strategy = 'RMS+' #strategy = '' #out = ROOT.TFile( 'out.root', 'recreate' ) masses = [mass for mass in mass_files] masses = sorted(masses) canvas = ROOT.TCanvas('plot_reso', '', 800, 600) for ch in channels: all_hists[ch] = {} graphs[ch] = ROOT.TGraphErrors(len(mass_files)) for index, mass in enumerate(masses): if 'RMS' in strategy: File = ROOT.TFile(mass_files[mass]) Tree = File.Get('tree_incl_all') all_hists[ch][mass] = ROOT.TH1F('hist_%s_%d' % (ch, mass), '', 100, 0.8 * mass, 1.2 * mass) #all_hists[ ch ][ mass ] = ROOT.TH1F( 'hist_%s_%d' % ( ch, mass ), '', 1500, 100, 1600 ) all_hists[ch][mass].SetDirectory(0) for entry in Tree: if entry.pass_vtx4lCut != 1: continue if entry.event_type == cuts[ch][ 0] or entry.event_type == cuts[ch][1]: all_hists[ch][mass].Fill( entry.m4l_constrained_HM) #, entry.weight ) graphs[ch].SetPoint(index, mass, all_hists[ch][mass].GetRMS()) graphs[ch].SetPointError(index, 0, all_hists[ch][mass].GetRMSError()) #print all_hists[ ch ][ mass ].GetRMS(), ' +/- ', all_hists[ ch ][ mass ].GetRMSError() else: pdf = w.pdf('ATLAS_Signal_ggF_ggF_%s_13TeV_cbga' % ch) higgs_mass.setVal(mass) data = pdf.generateBinned(ROOT.RooArgSet(my_mass), 1000000) all_hists[ch][mass] = data.createHistogram('m4l', 100) graphs[ch].SetPoint(index, mass, all_hists[ch][mass].GetRMS()) graphs[ch].SetPointError(index, 0, all_hists[ch][mass].GetRMSError()) #print mass_val, hist.GetRMS() #out.cd() #all_hists[ ch ][ mass ].Write() funcs = {} for index, ch in enumerate(channels): #graphs[ ch ].SetLineColor( colors[ ch ] ) #graphs[ ch ].SetMarkerColor( colors[ ch ] ) graphs[ch].SetLineColor(ROOT.kWhite) graphs[ch].SetMarkerColor(ROOT.kWhite) graphs[ch].SetMarkerStyle(1) graphs[ch].SetLineWidth(1) funcs[ch] = ROOT.TF1('function_%s' % ch, 'pol2', 200, 1400) funcs[ch].SetLineColor(colors[ch]) funcs[ch].SetLineWidth(3) funcs[ch].SetLineStyle(lines[ch]) #out.cd() #graphs[ ch ].Write() if index == 0: graphs[ch].Draw('apec') graphs[ch].Fit('function_%s' % ch) graphs[ch].GetXaxis().SetTitle('#it{m_{H}} [GeV]') graphs[ch].GetYaxis().SetTitle('RMS of ' + utils.m4lonly + ' distribution [GeV]') graphs[ch].GetXaxis().SetRangeUser(200, 1400) graphs[ch].GetYaxis().SetRangeUser(0, 70) graphs[ch] = utils.re_style(graphs[ch]) else: graphs[ch].Fit('function_%s' % ch) graphs[ch].Draw('pec') if '+' in strategy: for index, ch in enumerate(channels): if index == 0: graphs[ch].Draw('ap') funcs[ch].Draw('l same') else: funcs[ch].Draw('l same') x_l1, y_l1, latex1 = utils.draw_latex(None, False) latex1.DrawLatex( x_l1, y_l1 - 0.105, utils.h_to_zz_to + utils.lepp + utils.lepm + utils.lepp + utils.lepm) xLeg = x_l1 yLeg = y_l1 - 0.2 leg = ROOT.TLegend(xLeg, yLeg - 0.24, xLeg + 0.3, yLeg) leg.SetFillStyle(0) leg.SetBorderSize(0) leg.SetTextFont(42) leg.SetTextSize(0.036) for index, ch in enumerate(channels): leg.AddEntry(funcs[ch], titles[ch], 'l') leg.Draw() utils.save(canvas)
def main(): ROOT.gSystem.Load('libRooFit') ROOT.gROOT.SetBatch() ROOT.gErrorIgnoreLevel = 0 ROOT.RooMsgService.instance().setGlobalKillBelow(ROOT.RooFit.ERROR) f = ROOT.TFile('inputs/workspace_36fb_NWA_WithVBF.root') w = f.Get('combined') n_points = 10 min_mass = 300 max_mass = 900 step = (max_mass - min_mass) / float(n_points) colors = utils.init_colors(n_points + 1) files = { 300: 'inputs/mc15_13TeV.341275.PowhegPythia8EvtGen_CT10_AZNLOCTEQ6L1_ggH300NW_ZZ4lep.root', 600: 'inputs/mc15_13TeV.341278.PowhegPythia8EvtGen_CT10_AZNLOCTEQ6L1_ggH600NW_ZZ4lep.root', 900: 'inputs/mc15_13TeV.341281.PowhegPythia8EvtGen_CT10_AZNLOCTEQ6L1_ggH900NW_ZZ4lep.root', } channels = ['2mu2e'] #[ '4mu', '2mu2e', '4e' ] titles = { '4mu': '4#it{#mu}', '2mu2e': utils.mup + utils.mum + utils.ep + utils.em + ' + ' + utils.ep + utils.em + utils.mup + utils.mum, '4e': '4#it{e}' } cuts = {'4mu': (0, 0), '2mu2e': (2, 3), '4e': (1, 1)} #utils.h_to_zz_to + utils.lepp + utils.lepm + utils.lepp + '\'' + utils.lepm + '\'' for ch in channels: hist = {} canvas = ROOT.TCanvas('plot_shape_%s' % ch, '', 800, 600) for the_mass in files: hist[the_mass] = ROOT.TH1F('hist%d%s' % (the_mass, ch), '', 160, 200, 1000) hist[the_mass].SetDirectory(0) temp_file = ROOT.TFile(files[the_mass]) temp_tree = temp_file.Get('tree_incl_all') for entry in temp_tree: if entry.pass_vtx4lCut != 1: continue if entry.event_type == cuts[ch][0] or entry.event_type == cuts[ ch][1]: hist[the_mass].Fill(entry.m4l_constrained_HM, entry.weight) mass = w.var('m4l') higgs_mass = w.var('mH') Frame = utils.re_style(mass.frame()) data = {} for index in range(n_points + 1): mass_val = min_mass + index * step higgs_mass.setVal(mass_val) if mass_val in files: hist[mass_val].Scale(1. / hist[mass_val].Integral(), 'width') data[mass_val] = ROOT.RooDataHist( 'data%d' % mass_val, '', ROOT.RooArgList(mass), ROOT.RooFit.Import(hist[mass_val])) data[mass_val].plotOn(Frame, ROOT.RooFit.LineColor(colors[index]), ROOT.RooFit.MarkerColor(colors[index])) pdf = w.pdf('ATLAS_Signal_ggF_ggF_%s_13TeV_cbga' % ch) for index in range(n_points + 1): mass_val = min_mass + index * step higgs_mass.setVal(mass_val) #if index % 5 == 0: # pdf.plotOn( Frame, ROOT.RooFit.LineColor( colors[ index ] ), ROOT.RooFit.LineWidth( 2 ), ROOT.RooFit.Precision( 0.0001 ) ) #else: pdf.plotOn(Frame, ROOT.RooFit.LineColor(colors[index]), ROOT.RooFit.LineWidth(2), ROOT.RooFit.Precision(0.0001), ROOT.RooFit.LineStyle(2)) norm_values = {} for index in range(n_points + 1): mass_val = min_mass + index * step higgs_mass.setVal(mass_val) norm_values[mass_val] = pdf.getValV(ROOT.RooArgSet(mass)) Frame.Draw() Frame.GetXaxis().SetRangeUser(200, 1000) Frame.GetXaxis().SetTitle(utils.m4l) Frame.GetYaxis().SetTitle('Arbitrary Units') Frame.GetYaxis().SetRangeUser(0.0004, 0.6) x_l1, y_l1, latex1 = utils.draw_latex(None, False) latex1.DrawLatex(x_l1, y_l1 - 0.105, titles[ch]) xLeg = 0.6 yLeg = 0.89 leg = ROOT.TLegend(xLeg, yLeg - 0.18, xLeg + 0.3, yLeg) leg.SetFillStyle(0) leg.SetBorderSize(0) leg.SetTextFont(42) leg.SetTextSize(0.032) Marker = ROOT.TH1F('Marker', 'I am a fake histogram', 100, 0, 100) Marker.SetMarkerColor(ROOT.kGray + 2) Line = ROOT.TH1F('Line', 'I am a fake histogram', 100, 0, 100) Line.SetLineColor(ROOT.kGray + 2) Line.SetLineStyle(2) leg.AddEntry(Marker, 'Simulation', 'p') leg.AddEntry(Line, 'Parametrization', 'l') leg.Draw() canvas.SetLogy() utils.save(canvas)
def main(): ROOT.gROOT.SetBatch() line_width = 2 file = ROOT.TFile('inputs/graphs_llvv_graviton.root') exp = file.Get('median') exp.SetLineStyle(2) exp.SetLineWidth(line_width) exp.SetLineColor(ROOT.kBlack) exp.SetMarkerColor(ROOT.kBlack) obs = file.Get('observed') obs.SetLineStyle(1) obs.SetLineWidth(line_width) obs.SetLineColor(ROOT.kBlack) obs.SetMarkerColor(ROOT.kBlack) obs.SetMarkerSize(0.8) theory = file.Get('sm') #for i in range( 2 ): # theory.RemovePoint( 0 ) theory.SetLineStyle(1) theory.SetLineWidth(line_width) theory.SetLineColor(ROOT.kRed + 1) theory.SetMarkerColor(ROOT.kRed) band_1 = file.Get('1sigma') band_1.SetFillColor(3) band_1.SetFillStyle(1001) band_2 = file.Get('2sigma') band_2.SetFillColor(5) band_2.SetFillStyle(1001) canvas = ROOT.TCanvas('plot_graviton', '', 800, 600) band_2.Draw('af') #band_2.GetYaxis().SetRangeUser( 1, 100000 ) band_2.GetYaxis().SetRangeUser(1, 30000) band_2.GetXaxis().SetTitle('#it{m(G_{#it{KK}})} [TeV]') band_2.GetYaxis().SetTitle('95% C.L. limit on ' + utils.grav_axis + ' [fb]') band_2 = utils.re_style(band_2) band_1.Draw('f') exp.Draw('l') obs.Draw('pl') theory.Draw('l') band_2.GetXaxis().SetRangeUser(600, 2) box = utils.get_box(500, 1000, 200, 500) box.Draw() x_l1, y_l1, latex1 = utils.draw_latex(utils.lumi, False) latex1.DrawLatex( x_l1, y_l1 - 0.105, utils.g_to_zz_to + utils.lepp + utils.lepm + utils.nu + utils.nubar) latex1.DrawLatex(x_l1, y_l1 - 0.16, '#it{k/#bar{M}_{Pl}} = 1') xLeg = 0.62 yLeg = 0.89 leg = utils.create_legend_limit(5) leg.AddEntry(obs, 'Observed ' + utils.cls + ' limit', 'pl') leg.AddEntry(exp, 'Expected ' + utils.cls + ' limit', 'l') leg.AddEntry(band_1, 'Expected #pm 1#sigma', 'f') leg.AddEntry(band_2, 'Expected #pm 2#sigma', 'f') leg.AddEntry(theory, utils.grav_axis, 'l') leg.Draw() #utils.patch_bar( 240. / 566., 247. / 566., 329. / 407., 329. / 407., True ) canvas.SetLogy() utils.save(canvas)