Exemplo n.º 1
0
from ROOT import *
from PlotterMET import PlotterMET

tag = sys.argv[1]
fin = TFile.Open("step1_out/" + tag + "_ELE.root")
foutname = "step2_out/plotMET_ELE_" + tag
frootout = TFile.Open(foutname + ".root", "recreate")
frootout.Close()

DoZjets = True
sf_zjets_efakep = 1.9
sf_zjets_gamma = 1.1

if DoZjets == True:
    print "plot MET comparison before/after Zjets sfs"
    PlotMETZjets = PlotterMET()
    PlotMETZjets.pushbef(
        "before",
        fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammamatchnonele_ZJets"),
        col=kBlue)
    PlotMETZjets.addbef(
        fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammamatchele_ZJets"))
    PlotMETZjets.pushaft(
        "after",
        fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammamatchnonele_ZJets"),
        col=kRed,
        scal=sf_zjets_gamma)
    PlotMETZjets.addaft(fin.Get(tag +
                                "_ELE_pfMET_SR1_ele_bjj_gammamatchele_ZJets"),
                        scal=sf_zjets_efakep)
Exemplo n.º 2
0
def doCompTTaTTG(sf_nonpromptgamma,
                 sf_promptgamma,
                 k_ttbar,
                 sf_gpurity_ttbar,
                 sf_gpurity_ttg,
                 sys=""):
    print "#####################################################"
    print "plot MET comparison  (TT&TTG sfs)/(promptg/non-promptg sfs), use only plot"
    PlotMETTTcomp = PlotterMET()
    PlotMETTTcomp.pushbef("#gamma purity SFs",
                          fin.Get(tag +
                                  "_ELE_pfMET_SR1_ele_bjj_gammagennojet_TTG"),
                          col=kBlack,
                          scal=sf_promptgamma)
    PlotMETTTcomp.addbef(fin.Get(tag +
                                 "_ELE_pfMET_SR1_ele_bjj_gammagenjet_TTG"),
                         scal=sf_nonpromptgamma)
    PlotMETTTcomp.addbef(fin.Get(tag +
                                 "_ELE_pfMET_SR1_ele_bjj_gammagenjet_TT"),
                         scal=k_ttbar * sf_nonpromptgamma)
    PlotMETTTcomp.addbef(fin.Get(tag +
                                 "_ELE_pfMET_SR1_ele_bjj_gammagennojet_TT"),
                         scal=k_ttbar * sf_promptgamma)
    PlotMETTTcomp.pushaft("united SFs for tt(#gamma)",
                          fin.Get(tag +
                                  "_ELE_pfMET_SR1_ele_bjj_gammagennojet_TTG"),
                          col=kBlue,
                          scal=sf_gpurity_ttg)
    PlotMETTTcomp.addaft(fin.Get(tag +
                                 "_ELE_pfMET_SR1_ele_bjj_gammagenjet_TTG"),
                         scal=sf_gpurity_ttg)
    PlotMETTTcomp.addaft(fin.Get(tag +
                                 "_ELE_pfMET_SR1_ele_bjj_gammagenjet_TT"),
                         scal=sf_gpurity_ttbar * k_ttbar)
    PlotMETTTcomp.addaft(fin.Get(tag +
                                 "_ELE_pfMET_SR1_ele_bjj_gammagennojet_TT"),
                         scal=sf_gpurity_ttbar * k_ttbar)

    PlotMETTTcomp.plotMETcompare(foutname, "compTTaTTG_pfMET",
                                 "E_{T}^{miss} (GeV)", "", sys)
    #    print "In TT/TTG samples, SF for non-prompt photon(jet) events is ",sf_nonpromptgamma," and for prompt gamma is ",sf_promptgamma
    #    print "Before/After applying the above sfs, the total ratio for the whole sample is ",PlotMETTTcomp.ratio
    #    print "And the ratio Error is ",PlotMETTTcomp.ratioErr
    #    print "You need to carefully check the comparison ratio hists to make sure the seperate sfs won't affect the MET shape"
    print "*******************************************************\n\n\n"
    log.write(
        "\n\n####################################################################"
    )
    log.write(
        "Compare the (sf*ttbar+sf*ttg)/(sf*non_promptphoton+sf*promptphoton)")
    log.write("\n For SR1, the scale factor  is %s" % PlotMETTTcomp.ratio)
    log.write("\n For SR1, the scale factor Err is %s" %
              PlotMETTTcomp.ratioErr)
    log.write(
        "\n#################################################################\n\n\n"
    )
Exemplo n.º 3
0
def doCombTTaTTG(sf_nonpromptgamma, sf_promptgamma, k_ttbar, sys=""):
    print "#####################################################"
    print "plot MET comparison before/after TT&TTG sfs, use only plot, don't use the following sf"
    PlotMETTTcom = PlotterMET()
    PlotMETTTcom.pushbef("Before",
                         fin.Get(tag +
                                 "_ELE_pfMET_SR1_ele_bjj_gammagennojet_TTG"),
                         col=kBlack)
    PlotMETTTcom.addbef(fin.Get(tag +
                                "_ELE_pfMET_SR1_ele_bjj_gammagenjet_TTG"))
    PlotMETTTcom.addbef(fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammagenjet_TT"),
                        scal=k_ttbar)
    PlotMETTTcom.addbef(fin.Get(tag +
                                "_ELE_pfMET_SR1_ele_bjj_gammagennojet_TT"),
                        scal=k_ttbar)
    PlotMETTTcom.pushaft("After",
                         fin.Get(tag +
                                 "_ELE_pfMET_SR1_ele_bjj_gammagennojet_TTG"),
                         col=kBlue,
                         scal=sf_promptgamma)
    PlotMETTTcom.addaft(fin.Get(tag +
                                "_ELE_pfMET_SR1_ele_bjj_gammagenjet_TTG"),
                        scal=sf_nonpromptgamma)
    PlotMETTTcom.addaft(fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammagenjet_TT"),
                        scal=sf_nonpromptgamma * k_ttbar)
    PlotMETTTcom.addaft(fin.Get(tag +
                                "_ELE_pfMET_SR1_ele_bjj_gammagennojet_TT"),
                        scal=sf_promptgamma * k_ttbar)

    PlotMETTTcom.plotMETcompare(foutname, "combTTaTTG_pfMET",
                                "E_{T}^{miss} (GeV)", "", sys)
    print "In TT/TTG samples, SF for non-prompt photon(jet) events is ", sf_nonpromptgamma, " and for prompt gamma is ", sf_promptgamma
    print "Before/After applying the above sfs, the total ratio for the whole sample is ", PlotMETTTcom.ratio
    print "And the ratio Error is ", PlotMETTTcom.ratioErr
    print "You need to carefully check the comparison ratio hists to make sure the seperate sfs won't affect the MET shape"
    print "*******************************************************\n\n\n"
    log.write(
        "\n\n####################################################################"
    )
    log.write(
        "Combine the sfs for TT&TTG(prompt and non-prompt photons) into one sf"
    )
    log.write("\n For SR1, the scale factor for TT&TTG is %s" %
              PlotMETTTcom.ratio)
    log.write("\n For SR1, the scale factor for TT&TTG Err is %s" %
              PlotMETTTcom.ratioErr)
    log.write(
        "\n#################################################################\n\n\n"
    )
Exemplo n.º 4
0
def doCombTTG(sf_promptgamma,
              sferr_promptgamma,
              sf_nonpromptgamma,
              sferr_nonpromptgamma,
              sys=""):
    print "#####################################################"
    print "plot MET comparison before/after TTG sfs"
    PlotMETTTG = PlotterMET()
    PlotMETTTG.pushbef("before",
                       fin.Get(tag +
                               "_ELE_pfMET_SR1_ele_bjj_gammagennojet_TTG"),
                       col=kBlack)
    PlotMETTTG.addbef(fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammagenjet_TTG"))
    PlotMETTTG.pushaft("after",
                       fin.Get(tag +
                               "_ELE_pfMET_SR1_ele_bjj_gammagennojet_TTG"),
                       col=kBlue,
                       scal=sf_promptgamma)
    PlotMETTTG.addaft(fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammagenjet_TTG"),
                      scal=sf_nonpromptgamma)

    PlotMETTTG.syserror(
        fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammagennojet_TTG"),
        fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammagenjet_TTG"),
        sferr_promptgamma, sferr_nonpromptgamma)
    PlotMETTTG.plotMETcompare(foutname, "combTTG_pfMET", "pfMET(GeV)", "", sys)
    print "In TTG samples, SF for non-prompt photon(jet) events is ", sf_nonpromptgamma, " and for prompt gamma is ", sf_promptgamma
    print "Before/After applying the above sfs, the total ratio for the whole sample is ", PlotMETTTG.ratio
    print "And the ratio Error is ", PlotMETTTG.ratioErr
    print "And the ratio sys. Error is ", PlotMETTTG.ratiosysErr
    fitAstatErr = ((PlotMETTTG.ratiosysErr)**2 + (PlotMETTTG.ratioErr)**2)**0.5
    print "And the ratio Stat+Fit. Error is ", fitAstatErr
    print "You need to carefully check the before/after ratio hists to make sure the seperate sfs won't affect the MET shape"
    print "*******************************************************\n\n\n"

    log.write(
        "\n\n####################################################################"
    )
    log.write(
        "Combine the sfs for TTG(prompt and non-prompt photons) into one sf")
    log.write("\n For SR1, the scale factor for TTG is %s" % PlotMETTTG.ratio)
    log.write("\n For SR1, the scale factor for TTG Err is %s" %
              PlotMETTTG.ratioErr)
    log.write("\n For SR1, the scale factor for TTG Sys. Err is %s" %
              PlotMETTTG.ratiosysErr)
    log.write(
        "\n#################################################################\n\n\n"
    )
    return [PlotMETTTG.ratio, fitAstatErr]
Exemplo n.º 5
0
def doCombTTSR2(sf_promptgamma, sf_nonpromptgamma):
    print "#####################################################"
    print "plot SR1 MET comparison before/after TT sfs"
    PlotMETTT = PlotterMET()
    PlotMETTT.pushbef("before",
                      fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammagennojet_TT"),
                      col=kBlue)
    PlotMETTT.addbef(fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammagenjet_TT"))
    PlotMETTT.pushaft("after",
                      fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammagennojet_TT"),
                      col=kRed,
                      scal=sf_promptgamma)
    PlotMETTT.addaft(fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammagenjet_TT"),
                     scal=sf_nonpromptgamma)

    PlotMETTT.plotMETcompare(foutname, "combTT_pfMET", "pfMET(GeV)", "")
    print "In SR1, TT samples, SF for non-prompt photon(jet) events is ", sf_nonpromptgamma, " and for prompt gamma is ", sf_promptgamma
    print "Before/After applying the above sfs, the total ratio for the whole sample is ", PlotMETTT.ratio
    print "And the ratio Error is ", PlotMETTT.ratioErr
    print "You need to carefully check the before/after ratio hists to make sure the seperate sfs won't affect the MET shape"
    print "*******************************************************\n\n\n"

    log.write(
        "\n\n####################################################################"
    )
    log.write(
        "Combine the sfs for TT(prompt and non-prompt photons) into one sf")
    log.write("This sf is additional to the jetM3 k_ttbar, apply both in SR1")
    log.write("\n For SR1, the scale factor for TT is %s" % PlotMETTT.ratio)
    log.write("\n For SR1, the scale factor for TT Err is %s" %
              PlotMETTT.ratioErr)
    log.write(
        "\n#################################################################\n\n\n"
    )
Exemplo n.º 6
0
def doCombZJets(sf_zjets_gamma,
                sferr_zjets_gamma,
                sf_zjets_efakep,
                sferr_zjets_efakep,
                sys=""):
    print "#####################################################"
    print "Will try to comb the SFs for ZJets in previous step to get only one sf, need to check the MET plot before apply it in limitsetting!"
    print "plot MET comparison before/after the sfs for ele-faked gamma and non-ele-faked gamma in Zjets samples "
    PlotMETZjets = PlotterMET()
    PlotMETZjets.pushbef(
        "Before",
        fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammamatchnonele_ZJets"),
        col=kBlack)
    PlotMETZjets.addbef(
        fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammamatchele_ZJets"))
    PlotMETZjets.pushaft(
        "After",
        fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammamatchnonele_ZJets"),
        col=kBlue,
        scal=sf_zjets_gamma)
    PlotMETZjets.addaft(fin.Get(tag +
                                "_ELE_pfMET_SR1_ele_bjj_gammamatchele_ZJets"),
                        scal=sf_zjets_efakep)

    PlotMETZjets.syserror(
        fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammamatchnonele_ZJets"),
        fin.Get(tag + "_ELE_pfMET_SR1_ele_bjj_gammamatchele_ZJets"),
        sferr_zjets_gamma, sferr_zjets_efakep)
    PlotMETZjets.plotMETcompare(foutname, "combZjets_pfMET",
                                "E_{T}^{miss} (GeV)", "", sys)
    print "In Zjets samples, SF for non-ele-faked photon events is ", sf_zjets_gamma, " and for ele faked gamma is ", sf_zjets_efakep
    print "Before/After applying the above sfs, the total ratio for the whole sample is ", PlotMETZjets.ratio
    print "And the ratio Fit Error is ", PlotMETZjets.ratioErr
    print "And the ratio Stat. Error is ", PlotMETZjets.ratiosysErr
    fitAstatErr = ((PlotMETZjets.ratiosysErr)**2 +
                   (PlotMETZjets.ratioErr)**2)**0.5
    print "And the ratio Stat+Fit. Error is ", fitAstatErr
    print "You need to carefully check the before/after ratio hists to make sure the seperate sfs won't affect the MET shape\n\n\n"

    log.write(
        "\n\n####################################################################"
    )
    log.write(
        "Combine the sfs for ZJets(non-ele-faked and ele-faked photons) into one sf"
    )
    log.write("\n Only in Ele channel SR1, the scale factor for DY is %s" %
              PlotMETZjets.ratio)
    log.write("\n Only in Ele channel SR1, the scale factor for DY Err is %s" %
              PlotMETZjets.ratioErr)
    log.write(
        "\n Only in Ele channel SR1, the scale factor for DY Sys. Err is %s" %
        PlotMETZjets.ratiosysErr)
    log.write(
        "\n#################################################################\n\n\n"
    )

    return [PlotMETZjets.ratio, fitAstatErr]