def makeDeltaR(t, n): n.phL1DeltaR = deltaR( t._lEta[n.l1], t._phEta[n.ph], t._lPhi[n.l1], t._phPhi[n.ph]) if len(t.photons) > 0 and len(t.leptons) > 0 else -1 n.phL2DeltaR = deltaR( t._lEta[n.l2], t._phEta[n.ph], t._lPhi[n.l2], t._phPhi[n.ph]) if len(t.photons) > 0 and len(t.leptons) > 1 else -1 n.phJetDeltaR = min([ deltaR(t._jetEta[j], t._phEta[n.ph], t._jetPhi[j], t._phPhi[n.ph]) for j in t.jets ] + [999]) if len(t.photons) > 0 else -1
def isGoodJet(tree, index): if not tree._jetId[index]: return False if not abs(tree._jetEta[index]) < 2.4: return False for ph in tree.photons: if deltaR(tree._jetEta[index], tree._phEta[ph], tree._jetPhi[index], tree._phPhi[ph]) < 0.1: return False for lep in tree.leptons: if deltaR(tree._jetEta[index], tree._lEta[lep], tree._jetPhi[index], tree._lPhi[lep]) < 0.4: return False return True
def electronSelector(tree, index): for i in xrange(ord(tree._nMu)): # cleaning electrons around muons if not looseLeptonSelector(tree, i): continue if deltaR(tree._lEta[i], tree._lEta[index], tree._lPhi[i], tree._lPhi[index]) < 0.02: return False if tree.eleMva: return electronMva(tree, index) elif tree.cbVeto: return tree._lPOGVeto[index] elif tree.cbLoose: return tree._lPOGLoose[index] elif tree.cbMedium: return tree._lPOGMedium[index] elif tree.susyLoose: return electronSusyLoose(tree, index) else: return tree._lPOGTight[index]
def photonSelector(tree, index, n, minLeptons): if abs(tree._phEta[index]) > 1.4442 and abs(tree._phEta[index]) < 1.566: return False if abs(tree._phEta[index]) > 2.5: return False if tree._phPtCorr[index] < 15: return False if tree._phHasPixelSeed[index] and not tree.noPixelSeedVeto: return False if not tree._phPassElectronVeto[index]: return False for i in ([] if minLeptons == 0 else ([n.l1] if minLeptons == 1 else [n.l1, n.l2])): if deltaR(tree._lEta[i], tree._phEta[index], tree._lPhi[i], tree._phPhi[index]) < 0.1: return False if tree.photonCutBased: return photonCutBasedReduced(tree, index) if tree.photonMva: return tree._phMva[index] > 0.20 return True
def addGenPhotonInfo(t, n, index): n.genPhDeltaR = 99 n.genPhMinDeltaR = 99 n.genPhPassParentage = False n.genPhPt = -1 n.genPhEta = 99 for i in range(ord(t._gen_nPh)): myDeltaR = deltaR(t._phEta[index], t._gen_phEta[i], t._phPhi[index], t._gen_phPhi[i]) if myDeltaR < n.genPhDeltaR: n.genPhDeltaR = myDeltaR n.genPhPassParentage = t._gen_phPassParentage[i] n.genPhMinDeltaR = t._gen_phMinDeltaR[i] n.genPhRelPt = (t._gen_phPt[i] - t._phPt[n.ph]) / t._gen_phPt[i] n.genPhPt = t._gen_phPt[i] n.genPhEta = t._gen_phEta[i]
def isSignalPhoton(tree, index, oldDefinition=False): if not oldDefinition: return tree._phTTGMatchCategory[index] == 1 else: mcIndex = tree._phMatchMCPhotonAN15165[index] if mcIndex < 0: return False if (tree._gen_phPt[mcIndex] - tree._phPt[index]) / tree._gen_phPt[mcIndex] > 0.1: return False if (tree._gen_phEta[mcIndex] - tree._phEta[index]) / tree._gen_phEta[mcIndex] > 0.005: return False if deltaR(tree._gen_phEta[mcIndex], tree._phEta[index], tree._gen_phPhi[mcIndex], tree._phPhi[index]) > 0.01: return False if not tree._gen_phPassParentage[mcIndex]: return False if tree._gen_phMinDeltaR[mcIndex] < 0.2: return False return True
def isGoodElectron(tree, index, oldDefinition=False): if not oldDefinition: return tree._phTTGMatchCategory[index] == 2 else: if isSignalPhoton(tree, index): return False if isHadronicPhoton(tree, index): return False mcIndex = tree._phMatchMCLeptonAN15165[index] if mcIndex < 0: return False if (tree._gen_lPt[mcIndex] - tree._phPt[index]) / tree._gen_lPt[mcIndex] > 0.1: return False if not tree._gen_lPassParentage[mcIndex]: return False if tree._gen_lMinDeltaR[mcIndex] < 0.2: return False if deltaR(tree._gen_lEta[mcIndex], tree._phEta[index], tree._gen_lPhi[mcIndex], tree._phPhi[index]) > 0.04: return False if (tree._gen_lEta[mcIndex] - tree._phEta[index]) / tree._gen_lEta[mcIndex] > 0.005: return False return True
def makeDeltaR(t, n): n.phL1DeltaR = deltaR( t._lEta[n.l1], t._phEta[n.ph], t._lPhi[n.l1], t._phPhi[n.ph]) if len(t.photons) > 0 and len(t.leptons) > 0 else -1 n.phL2DeltaR = deltaR( t._lEta[n.l2], t._phEta[n.ph], t._lPhi[n.l2], t._phPhi[n.ph]) if len(t.photons) > 0 and len(t.leptons) > 1 else -1 for var in ['', '_JECUp', '_JECDown', '_JERUp', '_JERDown']: setattr( n, 'phJetDeltaR' + var, min([ deltaR(t._jetEta[j], t._phEta[n.ph], t._jetPhi[j], t._phPhi[ n.ph]) for j in getattr(t, 'jets' + var) ] + [999]) if len(t.photons) > 0 else -1) setattr( n, 'phBJetDeltaR' + var, min([ deltaR(t._jetEta[j], t._phEta[n.ph], t._jetPhi[j], t._phPhi[ n.ph]) for j in getattr(t, 'dbjets' + var) ] + [999]) if len(t.photons) > 0 else -1) setattr( n, 'l1JetDeltaR' + var, min([ deltaR(t._jetEta[j], t._lEta[n.l1], t._jetPhi[j], t._lPhi[ n.l1]) for j in getattr(t, 'jets' + var) ] + [999]) if len(t.leptons) > 0 else -1) setattr( n, 'l2JetDeltaR' + var, min([ deltaR(t._jetEta[j], t._lEta[n.l2], t._jetPhi[j], t._lPhi[ n.l2]) for j in getattr(t, 'jets' + var) ] + [999]) if len(t.leptons) > 1 else -1) setattr( n, 'jjDeltaR' + var, min([ deltaR(t._jetEta[getattr(n, 'j1' + var)], t._jetEta[getattr( n, 'j2' + var)], t._jetPhi[getattr(n, 'j1' + var)], t._jetPhi[getattr(n, 'j2' + var)]) ]) if getattr(n, 'njets' + var) > 1 else -1)