예제 #1
0
    # Category
    #cat = "CR_MB"
    cats = ["SR_MB_predict"]

    canvs = []

    for cat in cats:

        # Totals
        #hMCpred = yp.makeSampHisto(yds,"background_QCDsubtr",cat,"MC_prediction"); hMCpred.SetTitle("MC (Pred)")
        hDataPred = yp.makeSampHisto(yds,"data_QCDsubtr",cat,"Data_prediction"); hDataPred.SetTitle("Data (Pred)")
        hData = yp.makeSampHisto(yds,"data_QCDsubtr","SR_MB","Data"); hData.SetTitle("Data")

        # Ratio
        #ratio = yp.getRatio(hTotal,hDataPred)
        ratio = yp.getRatio(hData,hDataPred)

        #ratio.GetYaxis().SetRangeUser(0,5)

        if doPoisErr:
            from CMGTools.TTHAnalysis.plotter.mcPlots import getDataPoissonErrors
            hDataPois = getDataPoissonErrors(hData,True,True)
            hDataPois.SetName("DataPois")
            hDataPois.SetTitle("Data")

            ratioPois = yp.getRatio(hDataPois,hDataPred)

            hPredUnc = yp.getRatio(hDataPred,hDataPred)
            col = yp.kGray
            hPredUnc.SetName("PredictionUncertainty")
            hPredUnc.SetLineColor(1)
예제 #2
0
        # 1
        yp.colorDict[samp + "_1_" + cat] = yp.kBlue
        h1 = yp.makeSampHisto(yds1, samp, cat, samp + "_1_" + cat)
        h1.SetTitle(samp + " (with dilep corr.)")

        # 2
        yp.colorDict[samp + "_2_" + cat] = yp.kRed
        h2 = yp.makeSampHisto(yds2, samp, cat, samp + "_2_" + cat)
        h2.SetTitle(samp + " (std. weights)")
        #h2.SetTitle(samp+" (only btagSF 2)")
        #h2.SetTitle(samp+" (All but PU)")
        #h2.SetTitle(samp+" (PUwgt < 4.)")
        #h2.SetTitle(samp+" (1 hadrFlav)")

        ratio = yp.getRatio(h1, h2)
        ratio.GetYaxis().SetRangeUser(0.9, 1.10)
        for i in range(0, ratio.GetNbinsX()):
            print ratio.GetBinContent(i)
            ratio.SetBinError(i, 0.0)

        #h1.GetYaxis().SetRangeUser(0.55,1.45)
        if "WJets" in samp and "Kappa" in cat:
            h2.GetYaxis().SetRangeUser(0.05, 3.45)
            h1.GetYaxis().SetRangeUser(0.05, 3.45)

        hists += [h1, h2, ratio]
        canv = yp.plotHists(cat + "_" + samp, [h1, h2],
                            ratio,
                            "TM",
                            1200,
예제 #3
0
        yp.colorDict["Data_"+cat] = yp.kBlack
        hData = yp.makeSampHisto(ydsSele,"data",cat,"Data_"+cat)
        hData.SetTitle("Data (sele)")

        # Data Ele
        yp.colorDict["DataEle_"+cat] = yp.kOrange-3
        hDataEle = yp.makeSampHisto(ydsSeleEle,"data",cat,"DataEle_"+cat)
        hDataEle.SetTitle("Data (ele)")

        # Data Ele
        yp.colorDict["DataMu_"+cat] = yp.kCyan-3
        hDataMu = yp.makeSampHisto(ydsSeleMu,"data",cat,"DataMu_"+cat)
        hDataMu.SetTitle("Data (#mu)")

       # ratios and plots
        ratMu = yp.getRatio(hMuQCDpred,hDataMu)
        ratMu.GetYaxis().SetRangeUser(0,0.105)

        ratEle = yp.getRatio(hEleQCDpred,hDataEle)
        ratEle.GetYaxis().SetRangeUser(0,0.35)

        ## combined
        ratEle.SetLineColor(hEleQCDpred.GetLineColor())
        ratEle.SetMarkerColor(hEleQCDpred.GetMarkerColor())

        ratMu.SetLineColor(hMuQCDpred.GetLineColor())
        ratMu.SetMarkerColor(hMuQCDpred.GetMarkerColor())

        '''
        #ratio = yp.getRatio(hMuAnti,hEleQCDpred)
        ratio = yp.getRatio(hMuAnti,hDataMu)
예제 #4
0
        yp.colorDict[samp+"_1A_"+cat] = yp.kBlue
        h1A = yp.makeSampHisto(yds1A,samp,cat,samp+"_1A_"+cat)
        h1A.SetTitle(samp+" (Method 1A)")
        #h1A.SetTitle(samp+" (1A mcFlav)")
        #h1A.SetTitle(samp+" (All SF w/o PU)")

        # 1B
        yp.colorDict[samp+"_1B_"+cat] = yp.kRed
        h1B = yp.makeSampHisto(yds1B,samp,cat,samp+"_1B_"+cat)
        h1B.SetTitle(samp+" (Method 1B)")
        #h1B.SetTitle(samp+" (only btagSF 1B)")
        #h1B.SetTitle(samp+" (All but PU)")
        #h1B.SetTitle(samp+" (PUwgt < 4.)")
        #h1B.SetTitle(samp+" (1A hadrFlav)")

        ratio = yp.getRatio(h1A,h1B)
        #ratio.GetYaxis().SetRangeUser(0.75,1.25)

        #h1A.GetYaxis().SetRangeUser(0.55,1.45)
        if "WJets" in samp and "Kappa" in cat:
            h1B.GetYaxis().SetRangeUser(0.05,3.45)
            h1A.GetYaxis().SetRangeUser(0.05,3.45)

        hists += [h1A,h1B,ratio]
        canv = yp.plotHists(cat+"_"+samp,[h1A,h1B],ratio,"TM", 1200, 600, logY = logY)

        canvs.append(canv)

        if not yp._batchMode:
            answ = raw_input("Enter 'q' to exit: ")
            if "q" in answ: exit(0)
    # DATA
    hDataPred = yp.makeSampHisto(yds,"data_QCDsubtr",cat,"Data_prediction"); hDataPred.SetTitle("Data (Pred)")
    hData = yp.makeSampHisto(yds,"data_QCDsubtr","SR_MB","Data"); hData.SetTitle("Data")

    ## Append Systematics to prediction
    print "Appending syst. unc. to prediction and total MC"
    hDataPred = yp.getHistWithError(hDataPred, hKappaSysts, new = False)
    hTotal = yp.getHistWithError(hTotal, hMCSysts, new = False)

    # test MC
    #hDataPred = hMCpred

    # Ratio
    #ratio = yp.getRatio(hTotal,hDataPred)
    ratio = yp.getRatio(hData,hDataPred)

    logY = True
    #logY = False
    cname = "Data_2p24fb_"+mask
    canv = yp.plotHists("SR_MB_Prediction",[mcStack,hTotal,hDataPred,hData],ratio,'TM', 1200, 600, logY = logY)
    #canv = yp.plotHists("MC_2p24fb_"+cat+'_'+mask,[mcStack,hTotal,hDataPred],ratio,'TM', 1200, 600, logY = logY)

    canv.SetName(cname + canv.GetName())

    if logY: canv.SetName(canv.GetName() + "_log")
    canvs.append(canv)

    if not yp._batchMode: raw_input("Enter any key to exit")

    # Save canvases
예제 #6
0
        # Data Ele
        yp.colorDict["DataMu_"+cat] = yp.kCyan-3
        hDataMu = yp.makeSampHisto(ydsSeleMu,"data",cat,"DataMu_"+cat)
        hDataMu.SetTitle("Data (#mu)")

        ## MC
        #yp.colorDict["MC_Ele_"+cat] = kOrange-3
        #hMCele = yp.makeSampHisto(ydsSeleEle,"background",cat,"MC_Ele_"+cat)
        #hMCele.SetTitle("MC (ele)")

        #yp.colorDict["MC_Mu_"+cat] = kCyan
        #hMCmu = yp.makeSampHisto(ydsSeleMu,"background",cat,"MC_Mu_"+cat)
        #yp.hMCmu.SetTitle("MC (#mu)")

        #ratio = yp.getRatio(hMuAnti,hEleQCDpred)
        ratio = yp.getRatio(hMuAnti,hDataMu)
        #ratio.GetYaxis().SetRangeUser(-0.45,0.45)
        #ratio.GetYaxis().SetRangeUser(0,0.95)
        ratio.GetYaxis().SetRangeUser(0,0.105)

        #canv = yp.plotHists("Sele_QCDvsMC_Lep_"+cat,[hMCele,hMCmu,hEle,hMu])
        #canv = yp.plotHists("Data_vs_QCD_"+cat,[hDataEle,hDataMu,hEleQCDpred,hMuAnti],ratio)
        canv = yp.plotHists("Data_vs_QCD_Mu_"+cat,[hDataMu,hMuAnti],ratio)

        if not yp._batchMode: raw_input("Enter any key to exit")

        exts = [".pdf",".png"]
        #exts = [".pdf"]
        for ext in exts:
            canv.SaveAs("BinPlots/QCD/lumi2p1/DataCompare/"+mask+canv.GetName()+ext)
예제 #7
0
    masses.append((mass, massName, yp.kBlack))

    for (mass, massName, col) in masses:

        signame = "T1tttt_Scan_" + mass

        yp.colorDict[signame + "_Sig_" + cat] = col
        hSig = yp.makeSampHisto(ydsSig, signame, cat, signame + "_Sig_" + cat)
        #hSig.SetTitle("T1tttt_"+mass)
        hSig.SetTitle("T1tttt " + massName)

        sighists.append(hSig)

    #print sighists

    ratio = yp.getRatio(hSig, hTotal)
    ratio.SetName("SigOvMC")
    #ratio.GetYaxis().SetRangeUser(0.75,1.25)

    hists += [hMC, hTotal, ratio] + sighists
    #canv = yp.plotHists(cat,[hMC,hSig],ratio,"TM", 1200, 600, logY = True)
    canv = yp.plotHists(cat, [hMC] + sighists,
                        None,
                        "TM",
                        1200,
                        600,
                        logY=True)
    yp.gPad.RedrawAxis()

    cname = "MC_vs_T1tttt_" + cat
    canv.SetName(cname)