Exemplo n.º 1
0
def plotJetReco(contName, cont, sel, partName):
    plots = []

    plots.append(
        Plot.make1D(contName + "_deltaR",
                    op.map(cont, lambda m: op.deltaR(m.p4, m.genJet.p4)),
                    sel,
                    EquidistantBinning(100, 0., 0.2),
                    xTitle="#Delta R(%s_{gen},%s_{reco})" %
                    (partName, partName)))
    plots.append(
        Plot.make1D(
            contName + "_deltaR2",
            op.map(cont, lambda m: op.pow(op.deltaR(m.p4, m.genJet.p4), 2)),
            sel,
            EquidistantBinning(100, 0., 0.04),
            xTitle="#Delta R^{2}(%s_{gen},%s_{reco})" % (partName, partName)))

    plots.append(
        Plot.make1D(
            contName + "_deltaPtRel",
            op.map(cont, lambda m: (m.pt - m.genJet.pt) / m.pt),
            sel,
            EquidistantBinning(100, -2., 2.),
            xTitle="P_{T}(%s_{reco})-P_{T}(%s_{gen})/P_{T}(%s_{reco})" %
            (partName, partName, partName)))
    return plots
Exemplo n.º 2
0
def makeBoostedJetPLots(self, sel, jets, uname):
    maxJet = 1
    binScaling = 1
    plots = []
    for i in range(maxJet):
        plots.append(
            Plot.make1D(f"{uname}_boostedjet{i+1}_pt",
                        jets[i].pt,
                        sel,
                        EqB(60, 170., 800.),
                        title=f"{utils.getCounter(i+1)} jet p_{{T}} [GeV]",
                        plotopts=utils.getOpts(uname)))
        plots.append(
            Plot.make1D(f"{uname}_boostedjet{i+1}_eta",
                        jets[i].eta,
                        sel,
                        EqB(50 // binScaling, -2.4, 2.4),
                        title=f"{utils.getCounter(i+1)} jet eta",
                        plotopts=utils.getOpts(uname)))
        plots.append(
            Plot.make1D(f"{uname}_boostedjet{i+1}_phi",
                        jets[i].phi,
                        sel,
                        EqB(50 // binScaling, -3.1416, 3.1416),
                        title=f"{utils.getCounter(i+1)} jet phi",
                        plotopts=utils.getOpts(uname)))
        plots.append(
            Plot.make1D(f"{uname}_boostedjet{i+1}_mass",
                        jets[i].phi,
                        sel,
                        EqB(50 // binScaling, -3.1416, 3.1416),
                        title=f"{utils.getCounter(i+1)} jet mass [GeV]",
                        plotopts=utils.getOpts(uname)))

    return plots
Exemplo n.º 3
0
    def definePlots(self, tree, noSel, sample=None, sampleCfg=None):
        from bamboo.plots import Plot
        from bamboo.plots import EquidistantBinning as EqBin
        from bamboo import treefunctions as op

        plots = []

        verbose = False

        trijets = op.combine(tree.Jet, N=3)
        hadTop = op.rng_min_element_by(trijets,
            fun=lambda comb: op.abs((comb[0].p4+comb[1].p4+comb[2].p4).M()-172.5))
        hasTriJet = noSel.refine("hasTriJet", cut=(op.rng_len(trijets) > 0))
        hadTop_p4 = op.defineOnFirstUse(hadTop[0].p4 + hadTop[1].p4 + hadTop[2].p4)
        plots.append(Plot.make1D("trijet_topPt",
            hadTop_p4.Pt(), hasTriJet,
            EqBin(100, 15., 40.), title="Trijet p_{T} (GeV/c)"))
        plots.append(Plot.make1D("trijet_maxbtag",
            op.max(op.max(hadTop[0].btag, hadTop[1].btag), hadTop[2].btag), hasTriJet,
            EqBin(100, 0., 1.), title="Trijet maximum b-tag"))

        if verbose:
            plots.append(Plot.make1D("njets",
                op.rng_len(tree.Jet), noSel,
                EqBin(20, 0., 20.), title="Number of jets"))
            plots.append(Plot.make1D("ntrijets",
                op.rng_len(trijets), noSel,
                EqBin(100, 0., 1000.), title="Number of 3-jet combinations"))
            plots.append(Plot.make1D("trijet_mass",
                hadTop_p4.M(), hasTriJet,
                EqBin(100, 0., 250.), title="Trijet mass (GeV/c^{2})"))

        return plots
Exemplo n.º 4
0
def MakeEllipsesPLots(self, sel, bjets, lepton, wp, uname, suffix):
    plots = []
    binScaling = 1
    for key in sel.keys():

        tagger = key.replace(wp, "")
        bjets_ = safeget(bjets, tagger, wp)

        plots.append(
            Plot.make1D(
                "jj_M_{0}_{1}_hZA_lljj_{2}_mll_and_met_cut".format(
                    suffix, uname, key),
                op.invariant_mass(bjets_[0].p4, bjets_[1].p4),
                sel.get(key),
                EqB(60 // binScaling, 0., 1000.),
                title="invariant mass of two b-tagged jets wrt {0} Discriminator"
                .format(suffix, key),
                xTitle="mjj {0} {1} [GeV]".format(suffix, key),
                plotopts=utils.getOpts(uname, **{"log-y": False})))

        plots.append(
            Plot.make1D(
                "lljj_M_{0}_{1}_hZA_lljj_{2}_mll_and_met_cut".format(
                    suffix, uname, key), (lepton[0].p4 + lepton[1].p4 +
                                          bjets_[0].p4 + bjets_[1].p4).M(),
                sel.get(key),
                EqB(60 // binScaling, 0., 1000.),
                title=
                "invariant mass of 2 leptons two b-tagged jets wrt {0} Discriminator"
                .format(suffix, key),
                xTitle="mlljj {0} {1} [GeV]".format(suffix, key),
                plotopts=utils.getOpts(uname, **{"log-y": False})))

        plots.append(
            Plot.make2D(
                "Mjj_vs_Mlljj_{0}_{1}_hZA_lljj_{2}_mll_and_met_cut".format(
                    suffix, uname,
                    key), (op.invariant_mass(bjets_[0].p4, bjets_[1].p4),
                           (lepton[0].p4 + lepton[1].p4 + bjets_[0].p4 +
                            bjets_[1].p4).M()),
                sel.get(key), (EqB(60 // binScaling, 0.,
                                   1000.), EqB(60 // binScaling, 0., 1000.)),
                title="mlljj vs mjj invariant mass {0} wrt {1} Discriminator".
                format(suffix, key),
                plotopts=utils.getOpts(uname, **{"log-y": False})))

        plots.append(
            Plot.make1D(
                "ll_M_{0}_{1}_hZA_lljj_{2}_mll_and_met_cut".format(
                    suffix, uname, key),
                op.invariant_mass(lepton[0].p4, lepton[1].p4),
                sel.get(key),
                EqB(60 // binScaling, 70., 110.),
                title=" dilepton invariant mass {0} wrt {1} Discriminator".
                format(suffix, key),
                xTitle="mll {0} {1} [GeV]".format(suffix, key),
                plotopts=utils.getOpts(uname)))
    return plots
Exemplo n.º 5
0
 def controlPlots_4l(self, sel4l, bestZ, otherZ):
     prefix = sel4l.name[3:]
     plots = [
         Plot.make1D(f"{prefix}_Z1_l1PT", bestZ[0].pt, sel4l, EqBin(50, 0., 100.)),
         Plot.make1D(f"{prefix}_Z1_l2PT", bestZ[1].pt, sel4l, EqBin(50, 0., 100.)),
         Plot.make1D(f"{prefix}_Z2_l1PT", otherZ[0].pt, sel4l, EqBin(50, 0., 100.)),
         Plot.make1D(f"{prefix}_Z2_l2PT", otherZ[1].pt, sel4l, EqBin(50, 0., 100.)),
         ]
     return plots
Exemplo n.º 6
0
def makeControlPlotsForZpic(self, sel, lepton, uname):
    plots = []
    for i in range(2):
        if "mu" in uname:
            flav = "Muon"
        if "el" in uname:
            flav = "Electron"

        plots.append(
            Plot.make1D(f"{uname}_lep{i+1}_pt",
                        lepton[i].pt,
                        sel,
                        EqB(60 // binScaling, 30., 530.),
                        title="%s p_{T} [GeV]" % flav,
                        plotopts=utils.getOpts(uname)))
        plots.append(
            Plot.make1D(f"{uname}_lep{i+1}_eta",
                        lepton[i].eta,
                        sel,
                        EqB(50 // binScaling, -2.4, 2.4),
                        title="%s eta" % flav,
                        plotopts=utils.getOpts(uname, **{"log-y": False})))
        plots.append(
            Plot.make1D(f"{uname}_lep{i+1}_phi",
                        lepton[i].phi,
                        sel,
                        EqB(50 // binScaling, -3.1416, 3.1416),
                        title="%s phi" % flav,
                        plotopts=utils.getOpts(uname, **{"log-y": False})))

        plots.append(
            Plot.make1D("{0}_mll".format(uname),
                        op.invariant_mass(lepton[0].p4, lepton[1].p4),
                        sel,
                        EqB(60, 70., 110.),
                        title="mll [GeV]",
                        plotopts=utils.getOpts(uname)))
        plots.append(
            Plot.make1D("{0}_llpT".format(uname),
                        (dilepton[0].p4 + dilepton[1].p4).Pt(),
                        sel,
                        EqB(60, 0., 450.),
                        title="dilepton P_{T} [GeV]",
                        plotopts=utils.getOpts(uname)))
    # FIXME
    #plots.append(Plot.make1D("{0}_nVX".format(uname),
    #            t.PV.npvs, sel,
    #            EqB(10, 0., 60.),
    #            title="Distrubtion of the number of the reconstructed vertices",
    #            xTitle="number of reconstructed vertices "))
    #plots.append(Plot.make2D("{0}_Electron_dzdxy".format(uname),
    #            (lepton[0].dz ,lepton[0].dxy), sel,
    #            (EqB(10, 0., 2.),
    #            EqB(10, 0., 2.)) ,
    #            title="Electron in Barrel/EndCAP region" ))
    return plots
Exemplo n.º 7
0
def plotFatjetMatching(cont, sel, sub1, sub2):
    plots = []

    plots.append(
        Plot.make1D(f"fatjet{sub1}{sub2}_sub1_dE",
                    op.map(cont, lambda m: m[2].subJet1.p4.E() - m[0].p4.E()),
                    sel,
                    EquidistantBinning(1000, -1000., 1000.),
                    xTitle=f"subJet1 {sub1} E - gen {sub1} E"))
    plots.append(
        Plot.make2D(
            f"fatjet{sub1}{sub2}_sub1_TF", [
                op.map(cont, lambda m: m[0].p4.E()),
                op.map(cont, lambda m: m[2].subJet1.p4.E() - m[0].p4.E())
            ],
            sel, [
                EquidistantBinning(3000, 0., 3000.),
                EquidistantBinning(8000, -1000., 1000.)
            ],
            xTitle="E^{{parton}}({sub1})",
            yTitle=f"#Delta E = E^{{reco}}({sub1})-E^{{parton}}({sub1})"))

    plots.append(
        Plot.make1D(f"fatjet{sub1}{sub2}_sub2_dE",
                    op.map(cont, lambda m: m[2].subJet2.p4.E() - m[1].p4.E()),
                    sel,
                    EquidistantBinning(1000, -1000., 1000.),
                    xTitle=f"subJet2 {sub2} E - gen {sub2} E"))
    plots.append(
        Plot.make2D(
            f"fatjet{sub1}{sub2}_sub2_TF", [
                op.map(cont, lambda m: m[1].p4.E()),
                op.map(cont, lambda m: m[2].subJet1.p4.E() - m[1].p4.E())
            ],
            sel, [
                EquidistantBinning(3000, 0., 3000.),
                EquidistantBinning(8000, -1000., 1000.)
            ],
            xTitle="E^{{parton}}({sub2})",
            yTitle=f"#Delta E = E^{{reco}}({sub2})-E^{{parton}}({sub2})"))

    plots.append(
        Plot.make2D(f"fatjet{sub1}{sub2}_dE2D", [
            op.map(cont, lambda m: m[2].subJet1.p4.E() - m[0].p4.E()),
            op.map(cont, lambda m: m[2].subJet2.p4.E() - m[1].p4.E())
        ],
                    sel, [
                        EquidistantBinning(1000, -1000., 1000.),
                        EquidistantBinning(1000, -1000., 1000.)
                    ],
                    xTitle=f"subJet1 {sub1} E - gen {sub1} E",
                    yTitle=f"subJet2 {sub2} E - gen {sub2} E"))

    return plots
Exemplo n.º 8
0
def MakeExtraMETPlots(self, sel, lepton, met, uname, suffix):
    binScaling = 1
    plots = []
    for key in sel.keys():

        plots.append(
            Plot.make1D("{0}_{1}_{2}_MET_pt".format(uname, key, suffix),
                        met.pt,
                        sel.get(key),
                        EqB(60 // binScaling, 0., 600.),
                        title="MET p_{T} [GeV]",
                        plotopts=utils.getOpts(uname, **{"log-y": False})))
        plots.append(
            Plot.make1D("{0}_{1}_{2}_MET_phi".format(uname, key, suffix),
                        met.phi,
                        sel.get(key),
                        EqB(60 // binScaling, -3.1416, 3.1416),
                        title="MET #phi",
                        plotopts=utils.getOpts(uname, **{"log-y": False})))
        plots.append(
            Plot.make1D("{0}_{1}_{2}_MET_eta".format(uname, key, suffix),
                        met.phi,
                        sel.get(key),
                        EqB(60 // binScaling, -2.4, 2.4),
                        title="MET #eta",
                        plotopts=utils.getOpts(uname, **{"log-y": False})))

        for i in range(2):
            plots.append(
                Plot.make1D(
                    f"{uname}_{key}_{suffix}_MET_lep{i+1}_deltaPhi".format(
                        uname=uname, key=key, suffix=suffix),
                    op.Phi_mpi_pi(lepton[i].phi - met.phi),
                    sel.get(key),
                    EqB(60 // binScaling, -3.1416, 3.1416),
                    title="#Delta #phi (lepton, MET)",
                    plotopts=utils.getOpts(uname, **{"log-y": False})))

            MT = op.sqrt(
                2. * met.pt * lepton[i].p4.Pt() *
                (1. - op.cos(op.Phi_mpi_pi(met.phi - lepton[i].p4.Phi()))))
            plots.append(
                Plot.make1D(f"{uname}_{key}_{suffix}_MET_MT_lep{i+1}".format(
                    uname=uname, key=key, suffix=suffix),
                            MT,
                            sel.get(key),
                            EqB(60 // binScaling, 0., 600.),
                            title="Lepton M_{T} [GeV]",
                            plotopts=utils.getOpts(uname, **{"log-y": False})))
    return plots
Exemplo n.º 9
0
    def definePlots(self, t, noSel, sample=None, sampleCfg=None):
        from bamboo.plots import Plot, CutFlowReport, SummedPlot
        from bamboo.plots import EquidistantBinning as EqB
        from bamboo import treefunctions as op

        isMC = self.isMC(sample)
        if isMC:
            noSel = noSel.refine("mcWeight", weight=[t.genWeight])
        noSel = noSel.refine(
            "trig",
            cut=op.OR(t.HLT.HIL3DoubleMu0,
                      t.HLT.HIEle20_Ele12_CaloIdL_TrackIdL_IsoVL_DZ))

        plots = []

        muons = op.select(t.Muon, lambda mu: mu.pt > 20.)
        twoMuSel = noSel.refine("twoMuons", cut=[op.rng_len(muons) > 1])
        plots.append(
            Plot.make1D("dimu_M",
                        op.invariant_mass(muons[0].p4, muons[1].p4),
                        twoMuSel,
                        EqB(100, 20., 120.),
                        title="Dimuon invariant mass",
                        plotopts={
                            "show-overflow": False,
                            "legend-position": [0.2, 0.6, 0.5, 0.9]
                        }))

        return plots
Exemplo n.º 10
0
def plotMatching(contName, cont, sel, partName):
    plots = []

    #    plots.append(Plot.make1D(contName+"_deltaR",
    #                             op.map(cont,lambda m : op.deltaR(m[0].p4,m[1].p4)),
    #                             sel,
    #                             EquidistantBinning(1000,0.,0.2),
    #                             xTitle="#Delta R(%s_{gen},%s_{reco})"%(partName,partName)))
    #    plots.append(Plot.make1D(contName+"_deltaPtRel",
    #                             op.map(cont,lambda m : (m[1].pt-m[0].pt)/(m[0].pt+m[1].pt)),
    #                             sel,
    #                             EquidistantBinning(1000,-1.,1.),
    #                             xTitle="P_{T}(%s_{reco})-P_{T}(%s_{gen})/P_{T}(%s_{reco})+P_{T}(%s_{gen})"%(partName,partName,partName,partName)))
    #    plots.append(Plot.make2D(contName+"_Pt2D",
    #                             [op.map(cont,lambda m : m[0].pt),op.map(cont,lambda m : m[1].pt)],
    #                             sel,
    #                             [EquidistantBinning(1000,0,1000),EquidistantBinning(1000,0,1000)],
    #                             xTitle="P_{T}(gen)",
    #                             yTitle="P_{T}(reco)"))
    plots.append(
        Plot.make2D(contName + "_TF",
                    (op.map(cont, lambda m: m[0].p4.E()),
                     op.map(cont, lambda m: m[1].p4.E() - m[0].p4.E())),
                    sel, [
                        EquidistantBinning(3000, 0., 3000.),
                        EquidistantBinning(8000, -1000., 1000.)
                    ],
                    xTitle="E^{parton}(e^{-})",
                    yTitle="#Delta E = E^{reco}(%s)-E^{parton}(%s)" %
                    (partName, partName)))

    return plots
Exemplo n.º 11
0
    def definePlots(self, tree, noSel, sample=None, sampleCfg=None):
        from bamboo.plots import Plot
        from bamboo.plots import EquidistantBinning as EqBin
        from bamboo import treefunctions as op

        plots = []

        el10 = op.select(tree.Electron, lambda el: el.pt > 10.)
        mu10 = op.select(tree.Muon, lambda mu: mu.pt > 10.)
        cleanedJets30 = op.select(
            tree.Jet, lambda j: op.AND(
                j.pt > 30.,
                op.NOT(
                    op.rng_any(el10, lambda el: op.deltaR(j.p4, el.p4) < 0.4)),
                op.NOT(
                    op.rng_any(mu10, lambda mu: op.deltaR(j.p4, mu.p4) < 0.4)))
        )
        plots.append(
            Plot.make1D("sumCleanedJetPt",
                        op.rng_sum(cleanedJets30, lambda j: j.pt),
                        noSel,
                        EqBin(100, 15., 200.),
                        title="Sum p_{T} (GeV/c)"))

        return plots
Exemplo n.º 12
0
def plotNumber(contName, cont, sel, Nmax, xTitle):
    return [
        Plot.make1D(contName,
                    op.rng_len(cont),
                    sel,
                    EquidistantBinning(Nmax, 0., Nmax),
                    xTitle=xTitle)
    ]
Exemplo n.º 13
0
def makeResolvedBJetPlots(self, sel, bjets, wp, uname):
    plots = []
    binScaling = 1
    for key in sel.keys():

        tagger = key.replace(wp, "")
        bjets_ = safeget(bjets, tagger, wp)

        plots.append(
            Plot.make1D("{0}_nBJets_{1}".format(uname, key),
                        op.rng_len(bjets_),
                        sel.get(key),
                        EqB(5, 2., 6.),
                        xTitle="Jets multiplicty {0}".format(key),
                        plotopts=utils.getOpts(uname)))
        for i in range(1):
            plots.append(
                Plot.make1D(
                    f"{uname}_bjet{i+1}_pT_{key}",
                    bjets_[i].pt,
                    sel.get(key),
                    EqB(60, 0., 800.),
                    title=
                    f"{utils.getCounter(i+1)}-highest bjet pT {key} [GeV]",
                    plotopts=utils.getOpts(uname)))

            plots.append(
                Plot.make1D(
                    f"{uname}_bjet{i+1}_eta_{key}",
                    bjets_[i].eta,
                    sel.get(key),
                    EqB(50 // binScaling, -2.4, 2.4),
                    title=f"{utils.getCounter(i+1)}-highest bjet eta {key}",
                    plotopts=utils.getOpts(uname)))

            plots.append(
                Plot.make1D(
                    f"{uname}_bjet{i+1}_eta_{key}",
                    bjets_[i].phi,
                    sel.get(key),
                    EqB(50 // binScaling, -3.1416, 3.1416),
                    title=f"{utils.getCounter(i+1)}-highest bjet phi {key}",
                    plotopts=utils.getOpts(uname)))
    return plots
Exemplo n.º 14
0
def makeControlPlotsForFinalSel(self, sel, bjets, dilepton, uname):
    plots = []
    binScaling = 1
    for key in sel.keys():

        tagger = key.replace(wp, "")
        bjets_ = safeget(bjets, tagger, wp)

        plots.append(
            Plot.make1D("{0}_TwoBtaggedJets_pT_{1}".format(uname, key),
                        (bjets_[0].p4 + bjets_[1].p4).Pt(),
                        sel.get(key),
                        EqB(60, 170., 800.),
                        title="di-bjet P_{T} [GeV]",
                        plotopts=utils.getOpts(uname)))

        plots.append(
            Plot.make1D("{0}_mlljj_btagged_{1}".format(uname, key),
                        (lepton[0].p4 + lepton[1].p4 + bjets_[0].p4 +
                         bjets_[1].p4).M(),
                        sel.get(key),
                        EqB(60, 170., 1000.),
                        title="mlljj [GeV]",
                        plotopts=utils.getOpts(uname)))

        plots.append(
            Plot.make1D("{0}_mjj_btagged_{1}".format(uname, key),
                        op.invariant_mass(bjets_[0].p4 + bjets_[1].p4),
                        sel.get(key),
                        EqB(60, 170., 800.),
                        title="mjj [GeV]",
                        plotopts=utils.getOpts(uname)))

        plots.append(
            Plot.make2D("{0}_mlljjvsmjj_btagged_{1}".format(uname, key),
                        (op.invariant_mass(bjets_[0].p4 + bjets_[1].p4),
                         (lepton[0].p4 + lepton[1].p4 + bjets_[0].p4 +
                          bjets_[1].p4).M()),
                        sel.get(key),
                        (EqB(60, 170., 1000.), EqB(60, 170., 1000.)),
                        title="mlljj vs mjj invariant mass [GeV]",
                        plotopts=utils.getOpts(uname)))
    return plots
Exemplo n.º 15
0
def fatjetPlots(sel, fatjets, name):
    plots = []
    #    plots.append(Plot.make2D(name+'_Pt2D',
    #                             [op.map(fatjets, lambda fatjet : fatjet.subJet1.pt),op.map(fatjets, lambda fatjet : fatjet.subJet2.pt)],
    #                             sel,
    #                             [EquidistantBinning(1000,0.,1000.),EquidistantBinning(1000,0.,1000.)],
    #                             xTitle = "subjet 1 P_{T}",
    #                             yTitle = "subjet 2 P_{T}"))
    plots.append(
        Plot.make2D(name + '_E2D', [
            op.map(fatjets, lambda fatjet: fatjet.subJet1.p4.E()),
            op.map(fatjets, lambda fatjet: fatjet.subJet2.p4.E())
        ],
                    sel, [
                        EquidistantBinning(1000, 0., 1000.),
                        EquidistantBinning(1000, 0., 1000.)
                    ],
                    xTitle="subjet 1 E",
                    yTitle="subjet 2 E"))
    #    plots.append(Plot.make2D(name+'_partonflavour2D',
    #                             [op.map(fatjets, lambda fatjet : fatjet.subJet1.partonFlavour),op.map(fatjets, lambda fatjet : fatjet.subJet2.partonFlavour)],
    #                             sel,
    #                             [EquidistantBinning(7,0.,6.),EquidistantBinning(7,0.,6.)],
    #                             xTitle = "subjet 1 P_{T}",
    #                             yTitle = "subjet 2 P_{T}"))

    #    plots.append(Plot.make2D(name+'_subjet1VSFatjet_E2D',
    #                             [op.map(fatjets, lambda fatjet : fatjet.subJet1.p4.E()),op.map(fatjets, lambda fatjet : fatjet.p4.E())],
    #                             sel,
    #                             [EquidistantBinning(1000,0.,1000.),EquidistantBinning(1000,0.,1000.)],
    #                             xTitle = "subjet 1 E",
    #                             yTitle = "fatjet E"))
    #    plots.append(Plot.make2D(name+'_subjet2VSFatjet_E2D',
    #                             [op.map(fatjets, lambda fatjet : fatjet.subJet2.p4.E()),op.map(fatjets, lambda fatjet : fatjet.p4.E())],
    #                             sel,
    #                             [EquidistantBinning(1000,0.,1000.),EquidistantBinning(1000,0.,1000.)],
    #                             xTitle = "subjet 2 E",
    #                             yTitle = "fatjet E"))
    #
    #    plots.append(Plot.make2D(name+'_Eta2D',
    #                             [op.map(fatjets, lambda fatjet : fatjet.subJet1.p4.eta()),op.map(fatjets, lambda fatjet : fatjet.subJet2.p4.eta())],
    #                             sel,
    #                             [EquidistantBinning(500,-2.5,2.5),EquidistantBinning(500,-2.5,2.5)],
    #                             xTitle = "subjet 1 #eta",
    #                             yTitle = "subjet 2 #eta"))
    #    plots.append(Plot.make2D(name+'_Phi2D',
    #                             [op.map(fatjets, lambda fatjet : fatjet.subJet1.p4.phi()),op.map(fatjets, lambda fatjet : fatjet.subJet2.p4.phi())],
    #                             sel,
    #                             [EquidistantBinning(320,-3.2,3.2),EquidistantBinning(320,-3.2,3.2)],
    #                             xTitle = "subjet 1 #phi",
    #                             yTitle = "subjet 2 #phi"))

    return plots
Exemplo n.º 16
0
def makeBoostedJetPLots(self, sel, bjets, wp, uname):
    maxJet = 1
    binScaling = 1
    plots = []

    for key in sel.keys():
        tagger = key.replace(wp, "")
        bjets_ = safeget(bjets, tagger, wp)

        for i in range(maxJet):
            plots.append(
                Plot.make1D(f"{uname}_boostedjet{i+1}_pt",
                            bjets_[i].pt,
                            sel,
                            EqB(60, 170., 800.),
                            title=f"{utils.getCounter(i+1)} jet p_{{T}} [GeV]",
                            plotopts=utils.getOpts(uname)))
            plots.append(
                Plot.make1D(f"{uname}_boostedjet{i+1}_eta",
                            bjets_[i].eta,
                            sel,
                            EqB(50 // binScaling, -2.4, 2.4),
                            title=f"{utils.getCounter(i+1)} jet eta",
                            plotopts=utils.getOpts(uname)))
            plots.append(
                Plot.make1D(f"{uname}_boostedjet{i+1}_phi",
                            bjets_[i].phi,
                            sel,
                            EqB(50 // binScaling, -3.1416, 3.1416),
                            title=f"{utils.getCounter(i+1)} jet phi",
                            plotopts=utils.getOpts(uname)))
            plots.append(
                Plot.make1D(f"{uname}_boostedjet{i+1}_mass",
                            bjets_[i].phi,
                            sel,
                            EqB(50 // binScaling, -3.1416, 3.1416),
                            title=f"{utils.getCounter(i+1)} jet mass [GeV]",
                            plotopts=utils.getOpts(uname)))

    return plots
Exemplo n.º 17
0
def MakeMETPlots(self, sel, corrmet, met, uname, suffix):
    plots = []
    binScaling = 1
    for key in sel.keys():

        plots.append(
            Plot.make1D("met_pt_{0}_{1}_hZA_lljj_{2}".format(
                suffix, uname, key),
                        met.pt,
                        sel.get(key),
                        EqB(60 // binScaling, 0., 600.),
                        title="MET p_{T} [GeV]",
                        plotopts=utils.getOpts(uname, **{"log-y": False})))
        plots.append(
            Plot.make1D("xycorrmet_pt_{0}_{1}_hZA_lljj_{2}".format(
                suffix, uname, key),
                        corrmet.pt,
                        sel.get(key),
                        EqB(60 // binScaling, 0., 600.),
                        title="corrMET p_{T} [GeV]",
                        plotopts=utils.getOpts(uname, **{"log-y": False})))
    return plots
Exemplo n.º 18
0
    def definePlots(self, tree, noSel, sample=None, sampleCfg=None):
        from bamboo.plots import Plot
        from bamboo.plots import EquidistantBinning as EqBin

        plots = []

        plots.append(
            Plot.make1D("MET",
                        tree.MET.pt,
                        noSel,
                        EqBin(100, 0., 2000.),
                        title="MET (GeV)"))

        return plots
Exemplo n.º 19
0
    def definePlots(self, tree, noSel, sample=None, sampleCfg=None):
        from bamboo.plots import Plot
        from bamboo.plots import EquidistantBinning as EqBin
        from bamboo import treefunctions as op

        plots = []

        plots.append(
            Plot.make1D("jetPt",
                        op.map(tree.Jet, lambda j: j.pt),
                        noSel,
                        EqBin(100, 15., 60.),
                        title="Jet p_{T} (GeV/c)"))

        return plots
Exemplo n.º 20
0
    def definePlots(self, tree, noSel, sample=None, sampleCfg=None):
        from bamboo.plots import Plot, SummedPlot
        from bamboo.plots import EquidistantBinning as EqBin
        from bamboo import treefunctions as op

        plots = []

        # The plot is made for each of the different flavour categories (l+/- l-/+ l') and then summed,
        # because concatenation of containers is not (yet) supported.
        lepColl = {"El": tree.Electron, "Mu": tree.Muon}
        mt3lPlots = []
        for dlNm, dlCol in lepColl.items():
            dilep = op.combine(
                dlCol,
                N=2,
                pred=(lambda l1, l2: op.AND(l1.charge != l2.charge)))
            hasDiLep = noSel.refine("hasDilep{0}{0}".format(dlNm),
                                    cut=(op.rng_len(dilep) > 0))
            dilepZ = op.rng_min_element_by(
                dilep,
                fun=lambda ll: op.abs(
                    op.invariant_mass(ll[0].p4, ll[1].p4) - 91.2))
            for tlNm, tlCol in lepColl.items():
                if tlCol == dlCol:
                    hasTriLep = hasDiLep.refine("hasTrilep{0}{0}{1}".format(
                        dlNm, tlNm),
                                                cut=(op.rng_len(tlCol) > 2))
                    residLep = op.select(
                        tlCol, lambda l: op.AND(l.idx != dilepZ[0].idx, l.idx
                                                != dilepZ[1].idx))
                    l3 = op.rng_max_element_by(residLep, lambda l: l.pt)
                else:
                    hasTriLep = hasDiLep.refine("hasTriLep{0}{0}{1}".format(
                        dlNm, tlNm),
                                                cut=(op.rng_len(tlCol) > 0))
                    l3 = op.rng_max_element_by(tlCol, lambda l: l.pt)
                mtPlot = Plot.make1D(
                    "3lMT_{0}{0}{1}".format(dlNm, tlNm),
                    op.sqrt(2 * l3.pt * tree.MET.pt *
                            (1 - op.cos(l3.phi - tree.MET.phi))),
                    hasTriLep,
                    EqBin(100, 15., 250.),
                    title="M_{T} (GeV/c^2)")
                mt3lPlots.append(mtPlot)
                plots.append(mtPlot)
        plots.append(SummedPlot("3lMT", mt3lPlots))

        return plots
Exemplo n.º 21
0
    def definePlots(self, tree, noSel, sample=None, sampleCfg=None):
        from bamboo.plots import Plot
        from bamboo.plots import EquidistantBinning as EqBin
        from bamboo import treefunctions as op

        plots = []

        jets40 = op.select(tree.Jet, lambda j: j.pt > 40)
        hasTwoJets40 = noSel.refine("twoJets40", cut=(op.rng_len(jets40) >= 2))
        plots.append(
            Plot.make1D("twoJets40_MET",
                        tree.MET.pt,
                        hasTwoJets40,
                        EqBin(100, 0., 2000.),
                        title="MET (GeV)"))

        return plots
Exemplo n.º 22
0
def plotRecoForGen(sel, gen, reco, lambda_match, name):
    n_reco = [
        op.select(
            reco, lambda r: op.switch(
                op.rng_len(gen) > i, lambda_match(gen[i], r), op.c_bool(False))
        ) for i in range(10)
    ]

    plots = SummedPlot("n_reco_{}_per_gen".format(name), [
        Plot.make1D("n_reco_{}_per_gen_{}".format(name, i),
                    op.rng_len(nre),
                    sel,
                    EquidistantBinning(10, 0, 10),
                    xTitle="N reco {} for gen {}".format(name, i))
        for i, nre in enumerate(n_reco)
    ],
                       xTitle="N reco {} for each gen".format(name))

    return plots
Exemplo n.º 23
0
def makeResolvedJetPlots(self, sel, jets, uname):
    maxJet = 2
    binScaling = 1
    plots = []
    for i in range(maxJet):
        plots.append(
            Plot.make1D(f"{uname}_jet{i+1}_pt",
                        jets[i].pt,
                        sel,
                        EqB(60 // binScaling, 30., 730. - max(4, i) * 100),
                        title=f"{utils.getCounter(i+1)} jet p_{{T}} [GeV]",
                        plotopts=utils.getOpts(uname)))
        plots.append(
            Plot.make1D(f"{uname}_jet{i+1}_eta",
                        jets[i].eta,
                        sel,
                        EqB(50 // binScaling, -2.4, 2.4),
                        title=f"{utils.getCounter(i+1)} jet eta",
                        plotopts=utils.getOpts(uname, **{"log-y": False})))
        plots.append(
            Plot.make1D(f"{uname}_jet{i+1}_phi",
                        jets[i].phi,
                        sel,
                        EqB(50 // binScaling, -3.1416, 3.1416),
                        title=f"{utils.getCounter(i+1)} jet phi",
                        plotopts=utils.getOpts(uname, **{"log-y": False})))

    plots.append(
        Plot.make1D(f"{uname}_jet_DR",
                    op.deltaR(jets[0].p4, jets[1].p4),
                    sel,
                    EqB(50, 0.3, 3.),
                    title="Jets DR",
                    plotopts=utils.getOpts(uname, **{"log-y": False})))
    plots.append(
        Plot.make1D(f"{uname}_jet_M",
                    op.invariant_mass(jets[0].p4, jets[1].p4),
                    sel,
                    EqB(60, 0., 400.),
                    title="dijets invariant mass [GeV]",
                    plotopts=utils.getOpts(uname)))
    plots.append(
        Plot.make1D(f"{uname}_jet_pT", (jets[0].p4 + jets[1].p4).Pt(),
                    sel,
                    EqB(60, 0., 600.),
                    title=" dijets p_{T} [GeV]",
                    plotopts=utils.getOpts(uname)))
    return plots
Exemplo n.º 24
0
    def definePlots(self, tree, noSel, sample=None, sampleCfg=None):
        from bamboo.plots import Plot, SummedPlot
        from bamboo.plots import EquidistantBinning as EqBin
        from bamboo import treefunctions as op
        plots = []
        metSel = noSel.refine("MET", cut=(tree.met.et > 30000))
        trigSel = metSel.refine("trig", cut=op.OR(tree.trigE, tree.trigM))
        goodLeptons = op.select(
            tree.lep, lambda l: op.AND(l.isTightID, l.pt > 35000., l.ptcone30 /
                                       l.pt < 0.1, l.etcone20 / l.pt < 0.1))
        oneLepSel = trigSel.refine("1goodlep",
                                   cut=(op.rng_len(goodLeptons) == 1))
        lep = goodLeptons[0]
        signalSel = oneLepSel.refine(
            "signalRegion",
            cut=op.AND(
                op.abs(lep.z0 * op.sin(lep.p4.theta())) < 0.5,
                op.multiSwitch(
                    (lep.type == 11,
                     op.AND(
                         op.abs(lep.eta) < 2.46,
                         op.NOT(op.in_range(1.37, op.abs(lep.eta), 1.52)),
                         op.abs(lep.trackd0pvunbiased /
                                lep.tracksigd0pvunbiased) < 5)),
                    (lep.type == 13,
                     op.AND(
                         op.abs(lep.eta) < 2.5,
                         op.abs(lep.trackd0pvunbiased /
                                lep.tracksigd0pvunbiased) < 3)),
                    op.c_bool(False))))
        metp4 = makePtEtaPhiEP4(tree.met.et, op.c_float(0.), tree.met.phi,
                                tree.met.et)
        plots.append(
            Plot.make1D("mt_w", (lep.p4 + metp4).Mt() / 1000.,
                        signalSel,
                        EqBin(40, 60., 180.),
                        title="m_{T}^{W#rightarrow l#nu} (GeV)",
                        plotopts={"log-y-axis-range": [25., 2.5e8]}))

        return plots
Exemplo n.º 25
0
    def definePlots(self, tree, noSel, sample=None, sampleCfg=None):
        from bamboo.plots import Plot
        from bamboo.plots import EquidistantBinning as EqBin
        from bamboo import treefunctions as op

        plots = []

        dimu_Z = op.combine(
            tree.Muon,
            N=2,
            pred=(lambda mu1, mu2: op.AND(
                mu1.charge != mu2.charge,
                op.in_range(60., op.invariant_mass(mu1.p4, mu2.p4), 120.))))
        hasDiMuZ = noSel.refine("hasDiMuZ", cut=(op.rng_len(dimu_Z) > 0))
        plots.append(
            Plot.make1D("dimuZ_MET",
                        tree.MET.pt,
                        hasDiMuZ,
                        EqBin(100, 0., 2000.),
                        title="MET (GeV)"))

        return plots
Exemplo n.º 26
0
 def controlPlots_2l(self, noSel, muons, electrons):
     plots = [
         Plot.make1D("nEl", op.rng_len(electrons), noSel, EqBin(10, 0., 10.), xTitle="Number of tight electrons"),
         Plot.make1D("nMu", op.rng_len(muons), noSel, EqBin(10, 0., 10.), xTitle="Number of tight muons"),
         ]
     hasOSElEl = noSel.refine("hasOSElEl", cut=[ op.rng_len(electrons) >= 2,
         electrons[0].charge != electrons[1].charge, electrons[0].pt > 20., electrons[1].pt > 10. ])
     plots.append(Plot.make1D("massZto2e", op.invariant_mass(electrons[0].p4, electrons[1].p4),
         hasOSElEl, EqBin(120, 40., 120.), title="mass of Z to 2e",
         xTitle="Invariant Mass of Nelectrons=2 (in GeV/c^2)"))
     plots += [ 
         Plot.make1D("OSElEl_PTl1", electrons[0].pt, hasOSElEl, EqBin(50, 0., 100.)),
         Plot.make1D("OSElEl_PTl2", electrons[1].pt, hasOSElEl, EqBin(50, 0., 100.)),
         ]
     hasOSMuMu = noSel.refine("hasOSMuMu", cut=[ op.rng_len(muons) >= 2,
         muons[0].charge != muons[1].charge, muons[0].pt > 20., muons[1].pt > 10. ])
     plots.append(Plot.make1D("massZto2mu", op.invariant_mass(muons[0].p4, muons[1].p4),
         hasOSMuMu, EqBin(120, 40., 120.), title="mass of Z to 2mu",
         xTitle="Invariant Mass of Nmuons=2 (in GeV/c^2)"))
     plots += [ 
         Plot.make1D("OSMuMu_PTl1", muons[0].pt, hasOSMuMu, EqBin(50, 0., 100.)),
         Plot.make1D("OSMuMu_PTl2", muons[1].pt, hasOSMuMu, EqBin(50, 0., 100.)),
         ]
     return plots
Exemplo n.º 27
0
    def definePlots(self, t, noSel, sample=None, sampleCfg=None):
        noSel = super(TransferFunction,
                      self).prepareObjects(t, noSel, sample, sampleCfg, 'DL')
        noSel = self.beforeJetselection(noSel)
        era = sampleCfg['era']
        plots = []

        if not self.is_MC:
            return plots

        lambda_is_matched = lambda lep: op.OR(
            lep.genPartFlav == 1,  # Prompt muon or electron
            lep.genPartFlav == 15)  # From tau decay
        #lep.genPartFlav==22) # From photon conversion (only available for electrons)

        plots.append(
            Plot.make1D("totalWeight",
                        noSel.weight,
                        noSel,
                        EquidistantBinning(100, -int(10**5), int(10**5)),
                        xTitle="total weight"))
        plots.append(
            Plot.make1D("genWeight",
                        t.genWeight,
                        noSel,
                        EquidistantBinning(100, -int(10**5), int(10**5)),
                        xTitle="gen weight"))

        ##########################################################
        #                       Leptons                          #
        ##########################################################
        #----- Gen particles -----#
        gen_e = op.select(
            t.GenPart, lambda g: op.AND(
                op.abs(g.pdgId) == 11, g.statusFlags & (0x1 << 13), g.pt >= 10,
                op.abs(g.eta) < 2.5))
        gen_m = op.select(
            t.GenPart, lambda g: op.AND(
                op.abs(g.pdgId) == 13, g.statusFlags & (0x1 << 13), g.pt >= 10,
                op.abs(g.eta) < 2.4))

        #----- Reco particles -----#
        lambda_reco_e = lambda el: op.AND(
            op.abs(el.pdgId) == 11, el.pt >= 10,
            op.abs(el.eta) < 2.5, lambda_is_matched(el))
        lambda_reco_m = lambda mu: op.AND(
            op.abs(mu.pdgId) == 13, mu.pt >= 10,
            op.abs(mu.eta) < 2.4, lambda_is_matched(mu))

        reco_e = op.select(self.electronsFakeSel, lambda_reco_e)
        reco_m = op.select(self.muonsFakeSel, lambda_reco_m)

        #---- Matching -----#
        lambda_lepton_match = lambda gen, reco: op.AND(
            op.deltaR(gen.p4, reco.p4) < 0.1, (op.abs(gen.pt - reco.pt) /
                                               (gen.pt + reco.pt)) < 0.2)

        #        reco_e_matched = op.select(reco_e, lambda re : op.rng_any(gen_e, lambda ge: lambda_lepton_match(ge,re)))
        #        reco_m_matched = op.select(reco_m, lambda rm : op.rng_any(gen_m, lambda gm: lambda_lepton_match(gm,rm)))

        #match_e = op.combine((gen_e,reco_e), pred = lambda ge,re : re.idx == op.rng_min_element_by(reco_e_matched,lambda re_matched : op.deltaR(ge.p4,re_matched.p4)).idx)
        #match_m = op.combine((gen_m,reco_m), pred = lambda gm,rm : rm.idx == op.rng_min_element_by(reco_m_matched,lambda rm_matched : op.deltaR(gm.p4,rm_matched.p4)).idx)

        match_e = op.combine((gen_e, reco_e), pred=lambda_lepton_match)
        match_m = op.combine((gen_m, reco_m), pred=lambda_lepton_match)

        plots.extend(plotMatching("e", match_e, noSel, "e^{#pm}"))
        plots.extend(plotMatching("m", match_m, noSel, "#mu^{#pm}"))

        #        plots.append(plotRecoForGen(noSel,gen_e,tight_e,lambda_lepton_match,"e_tight"))
        #        plots.append(plotRecoForGen(noSel,gen_e,tight_m,lambda_lepton_match,"m_tight"))

        ##########################################################
        #                       Ak4 B jets                       #
        ##########################################################
        #----- RecoJets -----#
        recoJet_b = op.select(
            t.Jet, lambda j: op.AND(
                op.abs(j.partonFlavour) == 5, j.pt >= 20,
                op.abs(j.eta) < 2.4, j.genJet.isValid))
        #----- Parton -----#
        gen_b = op.select(
            t.GenPart, lambda g: op.AND(
                op.abs(g.pdgId) == 5, g.statusFlags & (0x1 << 13), g.pt >= 20,
                op.abs(g.eta) < 2.4))
        #----- Matching -----#
        lambda_jet_match = lambda gen, reco: op.AND(
            op.deltaR(gen.p4, reco.p4) < 0.2)
        reco_b_matched = op.select(
            recoJet_b, lambda jetb: op.rng_any(
                gen_b, lambda gb: lambda_jet_match(gb, jetb)))
        match_b = op.combine(
            (gen_b, recoJet_b),
            pred=lambda gb, jetb: jetb.idx == op.rng_min_element_by(
                reco_b_matched, lambda rb_matched: op.deltaR(
                    gb.p4, rb_matched.p4)).idx)
        plots.extend(plotMatching("ak4b", match_b, noSel, "b"))

        ##########################################################
        #                       Ak4 C jets                       #
        ##########################################################
        #----- RecoJets -----#
        recoJet_c = op.select(
            t.Jet, lambda j: op.AND(
                op.abs(j.partonFlavour) == 4, j.pt >= 20,
                op.abs(j.eta) < 2.4, j.genJet.isValid))
        #----- Parton -----#
        gen_c = op.select(
            t.GenPart, lambda g: op.AND(
                op.abs(g.pdgId) == 4, g.statusFlags & (0x1 << 13), g.pt >= 20,
                op.abs(g.eta) < 2.4))
        #----- Matching -----#
        reco_c_matched = op.select(
            recoJet_c, lambda jetc: op.rng_any(
                gen_c, lambda gc: lambda_jet_match(gc, jetc)))
        match_c = op.combine(
            (gen_c, recoJet_c),
            pred=lambda gc, jetc: jetc.idx == op.rng_min_element_by(
                reco_c_matched, lambda rc_matched: op.deltaR(
                    gc.p4, rc_matched.p4)).idx)
        plots.extend(plotMatching("ak4c", match_c, noSel, "c"))

        ##########################################################
        #                     Ak4 lightjets                      #
        ##########################################################
        #----- RecoJets -----#
        recoJet_l = op.select(
            t.Jet, lambda j: op.AND(
                op.OR(
                    op.abs(j.partonFlavour) == 1,
                    op.abs(j.partonFlavour) == 2,
                    op.abs(j.partonFlavour) == 3), j.pt >= 20,
                op.abs(j.eta) < 2.4, j.genJet.isValid))
        #----- Parton -----#
        gen_l = op.select(
            t.GenPart, lambda g: op.AND(
                op.OR(
                    op.abs(g.pdgId) == 1,
                    op.abs(g.pdgId) == 2,
                    op.abs(g.pdgId) == 3), g.statusFlags &
                (0x1 << 13), g.pt >= 20,
                op.abs(g.eta) < 2.4))
        #----- Matching -----#
        reco_l_matched = op.select(
            recoJet_l, lambda jetl: op.rng_any(
                gen_l, lambda gl: lambda_jet_match(gl, jetl)))
        match_l = op.combine(
            (gen_l, recoJet_l),
            pred=lambda gl, jetl: jetl.idx == op.rng_min_element_by(
                reco_l_matched, lambda rl_matched: op.deltaR(
                    gl.p4, rl_matched.p4)).idx)
        plots.extend(plotMatching("ak4l", match_l, noSel, "l"))

        ##########################################################
        #                        Ak8 jets                        #
        ##########################################################
        #----- RecoJets -----#
        recoFatJet = op.select(
            t.FatJet, lambda j: op.AND(
                j.pt >= 100,
                op.abs(j.eta) < 2.4,
                op.AND(j.subJet1.isValid, j.subJet1.pt >= 20.,
                       op.abs(j.subJet1.eta) <= 2.4, j.subJet2.isValid, j.
                       subJet2.pt >= 20.,
                       op.abs(j.subJet2.eta) <= 2.4),
                op.AND(j.msoftdrop >= 30, j.msoftdrop <= 210), j.tau2 / j.tau1
                <= 0.75))

        #plots.extend(fatjetPlots(noSel,recoFatJet,"fatjet"))

        reco_subJet1_b_matched = op.select(
            recoFatJet, lambda fat: op.rng_any(
                gen_b, lambda gb: lambda_jet_match(gb, fat.subJet1)))
        reco_subJet2_b_matched = op.select(
            recoFatJet, lambda fat: op.rng_any(
                gen_b, lambda gb: lambda_jet_match(gb, fat.subJet2)))
        reco_subJet1_c_matched = op.select(
            recoFatJet, lambda fat: op.rng_any(
                gen_c, lambda gc: lambda_jet_match(gc, fat.subJet1)))
        reco_subJet2_c_matched = op.select(
            recoFatJet, lambda fat: op.rng_any(
                gen_c, lambda gc: lambda_jet_match(gc, fat.subJet2)))
        reco_subJet1_l_matched = op.select(
            recoFatJet, lambda fat: op.rng_any(
                gen_l, lambda gl: lambda_jet_match(gl, fat.subJet1)))
        reco_subJet2_l_matched = op.select(
            recoFatJet, lambda fat: op.rng_any(
                gen_l, lambda gl: lambda_jet_match(gl, fat.subJet2)))

        def makeFatjetMatch(gen1, gen2, recoFatJet):
            return op.combine(
                (gen1, gen2, recoFatJet),
                pred=lambda g1, g2, fat: op.AND(
                    fat.subJet1.idx == op.rng_min_element_by(
                        reco_subJet1_b_matched, lambda sub1_matched: op.deltaR(
                            g1.p4, sub1_matched.p4)).idx, fat.subJet2.idx == op
                    .rng_min_element_by(
                        reco_subJet2_b_matched, lambda sub2_matched: op.deltaR(
                            g2.p4, sub2_matched.p4)).idx))

        match_fat_bb = makeFatjetMatch(gen_b, gen_b, recoFatJet)
        match_fat_bc = makeFatjetMatch(gen_b, gen_c, recoFatJet)
        match_fat_bl = makeFatjetMatch(gen_b, gen_l, recoFatJet)
        match_fat_cb = makeFatjetMatch(gen_c, gen_b, recoFatJet)
        match_fat_cc = makeFatjetMatch(gen_c, gen_c, recoFatJet)
        match_fat_cl = makeFatjetMatch(gen_c, gen_l, recoFatJet)
        match_fat_lb = makeFatjetMatch(gen_l, gen_b, recoFatJet)
        match_fat_lc = makeFatjetMatch(gen_l, gen_c, recoFatJet)
        match_fat_ll = makeFatjetMatch(gen_l, gen_l, recoFatJet)
        #        match_fat_bb = op.combine((gen_b,gen_b,recoFatJet), pred = lambda g1,g2,fat : op.AND(
        #                                                fat.subJet1.idx == op.rng_min_element_by(reco_subJet1_b_matched,
        #                                                                                         lambda sub1_matched : op.deltaR(gb1.p4,sub1_matched.p4)).idx,
        #                                                fat.subJet2.idx == op.rng_min_element_by(reco_subJet2_b_matched,
        #                                                                                         lambda sub2_matched : op.deltaR(gb2.p4,sub2_matched.p4)).idx))
        #        match_fat_bc = op.combine((gen_b,gen_b,recoFatJet), pred = lambda gb1,gb2,fat : op.AND(
        #                                                fat.subJet1.idx == op.rng_min_element_by(reco_subJet1_b_matched,
        #                                                                                         lambda sub1_matched : op.deltaR(gb1.p4,sub1_matched.p4)).idx,
        #                                                fat.subJet2.idx == op.rng_min_element_by(reco_subJet2_b_matched,
        #                                                                                         lambda sub2_matched : op.deltaR(gb2.p4,sub2_matched.p4)).idx))

        plots.extend(plotFatjetMatching(match_fat_bb, noSel, 'b', 'b'))
        plots.extend(plotFatjetMatching(match_fat_bc, noSel, 'b', 'c'))
        plots.extend(plotFatjetMatching(match_fat_bl, noSel, 'b', 'l'))
        plots.extend(plotFatjetMatching(match_fat_cb, noSel, 'c', 'b'))
        plots.extend(plotFatjetMatching(match_fat_cc, noSel, 'c', 'c'))
        plots.extend(plotFatjetMatching(match_fat_cl, noSel, 'c', 'l'))
        plots.extend(plotFatjetMatching(match_fat_bb, noSel, 'l', 'b'))
        plots.extend(plotFatjetMatching(match_fat_bc, noSel, 'l', 'c'))
        plots.extend(plotFatjetMatching(match_fat_bl, noSel, 'l', 'l'))

        return plots
Exemplo n.º 28
0
    def definePlots(self, t, noSel, sample=None, sampleCfg=None):
        from bamboo.plots import Plot, CutFlowReport, EquidistantBinning, VariableBinning
        from bamboo import treefunctions as op

        plots = []

        # definitions

        electrons = op.select(
            t.elec, lambda el: op.AND(el.pt > 20.,
                                      op.abs(el.eta) < 2.5))

        muons = op.select(t.muon, lambda mu: op.AND(mu.pt > 20.,
                                                    op.abs(mu.eta) < 2.5))

        cleanedElectrons = op.select(
            electrons, lambda el: op.NOT(
                op.rng_any(muons, lambda mu: op.deltaR(el.p4, mu.p4) < 0.3)))

        # we are taking the second isopass to be on which is equal to the medium working point
        isolatedElectrons = op.select(cleanedElectrons,
                                      lambda el: el.isopass & (1 << 2))

        identifiedElectrons = op.select(isolatedElectrons,
                                        lambda el: el.idpass & (1 << 2))

        cleanedMuons = op.select(
            muons, lambda mu: op.NOT(
                op.rng_any(electrons, lambda el: op.deltaR(mu.p4, el.p4) < 0.3)
            ))

        isolatedMuons = op.select(cleanedMuons,
                                  lambda mu: mu.isopass & (1 << 2))

        identifiedMuons = op.select(isolatedMuons,
                                    lambda mu: mu.idpass & (1 << 2))

        cleanedJets = op.select(
            t.jetpuppi, lambda j: op.AND(
                op.NOT(
                    op.rng_any(identifiedElectrons, lambda el: op.deltaR(
                        el.p4, j.p4) < 0.3)),
                op.NOT(
                    op.rng_any(identifiedMuons, lambda mu: op.deltaR(
                        mu.p4, j.p4) < 0.3))))

        cleanedGoodJets30_0to1_5 = op.select(
            cleanedJets, lambda j: op.AND(j.pt > 30,
                                          op.abs(j.eta) < 1.5))

        cleanedGoodJets30_1_5to3 = op.select(
            cleanedJets, lambda j: op.AND(
                j.pt > 30,
                op.NOT(op.AND(op.abs(j.eta) < 1.5,
                              op.abs(j.eta) > 3))))

        cleanedGoodJets30_3toInf = op.select(
            cleanedJets, lambda j: op.AND(j.pt > 30,
                                          op.abs(j.eta) > 3))

        cleanedGoodJets50_0to1_5 = op.select(
            cleanedJets, lambda j: op.AND(j.pt > 50,
                                          op.abs(j.eta) < 1.5))

        cleanedGoodJets50_1_5to3 = op.select(
            cleanedJets, lambda j: op.AND(
                j.pt > 50,
                op.NOT(op.AND(op.abs(j.eta) < 1.5,
                              op.abs(j.eta) > 3))))

        cleanedGoodJets50_3toInf = op.select(
            cleanedJets, lambda j: op.AND(j.pt > 50,
                                          op.abs(j.eta) > 3))

        cleanedGoodJets100_0to1_5 = op.select(
            cleanedJets, lambda j: op.AND(j.pt > 100,
                                          op.abs(j.eta) < 1.5))

        cleanedGoodJets100_1_5to3 = op.select(
            cleanedJets, lambda j: op.AND(
                j.pt > 100,
                op.NOT(op.AND(op.abs(j.eta) < 1.5,
                              op.abs(j.eta) > 3))))

        cleanedGoodJets100_3toInf = op.select(
            cleanedJets, lambda j: op.AND(j.pt > 100,
                                          op.abs(j.eta) > 3))

        cleanedGoodJets30 = op.select(cleanedJets, lambda j: j.pt > 30)

        cleanedGoodJets50 = op.select(cleanedJets, lambda j: j.pt > 50)

        cleanedGoodJets100 = op.select(cleanedJets, lambda j: j.pt > 100)

        met = op.select(t.metpuppi)

        sel1 = noSel.refine("nJet30", cut=[op.rng_len(cleanedGoodJets30) > 0])
        sel2 = noSel.refine("nJet50", cut=[op.rng_len(cleanedGoodJets50) > 0])
        sel3 = noSel.refine("nJet100",
                            cut=[op.rng_len(cleanedGoodJets100) > 0])

        sel1_1 = noSel.refine("nJet30_1",
                              cut=[op.rng_len(cleanedGoodJets30) > 0])
        sel1_1_1 = noSel.refine("nJet30_1_1",
                                cut=[op.rng_len(cleanedGoodJets30_0to1_5) > 0])
        sel1_1_2 = noSel.refine("nJet30_1_2",
                                cut=[op.rng_len(cleanedGoodJets30_1_5to3) > 0])
        sel1_1_3 = noSel.refine("nJet30_1_3",
                                cut=[op.rng_len(cleanedGoodJets30_3toInf) > 0])
        sel2_1 = noSel.refine("nJet50_1",
                              cut=[op.rng_len(cleanedGoodJets50) > 0])
        sel1_2_1 = noSel.refine("nJet50_1_1",
                                cut=[op.rng_len(cleanedGoodJets50_0to1_5) > 0])
        sel1_2_2 = noSel.refine("nJet50_1_2",
                                cut=[op.rng_len(cleanedGoodJets50_1_5to3) > 0])
        sel1_2_3 = noSel.refine("nJet50_1_3",
                                cut=[op.rng_len(cleanedGoodJets50_3toInf) > 0])
        sel3_1 = noSel.refine("nJet100_1",
                              cut=[op.rng_len(cleanedGoodJets100) > 0])
        sel1_3_1 = noSel.refine(
            "nJet100_1_1", cut=[op.rng_len(cleanedGoodJets100_0to1_5) > 0])
        sel1_3_2 = noSel.refine(
            "nJet100_1_2", cut=[op.rng_len(cleanedGoodJets100_1_5to3) > 0])
        sel1_3_3 = noSel.refine(
            "nJet100_1_3", cut=[op.rng_len(cleanedGoodJets100_3toInf) > 0])

        sel1_2 = noSel.refine("nJet30_2",
                              cut=[op.rng_len(cleanedGoodJets30) > 1])
        sel2_1_1 = noSel.refine("nJet30_2_1",
                                cut=[op.rng_len(cleanedGoodJets30_0to1_5) > 1])
        sel2_1_2 = noSel.refine("nJet30_2_2",
                                cut=[op.rng_len(cleanedGoodJets30_1_5to3) > 1])
        sel2_1_3 = noSel.refine("nJet30_2_3",
                                cut=[op.rng_len(cleanedGoodJets30_3toInf) > 1])
        sel2_2 = noSel.refine("nJet50_2",
                              cut=[op.rng_len(cleanedGoodJets50) > 1])
        sel2_2_1 = noSel.refine("nJet50_2_1",
                                cut=[op.rng_len(cleanedGoodJets50_0to1_5) > 1])
        sel2_2_2 = noSel.refine("nJet50_2_2",
                                cut=[op.rng_len(cleanedGoodJets50_1_5to3) > 1])
        sel2_2_3 = noSel.refine("nJet50_2_3",
                                cut=[op.rng_len(cleanedGoodJets50_3toInf) > 1])
        sel3_2 = noSel.refine("nJet100_2",
                              cut=[op.rng_len(cleanedGoodJets100) > 1])
        sel2_3_1 = noSel.refine(
            "nJet100_2_1", cut=[op.rng_len(cleanedGoodJets100_0to1_5) > 1])
        sel2_3_2 = noSel.refine(
            "nJet100_2_2", cut=[op.rng_len(cleanedGoodJets100_1_5to3) > 1])
        sel2_3_3 = noSel.refine(
            "nJet100_2_3", cut=[op.rng_len(cleanedGoodJets100_3toInf) > 1])

        sel1_3 = noSel.refine("nJet30_3",
                              cut=[op.rng_len(cleanedGoodJets30) > 2])
        sel3_1_1 = noSel.refine("nJet30_3_1",
                                cut=[op.rng_len(cleanedGoodJets30_0to1_5) > 2])
        sel3_1_2 = noSel.refine("nJet30_3_2",
                                cut=[op.rng_len(cleanedGoodJets30_1_5to3) > 2])
        sel3_1_3 = noSel.refine("nJet30_3_3",
                                cut=[op.rng_len(cleanedGoodJets30_3toInf) > 2])
        sel2_3 = noSel.refine("nJet50_3",
                              cut=[op.rng_len(cleanedGoodJets50) > 2])
        sel3_2_1 = noSel.refine("nJet50_3_1",
                                cut=[op.rng_len(cleanedGoodJets50_0to1_5) > 2])
        sel3_2_2 = noSel.refine("nJet50_3_2",
                                cut=[op.rng_len(cleanedGoodJets50_1_5to3) > 2])
        sel3_2_3 = noSel.refine("nJet50_3_3",
                                cut=[op.rng_len(cleanedGoodJets50_3toInf) > 2])
        sel3_3 = noSel.refine("nJet100_3",
                              cut=[op.rng_len(cleanedGoodJets100) > 2])
        sel3_3_1 = noSel.refine(
            "nJet100_3_1", cut=[op.rng_len(cleanedGoodJets100_0to1_5) > 2])
        sel3_3_2 = noSel.refine(
            "nJet100_3_2", cut=[op.rng_len(cleanedGoodJets100_1_5to3) > 2])
        sel3_3_3 = noSel.refine(
            "nJet100_3_3", cut=[op.rng_len(cleanedGoodJets100_3toInf) > 2])

        sel1_4 = noSel.refine("nJet30_4",
                              cut=[op.rng_len(cleanedGoodJets30) > 3])
        sel4_1_1 = noSel.refine("nJet30_4_1",
                                cut=[op.rng_len(cleanedGoodJets30_0to1_5) > 3])
        sel4_1_2 = noSel.refine("nJet30_4_2",
                                cut=[op.rng_len(cleanedGoodJets30_1_5to3) > 3])
        sel4_1_3 = noSel.refine("nJet30_4_3",
                                cut=[op.rng_len(cleanedGoodJets30_3toInf) > 3])
        sel2_4 = noSel.refine("nJet50_4",
                              cut=[op.rng_len(cleanedGoodJets50) > 3])
        sel4_2_1 = noSel.refine("nJet50_4_1",
                                cut=[op.rng_len(cleanedGoodJets50_0to1_5) > 3])
        sel4_2_2 = noSel.refine("nJet50_4_2",
                                cut=[op.rng_len(cleanedGoodJets50_1_5to3) > 3])
        sel4_2_3 = noSel.refine("nJet50_4_3",
                                cut=[op.rng_len(cleanedGoodJets50_3toInf) > 3])
        sel3_4 = noSel.refine("nJet100_4",
                              cut=[op.rng_len(cleanedGoodJets100) > 3])
        sel4_3_1 = noSel.refine(
            "nJet100_4_1", cut=[op.rng_len(cleanedGoodJets100_0to1_5) > 3])
        sel4_3_2 = noSel.refine(
            "nJet100_4_2", cut=[op.rng_len(cleanedGoodJets100_1_5to3) > 3])
        sel4_3_3 = noSel.refine(
            "nJet100_4_3", cut=[op.rng_len(cleanedGoodJets100_3toInf) > 3])

        # plots

        #     # ### 30 GeV

        plots.append(
            Plot.make1D("nJets_jetPT_30GeV",
                        op.rng_len(cleanedGoodJets30),
                        noSel,
                        EquidistantBinning(15, 0., 15.),
                        title="nJets (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet1_pT_jetPT_30GeV",
                        cleanedGoodJets30[0].pt,
                        sel1_1,
                        EquidistantBinning(50, 0., 4000.),
                        title="Jet1_pT (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet1_eta_jetPT_30GeV",
                        cleanedGoodJets30[0].eta,
                        sel1_1,
                        EquidistantBinning(30, -3, 3),
                        title="Jet1_eta (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet1_pT_0to1_5_jetPT_30GeV",
                        cleanedGoodJets30_0to1_5[0].pt,
                        sel1_1_1,
                        EquidistantBinning(50, 0, 4000),
                        title="Jet1_pT 0 < eta < 1.5, (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet1_pT_1_5to3_jetPT_30GeV",
                        cleanedGoodJets30_1_5to3[0].pt,
                        sel1_1_2,
                        EquidistantBinning(50, 0, 4000),
                        title="Jet1_pT 1.5 < eta < 3, (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet1_pT_3toInf_jetPT_30GeV",
                        cleanedGoodJets30_3toInf[0].pt,
                        sel1_1_3,
                        EquidistantBinning(50, 0, 1000),
                        title="Jet1_pT eta > 3, (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet2_pT_jetPT_30GeV",
                        cleanedGoodJets30[1].pt,
                        sel1_2,
                        EquidistantBinning(50, 0., 4000.),
                        title="Jet2_pT (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet2_eta_jetPT_30GeV",
                        cleanedGoodJets30[1].eta,
                        sel1_2,
                        EquidistantBinning(30, -3, 3),
                        title="Jet2_eta (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet2_pT_0to1_5_jetPT_30GeV",
                        cleanedGoodJets30_0to1_5[1].pt,
                        sel2_1_1,
                        EquidistantBinning(50, 0, 4000),
                        title="Jet2_pT 0 < eta < 1.5, (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet2_pT_1_5to3_jetPT_30GeV",
                        cleanedGoodJets30_1_5to3[1].pt,
                        sel2_1_2,
                        EquidistantBinning(50, 0, 4000),
                        title="Jet2_pT 1.5 < eta < 3, (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet2_pT_3toInf_jetPT_30GeV",
                        cleanedGoodJets30_3toInf[1].pt,
                        sel2_1_3,
                        EquidistantBinning(50, 0, 500),
                        title="Jet2_pT eta > 3, (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet3_pT_jetPT_30GeV",
                        cleanedGoodJets30[2].pt,
                        sel1_3,
                        EquidistantBinning(50, 0., 2000.),
                        title="Jet3_pT (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet3_eta_jetPT_30GeV",
                        cleanedGoodJets30[2].eta,
                        sel1_3,
                        EquidistantBinning(30, -3, 3),
                        title="Jet3_eta (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet3_pT_0to1_5_jetPT_30GeV",
                        cleanedGoodJets30_0to1_5[2].pt,
                        sel3_1_1,
                        EquidistantBinning(50, 0, 2000),
                        title="Jet3_pT 0 < eta < 1.5, (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet3_pT_1_5to3_jetPT_30GeV",
                        cleanedGoodJets30_1_5to3[2].pt,
                        sel3_1_2,
                        EquidistantBinning(50, 0, 2000),
                        title="Jet3_pT 1.5 < eta < 3, (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet3_pT_3toInf_jetPT_30GeV",
                        cleanedGoodJets30_3toInf[2].pt,
                        sel3_1_3,
                        EquidistantBinning(50, 0, 200),
                        title="Jet3_pT eta > 3, (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet4_pT_jetPT_30GeV",
                        cleanedGoodJets30[3].pt,
                        sel1_4,
                        EquidistantBinning(50, 0., 2000.),
                        title="Jet4_pT (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet4_eta_jetPT_30GeV",
                        cleanedGoodJets30[3].eta,
                        sel1_4,
                        EquidistantBinning(30, -3, 3),
                        title="Jet4_eta (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet4_pT_0to1_5_jetPT_30GeV",
                        cleanedGoodJets30_0to1_5[3].pt,
                        sel4_1_1,
                        EquidistantBinning(50, 0, 2000),
                        title="Jet4_pT 0 < eta < 1.5, (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet4_pT_1_5to3_jetPT_30GeV",
                        cleanedGoodJets30_1_5to3[3].pt,
                        sel4_1_2,
                        EquidistantBinning(50, 0, 2000),
                        title="Jet4_pT 1.5 < eta < 3, (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet4_pT_3toInf_jetPT_30GeV",
                        cleanedGoodJets30_3toInf[3].pt,
                        sel4_1_3,
                        EquidistantBinning(50, 0, 200),
                        title="Jet4_pT eta > 3, (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("MET_jetPT_30GeV",
                        met[0].pt,
                        sel1,
                        EquidistantBinning(50, 0, 1000),
                        title="MET (jet p_{T} > 30GeV)"))

        #     # ### 50 GeV

        plots.append(
            Plot.make1D("nJets_jetPT_50GeV",
                        op.rng_len(cleanedGoodJets50),
                        noSel,
                        EquidistantBinning(15, 0., 15.),
                        title="nJets (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet1_pT_jetPT_50GeV",
                        cleanedGoodJets50[0].pt,
                        sel2_1,
                        EquidistantBinning(50, 0., 4000.),
                        title="Jet1_pT (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet1_eta_jetPT_50GeV",
                        cleanedGoodJets50[0].eta,
                        sel2_1,
                        EquidistantBinning(30, -3, 3),
                        title="Jet1_eta (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet1_pT_0to1_5_jetPT_50GeV",
                        cleanedGoodJets50_0to1_5[0].pt,
                        sel1_2_1,
                        EquidistantBinning(50, 0, 4000),
                        title="Jet1_pT 0 < eta < 1.5, (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet1_pT_1_5to3_jetPT_50GeV",
                        cleanedGoodJets50_1_5to3[0].pt,
                        sel1_2_2,
                        EquidistantBinning(50, 0, 4000),
                        title="Jet1_pT 1.5 < eta < 3, (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet1_pT_3toInf_jetPT_50GeV",
                        cleanedGoodJets50_3toInf[0].pt,
                        sel1_2_3,
                        EquidistantBinning(50, 0, 1000),
                        title="Jet1_pT eta > 3, (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet2_pT_jetPT_50GeV",
                        cleanedGoodJets50[1].pt,
                        sel2_2,
                        EquidistantBinning(50, 0., 4000.),
                        title="Jet2_pT (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet2_eta_jetPT_50GeV",
                        cleanedGoodJets50[1].eta,
                        sel2_2,
                        EquidistantBinning(30, -3, 3),
                        title="Jet2_eta (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet2_pT_0to1_5_jetPT_50GeV",
                        cleanedGoodJets50_0to1_5[1].pt,
                        sel2_2_1,
                        EquidistantBinning(50, 0, 4000),
                        title="Jet2_pT 0 < eta < 1.5, (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet2_pT_1_5to3_jetPT_50GeV",
                        cleanedGoodJets50_1_5to3[1].pt,
                        sel2_2_2,
                        EquidistantBinning(50, 0, 4000),
                        title="Jet2_pT 1.5 < eta < 3, (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet2_pT_3toInf_jetPT_50GeV",
                        cleanedGoodJets50_3toInf[1].pt,
                        sel2_2_3,
                        EquidistantBinning(50, 0, 500),
                        title="Jet2_pT eta > 3, (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet3_pT_jetPT_50GeV",
                        cleanedGoodJets50[2].pt,
                        sel2_3,
                        EquidistantBinning(50, 0., 2000.),
                        title="Jet3_pT (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet3_eta_jetPT_50GeV",
                        cleanedGoodJets50[2].eta,
                        sel2_3,
                        EquidistantBinning(30, -3, 3),
                        title="Jet3_eta (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet3_pT_0to1_5_jetPT_50GeV",
                        cleanedGoodJets50_0to1_5[2].pt,
                        sel3_2_1,
                        EquidistantBinning(50, 0, 2000),
                        title="Jet3_pT 0 < eta < 1.5, (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet3_pT_1_5to3_jetPT_50GeV",
                        cleanedGoodJets50_1_5to3[2].pt,
                        sel3_2_2,
                        EquidistantBinning(50, 0, 2000),
                        title="Jet3_pT 1.5 < eta < 3, (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet3_pT_3toInf_jetPT_50GeV",
                        cleanedGoodJets50_3toInf[2].pt,
                        sel3_2_3,
                        EquidistantBinning(50, 0, 200),
                        title="Jet3_pT eta > 3, (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet4_pT_jetPT_50GeV",
                        cleanedGoodJets50[3].pt,
                        sel2_4,
                        EquidistantBinning(50, 0., 2000.),
                        title="Jet4_pT (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet4_eta_jetPT_50GeV",
                        cleanedGoodJets50[3].eta,
                        sel2_4,
                        EquidistantBinning(30, -3, 3),
                        title="Jet4_eta (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet4_pT_0to1_5_jetPT_50GeV",
                        cleanedGoodJets50_0to1_5[3].pt,
                        sel4_2_1,
                        EquidistantBinning(50, 0, 2000),
                        title="Jet4_pT 0 < eta < 1.5, (jet p_{T} > 30GeV)"))

        plots.append(
            Plot.make1D("Jet4_pT_1_5to3_jetPT_50GeV",
                        cleanedGoodJets50_1_5to3[3].pt,
                        sel4_2_2,
                        EquidistantBinning(50, 0, 2000),
                        title="Jet4_pT 1.5 < eta < 3, (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("Jet4_pT_3toInf_jetPT_50GeV",
                        cleanedGoodJets50_3toInf[3].pt,
                        sel4_2_3,
                        EquidistantBinning(50, 0, 200),
                        title="Jet4_pT eta > 3, (jet p_{T} > 50GeV)"))

        plots.append(
            Plot.make1D("MET_jetPT_50GeV",
                        met[0].pt,
                        sel2,
                        EquidistantBinning(50, 0, 1000),
                        title="MET (jet p_{T} > 50GeV)"))

        #  ### 100 GeV

        plots.append(
            Plot.make1D("nJets_jetPT_100GeV",
                        op.rng_len(cleanedGoodJets100),
                        noSel,
                        EquidistantBinning(15, 0., 15.),
                        title="nJets (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet1_pT_jetPT_100GeV",
                        cleanedGoodJets100[0].pt,
                        sel3_1,
                        EquidistantBinning(50, 0., 4000.),
                        title="Jet1_pT (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet1_eta_jetPT_100GeV",
                        cleanedGoodJets100[0].eta,
                        sel3_1,
                        EquidistantBinning(30, -3, 3),
                        title="Jet1_eta (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet1_pT_0to1_5_jetPT_100GeV",
                        cleanedGoodJets100_0to1_5[0].pt,
                        sel1_3_1,
                        EquidistantBinning(50, 0, 4000),
                        title="Jet1_pT 0 < eta < 1.5, (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet1_pT_1_5to3_jetPT_100GeV",
                        cleanedGoodJets100_1_5to3[0].pt,
                        sel1_3_2,
                        EquidistantBinning(50, 0, 4000),
                        title="Jet1_pT 1.5 < eta < 3, (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet1_pT_3toInf_jetPT_100GeV",
                        cleanedGoodJets100_3toInf[0].pt,
                        sel1_3_3,
                        EquidistantBinning(50, 0, 1000),
                        title="Jet1_pT eta > 3, (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet2_pT_jetPT_100GeV",
                        cleanedGoodJets100[1].pt,
                        sel3_2,
                        EquidistantBinning(50, 0., 4000.),
                        title="Jet2_pT (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet2_eta_jetPT_100GeV",
                        cleanedGoodJets100[1].eta,
                        sel3_2,
                        EquidistantBinning(30, -3, 3),
                        title="Jet2_eta (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet2_pT_0to1_5_jetPT_100GeV",
                        cleanedGoodJets100_0to1_5[1].pt,
                        sel2_3_1,
                        EquidistantBinning(50, 0, 4000),
                        title="Jet2_pT 0 < eta < 1.5, (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet2_pT_1_5to3_jetPT_100GeV",
                        cleanedGoodJets100_1_5to3[1].pt,
                        sel2_3_2,
                        EquidistantBinning(50, 0, 4000),
                        title="Jet2_pT 1.5 < eta < 3, (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet2_pT_3toInf_jetPT_100GeV",
                        cleanedGoodJets100_3toInf[1].pt,
                        sel2_3_3,
                        EquidistantBinning(50, 0, 500),
                        title="Jet2_pT eta > 3, (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet3_pT_jetPT_100GeV",
                        cleanedGoodJets100[2].pt,
                        sel3_3,
                        EquidistantBinning(50, 0., 2000.),
                        title="Jet3_pT (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet3_eta_jetPT_100GeV",
                        cleanedGoodJets100[2].eta,
                        sel3_3,
                        EquidistantBinning(30, -3, 3),
                        title="Jet3_eta (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet3_pT_0to1_5_jetPT_100GeV",
                        cleanedGoodJets100_0to1_5[2].pt,
                        sel3_3_1,
                        EquidistantBinning(50, 0, 2000),
                        title="Jet3_pT 0 < eta < 1.5, (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet3_pT_1_5to3_jetPT_100GeV",
                        cleanedGoodJets100_1_5to3[2].pt,
                        sel3_3_2,
                        EquidistantBinning(50, 0, 2000),
                        title="Jet3_pT 1.5 < eta < 3, (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet3_pT_3toInf_jetPT_100GeV",
                        cleanedGoodJets100_3toInf[2].pt,
                        sel3_3_3,
                        EquidistantBinning(50, 0, 200),
                        title="Jet3_pT eta > 3, (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet4_pT_jetPT_100GeV",
                        cleanedGoodJets100[3].pt,
                        sel3_4,
                        EquidistantBinning(50, 0., 2000.),
                        title="Jet4_pT (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet4_eta_jetPT_100GeV",
                        cleanedGoodJets100[3].eta,
                        sel3_4,
                        EquidistantBinning(30, -3, 3),
                        title="Jet4_eta (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet4_pT_0to1_5_jetPT_100GeV",
                        cleanedGoodJets100_0to1_5[3].pt,
                        sel4_3_1,
                        EquidistantBinning(50, 0, 2000),
                        title="Jet4_pT 0 < eta < 1.5, (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet4_pT_1_5to3_jetPT_100GeV",
                        cleanedGoodJets100_1_5to3[3].pt,
                        sel4_3_2,
                        EquidistantBinning(50, 0, 2000),
                        title="Jet4_pT 1.5 < eta < 3, (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("Jet4_pT_3toInf_jetPT_100GeV",
                        cleanedGoodJets100_3toInf[3].pt,
                        sel4_3_3,
                        EquidistantBinning(50, 0, 200),
                        title="Jet4_pT eta > 3, (jet p_{T} > 100GeV)"))

        plots.append(
            Plot.make1D("MET_jetPT_100GeV",
                        met[0].pt,
                        sel3,
                        EquidistantBinning(50, 0, 1000),
                        title="MET (jet p_{T} > 100GeV)"))

        # Efficiency Report on terminal and the .tex output

        cfr = CutFlowReport("yields")
        cfr.add(noSel, "None")
        cfr.add(sel1, "30GeV")
        cfr.add(sel2, "50GeV")
        cfr.add(sel3, "100GeV")

        plots.append(cfr)

        return plots
Exemplo n.º 29
0
def makeJetsPlots(self, sel, jets, suffix, channel):
    """
    Make basic plots
    sel         = refine selection 
    jets        = bjet container with len(jets)>=1 (we require at least one bjet) 
    suffix      = string identifying the selecton 
    channel     = string identifying the channel of the dilepton (can be "NoChannel")
    """

    plots = []

    # bjet 1 plots (always present by selection) #
    plots.append(
        Plot.make1D("%s_leadjetPT_%s" % (channel, suffix),
                    jets[0].p4.Pt(),
                    sel,
                    EquidistantBinning(100, 0, 300.),
                    title='Transverse momentum of the leading jet',
                    xTitle="P_{T}(leading jet) [GeV]"))
    plots.append(
        Plot.make1D("%s_leadjetEta_%s" % (channel, suffix),
                    jets[0].p4.Eta(),
                    sel,
                    EquidistantBinning(20, -3., 3.),
                    title='Transverse momentum of the leading jet',
                    xTitle="#eta(leading jet) [GeV]"))
    plots.append(
        Plot.make1D("%s_leadjetPhi_%s" % (channel, suffix),
                    jets[0].p4.Phi(),
                    sel,
                    EquidistantBinning(20, -3.2, 3.2),
                    title='Azimutal angle of the leading jet',
                    xTitle="#phi(leading jet) [GeV]"))

    # bjet 2 plots (not necessarily present) #
    hasAtLeastTwoBJets = sel.refine("hasAtLeastTwoBJets_%s_%s" %
                                    (channel, suffix),
                                    cut=[op.rng_len(jets) >= 2])
    hasOnlyOneBJet = sel.refine("hasAtLeast2BJets_%s_%s" % (channel, suffix),
                                cut=[op.rng_len(jets) == 1])
    # Fill a specific bin apart so that the information is not lost

    # PT plot #
    plot_hasTwoBJets_PT = Plot.make1D(
        "%s_hasSubleadjetPT_%s" % (channel, suffix),
        jets[1].p4.Pt(),
        hasAtLeastTwoBJets,
        EquidistantBinning(100, -10., 300.),
        title='Transverse momentum of the subleading jet',
        xTitle="P_{T}(subleading jet) [GeV]")
    plot_notTwoBJets_PT = Plot.make1D(
        "%s_notSubleadjetPT_%s" % (channel, suffix),
        op.c_float(-10.),
        hasOnlyOneBJet,
        EquidistantBinning(100, -10., 300.),
        title='Transverse momentum of the subleading jet',
        xTitle="P_{T}(subleading jet) [GeV]")
    plots.append(
        SummedPlot("%s_subleadjetPT_%s" % (channel, suffix),
                   [plot_hasTwoBJets_PT, plot_notTwoBJets_PT],
                   xTitle="P_{T}(subleading jet) [GeV]"))

    # Eta plot #
    plot_hasTwoBJets_Eta = Plot.make1D(
        "%s_hasSubleadjetEta_%s" % (channel, suffix),
        jets[1].p4.Eta(),
        hasAtLeastTwoBJets,
        EquidistantBinning(20, -3., 3.),
        title='Pseudorapidity of the subleading jet',
        xTitle="#eta(subleading jet) [GeV]")
    plot_notTwoBJets_Eta = Plot.make1D(
        "%s_notSubleadjetEta_%s" % (channel, suffix),
        op.c_float(-3.),
        hasOnlyOneBJet,
        EquidistantBinning(20, -3., 3.),
        title='Pseudorapidity of the subleading jet',
        xTitle="#eta(subleading jet) [GeV]")
    plots.append(
        SummedPlot("%s_subleadjetEta_%s" % (channel, suffix),
                   [plot_hasTwoBJets_Eta, plot_notTwoBJets_Eta],
                   xTitle="#eta(subleading jet) [GeV]"))

    # Phi plot #
    plot_hasTwoBJets_Phi = Plot.make1D(
        "%s_hasSubleadjetPhi_%s" % (channel, suffix),
        jets[1].p4.Phi(),
        hasAtLeastTwoBJets,
        EquidistantBinning(20, -3.2, 3.2),
        title='Azimutal angle of the subleading jet',
        xTitle="#phi(subleading jet) [GeV]")
    plot_notTwoBJets_Phi = Plot.make1D(
        "%s_notSubleadjetPhi_%s" % (channel, suffix),
        op.c_float(-3.2),
        hasOnlyOneBJet,
        EquidistantBinning(20, -3.2, 3.2),
        title='Azimutal angle of the subleading jet',
        xTitle="#phi(subleading jet) [GeV]")
    plots.append(
        SummedPlot("%s_subleadjetPhi_%s" % (channel, suffix),
                   [plot_hasTwoBJets_Phi, plot_notTwoBJets_Phi],
                   xTitle="#phi(subleading jet) [GeV]"))

    # InvMass plot #
    plot_hasTwoBJets_invMass = Plot.make1D(
        "%s_hasTwoBJets_invMass_%s" % (channel, suffix),
        op.invariant_mass(jets[0].p4, jets[1].p4),
        hasAtLeastTwoBJets,
        EquidistantBinning(100, -10, 500.),
        title="Dijet invariant mass (channel %s)" % channel,
        xTitle="Invariant mass [GeV]")
    plot_notTwoBJets_invMass = Plot.make1D(
        "%s_notTwoBJets_invMass_%s" % (channel, suffix),
        op.c_float(-10.),
        hasAtLeastTwoBJets,
        EquidistantBinning(100, -10, 500.),
        title="Dijet invariant mass (channel %s)" % channel,
        xTitle="Invariant mass [GeV]")
    plots.append(
        SummedPlot("%s_dijetInvariantMass_%s" % (channel, suffix),
                   [plot_hasTwoBJets_invMass, plot_notTwoBJets_invMass],
                   xTitle="Invariant mass [GeV]"))

    return plots
Exemplo n.º 30
0
def makeDileptonPlots(self, sel, dilepton, suffix, channel):
    """
    Make dilepton basic plots
    sel         = refine selection 
    dilepton    = dilepton object (ElEl, MuEl, ElMu, MuMu)
    suffix      = string identifying the selecton 
    channel     = string identifying the channel of the dilepton (can be "NoChannel")
    """
    plots = []
    # PT plot #
    plots.append(
        Plot.make1D(
            "%s_leadleptonPT_%s" % (channel, suffix),
            dilepton[0].p4.Pt(),
            sel,
            EquidistantBinning(100, 0., 150.),
            title="Transverse momentum of the leading lepton (channel %s)" %
            channel,
            xTitle="P_{T}(leading lepton) [GeV]"))
    plots.append(
        Plot.make1D(
            "%s_subleadleptonPT_%s" % (channel, suffix),
            dilepton[1].p4.Pt(),
            sel,
            EquidistantBinning(100, 0., 150.),
            title="Transverse momentum of the subleading lepton (channel %s)" %
            channel,
            xTitle="P_{T}(leading lepton) [GeV]"))

    # Eta plot #
    plots.append(
        Plot.make1D("%s_leadleptonEta_%s" % (channel, suffix),
                    dilepton[0].p4.Eta(),
                    sel,
                    EquidistantBinning(20, -3., 3.),
                    title="Pseudorapidity of the leading lepton (channel %s)" %
                    channel,
                    xTitle="#eta (leading lepton) [GeV]"))
    plots.append(
        Plot.make1D(
            "%s_subleadleptonEta_%s" % (channel, suffix),
            dilepton[1].p4.Eta(),
            sel,
            EquidistantBinning(20, -3., 3.),
            title="Pseudorapidity of the subleading lepton (channel %s)" %
            channel,
            xTitle="#eta (subleading sublepton) [GeV]"))

    # Phi plot #
    plots.append(
        Plot.make1D("%s_leadleptonPhi_%s" % (channel, suffix),
                    dilepton[0].p4.Phi(),
                    sel,
                    EquidistantBinning(20, -3.2, 3.2),
                    title="Azimutal angle of the leading lepton (channel %s)" %
                    channel,
                    xTitle="#phi (leading lepton) [GeV]"))
    plots.append(
        Plot.make1D(
            "%s_subleadleptonPhi_%s" % (channel, suffix),
            dilepton[1].p4.Phi(),
            sel,
            EquidistantBinning(20, -3.2, 3.2),
            title="Azimutal angle of the subleading lepton (channel %s)" %
            channel,
            xTitle="#phi (subleading lepton) [GeV]"))

    # InvMass plot #
    plots.append(
        Plot.make1D("%s_leptonInvariantMass_%s" % (channel, suffix),
                    op.invariant_mass(dilepton[0].p4, dilepton[1].p4),
                    sel,
                    EquidistantBinning(100, 0., 500.),
                    title="Dilepton invariant mass (channel %s)" % channel,
                    xTitle="Invariant mass [GeV]"))

    return plots