def __call__(self, event): leps = [l for l in Collection(event, "LepGood", "nLepGood")] jetsc = [j for j in Collection(event, "Jet", "nJet")] ret = {"nLepGood": event.nLepGood} for var in self.jetvars: ret["LepGood_awayJet%s_%s" % (self.label, var)] = [-99.0] * event.nLepGood ret["LepGood_CorrConePt"] = [-99.0] * event.nLepGood for il, lep in enumerate(leps): if not self.leptonSel(lep): continue ret["LepGood_CorrConePt"][il] = conept(lep.pt, lep.miniRelIso, lep.jetPtRatio, lep.jetPtRel, lep.pdgId, 2) # print ret["LepGood_CorrConePt"][il]/lep.pt,lep.miniRelIso,lep.jetPtRatio,lep.jetPtRel,lep.pdgId jets = [j for j in jetsc if self.jetSel(j, lep, deltaR(j, lep))] if len(jets) == 0: continue jet = max(jets, key=self.jetSort) #print "lepton pt %6.1f eta %+5.2f phi %+5.2f matched with jet pt %6.1f eta %+5.2f phi %+5.2f " % ( # lep.pt, lep.eta, lep.phi, jet.pt, jet.eta, jet.phi ) for var in self.jetvars: if var == "mcFlavour" and hasattr(jet, var) == False: ret["LepGood_awayJet%s_%s" % (self.label, var)][il] = 0 continue ret["LepGood_awayJet%s_%s" % (self.label, var)][il] = getattr( jet, var) return ret
def __call__(self,event): leps = [l for l in Collection(event,"LepGood","nLepGood")] for lep in leps: lep.conept = conept(lep.pt,lep.miniRelIso,lep.jetPtRatiov2,lep.jetPtRelv2,lep.pdgId,2) 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],"nJet"+self.systsJEC[_var])] jetsd[var] = [j for j in Collection(event,"DiscJet"+self.systsJEC[_var],"nDiscJet"+self.systsJEC[_var])] self.debugprinted = True ret = {}; jetret = {} lepsl = []; lepslv = []; ret, lepsl, lepslv = self.fillCollWithVeto(ret,leps,leps,'L','Loose',self.looseLeptonSel,None) lepsc = []; lepscv = []; ret, lepsc, lepscv = self.fillCollWithVeto(ret,leps,lepsl,'C','Cleaning',self.cleaningLeptonSel,lepsl) cleanjets={} cleanBjets={} for var in self.systsJEC: cleanjets[var]=[] cleanBjets[var]=[] cleanjets[var],cleanBjets[var] = self.recleanJets(jetsc[var],jetsd[var],lepsc,self.systsJEC[var],ret,jetret,(var==0)) for var in self.systsBTAG: ret["btagMediumSF"+self.systsBTAG[var]]=self.btagMediumScaleFactor(event,cleanBjets[0],cleanjets[0],var) if self.do_btagSF else 1.0 # calculate FOs and tight leptons using the cleaned HT lepsf = []; lepsfv = []; ret, lepsf, lepsfv = self.fillCollWithVeto(ret,leps,lepsl,'F','FO',self.FOLeptonSel,lepsl,ret["htJet40j"]) lepst = []; lepstv = []; ret, lepst, lepstv = self.fillCollWithVeto(ret,leps,lepsl,'T','Tight',self.tightLeptonSel,lepsl,ret["htJet40j"]) ### attach labels and return fullret = {} fullret["nLepGood"]=len(leps) fullret["LepGood_conePt"] = [lep.conept for lep in leps] fullret["LepGood_mcMatchPdgId"] = [0] * len(leps) if not event.isData: self.matchLeptons(fullret,leps,[l for l in Collection(event,"genLep","ngenLep")],[l for l in Collection(event,"genLepFromTau","ngenLepFromTau")],event) if self.isFastSim: fullret["pTGluinoPair"] = self.ptFirstPair(Collection(event,'GenPart','nGenPart'), 1000021, requireOnePair=True) for k,v in ret.iteritems(): fullret[k+self.label] = v for k,v in jetret.iteritems(): fullret["JetSel%s_%s" % (self.label,k)] = v return fullret
def __call__(self,event): leps = [l for l in Collection(event,"LepGood","nLepGood")] jetsc = [j for j in Collection(event,"Jet","nJet")] ret = { "nLepGood" : event.nLepGood } for var in self.jetvars: ret["LepGood_awayJet%s_%s"%(self.label,var)] = [-99.0] * event.nLepGood ret["LepGood_CorrConePt"] = [-99.0] * event.nLepGood for il,lep in enumerate(leps): if not self.leptonSel(lep): continue ret["LepGood_CorrConePt"][il] = conept(lep.pt,lep.miniRelIso,lep.jetPtRatiov2,lep.jetPtRelv2,lep.pdgId,2) # print ret["LepGood_CorrConePt"][il]/lep.pt,lep.miniRelIso,lep.jetPtRatiov2,lep.jetPtRelv2,lep.pdgId jets = [ j for j in jetsc if self.jetSel(j,lep,deltaR(j,lep)) ] if len(jets) == 0: continue jet = max(jets, key=self.jetSort) #print "lepton pt %6.1f eta %+5.2f phi %+5.2f matched with jet pt %6.1f eta %+5.2f phi %+5.2f " % ( # lep.pt, lep.eta, lep.phi, jet.pt, jet.eta, jet.phi ) for var in self.jetvars: if var=="mcFlavour" and hasattr(jet,var)==False: ret["LepGood_awayJet%s_%s"%(self.label,var)][il] = 0 continue ret["LepGood_awayJet%s_%s"%(self.label,var)][il] = getattr(jet,var) return ret
def _susy2lss_multiIso_withMiniIsoRelaxed_ConePtJetPtRatio(lep): if abs(lep.pdgId) == 13: A, B, C = (0.4, 0.68, 6.7) else: A, B, C = (0.4, 0.70, 7.0) return lep.miniRelIso < A and ( conept(lep.pt, lep.miniRelIso, lep.jetPtRatio, lep.jetPtRel, lep.pdgId, 2) / lep.pt * lep.jetPtRatio > B or lep.jetPtRel > C)
def __call__(self, event): leps = [l for l in Collection(event, "LepGood", "nLepGood")] for lep in leps: lep.conept = conept(lep.pt, lep.miniRelIso, lep.jetPtRatiov2, lep.jetPtRelv2, lep.pdgId, 2) 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], "nJet" + self.systsJEC[_var])] jetsd[var] = [ j for j in Collection(event, "DiscJet" + self.systsJEC[_var], "nDiscJet" + self.systsJEC[_var]) ] self.debugprinted = True ret = {} jetret = {} lepsl = [] lepslv = [] ret, lepsl, lepslv = self.fillCollWithVeto(ret, leps, leps, "L", "Loose", self.looseLeptonSel, None) lepsc = [] lepscv = [] ret, lepsc, lepscv = self.fillCollWithVeto(ret, leps, lepsl, "C", "Cleaning", self.cleaningLeptonSel, lepsl) cleanjets = {} cleanBjets = {} for var in self.systsJEC: cleanjets[var] = [] cleanBjets[var] = [] cleanjets[var], cleanBjets[var] = self.recleanJets( jetsc[var], jetsd[var], lepsc, self.systsJEC[var], ret, jetret, (var == 0) ) for var in self.systsBTAG: ret["btagMediumSF" + self.systsBTAG[var]] = ( self.btagMediumScaleFactor(event, cleanBjets[0], cleanjets[0], var) if self.do_btagSF else 1.0 ) # calculate FOs and tight leptons using the cleaned HT lepsf = [] lepsfv = [] ret, lepsf, lepsfv = self.fillCollWithVeto( ret, leps, lepsl, "F", "FO", self.FOLeptonSel, lepsl, ret["htJet40j"] ) lepst = [] lepstv = [] ret, lepst, lepstv = self.fillCollWithVeto( ret, leps, lepsl, "T", "Tight", self.tightLeptonSel, lepsl, ret["htJet40j"] ) ### attach labels and return fullret = {} fullret["nLepGood"] = len(leps) fullret["LepGood_conePt"] = [lep.conept for lep in leps] fullret["LepGood_mcMatchPdgId"] = [0] * len(leps) if not event.isData: self.matchLeptons( fullret, leps, [l for l in Collection(event, "genLep", "ngenLep")], [l for l in Collection(event, "genLepFromTau", "ngenLepFromTau")], event, ) if self.isFastSim: fullret["pTGluinoPair"] = self.ptFirstPair( Collection(event, "GenPart", "nGenPart"), 1000021, requireOnePair=True ) for k, v in ret.iteritems(): fullret[k + self.label] = v for k, v in jetret.iteritems(): fullret["JetSel%s_%s" % (self.label, k)] = v return fullret