def makeLeptons( data ):
            goodLeptons = getGoodLeptons( data, collVars = leptonVars + extraLepVars )
            extraLeptons = sorted( \
                [l for l in getLeptons( data, collVars = leptonVars + extraLepVars) if l not in goodLeptons] \
                + getOtherLeptons( data , collVars = leptonVars + extraLepVars), 
                            key=lambda l: -l['pt'] )
            #print len(goodLeptons), len(getLeptons( data, collVars = leptonVars + extraLepVars)), len(getOtherLeptons( data , collVars = leptonVars + extraLepVars)), len(extraLeptons) 
            if len(goodLeptons)==2: 
                setattr( data, "goodLeptons", goodLeptons )
                setattr( data, "extraLeptons", extraLeptons )

                extraMu  = filter(lambda l: abs(l['pdgId'])==13 and l['relIso04']>0.5, extraLeptons )
                extraEle = filter(lambda l: abs(l['pdgId'])==11 and l['relIso04']>0.5, extraLeptons )

                setattr( data, "extraMu", extraMu[-1] if len(extraMu)>0 else None )
                setattr( data, "extraEle", extraEle[-1] if len(extraEle)>0 else None )

                # MT2ll
                mt2Calc.reset()
                l1, l2 = goodLeptons[0], goodLeptons[1]
                mt2Calc.setLeptons(l1["pt"], l1["eta"], l1["phi"], l2["pt"], l2["eta"], l2["phi"])
                mt2Calc.setMet(data.met_pt, data.met_phi)
                setattr( data, "mt2ll", mt2Calc.mt2ll())
                #print data.mt2ll
            else:
                setattr( data, "goodLeptons", None)
                setattr( data, "extraLeptons", None)
                setattr( data, "extraMu", None)
                setattr( data, "extraEle", None)
                setattr( data, "mt2ll", None)
Ejemplo n.º 2
0
        def makeLeptons( data ):
            goodLeptons = getGoodLeptons( data, collVars = leptonVars + extraLepVars )
            extraLeptons = sorted( \
                [l for l in getLeptons( data, collVars = leptonVars + extraLepVars) if l not in goodLeptons] \
                + getOtherLeptons( data , collVars = leptonVars + extraLepVars), 
                            key=lambda l: -l['pt'] )
            setattr( data, "goodLeptons", goodLeptons )
            setattr( data, "extraLeptons", extraLeptons )

            extraMu  = filter(lambda l: abs(l['pdgId'])==13 and l['relIso04']>0.5, extraLeptons )
            extraEle = filter(lambda l: abs(l['pdgId'])==11 and l['relIso04']>0.5, extraLeptons )

            setattr( data, "extraMu", extraMu[-1] if len(extraMu)>0 else None )
            setattr( data, "extraEle", extraEle[-1] if len(extraEle)>0 else None )
Ejemplo n.º 3
0
        def makeLeptons(data):
            goodLeptons = getGoodLeptons(data,
                                         collVars=leptonVars + extraLepVars)
            extraLeptons = sorted( \
                [l for l in getLeptons( data, collVars = leptonVars + extraLepVars) if l not in goodLeptons] \
                + getOtherLeptons( data , collVars = leptonVars + extraLepVars),
                            key=lambda l: -l['pt'] )
            setattr(data, "goodLeptons", goodLeptons)
            setattr(data, "extraLeptons", extraLeptons)

            extraMu = filter(
                lambda l: abs(l['pdgId']) == 13 and l['relIso04'] > 0.5,
                extraLeptons)
            extraEle = filter(
                lambda l: abs(l['pdgId']) == 11 and l['relIso04'] > 0.5,
                extraLeptons)

            setattr(data, "extraMu", extraMu[-1] if len(extraMu) > 0 else None)
            setattr(data, "extraEle",
                    extraEle[-1] if len(extraEle) > 0 else None)
Ejemplo n.º 4
0
    def makeNonIsoLeptons(data):

        goodLeptons = getGoodLeptons(data, collVars=leptonVars)
        allExtraLeptons = sorted( \
            [l for l in getLeptons( data, collVars = leptonVars ) if l not in goodLeptons] + getOtherLeptons( data , collVars = leptonVars ),
                        key=lambda l: -l['pt'] )

        # print len(allLeptons), len(goodLeptons), len(allExtraLeptons)
        assert len(goodLeptons) == 2, "Analysis leptons not found!"
        l1, l2 = goodLeptons
        #print l1['pt'] - data.l1_pt, l2['pt'] - data.l2_pt
        data.allExtraLeptons = allExtraLeptons

        nonIsoMus = filter(
            lambda l: abs(l['pdgId']) == 13 and l['miniRelIso'] > 0.2 and l[
                'pt'] > 5, allExtraLeptons)
        nonIsoEles = filter(
            lambda l: abs(l['pdgId']) == 11 and l['miniRelIso'] > 0.2 and l[
                'pt'] > 7, allExtraLeptons)
        #print nonIsoMus, nonIsoEles

        data.nonIsoMu = nonIsoMus[-1] if len(nonIsoMus) > 0 else None
        data.nonIsoEle = nonIsoEles[-1] if len(nonIsoEles) > 0 else None

        # extra ele
        if data.nonIsoEle is not None:
            makeSwappedMT2ll(data, l1, l2, data.nonIsoEle, verbose=verbose)
        if data.nonIsoMu is not None:
            makeSwappedMT2ll(data, l1, l2, data.nonIsoMu, verbose=verbose)
        if verbose: print
Ejemplo n.º 5
0
#    lhe[i].GetXaxis().SetBinLabel(j+1, getBinName(bins[j]))


def getLHEWeights(c):
    res = {}
    for i in range(110):  #c.GetLeaf("nLHEweight").GetValue()):
        res[int(c.GetLeaf("LHEweight_id").GetValue(i))] = c.GetLeaf(
            "LHEweight_wgt").GetValue(i)
    return res


for ev in range(nEvents)[:maxN]:
    if ev % 10000 == 0: print "At %i/%i" % (ev, nEvents)
    c.GetEntry(eList.GetEntry(ev))
    weight = c.GetLeaf('genWeight').GetValue() * lumiScaleFactor
    leptons = getLeptons(c, leptonVars + ['relIso03']) + getOtherLeptons(
        c, leptonVars + ['relIso03'])
    ele = filter(lambda l: looseEleID(l), leptons)
    mu = filter(lambda l: looseMuID(l), leptons)
    ele = filter(lambda e: min([999] + [deltaR(m, e) for m in mu]) > 0.1, ele)
    lep = mu + ele
    lep.sort(key=lambda l: -l['pt'])
    if not (len(lep) == 3 and abs(closestOSDLMassToMZ(lep) - mZ) < 10):
        continue

    jets = getGoodJets(c)
    bTaggedJets = filter(lambda l: l['btagCSV'] > 0.605, jets)
    nJets = len(jets)
    nBTags = len(bTaggedJets)
    nBin = getBin(nJets, nBTags)
    if nBin < 0: continue
    #  print "#e %i #m %i #j %i  #b %i n-bin %i"%(len(ele), len(mu), nJets, nBTags, nBin)
Ejemplo n.º 6
0
    def makeNonIsoLeptons( data ):

        goodLeptons = getGoodLeptons( data, collVars = leptonVars )
        allExtraLeptons = sorted( \
            [l for l in getLeptons( data, collVars = leptonVars ) if l not in goodLeptons] + getOtherLeptons( data , collVars = leptonVars ), 
                        key=lambda l: -l['pt'] )

        # print len(allLeptons), len(goodLeptons), len(allExtraLeptons) 
        assert len(goodLeptons)==2, "Analysis leptons not found!"
        l1, l2 = goodLeptons
        #print l1['pt'] - data.l1_pt, l2['pt'] - data.l2_pt
        data.allExtraLeptons = allExtraLeptons

        nonIsoMus  = filter(lambda l: abs(l['pdgId'])==13 and l['miniRelIso']>0.2 and l['pt']>5, allExtraLeptons )
        nonIsoEles = filter(lambda l: abs(l['pdgId'])==11 and l['miniRelIso']>0.2 and l['pt']>7, allExtraLeptons )
        #print nonIsoMus, nonIsoEles

        data.nonIsoMu  = nonIsoMus[-1] if len(nonIsoMus)>0 else None 
        data.nonIsoEle = nonIsoEles[-1] if len(nonIsoEles)>0 else None 

        # extra ele
        if data.nonIsoEle is not None:
            makeSwappedMT2ll( data, l1, l2, data.nonIsoEle, verbose = verbose)
        if data.nonIsoMu is not None:
            makeSwappedMT2ll( data, l1, l2, data.nonIsoMu, verbose = verbose)
        if verbose: print
Ejemplo n.º 7
0
#for i in range(110):
#  lhe[i] = ROOT.TH1F("lhe_"+str(i), "lhe_"+str(i), len(bins),0,len(bins))
#  for j in range(len(bins)):
#    lhe[i].GetXaxis().SetBinLabel(j+1, getBinName(bins[j]))

def getLHEWeights(c):
    res={}
    for i in range(110):#c.GetLeaf("nLHEweight").GetValue()):
        res[int(c.GetLeaf("LHEweight_id").GetValue(i))] = c.GetLeaf("LHEweight_wgt").GetValue(i)
    return res

for ev in range(nEvents)[:maxN]:
    if ev%10000==0:print "At %i/%i"%(ev,nEvents)
    c.GetEntry(eList.GetEntry(ev))
    weight = c.GetLeaf('genWeight').GetValue()*lumiScaleFactor
    leptons = getLeptons(c, leptonVars+['relIso03'])+getOtherLeptons(c, leptonVars+['relIso03'])
    ele = filter(lambda l:looseEleID(l), leptons)
    mu  = filter(lambda l:looseMuID(l), leptons)
    ele = filter(lambda e:min([999]+[deltaR(m, e) for m in mu])>0.1, ele)
    lep = mu+ele
    lep.sort(key=lambda l:-l['pt'])
    if not (len(lep)==3 and abs( closestOSDLMassToMZ(lep) - mZ)< 10): continue

    jets = getGoodJets(c)
    bTaggedJets = filter(lambda l:l['btagCSV']>0.605, jets)
    nJets = len(jets)
    nBTags = len(bTaggedJets)
    nBin = getBin(nJets, nBTags)
    if nBin<0:continue
#  print "#e %i #m %i #j %i  #b %i n-bin %i"%(len(ele), len(mu), nJets, nBTags, nBin)
    central.Fill(nBin, weight)