Exemple #1
0
    bkgtest = copy.deepcopy(backgroundlist)
    sumbkg = 0
    sumdata = 0
    for each in bkgtest + datatest:
        each.cut_parameter(cut_btagin_is, 1)
        # each.cut_parameter(cut_btagout_less, 0)
        if "data" not in each.alias:
            sumbkg += sum(each.weight)
        else:
            sumdata += len(each.weight)
    print("Making plots...")
    direct = ""
    name = "mbbcut-1tag" + correctionname
    bins = [200, 220, 240, 260, 290, 320, 350, 380, 410,  450, 550, 650, 750, 850, 1000, 1200, 1400, 1800]
    stackplot(bkgtest + datatest,b'ptfj1',bins,1000.,
    xlabel=r"$p_{T}^{FJ}[GeV]$", filename=direct + "ptfj1" + name, print_height=True,
    title2=t2,auto_colour=False, limit_y = 0.5, upper_y=2.5, log_y=True, title3="2 lep. 1 btag merged", chi2=True)
    bins = [260, 300, 400, 500, 600, 700, 800, 1000, 1200, 1400, 1800, 2200]
    stackplot(bkgtest + datatest,b'mVH',bins,1000.,
    xlabel=r"$m_{VH}[GeV]$", filename=direct + "mvh" + name, print_height=True,
    title2=t2,auto_colour=False, limit_y = 0.5, upper_y=2.5, log_y=True, title3="2 lep. 1 btag merged", chi2=True)


    datatest = copy.deepcopy(datalist)
    bkgtest = copy.deepcopy(backgroundlist)
    sumbkg = 0
    sumdata = 0
    for each in bkgtest + datatest:
        each.cut_parameter(cut_btagin_is, 1)
        each.cut_parameter(cut_btagout_less, 0)
        if "data" not in each.alias:
         1850, 2000
     ]
     bincheck(binning, bins)
     all_sample1 = []
     for each in all_sample:
         #print(type(each))
         if isinstance(each, str):
             continue
         all_sample1.append(each)
     stackplot(all_sample1,
               variable_name,
               bins,
               1.,
               xlabel=r"$m_{VH}[GeV]$",
               title3="2 lep.," + btag + " b-tag " + region,
               filename="output/cpp_make_plot_test/" + filename[0:-5],
               print_height=False,
               title2=t2,
               auto_colour=False,
               limit_y=0.6,
               upper_y=2.6,
               sys=True,
               log_y=True)
 '''
 sample_list = {"Wl", "Wcl", "Wbl", "Wbb", "Wbc", "Wcc", "WZ", "WW",              "Zcc", "Zcl", "Zbl", "Zbc", "Zl", "Zbb", "ZZ", "stopWt", "stops", "stopt", "ttbar", "ggZllH125", "qqZllH125", "stopWt_dilep"}
 colors =      ['g', 'g',    'g',    'g',  'g',   'g',  'tab:orange','tab:orange', 'royalblue','royalblue','royalblue','royalblue','royalblue','royalblue','royalblue','yellow','yellow','yellow','yellow', 'yellow','yellow','yellow']
 with open("mVHsr.txt","r") as f:
     for each_line in f:
         sample = json.loads(each_line)
 nominals = []
 for each, color in zip(sample_list,colors):
     if each not in sample:
Exemple #3
0
 mysample = rescale(mysample)
 mysample = slopecorrection(mysample)
 title3 = "mBBcr " + str(2) + " btags"
 bins = [
     0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700,
     750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200, 1250, 1300
 ]
 print(bins)
 chi2, nod = stackplot(mysample,
                       b'pTV',
                       bins,
                       1000.,
                       xlabel=r"$p_{TV}[GeV]$",
                       title3=title3,
                       filename="test1",
                       print_height=True,
                       title2=t2,
                       auto_colour=False,
                       limit_y=0.5,
                       upper_y=2.0,
                       log_y=True,
                       printzpjets=True,
                       chi2=True)
 bins = range(0, 2000, 30)
 chi2, nod = stackplot(mysample,
                       b'mVH',
                       bins,
                       1000.,
                       xlabel=r"$p_{TV}[GeV]$",
                       title3=title3,
                       filename="testmvh1",
 ]
 if dorebin:
     bins = range(0, 1400, 20)
     bins = autobin_withdatazlljet(all_sample_after_beforecorrection,
                                   bins,
                                   alias="Zlljet",
                                   variable=b"pTV")
 print(bins)
 chi2, nod = stackplot(all_sample_after,
                       b'pTV',
                       bins,
                       1000.,
                       xlabel=r"$p_{TV}[GeV]$",
                       title3=title3,
                       filename=direct + "pTV" + name,
                       print_height=True,
                       title2=t2,
                       auto_colour=False,
                       limit_y=0.5,
                       upper_y=2.0,
                       log_y=True,
                       printzpjets=True,
                       chi2=True)
 print("pTV", chi2, nod)
 bins = [
     50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700,
     750, 800, 850, 900, 1000, 1150, 1350, 1550, 1800
 ]
 chi2, nod = stackplot(all_sample_after,
                       b'mVH',
                       bins,
Exemple #5
0
    bins = np.linspace(41,200,num=50)
    stackplot(all_sample,b'mLL',bins,1000.,
            xlabel=r"$M_{Z}[GeV]$", title3="2 lep., > 2 b-tag", filename="31amZ", print_height=True,
            title2=t2,auto_colour=False, limit_y = 0.5, upper_y=2.6)
'''
    #bins = np.linspace(100,1200,50)
    #bins = range(0,40000,20000)
    #bins = range(0,100,1)
    bins = range(0,10000,40)
    all_sample_after = [each for each in all_sample]
    # stackplot(all_sample_after,b'ptL1',bins,1000.,
    #         xlabel=r"$pt_{l1}[GeV]$", title3="loose selection, 2 btags", filename="ptL1", print_height=True,
    #         title2=t2,auto_colour=False, limit_y = 0.5, upper_y=2.0, log_y=True)
    #bins = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 1000, 1150, 1350, 1550, 1800]
    stackplot(all_sample_after,b'pTV',bins,1000.,
            xlabel=r"$p_{TV}[GeV]$", title3="mBB 1 btags", filename="output/t_make_plot/" + "pTV-mbbcr", print_height=True,
            title2=t2,auto_colour=False, limit_y = 0.5, upper_y=2.0, log_y=True)
    # bins = range(0,1000,50)
    # stackplot(all_sample_after,b'pTB1',bins,1000.,
    #         xlabel=r"$pt_{b1}[GeV]$", title3="loose selection, 2 btags", filename="pTB1", print_height=True,
    #         title2=t2,auto_colour=False, limit_y = 0.5, upper_y=2.0, log_y=True)
    # bins = range(5,80,3)
    # stackplot(all_sample_after,b'MET',bins,1000.,
    #         xlabel=r"$pt_{L2}[GeV]$", title3="muon same charge srcut, < 2 btag", filename="ptL2_3_test", print_height=True,
    #         title2=t2,auto_colour=False, limit_y = 0.5, upper_y=3.0, log_y=False)

    # bins = np.linspace(0, 3.15, num=20)
    # stackplot(all_sample_after,b'delphi1',bins,1.,
    #         xlabel=r"$delphi1$", title3="l same charge srcut, < 3 btag",title4 = "PTl2 < 20 GeV" ,filename="delphi1l", print_height=True,
    #         title2=t2,auto_colour=False, limit_y = 0.5, upper_y=3, log_y=False, blind = False) 
    # stackplot(all_sample_after,b'delphi2',bins,1.,
Exemple #6
0
def flow(new, old, ntag):

    t2 = r"$\mathit{\sqrt{s}=13\:TeV,139\:fb^{-1}}$"
    title3 = "mBBcr " + str(ntag) + " btags"
    bins = [
        50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700,
        750, 800, 850, 900, 1000, 1150, 1350, 1550, 1800
    ]
    chi2, nod = stackplot(Zsplit(new),
                          b'mVHres',
                          bins,
                          1000.,
                          xlabel=r"$m_{VH}[GeV]$",
                          title3=title3,
                          filename="mVH-new" + str(ntag) + "tag",
                          print_height=False,
                          title2=t2,
                          auto_colour=False,
                          limit_y=0.5,
                          upper_y=2.0,
                          log_y=True)
    chi2, nod = stackplot(Zsplit(old),
                          b'mVHres',
                          bins,
                          1000.,
                          xlabel=r"$m_{VH}[GeV]$",
                          title3=title3,
                          filename="mVH-old" + str(ntag) + "tag",
                          print_height=False,
                          title2=t2,
                          auto_colour=False,
                          limit_y=0.5,
                          upper_y=2.0,
                          log_y=True)

    bins = np.array([2, 3, 4, 5, 6, 7, 8, 9]) - 0.001
    chi2, nod = stackplot(Zsplit(new),
                          b"nJets",
                          bins,
                          1,
                          xlabel=r"number of jets",
                          title3=title3,
                          filename="njet-new" + str(ntag) + "tag",
                          print_height=False,
                          title2=t2,
                          auto_colour=False,
                          limit_y=0.5,
                          upper_y=2.0,
                          log_y=True)
    chi2, nod = stackplot(Zsplit(old),
                          b"nJets",
                          bins,
                          1,
                          xlabel=r"number of jets",
                          title3=title3,
                          filename="njet-old" + str(ntag) + "tag",
                          print_height=False,
                          title2=t2,
                          auto_colour=False,
                          limit_y=0.5,
                          upper_y=2.0,
                          log_y=True)

    bins = np.array([0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4.5]) - 0.001
    chi2, nod = stackplot(Zsplit(new),
                          b"dEtaBB",
                          bins,
                          1,
                          xlabel=r"$\Delta\eta_{BB}$",
                          title3=title3,
                          filename="etabb-new" + str(ntag) + "tag",
                          print_height=False,
                          title2=t2,
                          auto_colour=False,
                          limit_y=0.5,
                          upper_y=2.0,
                          log_y=True)
    chi2, nod = stackplot(Zsplit(old),
                          b"dEtaBB",
                          bins,
                          1,
                          xlabel=r"$\Delta\eta_{BB}$",
                          title3=title3,
                          filename="etabb-old" + str(ntag) + "tag",
                          print_height=False,
                          title2=t2,
                          auto_colour=False,
                          limit_y=0.5,
                          upper_y=2.0,
                          log_y=True)

    bins = [150, 200, 250, 300, 350, 400, 500, 600, 800, 1800]
    chi2, nod = stackplot(Zsplit(new),
                          b"ptH",
                          bins,
                          1000.,
                          xlabel=r"$pT_{BB}[GeV]$",
                          title3=title3,
                          filename="ptH-new" + str(ntag) + "tag",
                          print_height=False,
                          title2=t2,
                          auto_colour=False,
                          limit_y=0.5,
                          upper_y=2.0,
                          log_y=True)
    chi2, nod = stackplot(Zsplit(old),
                          b"ptH",
                          bins,
                          1000.,
                          xlabel=r"$pT_{BB}[GeV]$",
                          title3=title3,
                          filename="ptH-old" + str(ntag) + "tag",
                          print_height=False,
                          title2=t2,
                          auto_colour=False,
                          limit_y=0.5,
                          upper_y=2.0,
                          log_y=True)

    data = copy.deepcopy(old)
    eventpop(data, "Zlljet")
    for each in data:
        if each.alias != "data":
            each.weight *= -1

    new = eventkepp(new, "Zlljet")
    setcolour(new, "r")
    old = eventkepp(old, "Zlljet")
    setcolour(old, "b")
    setcolour(data, "k")

    bins = [
        150, 200, 250, 300, 350, 400, 500, 600, 700, 800, 900, 1000, 1500, 1800
    ]
    histplot_withsub([new, old, data],
                     b'mVHres',
                     bins,
                     labels=["Sherpa v2.2.10", "Sherpa v2.2.1", "data"],
                     scales=1000.,
                     removenorm=None,
                     filename="mVH" + str(ntag) + "tag",
                     central="data",
                     title3=title3,
                     title2=t2,
                     do_errorbar=True)
    histplot_withsub([new, old, data],
                     b'mVHres',
                     bins,
                     labels=["Sherpa v2.2.10", "Sherpa v2.2.1", "data"],
                     scales=1000.,
                     removenorm="data",
                     filename="mVH" + str(ntag) + "tag_density",
                     central="data",
                     title3=title3,
                     title2=t2,
                     do_errorbar=True)
    bins = [150, 200, 250, 300, 350, 400, 500, 600, 800, 1800]
    histplot_withsub([new, old, data],
                     b"ptH",
                     bins,
                     labels=["Sherpa v2.2.10", "Sherpa v2.2.1", "data"],
                     scales=1000.,
                     xlabel=r"$pT_{BB}[GeV]$",
                     removenorm=None,
                     filename="ptbb" + str(ntag) + "tag",
                     central="data",
                     title3=title3,
                     title2=t2,
                     do_errorbar=True)
    histplot_withsub([new, old, data],
                     b"ptH",
                     bins,
                     labels=["Sherpa v2.2.10", "Sherpa v2.2.1", "data"],
                     scales=1000.,
                     xlabel=r"$pT_{BB}[GeV]$",
                     removenorm="data",
                     filename="ptbb" + str(ntag) + "tag_density",
                     central="data",
                     title3=title3,
                     title2=t2,
                     do_errorbar=True)
    bins = [150, 200, 250, 300, 350, 400, 500, 600, 800, 1800]
    histplot_withsub([new, old, data],
                     b"pTV",
                     bins,
                     labels=["Sherpa v2.2.10", "Sherpa v2.2.1", "data"],
                     scales=1000.,
                     xlabel=r"$pT_{V}[GeV]$",
                     removenorm=None,
                     filename="ptV" + str(ntag) + "tag",
                     central="data",
                     title3=title3,
                     title2=t2,
                     do_errorbar=True)
    histplot_withsub([new, old, data],
                     b"pTV",
                     bins,
                     labels=["Sherpa v2.2.10", "Sherpa v2.2.1", "data"],
                     scales=1000.,
                     xlabel=r"$pT_{V}[GeV]$",
                     removenorm="data",
                     filename="ptV" + str(ntag) + "tag_density",
                     central="data",
                     title3=title3,
                     title2=t2,
                     do_errorbar=True)
    bins = np.array([2, 3, 4, 5, 6, 7, 8, 9]) - 0.001
    histplot_withsub([new, old, data],
                     b"nJets",
                     bins,
                     labels=["Sherpa v2.2.10", "Sherpa v2.2.1", "data"],
                     scales=1,
                     xlabel=r"number of jets",
                     removenorm=None,
                     filename="njet" + str(ntag) + "tag",
                     central="data",
                     title3=title3,
                     title2=t2,
                     do_errorbar=True)
    histplot_withsub([new, old, data],
                     b"nJets",
                     bins,
                     labels=["Sherpa v2.2.10", "Sherpa v2.2.1", "data"],
                     scales=1,
                     xlabel=r"number of jets",
                     removenorm="data",
                     filename="njet" + str(ntag) + "tag_density",
                     central="data",
                     title3=title3,
                     title2=t2,
                     do_errorbar=True)
    bins = np.array([0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4.5]) - 0.001
    histplot_withsub([new, old, data],
                     b"dEtaBB",
                     bins,
                     labels=["Sherpa v2.2.10", "Sherpa v2.2.1", "data"],
                     scales=1,
                     xlabel=r"$\Delta\eta_{BB}$",
                     removenorm=None,
                     filename="eta" + str(ntag) + "tag",
                     central="data",
                     title3=title3,
                     title2=t2,
                     do_errorbar=True)
    histplot_withsub([new, old, data],
                     b"dEtaBB",
                     bins,
                     labels=["Sherpa v2.2.10", "Sherpa v2.2.1", "data"],
                     scales=1,
                     xlabel=r"$\Delta\eta_{BB}$",
                     removenorm="data",
                     filename="eta" + str(ntag) + "tag_density",
                     central="data",
                     title3=title3,
                     title2=t2,
                     do_errorbar=True)
    #     title2=t2,auto_colour=False, limit_y = 0.5, upper_y=2.0, log_y=True, title3="2 lep.",)

    # bins = [10, 50, 100, 150, 250, 350, 450, 550, 650, 750]
    # stackplot(bkgtest + datatest,b'ptTrkJetsinFJ2',bins,1000.,
    #     xlabel=r"$pT_{Trkj2}[GeV]$", filename=direct + "ptTrkJetsinFJ2" + name, print_height=True,
    #     title2=t2,auto_colour=False, limit_y = 0.5, upper_y=2.5, log_y=True, title3="2 lep.",)

    datatest = copy.deepcopy(datalist)
    bkgtest = copy.deepcopy(backgroundlist)
    sumbkg = 0
    sumdata = 0
    for each in bkgtest + datatest:
        # each.cut_parameter(cut_btagout_less, 0)
        if "data" not in each.alias:
            sumbkg += sum(each.weight)
        else:
            sumdata += len(each.weight)
    print(sumbkg)
    print(sumdata)




    print("Making plots...")
    direct = ""
    name = "mbbcut-3ptag"
    bins = range(0,700,30)
    stackplot(bkgtest + datatest,b'ptHcorr',bins,1000.,
    xlabel=r"$pT_{BB}[GeV]$", filename=direct + "ptBB" + name, print_height=True,
    title2=t2,auto_colour=False, limit_y = 0.5, upper_y=2.5, log_y=True, title3="2 lep. 3+ btag resolved",)
        if "data" not in each.alias:
            sumbkg += sum(each.weight)
        else:
            sumdata += len(each.weight)
    print(sumbkg)
    print(sumdata)




    print("Making plots...")
    direct = ""
    name = "mbbcut-1tag"
    bins = [200, 220, 240, 260, 290, 320, 350, 380, 410,  450, 550, 650, 750, 850, 1000, 1200, 1400, 1800]
    stackplot(bkgtest + datatest,b'ptfj1',bins,1000.,
    xlabel=r"$pT_{FJ}[GeV]$", filename=direct + "ptfj1" + name, print_height=True,
    title2=t2,auto_colour=False, limit_y = 0.5, upper_y=2.5, log_y=True, title3="2 lep. 1 btag merged",)

    datatest = copy.deepcopy(datalist)
    bkgtest = copy.deepcopy(backgroundlist)
    sumbkg = 0
    sumdata = 0
    for each in bkgtest + datatest:
        each.cut_parameter(cut_btagin_is, 2)
        # each.cut_parameter(cut_btagout_less, 0)
        if "data" not in each.alias:
            sumbkg += sum(each.weight)
        else:
            sumdata += len(each.weight)
    print(sumbkg)
    print(sumdata)
                backgroundlist.append(content)
        
        test = get_signalid("ggA")
        out = splitesamples(signallist[0], test)
        new_signallist = []
        for each in out:
            new_signallist.append(each[1])
        for each in out:
            print(each[0], sum(each[1].weight))
            each[1].alias = "ggA" + str(each[0]) + " GeV"
            saveevents_pandas([each[1]], str(each[0])+".csv")
        saveevents_pandas(backgroundlist, "background.csv")

        # if datalist:
        #     saveevents(datalist,"data")
        # if signallist:
        #     saveevents(signallist,"signal")
        # if backgroundlist:
        #     saveevents(backgroundlist,"backgrounds")
    

    # make stack plot. delete if not needed.
    print("Making plots...")
    title3="mbbcr"
    direct = ""
    name = "SR-"
    bins = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 1000, 1150, 1350, 1550, 1800]
    stackplot(backgroundlist+datalist,b'mVHres',bins,1000.,
        xlabel=r"$m_{VH}[GeV]$", title3=title3, filename=direct + "mVH" + name, print_height=True,
        title2=t2, auto_colour=False, limit_y=0.5, upper_y=2.0, log_y=True)