def makeMETV(self, event): output = [] # loop on the leptons leptons = filter( lambda x: (abs(x.pdgId()) == 11 and x.heepID) or (abs(x.pdgId()) == 13 and x.highPtIDIso), event.selectedLeptons) fatJets = self.selectJets( event.jetsAK8, lambda x: x.pt() > 200.0 and abs(x.eta()) < 2.4 and x.jetID('POG_PFID_Tight'), leptons, 1.0) if len(fatJets) < 1: return output self.substructure(fatJets[0]) VV = Pair(event.met, fatJets[0]) # kinematics if VV.deltaPhi() < 2.0 or VV.leg1.pt() < 200: return output if self.cfg_comp.isMC: self.softDropGen(fatJets[0], event) VVGEN = Pair(event.met, Singlet(VV.leg2.genJet().p4())) VV.genPartialMass = VVGEN.mt() else: VV.genPartialMass = -1 # topology satteliteJets = self.selectJets( event.jets, lambda x: x.pt() > 30.0 and x.jetID('POG_PFID_Tight'), leptons, 0.3, [VV.leg2], 0.8) self.topology(VV, satteliteJets, leptons) output.append(VV) return output
def makeWV(self, event): output = [] # loop on the leptons looseLeptonsForW = filter(lambda x: (abs(x.pdgId()) == 11 and x.heepID) or ( abs(x.pdgId()) == 13 and x.highPtIDIso), event.selectedLeptons) tightLeptonsForW = filter(lambda x: (abs(x.pdgId()) == 11 and x.heepID and x.pt() > 55) or ( abs(x.pdgId()) == 13 and x.highPtIDIso and x.pt() > 55), event.selectedLeptons) if len(tightLeptonsForW) == 0: return output # make leptonic W W = self.vbTool.makeW(tightLeptonsForW, event.met) if len(W) == 0: return output bestW = max(W, key=lambda x: x.leg1.pt()) # now the jets, use lower pT cut since we'll recluster fatJets = self.selectJets(event.jetsAK8, lambda x: x.pt() > 200.0 and abs( x.eta()) < 2.4 and x.jetID('POG_PFID_Tight'), tightLeptonsForW, 1.0) if len(fatJets) == 0: return output bestJet = max(fatJets, key=lambda x: x.pt()) self.substructure(bestJet) self.softDropRECO(bestJet,event) VV = Pair(bestW, bestJet) if deltaR(bestW.leg1.eta(), bestW.leg1.phi(), bestJet.eta(), bestJet.phi()) < ROOT.TMath.Pi() / 2.0: return output if VV.deltaPhi() < 2.0: return output if abs(deltaPhi(bestW.leg2.phi(), bestJet.phi())) < 2.0: return output if self.cfg_comp.isMC: self.softDropGen(bestJet,event) if not hasattr(bestJet,'genJetP4'): VV.genPartialMass = -1 else: newMET = event.met.p4() + VV.leg2.p4() - VV.leg2.genJetP4 newMET.SetPz(0.0) newW = Pair(VV.leg1.leg1, Singlet(newMET)) self.vbTool.defaultWKinematicFit(newW) VV.genPartialMass = ( VV.leg1.p4() + VV.leg2.genJetP4 ).M() else: VV.genPartialMass = -1 # topology satteliteJets = self.selectJets(event.jets, lambda x: x.pt() > 30.0 and x.jetID( 'POG_PFID_Tight'), tightLeptonsForW, 0.4, [bestJet], 0.8) otherLeptons = self.cleanOverlap(looseLeptonsForW, [bestW.leg1]) self.topology(VV, satteliteJets, otherLeptons) output.append(VV) return output
def makeZV(self, event): output = [] # loop on the leptons leptonsForZ = filter( lambda x: (abs(x.pdgId()) == 11 and x.heepIDNoIso) or (abs(x.pdgId()) == 13 and (x.highPtID or x.highPtTrackID)), event.selectedLeptons) if len(leptonsForZ) < 2: return output # make leptonic Z Z = self.vbTool.makeZ(leptonsForZ) if len(Z) == 0: return output bestZ = max(Z, key=lambda x: x.pt()) # other higbn pt isolated letpons in the event otherGoodLeptons = self.cleanOverlap(leptonsForZ, [bestZ.leg1, bestZ.leg2]) otherTightLeptons = filter( lambda x: (abs(x.pdgId()) == 11 and x.heepID) or (abs(x.pdgId()) == 13 and (x.highPtIDIso)), otherGoodLeptons) # now the jets fatJets = self.selectJets( event.jetsAK8, lambda x: x.pt() > 200.0 and abs(x.eta()) < 2.4 and x.jetID('POG_PFID_Tight'), [bestZ.leg1, bestZ.leg2], 1.0) if len(fatJets) == 0: return output bestJet = max(fatJets, key=lambda x: x.pt()) self.substructure(bestJet) VV = Pair(bestZ, bestJet) if self.cfg_comp.isMC: self.softDropGen(bestJet, event) VV.genPartialMass = (VV.leg1.p4() + VV.leg2.genJet().p4()).M() else: VV.genPartialMass = -1 satteliteJets = self.selectJets( event.jets, lambda x: x.pt() > 30.0 and x.jetID('POG_PFID_Tight'), otherTightLeptons, 0.4, [bestJet], 0.8) self.topology(VV, satteliteJets, otherTightLeptons) output.append(VV) return output
def makeZV(self, event): output = [] # loop on the leptons leptonsForZ = filter(lambda x: (abs(x.pdgId()) == 11 and x.heepIDNoIso) or ( abs(x.pdgId()) == 13 and (x.highPtID or x.highPtTrackID)), event.selectedLeptons) if len(leptonsForZ) < 2: return output # make leptonic Z Z = self.vbTool.makeZ(leptonsForZ) if len(Z) == 0: return output bestZ = max(Z, key=lambda x: x.pt()) # other higbn pt isolated letpons in the event otherGoodLeptons = self.cleanOverlap( leptonsForZ, [bestZ.leg1, bestZ.leg2]) otherTightLeptons = filter(lambda x: (abs(x.pdgId()) == 11 and x.heepID) or ( abs(x.pdgId()) == 13 and (x.highPtIDIso)), otherGoodLeptons) # now the jets fatJets = self.selectJets(event.jetsAK8, lambda x: x.pt() > 200.0 and abs( x.eta()) < 2.4 and x.jetID('POG_PFID_Loose'), [bestZ.leg1, bestZ.leg2], 1.0) if len(fatJets) == 0: return output bestJet = max(fatJets, key=lambda x: x.pt()) VV = Pair(bestZ, bestJet) # substructure self.substructure(VV.leg2, event) # substructure changes jet, so we need to recalculate the resonance # mass VV = Pair(bestZ, bestJet) if not hasattr(VV.leg2, "substructure"): return output if self.cfg_comp.isMC: self.substructureGEN(VV.leg2, event) if hasattr(VV.leg2, 'substructureGEN'): VV.genPartialMass = (VV.leg1.p4() + VV.leg2.substructureGEN.jet).M() # check if there are subjets # if len(VV.leg2.substructure.prunedSubjets)<2: # print 'No substructure',len(VV.leg2.substructure.prunedSubjets) # return output # topology satteliteJets = self.selectJets(event.jets, lambda x: x.pt() > 30.0 and x.jetID( 'POG_PFID_Loose'), otherTightLeptons, 0.4, [bestJet], 0.8) self.topology(VV, satteliteJets, otherTightLeptons) output.append(VV) return output
def makeJJ(self, event): output = [] # loop on the leptons leptons = filter( lambda x: (abs(x.pdgId()) == 11 and x.heepID) or (abs(x.pdgId()) == 13 and x.highPtIDIso), event.selectedLeptons) fatJets = self.selectJets( event.jetsAK8, lambda x: x.pt() > 200.0 and abs(x.eta()) < 2.4 and x.jetID('POG_PFID_Tight'), leptons, 1.0) if len(fatJets) < 2: return output VV = Pair(fatJets[0], fatJets[1]) # kinematics if abs(VV.leg1.eta() - VV.leg2.eta()) > 1.3 or VV.mass() < 1000: return output self.substructure(VV.leg1, event) self.substructure(VV.leg2, event) # substructure changes jet, so we need to recalculate the resonance # mass VV = Pair(fatJets[0], fatJets[1]) # substructure truth if self.cfg_comp.isMC: self.substructureGEN(VV.leg2, event) self.substructureGEN(VV.leg1, event) if hasattr(VV.leg2, 'substructureGEN') and hasattr( VV.leg1, 'substructureGEN'): VV.genPartialMass = (VV.leg1.substructureGEN.jet + VV.leg2.substructureGEN.jet).M() if not hasattr(VV.leg1, "substructure"): return output if not hasattr(VV.leg2, "substructure"): return output # check if there are subjets # if len(VV.leg2.substructure.prunedSubjets)<2 or len(VV.leg1.substructure.prunedSubjets)<2: # print 'No substructure' # return output # topology satteliteJets = self.selectJets( event.jets, lambda x: x.pt() > 30.0 and x.jetID('POG_PFID_Tight'), leptons, 0.3, [VV.leg1, VV.leg2], 0.8) self.topology(VV, satteliteJets, leptons) output.append(VV) return output
def makeMETV(self, event): output = [] # loop on the leptons leptons = filter(lambda x: (abs(x.pdgId()) == 11 and x.heepID) or ( abs(x.pdgId()) == 13 and x.highPtIDIso), event.selectedLeptons) fatJets = self.selectJets(event.jetsAK8, lambda x: x.pt() > 200.0 and abs( x.eta()) < 2.4 and x.jetID('POG_PFID_Loose'), leptons, 1.0) if len(fatJets) < 1: return output VV = Pair(event.met, fatJets[0]) # kinematics if VV.deltaPhi() < 2.0 or VV.leg1.pt() < 200: return output self.substructure(VV.leg2, event) if not hasattr(VV.leg2, "substructure"): return output # substructure changes jet, so we need to recalculate the resonance # mass VV = Pair(event.met, fatJets[0]) # check if there are subjets # if len(VV.leg2.substructure.prunedSubjets)<2: # print 'No substructure' # return output if self.cfg_comp.isMC: self.substructureGEN(VV.leg2, event) if hasattr(VV.leg2, 'substructureGEN'): VVGEN = Pair(event.met,Singlet(VV.leg2.substructureGEN.jet)) VV.genPartialMass = VVGEN.mt() # topology satteliteJets = self.selectJets(event.jets, lambda x: x.pt() > 30.0 and x.jetID( 'POG_PFID_Loose'), leptons, 0.3, [VV.leg2], 0.8) self.topology(VV, satteliteJets, leptons) output.append(VV) return output
def makeWV(self, event): output = [] # loop on the leptons looseLeptonsForW = filter(lambda x: (abs(x.pdgId()) == 11 and x.heepID) or ( abs(x.pdgId()) == 13 and x.highPtIDIso), event.selectedLeptons) tightLeptonsForW = filter(lambda x: (abs(x.pdgId()) == 11 and x.heepID and x.pt() > 55) or ( abs(x.pdgId()) == 13 and x.highPtIDIso and x.pt() > 55), event.selectedLeptons) if len(tightLeptonsForW) == 0: return output # make leptonic W W = self.vbTool.makeW(tightLeptonsForW, event.met) if len(W) == 0: return output bestW = max(W, key=lambda x: x.leg1.pt()) # now the jets, use lower pT cut since we'll recluster fatJets = self.selectJets(event.jetsAK8, lambda x: x.pt() > 150.0 and abs( x.eta()) < 2.4 and x.jetID('POG_PFID_Loose'), tightLeptonsForW, 1.0) if len(fatJets) == 0: return output bestJet = max(fatJets, key=lambda x: x.pt()) VV = Pair(bestW, bestJet) if deltaR(bestW.leg1.eta(), bestW.leg1.phi(), bestJet.eta(), bestJet.phi()) < ROOT.TMath.Pi() / 2.0: return output if VV.deltaPhi() < 2.0: return output if abs(deltaPhi(bestW.leg2.phi(), bestJet.phi())) < 2.0: return output # substructure self.substructure(VV.leg2, event) if not hasattr(VV.leg2, 'substructure'): return output # substructure function has reclustered jet, so we need to check the pT # again if not VV.leg2.pt() > 200.: return output # also recalculate the resonance mass four vector VV = Pair(bestW, bestJet) # substructure truth if self.cfg_comp.isMC: self.substructureGEN(VV.leg2, event) if hasattr(VV.leg2, 'substructureGEN'): newMET = event.met.p4() + VV.leg2.p4() - VV.leg2.substructureGEN.jet newMET.SetPz(0.0) newW = Pair(VV.leg1.leg1, Singlet(newMET)) self.vbTool.defaultWKinematicFit(newW) VV.genPartialMass = ( VV.leg1.p4() + VV.leg2.substructureGEN.jet).M() # topology satteliteJets = self.selectJets(event.jets, lambda x: x.pt() > 30.0 and x.jetID( 'POG_PFID_Loose'), tightLeptonsForW, 0.4, [bestJet], 0.8) otherLeptons = self.cleanOverlap(looseLeptonsForW, [bestW.leg1]) self.topology(VV, satteliteJets, otherLeptons) output.append(VV) return output
def makeJJ(self, event): output = [] if len(event.jetsAK8) == 0: return output if not (event.jetsAK8[0].jetID('POG_PFID_TightLepVeto')): return output evt = event.input.eventAuxiliary().id().event() lumi = event.input.eventAuxiliary().id().luminosityBlock() run = event.input.eventAuxiliary().id().run() debug = False #if evt == 7276 and lumi == 43: debug = True #if not debug: return output if debug: print "******** FOUND EVENT ************* ", run, lumi, evt # loop on the leptons leptons = filter( lambda x: (abs(x.pdgId()) == 11 and x.heepID) or (abs(x.pdgId()) == 13 and x.highPtIDIso), event.selectedLeptons) fatJets = self.selectJets( event.jetsAK8, lambda x: x.pt() > 200.0 and abs(x.eta()) < 2.4 and x.jetID('POG_PFID_TightLepVeto'), leptons, 0.8) if len(fatJets) < 2: return output if debug: print "----------------- BEFORE SORTING ----------------- " i = 1 for j in fatJets: if debug: print " * jet ", i, " pt ", j.pt(), " eta ", j.eta( ), " phi ", j.phi() i += 1 fatJets = fatJets[:2] if evt % 2 != 0: fatJets = list(reversed(fatJets)) if debug: print "----------------- AFTER SORTING ----------------- " i = 1 for j in fatJets: #print " * jet ",i," pt ", j.pt(), " eta ", j.eta(), " mass no corr ",j.substructure.softDropJetMassBare, " mass corr ",j.substructure.softDropJetMassBare*j.substructure.softDropJetMassCor," tau21 ", j.substructure.ntau[1]/j.substructure.ntau[0] print " * jet ", i, " pt ", j.pt(), " eta ", j.eta() i += 1 VV = Pair(fatJets[0], fatJets[1]) # kinematics if abs(VV.leg1.eta() - VV.leg2.eta()) > 1.3 or VV.mass() < 700: return output self.substructure(VV.leg1, event) self.substructure(VV.leg2, event) # substructure changes jet, so we need to recalculate the resonance mass VV = Pair(fatJets[0], fatJets[1]) if debug: print "----------------- AFTER PARING ----------------- " print " * VV leg1 pt ", VV.leg1.pt(), " eta ", VV.leg1.eta() print " * VV leg2 pt ", VV.leg2.pt(), " eta ", VV.leg2.eta() print " === VV mass ", VV.mass(), " deta ", abs( VV.leg1.eta() - VV.leg2.eta()), " ======" # substructure truth if self.cfg_comp.isMC: self.substructureGEN(VV.leg2, event) self.substructureGEN(VV.leg1, event) if hasattr(VV.leg2, 'substructureGEN') and hasattr( VV.leg1, 'substructureGEN'): VV.genPartialMass = (VV.leg1.substructureGEN.jet + VV.leg2.substructureGEN.jet).M() if debug: print " === VV gen mass ", ( VV.leg1.substructureGEN.jet + VV.leg2.substructureGEN.jet).M(), " ======" if not hasattr(VV.leg1, "substructure"): return output if not hasattr(VV.leg2, "substructure"): return output # check if there are subjets # if len(VV.leg2.substructure.prunedSubjets)<2 or len(VV.leg1.substructure.prunedSubjets)<2: # print 'No substructure' # return output # topology satteliteJets = self.selectJets( event.jets, lambda x: x.pt() > 30.0 and x.jetID('POG_PFID_Tight'), leptons, 0.3, [VV.leg1, VV.leg2], 0.8) self.topology(VV, satteliteJets, leptons) output.append(VV) return output