def TauEnergyScale(self, diLeptons, event): # get genmatch-needed informations, needs to be done in this analyzer to scale, though information is usually gathered afterwards in HTTGenAnalyzer genParticles = self.handles['genParticles'].product() ptSelGentauleps = [ p for p in genParticles if abs(p.pdgId()) in [11, 13] and p.statusFlags().isDirectPromptTauDecayProduct() and p.pt() > 8. ] ptSelGenleps = [ p for p in genParticles if abs(p.pdgId()) in [11, 13] and p.statusFlags().isPrompt() and p.pt() > 8. ] event.gentaus = [ p for p in event.genParticles if abs(p.pdgId()) == 15 and p.statusFlags().isPrompt() and not any( abs(HTTGenAnalyzer.getFinalTau(p).daughter(i_d).pdgId()) in [11, 13] for i_d in xrange( HTTGenAnalyzer.getFinalTau(p).numberOfDaughters())) ] # create a list of all used leptons without duplicates, using the ROOT.pat::Tau objects as discriminant leps = [] for dilep in diLeptons: if dilep.leg1().tau not in [lep.tau for lep in leps]: leps.append(dilep.leg1()) if dilep.leg2().tau not in [lep.tau for lep in leps]: leps.append(dilep.leg2()) # scale leptons for lep in leps: self.Scale(lep, ptSelGentauleps, ptSelGenleps, event) for dilep in diLeptons: for leg in [dilep.leg1(), dilep.leg2()]: if leg.tau == lep.tau and (not hasattr(leg, 'unscaledP4')): leg.unscaledP4 = lep.unscaledP4
def process(self, event): self.readCollections(event.input) event.taus = [Tau(tau) for tau in self.handles['taus'].product()] event.gen = self.handles['gen'].product() event.genParticles = event.gen event.genJets = self.handles['gen_jets'].product() for pu_info in self.handles['pu'].product(): if pu_info.getBunchCrossing() == 0: event.n_true_interactions = pu_info.getTrueNumInteractions() event.genleps = [p for p in event.gen if abs(p.pdgId()) in [11, 13] and p.statusFlags().isPrompt()] event.gentauleps = [p for p in event.gen if abs(p.pdgId()) in [11, 13] and p.statusFlags().isDirectPromptTauDecayProduct()] event.gentaus = [p for p in event.gen if abs(p.pdgId()) == 15 and p.statusFlags().isPrompt() and not any(abs(HTTGenAnalyzer.getFinalTau(p).daughter(i_d).pdgId()) in [11, 13] for i_d in xrange(HTTGenAnalyzer.getFinalTau(p).numberOfDaughters()))] HTTGenAnalyzer.getGenTauJets(event) # saves event.genTauJets for gen_tau in event.genTauJets: gen_tau.charged = [d for d in gen_tau.daughters if d.charge()] gen_tau.pizeros = [daughters(d) for d in gen_tau.daughters if d.pdgId() == 111] pf_candidates = self.handles['pf_candidates'].product() for tau in event.taus: TauIsoAnalyzer.addInfo(tau, event, [c for c in pf_candidates if abs(c.pdgId()) == 211], maxDeltaR=0.8) matched_gen_jet, dr2 = bestMatch(tau, event.genJets) if dr2 < 0.25: tau.gen_jet = matched_gen_jet return True
def process(self, event): self.readCollections(event.input) event.rho = self.handles['rho'].product()[0] event.taus = [Tau(tau) for tau in self.handles['taus'].product()] dms = self.handles['DM'].product() loose_db_isos = self.handles['looseDBIso'].product() if len(event.taus) != len(dms) or len(event.taus) != len(loose_db_isos): import pdb; pdb.set_trace() for i_tau, tau in enumerate(event.taus): tau.dm = dms.value(i_tau) tau.loose_db_iso = loose_db_isos.value(i_tau) if tau.dm > 1: import pdb; pdb.set_trace() event.hlt_taus = [] if self.handles['hlt_taus'].isValid(): event.hlt_taus = [Tau(tau) for tau in self.handles['hlt_taus'].product()] if event.hlt_taus: hlt_dms = self.handles['hltDM'].product() hlt_loose_db_isos = self.handles['hltLooseDB'].product() for i_tau, tau in enumerate(event.hlt_taus): tau.dm = hlt_dms.value(i_tau) tau.loose_db_iso = hlt_loose_db_isos.value(i_tau) else: # print self.handles['hlt_taus']._exception if self.handles['hlt_taus']._exception is None: import pdb; pdb.set_trace() event.hlt_single_taus = [] if self.handles['hltSingle_taus'].isValid(): event.hlt_single_taus = [Tau(tau) for tau in self.handles['hltSingle_taus'].product()] if event.hlt_single_taus: hlt_dms = self.handles['hltSingleDM'].product() hlt_loose_db_isos = self.handles['hltSingleLooseDB'].product() for i_tau, tau in enumerate(event.hlt_single_taus): tau.dm = hlt_dms.value(i_tau) tau.loose_db_iso = hlt_loose_db_isos.value(i_tau) else: # print self.handles['hlt_taus']._exception if self.handles['hltSingle_taus']._exception is None: import pdb; pdb.set_trace() event.genParticles = self.handles['genParticles'].product() event.genleps = [p for p in event.genParticles if abs(p.pdgId()) in [11, 13] and p.statusFlags().isPrompt()] event.gentauleps = [p for p in event.genParticles if abs(p.pdgId()) in [11, 13] and p.statusFlags().isDirectPromptTauDecayProduct()] event.gentaus = [p for p in event.genParticles if abs(p.pdgId()) == 15 and p.statusFlags().isPrompt() and not any(abs(HTTGenAnalyzer.getFinalTau(p).daughter(i_d).pdgId()) in [11, 13] for i_d in xrange(HTTGenAnalyzer.getFinalTau(p).numberOfDaughters()))] def addInfo(tau, cands=None, maxDeltaR=None): HTTGenAnalyzer.genMatch(event, tau, event.gentauleps, event.genleps, [], dR=0.2, matchAll=True) self.tauIsoBreakdown(tau, cands, maxDeltaR=maxDeltaR) tau.nphotons = sum(1 for cand in TauHLTAnalyzer.tauFilteredPhotons(tau)) pfCandidates = self.handles['pfCandidates'].product() hltPfCandidates = self.handles['hltPfCandidates'].product() if self.handles['hltPfCandidates'].isValid() else None hltSinglePfCandidates = self.handles['hltSinglePfCandidates'].product() if self.handles['hltSinglePfCandidates'].isValid() else None for tau in event.taus: addInfo(tau, [c for c in pfCandidates if abs(c.pdgId()) == 211], maxDeltaR=0.8) for tau in event.hlt_taus : addInfo(tau, [c for c in hltPfCandidates if abs(c.pdgId()) == 211], maxDeltaR=0.5) for tau in event.hlt_single_taus: addInfo(tau, [c for c in hltSinglePfCandidates if abs(c.pdgId()) == 211], maxDeltaR=0.5) return True