def plot(fileList): print '-----> Running def plot()...' signalRegion = True region = 'signal_Zuu_low_Zpt' var = 'HCSV_mass' # for subtracted bkg mass plot #mjj_sub = True opts.fom = 's/s+b' print '-----> Making Stacks...' stack = StackMaker(config, var, region, signalRegion) histosL = [] overlayL = [] #7-9 for the higgs #5-6 for the VV binmin = 7 binmax = 9 #binmin=5 #binmax=6 max_sb = 0 max_ssb = 0 for file in fileList: if max_sb < get_s_over_b(file, binmin, binmax): max_sb = get_s_over_b(file, binmin, binmax) if max_ssb < get_s_over_sb(file, binmin, binmax): max_ssb = get_s_over_sb(file, binmin, binmax) print '-----> max_ssb: ', max_ssb print '-----> max_sb : ', max_sb for file in fileList: #if eval(opts.rescale) == False: # max_sb = 1. # max_ssb = 1. for th1 in get_th1_allRegions(file): print 'Scaling factor for ', th1, ':', get_s_over_sb( file, binmin, binmax) if 's/b' in opts.fom: th1.Scale(get_s_over_b(th1, binmin, binmax) / max_sb) if 's/s+b' in opts.fom: print '--->Scaling by s/s+b...' #th1.Scale(get_s_over_sb(th1,binmin,binmax)/max_ssb) th1.Scale(get_s_over_sb(file, binmin, binmax)) if 'Zj1b' in th1.GetName(): th1.SetName('DY1b') if 'Zj2b' in th1.GetName(): th1.SetName('DY2b') if 'Zj0b' in th1.GetName(): th1.SetName('DYlight') if 's_Top' in th1.GetName(): th1.SetName('ST') if 'Wj1b' in th1.GetName(): th1.SetName('Wj1b') #if mjj_sub: # if 'VVHF' in th1.GetName(): # th1.SetName('VV') # if 'VH' in th1.GetName(): # th1.SetName('VH') # new stack for the overlay plot if 'VH' in th1.GetName() or 'VVHF' in th1.GetName( ) or 'ZH' in th1.GetName(): overlayL.append(th1) histosL.append(th1) print 'histoL' print histosL typs = [] typsL = [] datas = [] datasL = [] overlay_typs = [] #append the name just once for histo in histosL: typsL.append(histo.GetName()) if 'data' in histo.GetName(): datasL.append(histo) if 'VH' in histo.GetName() or 'VV' in histo.GetName( ) or 'ZH' in th1.GetName(): overlay_typs.append(histo.GetName()) if 'TT' in histo.GetName(): datasL.append(histo) # temp hack #datasL.append(datas) #typsL.append(typs) print typsL print 'Overlay list' print overlayL #overlay_histo_dict = HistoMaker.orderandadd([{overlay_typs[i]:overlayL[i]} for i in range(len(overlayL))],['VH','VV']) overlayL2 = [] stack.histos = histosL stack.typs = typsL stack.datas = datasL # stack.datatyps = Ldatatyps[v] stack.datanames = 'data_obs' #for key in overlay_histo_dict: # overlayL2.append(overlay_histo_dict[key]) mjj_sub = eval(opts.sub) #if not mjj_sub: # stack.overlay = overlayL2 appendix = '' if (eval(opts.rescale) == True): appendix = '_rescaled_' if 's/s+b' in opts.fom: stack.options['pdfName'] = stack.options['pdfName'].replace( '.pdf', '_combined78tev_postFit_s_over_sb' + appendix + '.' + opts.format) elif 's/b' in opts.fom: stack.options['pdfName'] = stack.options['pdfName'].replace( '.pdf', '_combined78tev_postFit_s_over_b' + appendix + '.' + opts.format) else: stack.options['pdfName'] = stack.options['pdfName'].replace( '.pdf', '_unweighted.' + opts.format) # stack.options['pdfName'] = stack.options['pdfName'].replace('.pdf','_highPt_7tev.pdf') # stack.options['pdfName'] = stack.options['pdfName'].replace('.pdf','_combined_postFit_s_over_b_Hpt_weight_1.pdf' stack.lumi = 18940 if mjj_sub == False: print '\n\t----> Making Nominal Mass plot...' stack.doPlot() elif mjj_sub == True: print '\n\t----> Making Subtracted Mass plot...' stack.options['pdfName'] = stack.options['pdfName'].replace( '.' + opts.format, '_subtracted.' + opts.format) #stack.doSubPlot(['VH','VV']) stack.doSubPlot(['VVHF', 'ZH', 'ggZH']) print 'i am done!\n'
def plot(fileList): signalRegion = True region = 'plot' var = 'Hmass' stack = StackMaker(config,var,region,signalRegion) histosL = [] overlayL = [] #7-9 for the higgs #5-6 for the VV binmin=7 binmax=9 max_sb = 0 max_ssb = 0 for file in fileList: if max_sb < get_s_over_b(file,binmin,binmax): max_sb = get_s_over_b(file,binmin,binmax) if max_ssb < get_s_over_sb(file,binmin,binmax): max_ssb = get_s_over_sb(file,binmin,binmax) print max_ssb print max_sb for file in fileList: print file print get_s_over_b(file,binmin,binmax) if eval(opts.rescale) == False: max_sb = 1. max_ssb = 1. for th1 in get_th1(file): #th1.Sumw2() if 's/b' in opts.fom: th1.Scale(get_s_over_b(file,binmin,binmax)/max_sb) if 's/s+b' in opts.fom: th1.Scale(get_s_over_sb(file,binmin,binmax)/max_ssb) if 'VV' in th1.GetName(): th1.SetName('VV') if 'Zj1b' in th1.GetName(): th1.SetName('Zj2b') if 'Wj1b' in th1.GetName(): th1.SetName('Wj2b') # new stack for the overlay plot if 'VH' in th1.GetName() or 'VV' in th1.GetName(): overlayL.append(th1) histosL.append(th1) print 'histoL' print histosL typs = [] typsL = [] datas = [] datasL = [] overlay_typs=[] #append the name just once for histo in histosL: typsL.append(histo.GetName()) if 'data' in histo.GetName(): datasL.append(histo) if 'VH' in histo.GetName() or 'VV' in histo.GetName(): overlay_typs.append(histo.GetName()) #datasL.append(datas) #typsL.append(typs) print typsL print 'Overlay list' print overlayL overlay_histo_dict = HistoMaker.orderandadd([{overlay_typs[i]:overlayL[i]} for i in range(len(overlayL))],['VH','VV']) overlayL2=[] stack.histos = histosL stack.typs = typsL stack.datas = datasL # stack.datatyps = Ldatatyps[v] stack.datanames='data_obs' for key in overlay_histo_dict: overlayL2.append(overlay_histo_dict[key]) mjj_sub = eval(opts.sub) if not mjj_sub: stack.overlay = overlayL2 appendix = '' if(eval(opts.rescale) == True): appendix = '_rescaled_' if 's/s+b' in opts.fom: stack.options['pdfName'] = stack.options['pdfName'].replace('.pdf','_combined78tev_postFit_s_over_sb'+appendix+'.'+opts.format) elif 's/b' in opts.fom: stack.options['pdfName'] = stack.options['pdfName'].replace('.pdf','_combined78tev_postFit_s_over_b'+appendix+'.'+opts.format) else: stack.options['pdfName'] = stack.options['pdfName'].replace('.pdf','_unweighted.'+opts.format) # stack.options['pdfName'] = stack.options['pdfName'].replace('.pdf','_highPt_7tev.pdf') # stack.options['pdfName'] = stack.options['pdfName'].replace('.pdf','_combined_postFit_s_over_b_Hpt_weight_1.pdf' stack.lumi = 18940 if mjj_sub == False: stack.doPlot() elif mjj_sub == True: stack.options['pdfName'] = stack.options['pdfName'].replace('.'+opts.format,'_subtracted.'+opts.format) stack.doSubPlot(['VH','VV']) print 'i am done!\n'
def plot(fileList): signalRegion = True #region = 'plot' region = opts.region var = 'HCSVmass' stack = StackMaker(config, var, region, signalRegion) histosL = [] overlayL = [] #7-9 for the higgs #5-6 for the VV binmin = 7 binmax = 9 max_sb = 0 max_ssb = 0 for file in fileList: if max_sb < get_s_over_b(file, binmin, binmax): max_sb = get_s_over_b(file, binmin, binmax) if max_ssb < get_s_over_sb(file, binmin, binmax): max_ssb = get_s_over_sb(file, binmin, binmax) print max_ssb print max_sb for file in fileList: print file print get_s_over_b(file, binmin, binmax) if eval(opts.rescale) == False: max_sb = 1. max_ssb = 1. for th1 in get_th1(file): #th1.Sumw2() if 's/b' in opts.fom: th1.Scale(get_s_over_b(file, binmin, binmax) / max_sb) if 's/s+b' in opts.fom: th1.Scale(get_s_over_sb(file, binmin, binmax) / max_ssb) if 'VV' in th1.GetName(): th1.SetName('VV') if 'Zj1b' in th1.GetName(): th1.SetName('Zj2b') if 'Wj1b' in th1.GetName(): th1.SetName('Wj2b') # new stack for the overlay plot if 'VH' in th1.GetName() or 'VV' in th1.GetName(): overlayL.append(th1) histosL.append(th1) print 'histoL' print histosL typs = [] typsL = [] datas = [] datasL = [] overlay_typs = [] #append the name just once for histo in histosL: typsL.append(histo.GetName()) if 'data' in histo.GetName(): datasL.append(histo) if 'VH' in histo.GetName() or 'VV' in histo.GetName(): overlay_typs.append(histo.GetName()) #datasL.append(datas) #typsL.append(typs) print typsL print 'Overlay list' print overlayL overlay_histo_dict = HistoMaker.orderandadd([{ overlay_typs[i]: overlayL[i] } for i in range(len(overlayL))], ['VH', 'VV']) overlayL2 = [] stack.histos = histosL stack.typs = typsL stack.datas = datasL # stack.datatyps = Ldatatyps[v] stack.datanames = 'data_obs' for key in overlay_histo_dict: overlayL2.append(overlay_histo_dict[key]) mjj_sub = eval(opts.sub) if not mjj_sub: stack.overlay = overlayL2 appendix = '' if (eval(opts.rescale) == True): appendix = '_rescaled_' if 's/s+b' in opts.fom: stack.options['pdfName'] = stack.options['pdfName'].replace( '.pdf', '_combined78tev_postFit_s_over_sb' + appendix + '.' + opts.format) elif 's/b' in opts.fom: stack.options['pdfName'] = stack.options['pdfName'].replace( '.pdf', '_combined78tev_postFit_s_over_b' + appendix + '.' + opts.format) else: stack.options['pdfName'] = stack.options['pdfName'].replace( '.pdf', '_unweighted.' + opts.format) # stack.options['pdfName'] = stack.options['pdfName'].replace('.pdf','_highPt_7tev.pdf') # stack.options['pdfName'] = stack.options['pdfName'].replace('.pdf','_combined_postFit_s_over_b_Hpt_weight_1.pdf' stack.lumi = 18940 if mjj_sub == False: stack.doPlot() elif mjj_sub == True: stack.options['pdfName'] = stack.options['pdfName'].replace( '.' + opts.format, '_subtracted.' + opts.format) stack.doSubPlot(['VH', 'VV']) print 'i am done!\n'