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 #check if there are subjets # if len(VV.leg2.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_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() > 120) or (abs(x.pdgId()) == 13 and x.highPtIDIso and x.pt() > 53 and abs( x.eta()) < 2.1), 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 fatJets = self.selectJets( event.jetsAK8, lambda x: x.pt() > 200.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 #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'), tightLeptonsForW, 0.3, [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_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 makeTauTau(self,event,taus): output=[] #If two di-taus build pair taus=sorted(taus,key=lambda x: x.pt(),reverse=True) if len(taus)>1: VV=Pair(taus[0],taus[1]) VV.LV=VV.LV+event.met.p4() 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_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 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 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 truth if self.cfg_comp.isMC: self.substructureGEN(VV.leg2, event) self.substructureGEN(VV.leg1, event) 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_Loose'), leptons, 0.3, [VV.leg1, VV.leg2], 0.8) self.topology(VV, satteliteJets, leptons) output.append(VV) return output
def makeTauJet(self,event,taus,jets): output=[] #If two di-taus build pair but you need a lepton! if len(taus)>0 and len(jets)>0: #since we trigger with lepton find taus that have a lepton tausWithLeptons=[] for t in taus: if t.nMuons+t.nElectrons>0: leptonsOK=False for c in t.signalConstituents: if abs(c.pdgId()) ==11: leptonsOK=True break; if abs(c.pdgId()) ==13: leptonsOK=True break; if leptonsOK: tausWithLeptons.append(t) if len(tausWithLeptons)==0: return output tau=max(tausWithLeptons,key=lambda x:x.pt()) #cross clean jets crossCleanedJets = [] for jet in jets: if deltaR(jet.eta(),jet.phi(),tau.eta(),tau.phi())>0.5: if deltaPhi(jet.phi(),tau.phi())>0.5: crossCleanedJets.append(jet) if len(crossCleanedJets)==0: return output; jet=max(crossCleanedJets,key=lambda x:x.pt()) self.substructure(jet) if not hasattr(jet,'substructure'): print 'No substructure' return output VV=Pair(tau,jet) VV.LVWithMET=VV.LV+event.met.p4() 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 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 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_Tight'), leptons, 0.3, [VV.leg2], 0.8) self.topology(VV, satteliteJets, leptons) output.append(VV) return output
def process(self, event): super(JJ, self).process(event) output = [] if self.cfg_ana.doCHS: cleanedPackedCandidates = filter(lambda x: x.fromPV(0), event.packedCandidatesForJets) else: cleanedPackedCandidates = event.packedCandidatesForJets #create Fat Jets selectedFatJets = self.makeFatJets(cleanedPackedCandidates) if self.isMC: self.matchSubJets(selectedFatJets, event.genwzquarks) for j1, j2 in itertools.combinations(selectedFatJets, 2): if j1.softDropJet.mass() < j2.softDropJet.mass(): VV = Pair(j1, j2) else: VV = Pair(j2, j1) if self.selectPair(VV): selected = {'pair': VV} remainingCands = self.removeJetFootPrint( [j1, j2], event.packedCandidatesForJets) selected['satelliteJets'] = self.makeSatelliteJets( remainingCands) #add VBF info self.vbfTopology(selected) output.append(selected) if len(output) > 0: output = sorted( output, key=lambda x: x['pair'].leg1.pt() + x['pair'].leg2.pt(), reverse=True) setattr(event, 'JJ' + self.cfg_ana.suffix, output) return True
def makeTauJet(self, event, taus, jets): output = [] #If two di-taus build pair but you need a lepton! if len(taus) > 0 and len(jets) > 0: #since we trigger with lepton find taus that have a lepton tausWithLeptons = [] for t in taus: if t.nMuons + t.nElectrons > 0: leptonsOK = False for c in t.signalConstituents: if abs(c.pdgId()) == 11 and c.pt() > 100.0: leptonsOK = True break if abs(c.pdgId()) == 13 and c.pt() > 55.0: leptonsOK = True break if leptonsOK: tausWithLeptons.append(t) if len(tausWithLeptons) == 0: return output tau = max(tausWithLeptons, key=lambda x: x.pt()) jet = max(jets, key=lambda x: x.pt()) if deltaPhi(tau.phi(), jet.phi()) < 1: return output self.substructure(jet) if not hasattr(jet, 'substructure'): print 'No substructure' return output VV = Pair(tau, jet) VV.LV = VV.LV + event.met.p4() output.append(VV) return output
def process(self, event): super(LLJJ, self).process(event) output = [] #read the W for w in event.LL: leptons = [w.leg1, w.leg2] cleanedPackedCandidates = self.removeLeptonFootPrint( leptons, event.packedCandidatesForJets) if self.cfg_ana.doCHS: cleanedPackedCandidates = filter(lambda x: x.fromPV(0), cleanedPackedCandidates) #apply selections selectedFatJets = self.makeFatJets(cleanedPackedCandidates) if self.isMC: self.matchSubJets(selectedFatJets, event.genwzquarks) for fat in selectedFatJets: VV = Pair(w, fat) if self.selectPair(VV): selected = {'pair': VV} remainingCands = self.removeJetFootPrint( [fat], cleanedPackedCandidates) selected['satelliteJets'] = self.makeSatelliteJets( remainingCands) #add VBF info self.vbfTopology(selected) output.append(selected) # import pdb;pdb.set_trace() if len(output) > 0: output = sorted(output, key=lambda x: x['pair'].leg2.pt(), reverse=True) # print 'Masses',output[0]['pair'].p4().M(),(output[0]['pair'].leg1.alternateLV+output[0]['pair'].leg2.p4()).M() , 'Delta',abs(output[0]['pair'].leg1.pz()+output[0]['pair'].leg2.pz()),abs(output[0]['pair'].leg1.alternateLV.pz()+output[0]['pair'].leg2.pz()) setattr(event, 'LLJJ' + self.cfg_ana.suffix, output) return True
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 process(self, event): super(MultiFinalState,self).process(event) LNuJJ=[] LLJJ =[] JJ=[] JJNuNu=[] TopCR=[] leadJetConstituents=[] #clean leptons from reconstructed W->lnu and Z-> LL and make jets goldenLeptonsList=[] for W in event.LNu: goldenLeptonsList.append(W.leg1) for Z in event.LL: goldenLeptonsList.append(Z.leg1) goldenLeptonsList.append(Z.leg2) goldenLeptonsSet=set(goldenLeptonsList) goldenLeptons=list(goldenLeptonsSet) if self.doSkim and not self.skim(goldenLeptons,event.met): return False cleanedPackedCandidates = self.removeLeptonFootPrint(goldenLeptons,event.packedCandidatesForJets) if self.cfg_ana.doCHS: cleanedPackedCandidates = filter(lambda x: x.fromPV(0) ,cleanedPackedCandidates) elif self.cfg_ana.doPUPPI: cleanedPackedCandidates = self.puppiWeight(cleanedPackedCandidates) selectedFatJets = self.makeFatJets(cleanedPackedCandidates) if self.isMC: self.matchSubJets(selectedFatJets,event.genwzquarks) #Before the signal selection lets look at the top control region #This can have overlap with the signal region if len(event.LNu)>0: bestW = max(event.LNu,key = lambda x: x.leg1.pt()) #find the jets in the opposite hemisphere of the lepton oppositeHemishereJets=[] for jet in selectedFatJets: if jet.pt()>200 and deltaPhi(jet.phi(),bestW.phi())>3.14/2.: oppositeHemishereJets.append(jet) if len(oppositeHemishereJets)>0: bestJet = max(oppositeHemishereJets,key=lambda x: x.prunedJet.mass()) VV=Pair(bestW,bestJet) selected = {'pair':VV} #Additional leptons selected['otherLeptons'] = list(goldenLeptonsSet-set([VV.leg1.leg1])) remainingCands =self.removeJetFootPrint([bestJet],cleanedPackedCandidates) selected['satelliteJets']=self.makeSatelliteJets(remainingCands) self.topology(selected) TopCR.append(selected) finished= False #OK lets start from LL+JJ that has the highest purity #take the Z->ll nearest to the Z mass and the highest pt jets if len(event.LL)>0 and not finished: bestZ = min(event.LL,key = lambda x: abs(x.M()-91.118)) for jet in selectedFatJets: VV=Pair(bestZ,jet) if self.selectPairLL(VV): selected = {'pair':VV} remainingCands =self.removeJetFootPrint([jet],cleanedPackedCandidates) selected['satelliteJets']=self.makeSatelliteJets(remainingCands) leadJetConstituents=jet.prunedJet.constituents #Additional leptons selected['otherLeptons'] = list(goldenLeptonsSet-set([VV.leg1.leg1,VV.leg1.leg2])) #add VBF info self.topology(selected) LLJJ.append(selected) finished=True break; #OK Now the W . Highest Pt lepton + j if len(event.LNu)>0 and not finished: bestW = max(event.LNu,key = lambda x: x.leg1.pt()) for jet in selectedFatJets: VV=Pair(bestW,jet) if self.selectPairLNu(VV): selected = {'pair':VV} remainingCands =self.removeJetFootPrint([jet],cleanedPackedCandidates) selected['satelliteJets']=self.makeSatelliteJets(remainingCands) leadJetConstituents=jet.prunedJet.constituents #Additional leptons selected['otherLeptons'] = list(goldenLeptonsSet-set([VV.leg1.leg1])) #add VBF info self.topology(selected) LNuJJ.append(selected) finished=True break; #Now look for jet+MET if len(selectedFatJets)>0 and not finished: jet = selectedFatJets[0] VV=Pair(event.met,jet) if self.selectPairJJNuNu(VV): selected = {'pair':VV} remainingCands =self.removeJetFootPrint([jet],cleanedPackedCandidates) selected['satelliteJets']=self.makeSatelliteJets(remainingCands) leadJetConstituents=jet.prunedJet.constituents #Additional leptons selected['otherLeptons'] = goldenLeptons #add VBF info self.topology(selected) JJNuNu.append(selected) finished=True #Now look for jet+jet if len(selectedFatJets)>1 and not finished: jet1 = selectedFatJets[0] jet2 = selectedFatJets[1] VV=Pair(jet1,jet2) if self.selectPairJJ(VV): selected = {'pair':VV} remainingCands =self.removeJetFootPrint([jet1,jet2],cleanedPackedCandidates) selected['satelliteJets']=self.makeSatelliteJets(remainingCands) leadJetConstituents=jet1.prunedJet.constituents #Additional leptons selected['otherLeptons'] = goldenLeptons #add VBF info self.topology(selected) JJ.append(selected) finished=True setattr(event,'LNuJJ'+self.cfg_ana.suffix,LNuJJ) setattr(event,'JJ'+self.cfg_ana.suffix,JJ) setattr(event,'LLJJ'+self.cfg_ana.suffix,LLJJ) setattr(event,'JJNuNu'+self.cfg_ana.suffix,JJNuNu) setattr(event,'TopCR'+self.cfg_ana.suffix,TopCR) setattr(event,'leadJetConstituents'+self.cfg_ana.suffix,leadJetConstituents)
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