def process(self, event): #print "<TTHtoTauTauAnalyzer::process>:" self.readCollections( event.input ) ##taus = list( self.handles['taus'].product() ) taus = event.inclusiveTaus taus_modified = [] for idxTau in range(len(taus)): tau = Tau(taus[idxTau]) #print "processing tau #%i: Pt = %1.2f, eta = %1.2f, phi = %1.2f" % (idxTau, tau.pt(), tau.eta(), tau.phi()) # if not MC, nothing to do if self.cfg_comp.isMC: tau.genMatchType = self.addTau_genMatchType(event, tau) else: tau.genMatchType = -1 #print " genMatchType = %i" % tau.genMatchType taus_modified.append(tau) event.inclusiveTaus = taus_modified return True
def buildDiLeptonsSingle(self, leptons, event): di_leptons = [] met = self.handles['pfMET'].product()[0] for pat_mu in leptons: muon = self.__class__.LeptonClass(pat_mu) for pat_tau in self.handles['taus'].product(): tau = Tau(pat_tau) di_tau = DirectDiTau(muon, tau, met) di_tau.leg2().associatedVertex = event.goodVertices[0] di_tau.leg1().associatedVertex = event.goodVertices[0] if not self.testLeg1(di_tau.leg1(), 99999): continue di_tau.mvaMetSig = None di_leptons.append(di_tau) return di_leptons
def buildDiLeptonsSingle(self, leptons, event): di_leptons = [] met = self.handles['pfMET'].product()[0] for pat_ele in leptons: ele = self.__class__.LeptonClass(pat_ele) for pat_tau in self.handles['taus'].product(): tau = Tau(pat_tau) di_tau = DirectDiTau(ele, tau, met) di_tau.leg2().associatedVertex = event.goodVertices[0] di_tau.leg1().associatedVertex = event.goodVertices[0] di_tau.leg1().event = event.input.object() di_tau.leg2().event = event.input.object() di_tau.leg1().rho = event.rho di_tau.mvaMetSig = None di_leptons.append(di_tau) return di_leptons
def process(self, event): event.goodVertices = event.vertices result = super(MuEleAnalyzer, self).process(event) event.isSignal = False if result: event.isSignal = True # trying to get a dilepton from the control region. # it must have well id'ed and trig matched legs, # di-lepton and tri-lepton veto must pass result = self.selectionSequence(event, fillCounter=True, leg1IsoCut=self.cfg_ana.looseiso1, leg2IsoCut=self.cfg_ana.looseiso2) if result is False: # really no way to find a suitable di-lepton, # even in the control region return False event.selectedTaus = [Tau(tau) for tau in self.handles['taus'].product() if tau.pt() > 18. and deltaR2(tau, event.leg1) > 0.25 and deltaR2(tau, event.leg2) > 0.25] for tau in event.selectedTaus: tau.associatedVertex = event.goodVertices[0] event.otherLeptons = event.selectedTaus[:] event.pfmet = self.handles['pfMET'].product()[0] event.puppimet = self.handles['puppiMET'].product()[0] return True
def buildDiLeptonsSingle(self, leptons, event): di_leptons = [] met = self.handles['pfMET'].product()[0] for pat_mu in leptons: muon = self.__class__.LeptonClass(pat_mu) for i_jet, pat_jet in enumerate(self.handles['jets'].product()): for pat_tau in self.handles['taus'].product(): # Get highest-pt tau in jet cone, if any if deltaR2(pat_jet.eta(), pat_jet.phi(), pat_tau.eta(), pat_tau.phi()) < 0.25: pat_jet.tau = Tau(pat_tau) pat_jet.tau.associatedVertex = event.goodVertices[0] break di_tau = DirectDiTau(muon, pat_jet, met) di_tau.leg2().associatedVertex = event.goodVertices[0] di_tau.leg2().nth_jet = i_jet di_tau.leg1().associatedVertex = event.goodVertices[0] if not self.testLeg1(di_tau.leg1(), 99999): continue di_tau.mvaMetSig = None di_leptons.append(di_tau) return di_leptons
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