Beispiel #1
0
    def fill(self,eh,downscale=1):

        isrJetPt = eh.get("isrJetPt")
        if math.isnan(isrJetPt):
            return

        imus = isolatedMuons(eh,ptmin1=5.,etamax=1.5,ptmin2=20.,reliso=0.5)
        if len(imus)!=1:
            return False
        imu = imus[0]

        muPdgs = eh.get("muPdg")
        muPts = eh.get("muPt")
        muEtas = eh.get("muEta")
        muPhis = eh.get("muPhi")
        if muPts[imu]<20:
            return

#        if isrJetPt<350:
#            return

        njet = int(eh.get("njetCount")+0.5)
        jetPts = eh.get("jetPt")
        jetEtas = eh.get("jetEta")
        jetBtags = eh.get("jetBtag")
        ib = None
        for i in range(njet):
#            if jetPts[i]>30 and jetPts[i]<60 and jetBtags[i]>0.679:
            if jetPts[i]>30 and abs(jetEtas[i])<2.4 and jetBtags[i]>0.679:
                ib = i
                break
        if ib!=None:
            return

        softMuPt = muPts[imu]
        softMuPhi = muPhis[imu]
        softMuEta = muEtas[imu]
        met = eh.get("type1phiMet")
#        if met<300:
#            return
        metphi = eh.get("type1phiMetphi")
        mt = math.sqrt(2*met*softMuPt*(1-math.cos(metphi-softMuPhi)))
#        mt = eh.get("softIsolatedMT")
#        if ( mt < 60 ) or ( mt > 88 ):
#            return

#        ht = 0
#        for i in range(njet):
#            if jetPts[i]>30:
#                ht += jetPts[i]
        ht = eh.get("ht")

        ihtmet = 25
        while True:
            metcut = 300 + ihtmet
            htcut = 400 + ihtmet
#            if metcut<0 or htcut<0:
#                return
            if met >= metcut and ht >= htcut:
                break
            ihtmet -= 25
        
        self.timers[0].start()
        if self.name!="data":
            w = eh.get("puWeight")*downscale
        else:
            w = 1
        self.timers[0].stop()

        if self.name.startswith("WJets") and polVar!=None:
            polVars = calcPolWeights(eh)
            w *= polVars[polVar]
        
        pdg = muPdgs[imu]

        if met>300 and ht>400:
            if pdg>0:
                self.hcountMinus.Fill(0.,w)
            else:
                self.hcountPlus.Fill(0.,w)

        self.hht_vs_met.Fill(met,ht,w)
        self.fillOne1D("htmetIndex",pdg,ihtmet,w)

        self.fillOne2D("muPt_vs_met",pdg,met,softMuPt,w)
        iHt = self.findBin(ht,self.htLimits)
        if iHt!=None:
            iMet = self.findBin(met,self.muPtMetLimits)
            if iMet!=None:
                iMuPt = self.findBin(softMuPt,self.muPtMetLimits)
                if iMuPt!=None:
                    self.fillOne1D("muPtMetIndex",pdg,
                                   len(self.muPtMetLimits)**2*iHt+len(self.muPtMetLimits)*iMet+iMuPt,w)


        self.fillOne1D("ht",pdg,ht,w)
        self.fillOne1D("met",pdg,met,w)

#        if ihtmet<-100:
#            return

        self.fillOne1D("mt",pdg,mt,w)
        
        self.fillOne1D("isrJetPt",pdg,isrJetPt,w)
        self.fillOne1D("isrJetEta",pdg,abs(eh.get("isrJetEta")),w)

        jetPtRatio = 0.
        jet2Pt = 0.
        jet2Eta = 0.
        if njet>1:
#            jetPts = eh.get("jetPt")
            jetPtRatio = jetPts[1]/jetPts[0]
            jet2Pt = jetPts[1]
#            jetEtas = eh.get("jetEta")
            jet2Eta = jetEtas[1]
        self.fillOne1D("jetPtRatio",pdg,jetPtRatio,w)
        self.fillOne1D("jet2Pt",pdg,jet2Pt,w)
        self.fillOne1D("jet2Eta",pdg,jet2Eta,w)

        self.fillOne1D("njet60",pdg,eh.get("njet60"),w)
        self.fillOne1D("njet",pdg,eh.get("njetCount"),w)


        self.fillOne1D("softMuPt",pdg,softMuPt,w)
        self.fillOne1D("softMuEta",pdg,abs(softMuEta),w)
           
        jetPhis = eh.get("jetPhi")
        self.fillOne1D("jetmuDeltaEta",pdg,abs(jetEtas[0]-softMuEta),w)
        self.fillOne1D("jetmuDeltaR",pdg,deltaR(jetPhis[0],jetEtas[0],softMuPhi,softMuEta),w)

        muPx = softMuPt*math.cos(softMuPhi)
        muPy = softMuPt*math.sin(softMuPhi)
        wPx = met*math.cos(metphi) + muPx
        wPy = met*math.sin(metphi) + muPy
        lp = (muPx*wPx+muPy*wPy)/(wPx*wPx+wPy*wPy)
        self.fillOne1D("lp",pdg,lp,w)
Beispiel #2
0
    def fill(self,eh,downscale=1):

        isrJetPt = eh.get("isrJetPt")
        softMuPt = eh.get("softIsolatedMuPt")
        if math.isnan(softMuPt) or math.isnan(isrJetPt):
            return

#        if isrJetPt<350:
#            return


        njet = int(eh.get("njetCount")+0.5)
        jetPts = eh.get("jetPt")
        jetEtas = eh.get("jetEta")
        jetBtags = eh.get("jetBtag")
        ib = None
        for i in range(njet):
#            if jetPts[i]>30 and jetPts[i]<60 and jetBtags[i]>0.679:
            if jetPts[i]>30 and abs(jetEtas[i])<2.4 and jetBtags[i]>0.679:
                ib = i
                break
        if ib!=None:
            return

        softMuPhi = eh.get("softIsolatedMuPhi")
        met = eh.get("type1phiMet")
#        if met<300:
#            return
        metphi = eh.get("type1phiMetphi")
#        mt = math.sqrt(2*met*softMuPt*(1-math.cos(metphi-softMuPhi)))
        mt = eh.get("softIsolatedMT")
        if ( mt < 60 ) or ( mt > 88 ):
            return

#        ht = 0
#        for i in range(njet):
#            if jetPts[i]>30:
#                ht += jetPts[i]
        ht = eh.get("ht")

        ihtmet = -25
        while True:
            metcut = 300 + ihtmet
            htcut = 400 + ihtmet
#            if metcut<0 or htcut<0:
#                return
            if met >= metcut and ht >= htcut:
                break
            ihtmet -= 25
        


        self.timers[0].start()
        if self.name!="data":
            w = eh.get("puWeight")*downscale
        else:
            w = 1
        self.timers[0].stop()

        if self.name.startswith("WJets") and polVar!=None:
            polVars = calcPolWeights(eh)
            w *= polVars[polVar]
        
        pdg = eh.get("softIsolatedMuPdg")

        if met>300 and ht>400:
            if pdg>0:
                self.hcountMinus.Fill(0.,w)
            else:
                self.hcountPlus.Fill(0.,w)

        self.hht_vs_met.Fill(met,ht,w)
        self.fillOne1D("htmetIndex",pdg,ihtmet,w)

        if ihtmet<-100:
            return

        self.fillOne1D("ht",pdg,ht,w)
        self.fillOne1D("met",pdg,met,w)

        self.fillOne1D("mt",pdg,mt,w)
        
        self.fillOne1D("isrJetPt",pdg,isrJetPt,w)
        self.fillOne2D("htmet_vs_isrJetPt",pdg,isrJetPt,ihtmet,w)
        self.fillOne1D("isrJetEta",pdg,abs(eh.get("isrJetEta")),w)
        self.fillOne2D("htmet_vs_isrJetEta",pdg,abs(eh.get("isrJetEta")),ihtmet,w)

        softMuIso = eh.get("softIsolatedMuRelIso")
        self.fillOne2D("htmet_vs_muabsiso",pdg,softMuIso*softMuPt,ihtmet,w)

        softMuDxy = eh.get("softIsolatedMuDxy")
        self.fillOne2D("htmet_vs_mudxy",pdg,softMuDxy,ihtmet,w)

        softMuDz = eh.get("softIsolatedMuDz")
        self.fillOne2D("htmet_vs_mudz",pdg,softMuDz,ihtmet,w)

        softMuPix = eh.get("softIsolatedMuPixelHits")
        self.fillOne2D("htmet_vs_mupix",pdg,softMuPix,ihtmet,w)

        softMuIsGlob = eh.get("softIsolatedMuIsGlobal")
        self.fillOne2D("htmet_vs_softMuIsGlob",pdg,softMuIsGlob,ihtmet,w)

        softMuIsTk = eh.get("softIsolatedMuIsTracker")
        self.fillOne2D("htmet_vs_softMuIsTk",pdg,softMuIsTk,ihtmet,w)

        softMuNValMu = eh.get("softIsolatedMuNValMuonHits")
        self.fillOne2D("htmet_vs_softMuNValMu",pdg,softMuNValMu,ihtmet,w)

        softMuNormChi2 = eh.get("softIsolatedMuNormChi2")
        self.fillOne2D("htmet_vs_softMuNormChi2",pdg,softMuNormChi2,ihtmet,w)

        softMuNMatched = eh.get("softIsolatedMuNumMatchedStations")
        self.fillOne2D("htmet_vs_softMuNMatched",pdg,softMuNMatched,ihtmet,w)

        softMuNTkLayer = eh.get("softIsolatedMuNumtrackerLayerWithMeasurement")
        self.fillOne2D("htmet_vs_softMuNTkLayer",pdg,softMuNTkLayer,ihtmet,w)

        self.fillOne2D("htmet_vs_softEle",pdg,eh.get("nSoftElectrons"),ihtmet,w)
        self.fillOne2D("htmet_vs_softTau",pdg,eh.get("nSoftTaus"),ihtmet,w)
        self.fillOne2D("htmet_vs_softB",pdg,eh.get("nSoftbtags"),ihtmet,w)

        jetPtRatio = 0.
        jet2Pt = 0.
        jet2Eta = 0.
        if njet>1:
#            jetPts = eh.get("jetPt")
            jetPtRatio = jetPts[1]/jetPts[0]
            jet2Pt = jetPts[1]
#            jetEtas = eh.get("jetEta")
            jet2Eta = jetEtas[1]
        self.fillOne1D("jetPtRatio",pdg,jetPtRatio,w)
        self.fillOne1D("jet2Pt",pdg,jet2Pt,w)
        self.fillOne1D("jet2Eta",pdg,jet2Eta,w)

        self.fillOne1D("njet60",pdg,eh.get("njet60"),w)
        self.fillOne2D("htmet_vs_njet60",pdg,eh.get("njet60"),ihtmet,w)
        self.fillOne1D("njet",pdg,eh.get("njetCount"),w)
        self.fillOne2D("htmet_vs_njet",pdg,eh.get("njetCount"),ihtmet,w)


        softMuEta = eh.get("softIsolatedMuEta")
        self.fillOne1D("softMuPt",pdg,softMuPt,w)
        self.fillOne2D("htmet_vs_softMuPt",pdg,softMuPt,ihtmet,w)
        self.fillOne1D("softMuEta",pdg,abs(softMuEta),w)
        self.fillOne2D("htmet_vs_softMuEta",pdg,abs(softMuEta),ihtmet,w)
           
        jetPhis = eh.get("jetPhi")
        self.fillOne1D("jetmuDeltaEta",pdg,abs(jetEtas[0]-softMuEta),w)
        self.fillOne2D("htmet_vs_jetmuDeltaEta",pdg,abs(jetEtas[0]-softMuEta),ihtmet,w)
        self.fillOne1D("jetmuDeltaR",pdg,deltaR(jetPhis[0],jetEtas[0],softMuPhi,softMuEta),w)
        self.fillOne2D("htmet_vs_jetmuDeltaR",pdg,deltaR(jetPhis[0],jetEtas[0],softMuPhi,softMuEta),ihtmet,w)
Beispiel #3
0
    def fill(self, eh, downscale=1):

        isrJetPt = eh.get("isrJetPt")
        if math.isnan(isrJetPt):
            return

        imus = isolatedMuons(eh, ptmin1=5., etamax=1.5, ptmin2=20., reliso=0.5)
        if len(imus) != 1:
            return False
        imu = imus[0]

        muPdgs = eh.get("muPdg")
        muPts = eh.get("muPt")
        muEtas = eh.get("muEta")
        muPhis = eh.get("muPhi")
        if muPts[imu] < 20:
            return

#        if isrJetPt<350:
#            return

        njet = int(eh.get("njetCount") + 0.5)
        jetPts = eh.get("jetPt")
        jetEtas = eh.get("jetEta")
        jetBtags = eh.get("jetBtag")
        ib = None
        for i in range(njet):
            #            if jetPts[i]>30 and jetPts[i]<60 and jetBtags[i]>0.679:
            if jetPts[i] > 30 and abs(
                    jetEtas[i]) < 2.4 and jetBtags[i] > 0.679:
                ib = i
                break
        if ib != None:
            return

        softMuPt = muPts[imu]
        softMuPhi = muPhis[imu]
        softMuEta = muEtas[imu]
        met = eh.get("type1phiMet")
        #        if met<300:
        #            return
        metphi = eh.get("type1phiMetphi")
        mt = math.sqrt(2 * met * softMuPt * (1 - math.cos(metphi - softMuPhi)))
        #        mt = eh.get("softIsolatedMT")
        #        if ( mt < 60 ) or ( mt > 88 ):
        #            return

        #        ht = 0
        #        for i in range(njet):
        #            if jetPts[i]>30:
        #                ht += jetPts[i]
        ht = eh.get("ht")

        ihtmet = 25
        while True:
            metcut = 300 + ihtmet
            htcut = 400 + ihtmet
            #            if metcut<0 or htcut<0:
            #                return
            if met >= metcut and ht >= htcut:
                break
            ihtmet -= 25

        self.timers[0].start()
        if self.name != "data":
            w = eh.get("puWeight") * downscale
        else:
            w = 1
        self.timers[0].stop()

        if self.name.startswith("WJets") and polVar != None:
            polVars = calcPolWeights(eh)
            w *= polVars[polVar]

        pdg = muPdgs[imu]

        if met > 300 and ht > 400:
            if pdg > 0:
                self.hcountMinus.Fill(0., w)
            else:
                self.hcountPlus.Fill(0., w)

        self.hht_vs_met.Fill(met, ht, w)
        self.fillOne1D("htmetIndex", pdg, ihtmet, w)

        self.fillOne2D("muPt_vs_met", pdg, met, softMuPt, w)
        iHt = self.findBin(ht, self.htLimits)
        if iHt != None:
            iMet = self.findBin(met, self.muPtMetLimits)
            if iMet != None:
                iMuPt = self.findBin(softMuPt, self.muPtMetLimits)
                if iMuPt != None:
                    self.fillOne1D(
                        "muPtMetIndex", pdg,
                        len(self.muPtMetLimits)**2 * iHt +
                        len(self.muPtMetLimits) * iMet + iMuPt, w)

        self.fillOne1D("ht", pdg, ht, w)
        self.fillOne1D("met", pdg, met, w)

        #        if ihtmet<-100:
        #            return

        self.fillOne1D("mt", pdg, mt, w)

        self.fillOne1D("isrJetPt", pdg, isrJetPt, w)
        self.fillOne1D("isrJetEta", pdg, abs(eh.get("isrJetEta")), w)

        jetPtRatio = 0.
        jet2Pt = 0.
        jet2Eta = 0.
        if njet > 1:
            #            jetPts = eh.get("jetPt")
            jetPtRatio = jetPts[1] / jetPts[0]
            jet2Pt = jetPts[1]
            #            jetEtas = eh.get("jetEta")
            jet2Eta = jetEtas[1]
        self.fillOne1D("jetPtRatio", pdg, jetPtRatio, w)
        self.fillOne1D("jet2Pt", pdg, jet2Pt, w)
        self.fillOne1D("jet2Eta", pdg, jet2Eta, w)

        self.fillOne1D("njet60", pdg, eh.get("njet60"), w)
        self.fillOne1D("njet", pdg, eh.get("njetCount"), w)

        self.fillOne1D("softMuPt", pdg, softMuPt, w)
        self.fillOne1D("softMuEta", pdg, abs(softMuEta), w)

        jetPhis = eh.get("jetPhi")
        self.fillOne1D("jetmuDeltaEta", pdg, abs(jetEtas[0] - softMuEta), w)
        self.fillOne1D("jetmuDeltaR", pdg,
                       deltaR(jetPhis[0], jetEtas[0], softMuPhi, softMuEta), w)

        muPx = softMuPt * math.cos(softMuPhi)
        muPy = softMuPt * math.sin(softMuPhi)
        wPx = met * math.cos(metphi) + muPx
        wPy = met * math.sin(metphi) + muPy
        lp = (muPx * wPx + muPy * wPy) / (wPx * wPx + wPy * wPy)
        self.fillOne1D("lp", pdg, lp, w)