Exemplo n.º 1
0
 def analyze(self, event):
     event.jets = Collection(event, "Jet")
     event.discjets = Collection(event, "DiscJet")
     event.selJets = []
     event.selJets25 = []
     event.iJetSel = [int(ijet) for ijet in event.JetSelIndex]
     for ijet in event.iJetSel:
         #for ijet in event.JetSelIndex:
         try:
             jetToAdd = None
             if ijet >= 0:
                 index = ijet
                 jetToAdd = event.jets[index]
             else:
                 index = -ijet - 1
                 jetToAdd = event.discjets[index]
             if jetToAdd and jetToAdd.pt > 40 and abs(jetToAdd.eta) < 2.4:
                 event.selJets25.append(jetToAdd)
             if jetToAdd and jetToAdd.pt > 40 and abs(jetToAdd.eta) < 2.4:
                 event.selJets.append(jetToAdd)
         except IndexError:
             self.writer.objs["DiscardedEvent"].Fill(0)
             return False
     event.selJets.sort(key=lambda x: x.pt, reverse=True)
     event.selJets25.sort(key=lambda x: x.pt, reverse=True)
     return True
    def analyze(self,event):
        event.genleps = [genlep for genlep in Collection(event,"GENlep") if ((abs(genlep.eta) < 2.5 and abs(genlep.id) == 11 and genlep.pt > 7) or (abs(genlep.eta) < 2.4 and abs(genlep.id) == 13 and genlep.pt > 5)) and genlep.RelIso < 0.35]
        event.genleps.sort(key=lambda x: x.pt,reverse=True)

        if len(event.genleps) < 4: return False
        
        if event.genleps[0].pt < 20: return False
        if event.genleps[1].pt < 10: return False

        if not self.OSSFLeptonPairs(event.genleps): return False
        event.ZCandidates = self.HZZAlgo.makeZCandidatesFromCollection(event.genleps)
        Z1,Z2,passZ1Z2 = self.HZZAlgo.makeZ1Z2(event.ZCandidates,[40.,120.],[12.,120.]) 
        #if Z1.vec.M() < 40 or Z1.vec.M() > 120: return False
        #if Z2.vec.M() < 12 or Z2.vec.M() > 120: return False
        event.Z1 = Z1
        event.Z2 = Z2
        if not passZ1Z2: return False

        lep_vec_list = [Z1.lep1.vec,Z1.lep2.vec,Z2.lep1.vec,Z2.lep2.vec]
        deltaRs = []
        for i,vec1 in enumerate(lep_vec_list):
            for j,vec2 in enumerate(lep_vec_list):
                if i >= j: continue
                deltaRs.append(vec1.DeltaR(vec2))
        if min(deltaRs) < 0.02: return False
        
        hvec = Z1.vec + Z2.vec
        event.hmass = hvec.M()
        if event.hmass < 105 or event.hmass > 140: return False
        
        #return event.passedFiducialSelection[0]
        return True
 def analyze(self, event):
     photons = Collection(event, "Photon")
     event.selPhotons = [
         ph for ph in photons
         if self.idSelection(ph) and self.isoSelection(ph)
         and self.otherSelection(ph) and self.overlapRemoval(event, ph)
     ]
     return True
 def analyze(self, event):
     phyObjs = Collection(event, self.inCollName)
     selObjs = [
         phyObj for phyObj in phyObjs
         if phyObjDefDict[self.selection](phyObj)
     ]
     setattr(event, self.outCollName, selObjs)
     return True
 def analyze(self, event):
     jets = Collection(event, self.inCollName)
     selectedJets = [j for j in jets if phyObjDefDict[self.selection](j)]
     for inOtherCollName in self.inOtherCollNames:
         selectedJets, _ = cleanJetsAndLeptons(
             selectedJets, getattr(event, inOtherCollName), self.deltaR)
     setattr(event, self.outCollName, selectedJets)
     return True
 def analyze(self, event):
     event.leps = [
         lep for lep in Collection(event, "lep")
         if ((abs(lep.eta) < 2.5 and abs(lep.id) == 11 and lep.pt > 7) or
             (abs(lep.eta) < 2.4 and abs(lep.id) == 13 and lep.pt > 5))
         and lep.RelIso < 0.35
     ]
     event.leps.sort(key=lambda x: x.pt, reverse=True)
     return True
 def analyze(self, event):
     event.goodLeps = [l for l in Collection(event, "LepGood")]
     event.looseLeps = []
     event.tightLeps = []
     event.cleanLeps = []
     for il, l in enumerate(event.goodLeps):
         if l.isTight: event.tightLeps.append(l)
         if l.isLoose and not l.isTight: event.looseLeps.append(l)
         if l.isCleaning and not l.isTight: event.cleanLeps.append(l)
     return True
Exemplo n.º 8
0
    def analyze(self, event):
        event.ret = leptonAlgoDict[self.algoStr](event)

        event.goodLeps = [l for l in Collection(event, "LepGood")]
        event.looseLeps = []
        event.tightLeps = []
        for il, l in enumerate(event.goodLeps):
            if event.ret["LepGood_isTight_Mini"][il]: event.tightLeps.append(l)
            if event.ret["LepGood_isLoose_Mini"][il]: event.looseLeps.append(l)
        return True
Exemplo n.º 9
0
 def analyze(self, event):
     event.leptons = [l for l in Collection(event, var_lep_str)]
     event.leptons_Zp = [
         l for l in event.leptons if abs(l.matchedR03_MomId) == Zp.pdgId
     ]
     event.leptons_nonZp = [
         l for l in event.leptons if abs(l.matchedR03_MomId) != Zp.pdgId
     ]
     event.leptons_matched = event.leptons_Zp if self.dataset.isZp else event.leptons_nonZp
     return True
Exemplo n.º 10
0
    def analyze(self, event):
        event.jets = Collection(event, "Jet")
        event.discjets = Collection(event, "DiscJet")
        event.nJet40_recal = 0
        for ijet in event.iJetSel:
            try:
                if ijet >= 0:
                    index = ijet
                    jetPt = event.jets[index].pt
                    jetEta = abs(event.jets[index].eta)
                else:
                    index = -ijet - 1
                    jetPt = event.discjets[index].pt
                    jetEta = abs(event.discjets[index].eta)
            except IndexError:
                self.writer.objs["DiscardedEvent"].Fill(0)
            if jetPt > 40 and jetEta < 2.4:
                event.nJet40_recal += 1

        return True
    def analyze(self,event):
        event.standAloneMuons = [m for m in Collection(event,"muons") if m.isStandAloneMuon]
        event.cscSegments = [s for s in Collection(event,"cscSegments",length_var="cscSegments_nSegments")]
        for m in event.standAloneMuons:
            n_mu_segment = len(m.cscSegmentRecord_endcap)
            m.segments_globalX = []
            m.segments_globalY = []
            m.segments_endcap = []
            m.segments_chamber = []
            m.segments_station = []
            m.segments_ring = []
            for i in range(n_mu_segment):
                mu_endcap = m.cscSegmentRecord_endcap[i]
                mu_chamber = m.cscSegmentRecord_chamber[i]
                mu_station = m.cscSegmentRecord_station[i]
                mu_ring = m.cscSegmentRecord_ring[i]
                mu_localX = m.cscSegmentRecord_localX[i]
                mu_localY = m.cscSegmentRecord_localY[i]
                for seg in event.cscSegments:
                    seg_endcap = seg.ID_endcap
                    seg_ring = seg.ID_ring
                    seg_station = seg.ID_station
                    seg_chamber = seg.ID_chamber
                    seg_localX = seg.localX
                    seg_localY = seg.localY
                    if seg_endcap == mu_endcap and seg_ring == mu_ring and seg_station == mu_station and seg_chamber == mu_chamber and seg_localX == mu_localX and seg_localY == mu_localY:
                        m.segments_globalX.append(seg.globalX)
                        m.segments_globalY.append(seg.globalY)
                        m.segments_endcap.append(seg_endcap)
                        m.segments_chamber.append(seg_chamber)
                        m.segments_station.append(seg_station)
                        m.segments_ring.append(seg_ring)
 
            if len(m.segments_globalX) < n_max_segment: m.segments_globalX += [0.]*(n_max_segment-len(m.segments_globalX))
            if len(m.segments_globalY) < n_max_segment: m.segments_globalY += [0.]*(n_max_segment-len(m.segments_globalY))
            if len(m.segments_endcap) < n_max_segment: m.segments_endcap += [0.]*(n_max_segment-len(m.segments_endcap))
            if len(m.segments_chamber) < n_max_segment: m.segments_chamber += [0.]*(n_max_segment-len(m.segments_chamber))
            if len(m.segments_station) < n_max_segment: m.segments_station += [0.]*(n_max_segment-len(m.segments_station))
            if len(m.segments_ring) < n_max_segment: m.segments_ring += [0.]*(n_max_segment-len(m.segments_ring))
        
        return True
Exemplo n.º 12
0
    def analyze(self, event):
        event.leps = [
            lep for lep in Collection(event, "lep")
            if ((abs(lep.eta) < self.elEtaCut and abs(lep.id) == 11
                 and lep.pt > self.elPtCut) or
                (abs(lep.eta) < self.muEtaCut and abs(lep.id) == 13
                 and lep.pt > self.muPtCut)) and lep.RelIso < self.lepRelIso
        ]
        #event.leps = [lep for lep in Collection(event,"lepFSR") if ((abs(lep.eta) < 2.5 and abs(lep.id) == 11 and lep.pt > 7) or (abs(lep.eta) < 2.4 and abs(lep.id) == 13 and lep.pt > 5)) and lep.RelIso < 0.35]
        event.leps.sort(key=lambda x: x.pt, reverse=True)

        # Check for Nlep >= 4:
        if len(event.leps) < self.nLep: return False

        if event.leps[0].pt < self.leadingPtCut: return False
        if event.leps[1].pt < self.subleadingPtCut: return False

        if not self.OSSFLeptonPairs(event.leps): return False
        event.ZCandidates = self.HZZAlgo.makeZCandidatesFromCollection(
            event.leps, useFSR=True)
        Z1, Z2, passZ1Z2 = self.HZZAlgo.makeZ1Z2(event.ZCandidates,
                                                 self.Z1MassRange,
                                                 self.Z2MassRange)
        #if Z1.vec.M() < 40 or Z1.vec.M() > 120: return False
        #if Z2.vec.M() < 12 or Z2.vec.M() > 120: return False
        event.Z1 = Z1
        event.Z2 = Z2
        if not passZ1Z2: return False
        event.Z1mass = Z1.vec.M()
        event.Z2mass = Z2.vec.M()

        # Make list of the four leptons which come from the Z bosons.
        # Generally, lep1 and lep2 come from Z1; lep3 and lep4 come from Z2
        lep_vec_list = [Z1.lep1.vec, Z1.lep2.vec, Z2.lep1.vec, Z2.lep2.vec]
        deltaRs = []
        for i, vec1 in enumerate(lep_vec_list):
            for j, vec2 in enumerate(lep_vec_list):
                if i >= j: continue
                deltaRs.append(vec1.DeltaR(vec2))
        if min(deltaRs) < self.deltaRCut: return False

        hvec = Z1.vec + Z2.vec
        event.hmass = hvec.M()
        if event.hmass < self.m4lRange[0] or event.hmass > self.m4lRange[1]:
            return False

        #return event.passedFiducialSelection[0]
        return True
Exemplo n.º 13
0
 def analyze(self, event):
     event.standAloneMuons = [
         m for m in Collection(event, "muons") if m.isStandAloneMuon
     ]
     event.segment_localX = [0 for i in range(n_channel)]
     event.segment_localY = [0 for i in range(n_channel)]
     event.segment_muon = [0 for i in range(n_channel)]
     for im, m in enumerate(event.standAloneMuons):
         n_segment = len(m.cscSegmentRecord_endcap)
         for i in range(n_segment):
             endcap = m.cscSegmentRecord_endcap[i]
             chamber = m.cscSegmentRecord_chamber[i]
             station = m.cscSegmentRecord_station[i]
             ring = m.cscSegmentRecord_ring[i]
             hash = int(self.hash(chamber, station, ring, endcap))
             event.segment_localX[hash] = m.cscSegmentRecord_localX[i]
             event.segment_localX[hash] = m.cscSegmentRecord_localY[i]
             event.segment_muon[hash] = im
     return True
    def analyze(self, event):
        event.goodLeps = Collection(event, "LepGood")
        event.tightLeps = [l for l in event.goodLeps if l.isTight]
        event.tightLeps.sort(key=lambda x: x.pt, reverse=True)
        if len(event.tightLeps) != 2: return False
        event.cat = Category()
        if event.tightLeps[0].pt > 25 and event.tightLeps[1].pt > 25:
            event.cat.lepCat = "HH"
        if event.tightLeps[0].pt > 25 and event.tightLeps[1].pt < 25:
            event.cat.lepCat = "HL"
        if event.tightLeps[0].pt < 25 and event.tightLeps[1].pt < 25:
            event.cat.lepCat = "LL"

        mt = min([
            mtFunc(event.tightLeps[0].pt, event.tightLeps[0].phi,
                   event.met_pt[0], event.met_phi[0]),
            mtFunc(event.tightLeps[1].pt, event.tightLeps[1].phi,
                   event.met_pt[0], event.met_phi[0]),
        ])

        #veclep1 = event.tightLeps[0].p4()
        #veclep2 = event.tightLeps[1].p4()
        #met_pt = event.met_pt[0]
        #met_phi = event.met_phi[0]
        #met = ROOT.TLorentzVector()
        #met.SetPtEtaPhiM(met_pt,0,met_phi,0)
        #met.SetPz(0)
        #met.SetE(met.Pt())
        #mt1 = (veclep1 + met).Mt()
        #mt2 = (veclep2 + met).Mt()
        #mt = min([mt1,mt2])
        event.mtmin = mt
        event.cat.jetCat = "0"
        #print(event.cat.lepCat, event.nJet25[0], mt, event.met_pt[0], event.nJet40_recal, event.htJet40[0], event.tightLeps[0].charge, event.tightLeps[1].charge)
        if event.cat.lepCat == "HH":
            if event.htJet40[0] >= 1125 and event.htJet40[
                    0] <= 1300 and event.nJet40_recal >= 2 and event.met_pt[
                        0] >= 50 and event.met_pt[0] <= 300:
                if event.tightLeps[0].charge > 0:
                    event.cat.jetCat = "SR46"
                elif event.tightLeps[0].charge < 0:
                    event.cat.jetCat = "SR47"
            elif event.htJet40[0] >= 1300 and event.htJet40[
                    0] <= 1600 and event.nJet40_recal >= 2 and event.met_pt[
                        0] >= 50 and event.met_pt[0] <= 300:
                if event.tightLeps[0].charge > 0:
                    event.cat.jetCat = "SR48"
                elif event.tightLeps[0].charge < 0:
                    event.cat.jetCat = "SR49"
            elif event.htJet40[
                    0] > 1600 and event.nJet40_recal >= 2 and event.met_pt[
                        0] >= 50 and event.met_pt[0] <= 300:
                if event.tightLeps[0].charge > 0:
                    event.cat.jetCat = "SR50"
                elif event.tightLeps[0].charge < 0:
                    event.cat.jetCat = "SR51"

            if event.met_pt[0] >= 300 and event.met_pt[
                    0] <= 500 and event.nJet40_recal >= 2 and event.htJet40[
                        0] >= 300 and event.tightLeps[0].charge > 0:
                event.cat.jetCat = "SR42"
            if event.met_pt[0] >= 300 and event.met_pt[
                    0] <= 500 and event.nJet40_recal >= 2 and event.htJet40[
                        0] >= 300 and event.tightLeps[0].charge < 0:
                event.cat.jetCat = "SR43"
            if event.met_pt[
                    0] > 500 and event.nJet40_recal >= 2 and event.htJet40[
                        0] >= 300 and event.tightLeps[0].charge > 0:
                event.cat.jetCat = "SR44"
            if event.met_pt[
                    0] > 500 and event.nJet40_recal >= 2 and event.htJet40[
                        0] >= 300 and event.tightLeps[0].charge < 0:
                event.cat.jetCat = "SR45"

            if event.nJet25 == 0:
                if mt < 120:
                    if event.met_pt[0] < 200 and event.met_pt[0] > 50:
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2:
                            if event.htJet40[0] < 300:
                                event.cat.jetCat = "SR1"
                            elif event.htJet40[0] <= 1125:
                                event.cat.jetCat = "SR2"
                        elif event.nJet40_recal >= 5:
                            if event.htJet40[0] < 300:
                                event.cat.jetCat = "SR3"
                            elif event.htJet40[0] <= 1125:
                                event.cat.jetCat = "SR4"
                    elif event.met_pt[0] < 300 and event.met_pt[0] > 200:
                        if event.htJet40[0] < 300:
                            event.cat.jetCat = "SR3"
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2 and event.htJet40[
                                0] >= 300 and event.htJet40[
                                    0] <= 1125 and event.tightLeps[
                                        0].charge > 0:
                            event.cat.jetCat = "SR5"
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2 and event.htJet40[
                                0] >= 300 and event.htJet40[
                                    0] <= 1125 and event.tightLeps[
                                        0].charge < 0:
                            event.cat.jetCat = "SR6"
                        if event.nJet40_recal >= 5 and event.htJet40[
                                0] >= 300 and event.htJet40[0] <= 1125:
                            event.cat.jetCat = "SR7"
                elif event.htJet40[0] < 300:
                    event.cat.jetCat = "SR3"
                elif event.htJet40[0] >= 300 and event.htJet40[0] <= 1125:
                    if event.met_pt[0] < 200 and event.met_pt[0] > 50:
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2:
                            if event.tightLeps[0].charge > 0:
                                event.cat.jetCat = "SR8"
                            else:
                                event.cat.jetCat = "SR9"
                        elif event.nJet40_recal >= 5:
                            event.cat.jetCat = "SR10"
                    elif event.met_pt[0] < 300 and event.met_pt[0] > 200:
                        event.cat.jetCat = "SR10"
            elif event.nJet25 == 1:
                if mt < 120:
                    if event.met_pt[0] < 200 and event.met_pt[0] > 50:
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2:
                            if event.htJet40[0] < 300:
                                event.cat.jetCat = "SR11"
                            elif event.htJet40[0] <= 1125:
                                event.cat.jetCat = "SR12"
                        elif event.nJet40_recal >= 5:
                            if event.htJet40[0] < 300 and event.tightLeps[
                                    0].charge > 0:
                                event.cat.jetCat = "SR13"
                            if event.htJet40[0] < 300 and event.tightLeps[
                                    0].charge < 0:
                                event.cat.jetCat = "SR14"
                            if event.htJet40[0] <= 1125 and event.htJet40[
                                    0] >= 300 and event.tightLeps[0].charge > 0:
                                event.cat.jetCat = "SR15"
                            if event.htJet40[0] <= 1125 and event.htJet40[
                                    0] >= 300 and event.tightLeps[0].charge < 0:
                                event.cat.jetCat = "SR16"
                    elif event.met_pt[0] < 300 and event.met_pt[0] > 200:
                        if event.htJet40[0] < 300 and event.tightLeps[
                                0].charge > 0:
                            event.cat.jetCat = "SR13"
                        if event.htJet40[0] < 300 and event.tightLeps[
                                0].charge < 0:
                            event.cat.jetCat = "SR14"
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2 and event.htJet40[
                                0] >= 300 and event.htJet40[
                                    0] <= 1125 and event.tightLeps[
                                        0].charge > 0:
                            event.cat.jetCat = "SR17"
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2 and event.htJet40[
                                0] >= 300 and event.htJet40[
                                    0] <= 1125 and event.tightLeps[
                                        0].charge < 0:
                            event.cat.jetCat = "SR18"
                        if event.nJet40_recal >= 5 and event.htJet40[
                                0] >= 300 and event.htJet40[0] <= 1125:
                            event.cat.jetCat = "SR19"
                elif event.htJet40[0] < 300:
                    if event.tightLeps[0].charge > 0:
                        event.cat.jetCat = "SR13"
                    else:
                        event.cat.jetCat = "SR14"
                elif event.htJet40[0] >= 300 and event.htJet40[0] <= 1125:
                    if event.met_pt[0] < 200 and event.met_pt[0] > 50:
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2:
                            if event.tightLeps[0].charge > 0:
                                event.cat.jetCat = "SR20"
                            else:
                                event.cat.jetCat = "SR21"
                        elif event.nJet40_recal >= 5:
                            event.cat.jetCat = "SR22"
                    elif event.met_pt[0] < 300 and event.met_pt[0] > 200:
                        event.cat.jetCat = "SR22"
            elif event.nJet25 == 2:
                if mt < 120:
                    if event.met_pt[0] < 200 and event.met_pt[0] > 50:
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2:
                            if event.htJet40[0] < 300:
                                event.cat.jetCat = "SR23"
                            elif event.htJet40[0] <= 1125:
                                event.cat.jetCat = "SR24"
                        elif event.nJet40_recal >= 5:
                            if event.htJet40[0] < 300 and event.tightLeps[
                                    0].charge > 0:
                                event.cat.jetCat = "SR25"
                            if event.htJet40[0] < 300 and event.tightLeps[
                                    0].charge < 0:
                                event.cat.jetCat = "SR26"
                            if event.htJet40[0] <= 1125 and event.htJet40[
                                    0] >= 300 and event.tightLeps[0].charge > 0:
                                event.cat.jetCat = "SR27"
                            if event.htJet40[0] <= 1125 and event.htJet40[
                                    0] >= 300 and event.tightLeps[0].charge < 0:
                                event.cat.jetCat = "SR28"
                    elif event.met_pt[0] < 300 and event.met_pt[0] > 200:
                        if event.htJet40[0] < 300 and event.tightLeps[
                                0].charge > 0:
                            event.cat.jetCat = "SR25"
                        if event.htJet40[0] < 300 and event.tightLeps[
                                0].charge < 0:
                            event.cat.jetCat = "SR26"
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2 and event.htJet40[
                                0] >= 300 and event.htJet40[
                                    0] <= 1125 and event.tightLeps[
                                        0].charge > 0:
                            event.cat.jetCat = "SR29"
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2 and event.htJet40[
                                0] >= 300 and event.htJet40[
                                    0] <= 1125 and event.tightLeps[
                                        0].charge < 0:
                            event.cat.jetCat = "SR30"
                        if event.nJet40_recal >= 5 and event.htJet40[
                                0] >= 300 and event.htJet40[0] <= 1125:
                            event.cat.jetCat = "SR31"
                elif event.htJet40[0] < 300:
                    if event.tightLeps[0].charge > 0:
                        event.cat.jetCat = "SR25"
                    else:
                        event.cat.jetCat = "SR26"
                elif event.htJet40[0] >= 300 and event.htJet40[0] <= 1125:
                    if event.met_pt[0] < 200 and event.met_pt[0] > 50:
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2:
                            if event.tightLeps[0].charge > 0:
                                event.cat.jetCat = "SR32"
                            else:
                                event.cat.jetCat = "SR33"
                        elif event.nJet40_recal >= 5:
                            event.cat.jetCat = "SR34"
                    elif event.met_pt[0] < 300 and event.met_pt[0] > 200:
                        event.cat.jetCat = "SR34"
            if event.nJet25 >= 3 and event.nJet40_recal >= 2:
                if mt < 120:
                    if event.met_pt[0] < 200 and event.met_pt[0] > 50:
                        if event.htJet40[0] < 300 and event.tightLeps[
                                0].charge > 0:
                            event.cat.jetCat = "SR35"
                        if event.htJet40[0] < 300 and event.tightLeps[
                                0].charge < 0:
                            event.cat.jetCat = "SR36"
                        if event.htJet40[0] >= 300 and event.htJet40[
                                0] <= 1125 and event.tightLeps[0].charge > 0:
                            event.cat.jetCat = "SR37"
                        if event.htJet40[0] >= 300 and event.htJet40[
                                0] <= 1125 and event.tightLeps[0].charge < 0:
                            event.cat.jetCat = "SR38"
                    elif event.met_pt[0] < 300 and event.met_pt[0] > 200:
                        if event.htJet40[0] < 300 and event.tightLeps[
                                0].charge > 0:
                            event.cat.jetCat = "SR35"
                        if event.htJet40[0] < 300 and event.tightLeps[
                                0].charge < 0:
                            event.cat.jetCat = "SR36"
                        if event.htJet40[0] >= 300 and event.htJet40[0] <= 1125:
                            event.cat.jetCat = "SR39"
                else:
                    if event.met_pt[0] > 50 and event.met_pt[0] < 300:
                        if event.htJet40[0] < 300:
                            event.cat.jetCat = "SR40"
                        if event.htJet40[0] >= 300 and event.htJet40[0] <= 1125:
                            event.cat.jetCat = "SR41"

        if event.cat.lepCat == "HL":
            if event.htJet40[0] >= 1125 and event.htJet40[
                    0] <= 1300 and event.nJet40_recal >= 2 and event.met_pt[
                        0] >= 50 and event.met_pt[0] <= 300:
                if event.tightLeps[0].charge > 0:
                    event.cat.jetCat = "SR38"
                elif event.tightLeps[0].charge < 0:
                    event.cat.jetCat = "SR39"
            elif event.htJet40[0] >= 1300 and event.htJet40[
                    0] <= 1600 and event.nJet40_recal >= 2 and event.met_pt[
                        0] >= 50 and event.met_pt[0] <= 300:
                if event.tightLeps[0].charge > 0:
                    event.cat.jetCat = "SR40"
                elif event.tightLeps[0].charge < 0:
                    event.cat.jetCat = "SR41"

            if event.met_pt[0] >= 300 and event.met_pt[
                    0] <= 500 and event.nJet40_recal >= 2 and event.htJet40[
                        0] >= 300 and event.tightLeps[0].charge > 0:
                event.cat.jetCat = "SR34"
            if event.met_pt[0] >= 300 and event.met_pt[
                    0] <= 500 and event.nJet40_recal >= 2 and event.htJet40[
                        0] >= 300 and event.tightLeps[0].charge < 0:
                event.cat.jetCat = "SR35"
            if event.met_pt[
                    0] > 500 and event.nJet40_recal >= 2 and event.htJet40[
                        0] >= 300 and event.tightLeps[0].charge > 0:
                event.cat.jetCat = "SR36"
            if event.met_pt[
                    0] > 500 and event.nJet40_recal >= 2 and event.htJet40[
                        0] >= 300 and event.tightLeps[0].charge < 0:
                event.cat.jetCat = "SR37"
            if mt > 120 and event.met_pt[0] <= 300 and event.met_pt[
                    0] >= 50 and event.nJet40_recal >= 2 and event.htJet40[
                        0] < 300:
                event.cat.jetCat = "SR32"
            if mt > 120 and event.met_pt[0] <= 300 and event.met_pt[
                    0] >= 50 and event.nJet40_recal >= 2 and event.htJet40[
                        0] >= 300 and event.htJet40[0] <= 1125:
                event.cat.jetCat = "SR33"

            if event.nJet25 == 0:
                if mt < 120:
                    if event.met_pt[0] < 200 and event.met_pt[0] > 50:
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2:
                            if event.htJet40[0] < 300:
                                event.cat.jetCat = "SR1"
                            elif event.htJet40[0] <= 1125:
                                event.cat.jetCat = "SR2"
                        elif event.nJet40_recal >= 5:
                            if event.htJet40[0] < 300:
                                event.cat.jetCat = "SR3"
                            elif event.htJet40[0] <= 1125:
                                event.cat.jetCat = "SR4"
                    elif event.met_pt[0] < 300 and event.met_pt[0] > 200:
                        if event.htJet40[0] < 300:
                            event.cat.jetCat = "SR3"
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2 and event.htJet40[
                                0] >= 300 and event.htJet40[
                                    0] <= 1125 and event.tightLeps[
                                        0].charge > 0:
                            event.cat.jetCat = "SR5"
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2 and event.htJet40[
                                0] >= 300 and event.htJet40[
                                    0] <= 1125 and event.tightLeps[
                                        0].charge < 0:
                            event.cat.jetCat = "SR6"
                        if event.nJet40_recal >= 5 and event.htJet40[
                                0] >= 300 and event.htJet40[0] <= 1125:
                            event.cat.jetCat = "SR7"
            elif event.nJet25 == 1:
                if mt < 120:
                    if event.met_pt[0] < 200 and event.met_pt[0] > 50:
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2:
                            if event.htJet40[0] < 300:
                                event.cat.jetCat = "SR8"
                            elif event.htJet40[0] <= 1125:
                                event.cat.jetCat = "SR9"
                        elif event.nJet40_recal >= 5:
                            if event.htJet40[0] < 300 and event.tightLeps[
                                    0].charge > 0:
                                event.cat.jetCat = "SR10"
                            if event.htJet40[0] < 300 and event.tightLeps[
                                    0].charge < 0:
                                event.cat.jetCat = "SR11"
                            if event.htJet40[0] <= 1125 and event.htJet40[
                                    0] >= 300 and event.tightLeps[0].charge > 0:
                                event.cat.jetCat = "SR12"
                            if event.htJet40[0] <= 1125 and event.htJet40[
                                    0] >= 300 and event.tightLeps[0].charge < 0:
                                event.cat.jetCat = "SR13"
                    elif event.met_pt[0] < 300 and event.met_pt[0] > 200:
                        if event.htJet40[0] < 300 and event.tightLeps[
                                0].charge > 0:
                            event.cat.jetCat = "SR10"
                        if event.htJet40[0] < 300 and event.tightLeps[
                                0].charge < 0:
                            event.cat.jetCat = "SR11"
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2 and event.htJet40[
                                0] >= 300 and event.htJet40[0] <= 1125:
                            event.cat.jetCat = "SR14"
                        if event.nJet40_recal >= 5 and event.htJet40[
                                0] >= 300 and event.htJet40[
                                    0] <= 1125 and event.tightLeps[
                                        0].charge > 0:
                            event.cat.jetCat = "SR16"
                        if event.nJet40_recal >= 5 and event.htJet40[
                                0] >= 300 and event.htJet40[
                                    0] <= 1125 and event.tightLeps[
                                        0].charge < 0:
                            event.cat.jetCat = "SR17"
            elif event.nJet25 == 2:
                if mt < 120:
                    if event.met_pt[0] < 200 and event.met_pt[0] > 50:
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2:
                            if event.htJet40[0] < 300:
                                event.cat.jetCat = "SR18"
                            elif event.htJet40[0] <= 1125:
                                event.cat.jetCat = "SR19"
                        elif event.nJet40_recal >= 5:
                            if event.htJet40[0] < 300 and event.tightLeps[
                                    0].charge > 0:
                                event.cat.jetCat = "SR20"
                            if event.htJet40[0] < 300 and event.tightLeps[
                                    0].charge < 0:
                                event.cat.jetCat = "SR21"
                            if event.htJet40[0] <= 1125 and event.htJet40[
                                    0] >= 300 and event.tightLeps[0].charge > 0:
                                event.cat.jetCat = "SR22"
                            if event.htJet40[0] <= 1125 and event.htJet40[
                                    0] >= 300 and event.tightLeps[0].charge < 0:
                                event.cat.jetCat = "SR23"
                    elif event.met_pt[0] < 300 and event.met_pt[0] > 200:
                        if event.htJet40[0] < 300 and event.tightLeps[
                                0].charge > 0:
                            event.cat.jetCat = "SR20"
                        if event.htJet40[0] < 300 and event.tightLeps[
                                0].charge < 0:
                            event.cat.jetCat = "SR21"
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2 and event.htJet40[
                                0] >= 300 and event.htJet40[
                                    0] <= 1125 and event.tightLeps[
                                        0].charge > 0:
                            event.cat.jetCat = "SR24"
                        if event.nJet40_recal <= 4 and event.nJet40_recal >= 2 and event.htJet40[
                                0] >= 300 and event.htJet40[
                                    0] <= 1125 and event.tightLeps[
                                        0].charge < 0:
                            event.cat.jetCat = "SR25"
                        if event.nJet40_recal >= 5 and event.htJet40[
                                0] >= 300 and event.htJet40[0] <= 1125:
                            event.cat.jetCat = "SR26"
            if event.nJet25 >= 3 and event.nJet40_recal >= 2:
                if mt < 120:
                    if event.met_pt[0] < 200 and event.met_pt[0] > 50:
                        if event.htJet40[0] < 300 and event.tightLeps[
                                0].charge > 0:
                            event.cat.jetCat = "SR27"
                        if event.htJet40[0] < 300 and event.tightLeps[
                                0].charge < 0:
                            event.cat.jetCat = "SR28"
                        if event.htJet40[0] >= 300 and event.htJet40[
                                0] <= 1125 and event.tightLeps[0].charge > 0:
                            event.cat.jetCat = "SR29"
                        if event.htJet40[0] >= 300 and event.htJet40[
                                0] <= 1125 and event.tightLeps[0].charge < 0:
                            event.cat.jetCat = "SR30"
                    elif event.met_pt[0] < 300 and event.met_pt[0] > 200:
                        if event.htJet40[0] < 300 and event.tightLeps[
                                0].charge > 0:
                            event.cat.jetCat = "SR27"
                        if event.htJet40[0] < 300 and event.tightLeps[
                                0].charge < 0:
                            event.cat.jetCat = "SR28"
                        if event.htJet40[0] >= 300 and event.htJet40[0] <= 1125:
                            event.cat.jetCat = "SR31"

        if event.cat.lepCat == "LL":
            if event.nJet40_recal >= 2 and event.htJet40[0] > 300:
                if mt > 120 and event.met_pt[0] >= 50:
                    event.cat.jetCat = "SR8"
                if event.nJet25 >= 3 and mt < 120 and event.met_pt[0] >= 50:
                    event.cat.jetCat = "SR7"
                if event.nJet25 == 0 and mt < 120 and event.met_pt[
                        0] >= 50 and event.met_pt[0] <= 200:
                    event.cat.jetCat = "SR1"
                if event.nJet25 == 0 and mt < 120 and event.met_pt[0] >= 200:
                    event.cat.jetCat = "SR2"
                if event.nJet25 == 1 and mt < 120 and event.met_pt[
                        0] >= 50 and event.met_pt[0] <= 200:
                    event.cat.jetCat = "SR3"
                if event.nJet25 == 1 and mt < 120 and event.met_pt[0] >= 200:
                    event.cat.jetCat = "SR4"
                if event.nJet25 == 2 and mt < 120 and event.met_pt[
                        0] >= 50 and event.met_pt[0] <= 200:
                    event.cat.jetCat = "SR5"
                if event.nJet25 == 2 and mt < 120 and event.met_pt[0] >= 200:
                    event.cat.jetCat = "SR6"
        #print(event.cat.jetCat)
        #event.cat.lepCat.__dict__
        return True
 def analyze(self,event):
     electrons = Collection(event,"Electron")
     event.selElectrons = [el for el in electrons if self.idSelection(el) and self.isoSelection(el) and self.otherSelection(el)]
     return True
Exemplo n.º 16
0
    def __call__(self, event):
        self.ev = event
        fullret = {}
        leps = [l for l in Collection(event, "LepGood")]
        if not self.coneptdef:
            raise RuntimeError, 'Choose the definition to be used for cone pt'
        for lep in leps:
            lep.conept = self.coneptdef(lep)
        tausc = [t for t in Collection(event, "TauGood")]
        tausd = [t for t in Collection(event, "TauOther")]
        jetsc = {}
        jetsd = {}
        for var in self.systsJEC:
            _var = var
            if not hasattr(event, "nJet" + self.systsJEC[var]):
                _var = 0
                if not self.debugprinted:
                    print '-' * 15
                    print 'WARNING: jet energy scale variation %s not found, will set it to central value' % self.systsJEC[
                        var]
                    print '-' * 15
            jetsc[var] = [
                j for j in Collection(event, "Jet" + self.systsJEC[_var])
            ]
            jetsd[var] = [
                j for j in Collection(event, "DiscJet" + self.systsJEC[_var])
            ]
        self.debugprinted = True
        ret = {}
        retwlabel = {}
        jetret = {}
        discjetret = {}
        lepsl = []
        lepslv = []
        ret, lepsl, lepslv = self.fillCollWithVeto(ret,
                                                   leps,
                                                   leps,
                                                   'L',
                                                   'Loose',
                                                   self.looseLeptonSel,
                                                   lepsforveto=None,
                                                   doVetoZ=self.doVetoZ,
                                                   doVetoLM=self.doVetoLMf,
                                                   sortby=None)
        lepsc = []
        lepscv = []
        ret, lepsc, lepscv = self.fillCollWithVeto(ret,
                                                   leps,
                                                   lepsl,
                                                   'C',
                                                   'Cleaning',
                                                   self.cleaningLeptonSel,
                                                   lepsforveto=lepsl,
                                                   doVetoZ=self.doVetoZ,
                                                   doVetoLM=self.doVetoLMf,
                                                   sortby=None)

        ret['mZ1'] = bestZ1TL(lepsl, lepsl)
        ret['minMllAFAS'] = minMllTL(lepsl, lepsl)
        ret['minMllAFOS'] = minMllTL(
            lepsl, lepsl, paircut=lambda l1, l2: l1.charge != l2.charge)
        ret['minMllAFSS'] = minMllTL(
            lepsl, lepsl, paircut=lambda l1, l2: l1.charge == l2.charge)
        ret['minMllSFOS'] = minMllTL(
            lepsl, lepsl, paircut=lambda l1, l2: l1.pdgId == -l2.pdgId)

        loosetaus = []
        rettlabel = {}
        tauret = {}
        loosetaus = self.recleanTaus(
            tausc, tausd, lepsl if self.cleanTausWithLoose else lepsc,
            self.label, rettlabel, tauret, event)

        cleanjets = {}
        for var in self.systsJEC:
            cleanjets[var] = self.recleanJets(
                jetsc[var], jetsd[var],
                lepsc + loosetaus if self.cleanJetsWithTaus else lepsc,
                self.label + self.systsJEC[var], retwlabel, jetret, discjetret)

        # calculate FOs and tight leptons using the cleaned HT, sorted by conept
        lepsf = []
        lepsfv = []
        ret, lepsf, lepsfv = self.fillCollWithVeto(
            ret,
            leps,
            lepsl,
            'F',
            'FO',
            self.FOLeptonSel,
            lepsforveto=lepsl,
            ht=retwlabel["htJet" + self.strJetPt + "j" + self.label],
            sortby=lambda x: x.conept,
            doVetoZ=self.doVetoZ,
            doVetoLM=self.doVetoLMf)
        lepst = []
        lepstv = []
        ret, lepst, lepstv = self.fillCollWithVeto(
            ret,
            leps,
            lepsl,
            'T',
            'Tight',
            self.tightLeptonSel,
            lepsforveto=lepsl,
            ht=retwlabel["htJet" + self.strJetPt + "j" + self.label],
            sortby=lambda x: x.conept,
            doVetoZ=self.doVetoZ,
            doVetoLM=self.doVetoLMt)

        ### attach labels and return
        fullret["nLepGood"] = len(leps)
        fullret["LepGood_conePt"] = [lep.conept for lep in leps]
        for k, v in ret.iteritems():
            fullret[k + self.label] = v
        fullret.update(retwlabel)
        fullret.update(rettlabel)
        for k, v in tauret.iteritems():
            fullret["TauSel%s_%s" % (self.label, k)] = v
        for k, v in jetret.iteritems():
            fullret["JetSel%s_%s" % (self.label, k)] = v
        return fullret
Exemplo n.º 17
0
    def analyze(self, event):
        event.photons = Collection(event, "PhoGood")
        event.selPhotons = [p for p in event.photons if self.isTightPho(p)]
        event.selPhotons.sort(key=lambda x: x.pt, reverse=True)

        return True
Exemplo n.º 18
0
 def analyze(self,event):
     muons = Collection(event,"Muon")
     event.selMuons = [mu for mu in muons if self.idSelection(mu) and self.isoSelection(mu) and self.otherSelection(mu)]
     return True