Exemple #1
0
def plot(file, var, region):
    signalRegion = False

    stack = StackMaker(config, var, region, signalRegion)

    histosL = []
    overlayL = []

    print file
    datas = []
    datasL = []
    for th1 in get_th1(file):
        print th1.GetBinLowEdge(0)
        if 'VH' in th1.GetName():
            overlayL.append(th1)
            th1.SetLineWidth(1)
        if 'data_obs' in th1.GetName():
            datasL.append(th1)
        else:
            histosL.append(th1)

    print 'histoL'
    print histosL
    typs = []
    typsL = []

    overlay_typs = []

    #append the name just once
    for histo in histosL:
        typsL.append(histo.GetName())
        print histo.GetName()
        if 'VH' in histo.GetName():
            overlay_typs.append(histo.GetName())

    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.datanames = region
    for key in overlay_histo_dict:
        overlayL2.append(overlay_histo_dict[key])

    appendix = ''

    stack.options['pdfName'] = stack.options['pdfName'].replace(
        '.pdf', '_unweighted.' + opts.format)

    stack.lumi = 18940

    stack.doPlot()
    print 'i am done!\n'
def plot(file,var,region):
    signalRegion = False

    stack = StackMaker(config,var,region,signalRegion)

    histosL = []
    overlayL = []


    print file
    datas = []
    datasL = []
    for th1 in get_th1(file):
        print th1.GetBinLowEdge(0)
        if 'VH' in th1.GetName(): 
            overlayL.append(th1)
            th1.SetLineWidth(1)
        if 'data_obs' in th1.GetName():
            datasL.append(th1)
        else:
            histosL.append(th1)

    print 'histoL'
    print histosL
    typs = []
    typsL = []

    overlay_typs=[]

    #append the name just once
    for histo in histosL:
        typsL.append(histo.GetName())
        print histo.GetName()
        if 'VH' in histo.GetName():
            overlay_typs.append(histo.GetName())

    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.datanames=region
    for key in overlay_histo_dict:
         overlayL2.append(overlay_histo_dict[key])

    appendix = ''
    
    stack.options['pdfName'] = stack.options['pdfName'].replace('.pdf','_unweighted.'+opts.format)            
    
    stack.lumi = 18940

    stack.doPlot()
    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'
Exemple #4
0
outfile = ROOT.TFile(outpath+'vhbb_TH_'+ROOToutname+'.root', 'RECREATE')
outfile.mkdir(Datacardbin,Datacardbin)
outfile.cd(Datacardbin)

# generate the Workspace:
WS = ROOT.RooWorkspace('%s'%Datacardbin,'%s'%Datacardbin) #Zee
print '\n\n-----> Workspace Initialized....'

disc= ROOT.RooRealVar(name,name,xMin,xMax)
obs = ROOT.RooArgList(disc)
ROOT.gROOT.SetStyle("Plain")

#order and add all together
final_histos = {}
print '\n-----> Ordering and Adding Histos'
final_histos['nominal'] = HistoMaker.orderandadd([all_histos['%s'%job][0] for job in all_samples],setup) 


print '\n------> Final Histograms: ', final_histos

#SYSTEMATICS:
ind = 1

for syst in systematics:
    print '\n\t-----> Preparing Systematics, Ordering Histograms for : ', syst
    for Q in UD:
        final_histos['%s_%s'%(systematicsnaming[syst],Q)] = HistoMaker.orderandadd([all_histos[job.name][ind] for job in all_samples],setup)
        ind+=1


#for weightF_sys in weightF_systematics: 
Exemple #5
0
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'
Exemple #6
0
#
ROOT.gROOT.SetStyle("Plain")

#order and add all together
final_histos = {}

print '\n\t--> Ordering and Adding Histos\n'

print 'workspace_datacard-all_samples:', [
    all_histos['%s' % job][0] for job in all_samples
]

jobnames = [job.name for job in all_samples]

#NOMINAL:
final_histos['nominal'] = HistoMaker.orderandadd(
    [all_histos['%s' % job][0] for job in all_samples], setup)

#SYSTEMATICS:
ind = 1
#print 'systematics is', systematics

print 'all_histos[job.name]', all_histos[job.name]
print 'len(all_histos[job.name])', len(all_histos[job.name])

print 'add UD sys'
print '==========\n'
for syst in systematics:
    for Q in UD:
        final_histos['%s_%s' %
                     (systematicsnaming[syst], Q)] = HistoMaker.orderandadd(
                         [all_histos[job.name][ind] for job in all_samples],
disc = ROOT.RooRealVar(name, name, xMin, xMax)
obs = ROOT.RooArgList(disc)
#
ROOT.gROOT.SetStyle("Plain")

# order and add all together
final_histos = {}

print "\n\t--> Ordering and Adding Histos\n"

print "workspace_datacard-all_samples:", [all_histos["%s" % job][0] for job in all_samples]

jobnames = [job.name for job in all_samples]

# NOMINAL:
final_histos["nominal"] = HistoMaker.orderandadd([all_histos["%s" % job][0] for job in all_samples], setup, jobnames)

# SYSTEMATICS:
ind = 1
for syst in systematics:
    for Q in UD:
        final_histos["%s_%s" % (systematicsnaming[syst], Q)] = HistoMaker.orderandadd(
            [all_histos[job.name][ind] for job in all_samples], setup, jobnames
        )
        ind += 1
for weightF_sys in weightF_systematics:
    for Q in UD:
        final_histos["%s_%s" % (systematicsnaming[weightF_sys], Q)] = HistoMaker.orderandadd(
            [all_histos[job.name][ind] for job in all_samples], setup, jobnames
        )
        ind += 1