def findTriples(self, already, leps1, leps2, leps3, bypassMV, nF=0): ## produces a list of all valid 3lepton combinations in the event, ## ordered by pt (first one hardest), and also returns the list of ## fakes in the triple triples = [] fakes = [] tr_raw = [] tr_sorted = [] fk_raw = [] fk_sorted = [] pt_raw = [] pt_sorted = [] ## collect all three lepton combinations for p in [(l1, l2, l3) for l1 in leps1 for l2 in leps2 for l3 in leps3 if l1 != l2 and l1 != l3 and l2 != l3]: if (p[0], p[1], p[2]) in tr_raw: continue tr_raw.append(p) if nF == 1: fk_raw.append((None, None, p[2])) pt_raw.append((p[0].pt, p[1].pt, p[2].conePt)) elif nF == 2: fk_raw.append((None, p[1], p[2])) pt_raw.append((p[0].pt, p[1].conePt, p[2].conePt)) elif nF == 3: fk_raw.append((p[0], p[1], p[2])) pt_raw.append((p[0].conePt, p[1].conePt, p[2].conePt)) else: fk_raw.append((None, None, None)) pt_raw.append((p[0].pt, p[1].pt, p[2].pt)) ## sort them by pT (first one always the hardest) for i, l in enumerate(tr_raw): p = pt_raw[i] ls = sorted([[p[0], 0], [p[1], 1], [p[2], 2]], key=lambda x: x[0], reverse=True) np = (l[ls[0][1]], l[ls[1][1]], l[ls[2][1]]) if np not in tr_sorted: tr_sorted.append((l[ls[0][1]], l[ls[1][1]], l[ls[2][1]])) fk_sorted.append((fk_raw[i][ls[0][1]], fk_raw[i][ls[1][1]], fk_raw[i][ls[2][1]])) pt_sorted.append((p[ls[0][1]], p[ls[1][1]], p[ls[2][1]])) ## selection: only keep the good ones for i, (l1, l2, l3) in enumerate(tr_sorted): if (l1, l2, l3) in already: continue # fake-not-tight! if not bypassMV and not passTripleMllVeto(l1, l2, l3, 0, 12, True): continue if pt_sorted[i][0] > 20 and pt_sorted[i][1] > 15 and pt_sorted[i][ 2] > 10: triples.append((l1, l2, l3)) fakes.append(fk_sorted[i]) if len(triples): return triples, fakes return [], []
def passPtAndMll(self): ## we can throw away the event if the pt cut is not passed because we already take the three hardest leps if len(self.lepSelFO) >= 3: l1 = self.lepSelFO[0] l2 = self.lepSelFO[1] l3 = self.lepSelFO[2] if not (passTripleMllVeto(l1, l2, l3, 0, 12, True) and passPtCutTriple(l1, l2, l3)): return False if len(self.lepSelFO) >= 4: l4 = self.lepSelFO[3] if l4.conePt < 10 or not passMllTLVeto(l4, [l1, l2, l3], 0, 12, True): return False return True