def passedFilter(self, cutter, region): if not self.initEvent(cutter): return False if self.flavors_of_interest == ['tau'] and region == 'TauFakesDY': if not cutter.cut(self.new_chain.l_flavor.count(2) == 1, '1 tau'): return False if not cutter.cut( self.new_chain.l_flavor[0] == self.new_chain.l_flavor[1], 'SF'): return False if not cutter.cut( self.new_chain.l_charge[0] != self.new_chain.l_charge[1], 'OS'): return False l1Vec = getFourVec(self.new_chain.l_pt[0], self.new_chain.l_eta[0], self.new_chain.l_phi[0], self.new_chain.l_e[0]) l2Vec = getFourVec(self.new_chain.l_pt[1], self.new_chain.l_eta[1], self.new_chain.l_phi[1], self.new_chain.l_e[1]) if not cutter.cut( abs(91.19 - (l1Vec + l2Vec).M()) < 15, 'Z window'): return False if not cutter.cut(self.chain._met < 50, 'MET > 50'): return False if not cutter.cut(not bVeto(self.chain), 'b-veto'): return False self.loose_leptons_of_interest = [2] return True elif self.flavors_of_interest == ['tau'] and region == 'Mix': return passedFilterTauMixCT(self.chain, self.new_chain, self.is_reco_level, cutter) else: return False
def passedFilter(self, cutter): if not self.initEvent(cutter): return False if not cutter.cut(self.new_chain.l_flavor.count(2) == 1, '1 tau'): return False if not cutter.cut( self.new_chain.l_flavor[0] == self.new_chain.l_flavor[1], 'SF'): return False if not cutter.cut( self.new_chain.l_charge[0] != self.new_chain.l_charge[1], 'OS'): return False l1Vec = getFourVec(self.new_chain.l_pt[0], self.new_chain.l_eta[0], self.new_chain.l_phi[0], self.new_chain.l_e[0]) l2Vec = getFourVec(self.new_chain.l_pt[1], self.new_chain.l_eta[1], self.new_chain.l_phi[1], self.new_chain.l_e[1]) if not cutter.cut(abs(91.19 - (l1Vec + l2Vec).M()) < 15, 'Z window'): return False if not cutter.cut(self.chain._met < 50, 'MET < 50'): return False # if not cutter.cut(self.chain._tauGenStatus[self.chain.l_indices[2]] == 6, 'fake tau'): return False return True
def passedFilter(self, cutter): if not self.initEvent(cutter): return False if not cutter.cut(self.new_chain.l_flavor.count(0) == 1, '1 e'): return False if not cutter.cut(self.new_chain.l_flavor.count(1) == 1, '1 mu'): return False if not cutter.cut(self.new_chain.l_flavor.count(2) == 1, '1 tau'): return False if not cutter.cut( self.new_chain.l_charge[0] != self.new_chain.l_charge[1], 'OS'): return False if nBjets(self.chain, 'tight') < 1: return False l1Vec = getFourVec(self.new_chain.l_pt[0], self.new_chain.l_eta[0], self.new_chain.l_phi[0], self.new_chain.l_e[0]) l2Vec = getFourVec(self.new_chain.l_pt[1], self.new_chain.l_eta[1], self.new_chain.l_phi[1], self.new_chain.l_e[1]) if not cutter.cut((l1Vec + l2Vec).M() > 20, 'Mll cut'): return False if not cutter.cut(self.chain._met < 50, 'MET < 50'): return False # if not cutter.cut(self.chain._tauGenStatus[self.chain.l_indices[2]] == 6, 'fake tau'): return False return True
def passesZcuts(chain, new_chain, same_flavor=False): for fl in [0, 1]: l1Vec = getFourVec(new_chain.l_pt[fl], new_chain.l_eta[fl], new_chain.l_phi[fl], new_chain.l_e[fl]) for sl in [1, 2]: if fl == sl: continue if new_chain.l_charge[fl] == new_chain.l_charge[sl]: continue if same_flavor and new_chain.l_flavor[fl] != new_chain.l_flavor[sl]: continue l2Vec = getFourVec(new_chain.l_pt[sl], new_chain.l_eta[sl], new_chain.l_phi[sl], new_chain.l_e[sl]) if abs((l1Vec + l2Vec).M() - 90.) < 15: return False return True
def passCuts(chain, indices): if len(indices) != 3: return False if chain._lCharge[indices[0]] == chain._lCharge[ indices[1]] and chain._lCharge[indices[2]] == chain._lCharge[ indices[1]]: return False if bVeto(chain): return False vectors = [] for lepton_index in indices: vectors.append( getFourVec(chain._lPt[lepton_index], chain._lEta[lepton_index], chain._lPhi[lepton_index], chain._lE[lepton_index])) mass_lll = (vectors[0] + vectors[1] + vectors[2]).M() if abs(mass_lll - 91.19) < 15: return False return True
from HNL.Tools.helpers import progress, makeDirIfNeeded for entry in event_range: chain.GetEntry(entry) progress(entry - event_range[0], len(event_range)) lepton_indices = [] for l in xrange(chain._nLight): if isGoodLightLepton(chain, l, 'tight'): lepton_indices.append(l) if len(lepton_indices) > 2: continue if len(lepton_indices) == 0: continue if len(lepton_indices) == 2 and chain._lFlavor[lepton_indices[ 0]] == chain._lFlavor[lepton_indices[1]] and chain._lCharge[ lepton_indices[0]] != chain._lCharge[lepton_indices[1]]: v0 = getFourVec(chain._lPt[lepton_indices[0]], chain._lEta[lepton_indices[0]], chain._lPhi[lepton_indices[0]], chain._lE[lepton_indices[0]]) v1 = getFourVec(chain._lPt[lepton_indices[1]], chain._lEta[lepton_indices[1]], chain._lPhi[lepton_indices[1]], chain._lE[lepton_indices[1]]) if abs((v0 + v1).M() - 91.19) < 15: continue #pre-filtering tau with common cuts to decrease time later on base_tau_indices_per_algo = {} for algo in algos.keys(): base_tau_indices_per_algo[algo] = [] for index in xrange(chain._nLight, chain._nL): if chain._lFlavor[index] != 2: continue if chain._lPt[index] < 20: continue
def calculateKinematicVariables(chain, new_chain, is_reco_level=True): l1Vec = getFourVec(new_chain.l_pt[l1], new_chain.l_eta[l1], new_chain.l_phi[l1], new_chain.l_e[l1]) l2Vec = getFourVec(new_chain.l_pt[l2], new_chain.l_eta[l2], new_chain.l_phi[l2], new_chain.l_e[l2]) l3Vec = getFourVec(new_chain.l_pt[l3], new_chain.l_eta[l3], new_chain.l_phi[l3], new_chain.l_e[l3]) lVec = [l1Vec, l2Vec, l3Vec] #M3l new_chain.M3l = (l1Vec + l2Vec + l3Vec).M() #All combinations of dilepton masses new_chain.Ml12 = (l1Vec + l2Vec).M() new_chain.Ml23 = (l2Vec + l3Vec).M() new_chain.Ml13 = (l1Vec + l3Vec).M() # # Get OS, OSSF, SS, SSSF variables # min_os = [None, None] max_os = [None, None] min_ss = [None, None] max_ss = [None, None] min_ossf = [None, None] max_ossf = [None, None] min_sssf = [None, None] max_sssf = [None, None] tmp_minos = 99999999. tmp_minss = 99999999. tmp_minossf = 99999999. tmp_minsssf = 99999999. tmp_maxos = 0 tmp_maxss = 0 tmp_maxossf = 0 tmp_maxsssf = 0 for i1, l in enumerate(new_chain.l_indices): for i2, sl in enumerate(new_chain.l_indices): if i2 <= i1: continue tmp_mass = (lVec[i1] + lVec[i2]).M() if new_chain.l_charge[i1] == new_chain.l_charge[i2]: if tmp_mass < tmp_minss: min_ss = [i1, i2] tmp_minss = tmp_mass if tmp_mass > tmp_maxss: max_ss = [i1, i2] tmp_maxss = tmp_mass if new_chain.l_flavor[i1] == new_chain.l_flavor[i2]: if tmp_mass < tmp_minsssf: min_sssf = [i1, i2] tmp_minsssf = tmp_mass if tmp_mass > tmp_maxsssf: max_sssf = [i1, i2] tmp_maxsssf = tmp_mass else: if tmp_mass < tmp_minos: min_os = [i1, i2] tmp_minos = tmp_mass if tmp_mass > tmp_maxos: max_os = [i1, i2] tmp_maxos = tmp_mass if new_chain.l_flavor[i1] == new_chain.l_flavor[i2]: if tmp_mass < tmp_minossf: min_ossf = [i1, i2] tmp_minossf = tmp_mass if tmp_mass > tmp_maxossf: max_ossf = [i1, i2] tmp_maxossf = tmp_mass #Mass variables chain.minMos = (lVec[min_os[0]] + lVec[min_os[1]]).M() if all(min_os) else 0 chain.maxMos = (lVec[max_os[0]] + lVec[max_os[1]]).M() if all(max_os) else 0 chain.minMss = (lVec[min_ss[0]] + lVec[min_ss[1]]).M() if all(min_ss) else 0 chain.maxMss = (lVec[max_ss[0]] + lVec[max_ss[1]]).M() if all(max_ss) else 0 chain.minMossf = (lVec[min_ossf[0]] + lVec[min_ossf[1]]).M() if all(min_ossf) else 0 chain.maxMossf = (lVec[max_ossf[0]] + lVec[max_ossf[1]]).M() if all(max_ossf) else 0 chain.minMsssf = (lVec[min_sssf[0]] + lVec[min_sssf[1]]).M() if all(min_sssf) else 0 chain.maxMsssf = (lVec[max_sssf[0]] + lVec[max_sssf[1]]).M() if all(max_sssf) else 0 #MTother new_chain.index_other = [ item for item in new_chain.l_indices if item not in min_os ][0] #TODO: Seems like there must be a better way to do this if is_reco_level: new_chain.mtOther = np.sqrt( 2 * chain._met * chain._lPt[new_chain.index_other] * (1 - np.cos( deltaPhi(chain._lPhi[new_chain.index_other], chain._metPhi)))) #ptCone new_chain.pt_cone = [] for l in xrange(chain._nLight): new_chain.pt_cone.append(chain._lPt[l] * (1 + max(0., chain._miniIso[l] - 0.4)) ) #TODO: is this the correct definition? else: new_chain.mtOther = np.sqrt( 2 * chain._gen_met * chain._gen_lPt[new_chain.index_other] * (1 - np.cos( deltaPhi(chain._gen_lPhi[new_chain.index_other], chain._gen_metPhi)))) # #ptCone # new_chain.pt_cone = [] # for l in xrange(chain._nLight): # new_chain.pt_cone.append(chain._lPt[l]) #TODO: is this the correct definition? #calculate #jets and #bjets new_chain.njets = selectJets(chain) new_chain.nbjets = nBjets(chain, 'loose') new_chain.hasOSSF = containsOSSF(new_chain) # # dR variables # new_chain.dr_l1l2 = l1Vec.DeltaR(l2Vec) new_chain.dr_l1l3 = l1Vec.DeltaR(l2Vec) new_chain.dr_l2l3 = l1Vec.DeltaR(l2Vec) new_chain.dr_minOS = lVec[min_os[0]].DeltaR( lVec[min_os[1]]) if all(min_os) else -999. new_chain.dr_maxOS = lVec[max_os[0]].DeltaR( lVec[max_os[1]]) if all(max_os) else -999. new_chain.dr_minSS = lVec[min_ss[0]].DeltaR( lVec[min_ss[1]]) if all(min_ss) else -999. new_chain.dr_maxSS = lVec[max_ss[0]].DeltaR( lVec[max_ss[1]]) if all(max_ss) else -999. new_chain.dr_minOSSF = lVec[min_ossf[0]].DeltaR( lVec[min_ossf[1]]) if all(min_ossf) else -999. new_chain.dr_maxOSSF = lVec[max_ossf[0]].DeltaR( lVec[max_ossf[1]]) if all(max_ossf) else -999. new_chain.dr_minSSSF = lVec[min_sssf[0]].DeltaR( lVec[min_sssf[1]]) if all(min_sssf) else -999. new_chain.dr_maxSSSF = lVec[max_sssf[0]].DeltaR( lVec[max_sssf[1]]) if all(max_sssf) else -999. new_chain.mindr_l1 = min(new_chain.dr_l1l2, new_chain.dr_l1l3) new_chain.maxdr_l1 = max(new_chain.dr_l1l2, new_chain.dr_l1l3) new_chain.mindr_l2 = min(new_chain.dr_l1l2, new_chain.dr_l2l3) new_chain.maxdr_l2 = max(new_chain.dr_l1l2, new_chain.dr_l2l3) new_chain.mindr_l3 = min(new_chain.dr_l1l3, new_chain.dr_l2l3) new_chain.maxdr_l3 = max(new_chain.dr_l1l3, new_chain.dr_l2l3) return
def calculateFourLepVariables(chain, new_chain): l1Vec = getFourVec(new_chain.l_pt[l1], new_chain.l_eta[l1], new_chain.l_phi[l1], new_chain.l_e[l1]) l2Vec = getFourVec(new_chain.l_pt[l2], new_chain.l_eta[l2], new_chain.l_phi[l2], new_chain.l_e[l2]) l3Vec = getFourVec(new_chain.l_pt[l3], new_chain.l_eta[l3], new_chain.l_phi[l3], new_chain.l_e[l3]) l4Vec = getFourVec(new_chain.l_pt[l4], new_chain.l_eta[l4], new_chain.l_phi[l4], new_chain.l_e[l4]) lVec = [l1Vec, l2Vec, l3Vec, l4Vec] if len(chain.l_pt) < 4: raise RuntimeError( 'Inconsistent input: No 4 leptons to use in 4 lepton calculations') min_os = None tmp_minos = 99999999. for i1 in xrange(len(new_chain.l_indices)): for i2 in xrange(i1, len(new_chain.l_indices)): if i2 <= i1: continue tmp_mass = (lVec[i1] + lVec[i2]).M() if new_chain.l_charge[i1] != new_chain.l_charge[ i2] and tmp_mass < tmp_minos: min_os = [i1, i2] tmp_minos = tmp_mass new_chain.minMos = (lVec[min_os[0]] + lVec[min_os[1]]).M() if min_os is not None else -1 new_chain.M4l = (l1Vec + l2Vec + l3Vec + l4Vec).M() #Mll(Z1) amd Mll(Z2) trial_pairs = [[(l1, l2), (l3, l4)], [(l1, l3), (l2, l4)], [(l1, l4), (l2, l3)]] candidate_pairs = [] for t in trial_pairs: if isOSSF(chain, t[0][0], t[0][1]) and isOSSF(chain, t[1][0], t[1][1]): candidate_pairs.append(t) if len(candidate_pairs) == 0: mass1, mass2 = (-1., -1.) elif len(candidate_pairs) == 1: mass1 = (lVec[candidate_pairs[0][0][0]] + lVec[candidate_pairs[0][0][1]]).M() mass2 = (lVec[candidate_pairs[0][1][0]] + lVec[candidate_pairs[0][1][1]]).M() else: mass1 = (lVec[candidate_pairs[0][0][0]] + lVec[candidate_pairs[0][0][1]]).M() mass2 = (lVec[candidate_pairs[1][0][0]] + lVec[candidate_pairs[1][0][1]]).M() for c in candidate_pairs[1:]: tmp_mass1 = (lVec[c[0][0]] + lVec[c[0][1]]).M() tmp_mass2 = (lVec[c[1][0]] + lVec[c[1][1]]).M() if (massDiff(tmp_mass1, MZ) + massDiff(tmp_mass2, MZ)) < ( massDiff(mass1, MZ) + massDiff(mass1, MZ)): mass1 = tmp_mass1 mass2 = tmp_mass2 if massDiff(mass1, MZ) < massDiff(mass2, MZ): new_chain.Mll_Z1 = mass1 new_chain.Mll_Z2 = mass2 else: new_chain.Mll_Z1 = mass2 new_chain.Mll_Z2 = mass1
def calculateThreeLepVariables(chain, new_chain, is_reco_level=True): l1Vec = getFourVec(new_chain.l_pt[l1], new_chain.l_eta[l1], new_chain.l_phi[l1], new_chain.l_e[l1]) l2Vec = getFourVec(new_chain.l_pt[l2], new_chain.l_eta[l2], new_chain.l_phi[l2], new_chain.l_e[l2]) l3Vec = getFourVec(new_chain.l_pt[l3], new_chain.l_eta[l3], new_chain.l_phi[l3], new_chain.l_e[l3]) if is_reco_level: metVec = getFourVec(chain._met, 0., chain._metPhi, chain._met) else: metVec = getFourVec(chain._gen_met, 0., chain._gen_metPhi, chain._gen_met) lVec = [l1Vec, l2Vec, l3Vec] #M3l new_chain.M3l = (l1Vec + l2Vec + l3Vec).M() #All combinations of dilepton masses new_chain.Ml12 = (l1Vec + l2Vec).M() new_chain.Ml23 = (l2Vec + l3Vec).M() new_chain.Ml13 = (l1Vec + l3Vec).M() # # Get OS, OSSF, SS, SSSF variables # min_os = None max_os = None min_ss = None max_ss = None min_ossf = None max_ossf = None min_sssf = None max_sssf = None z_ossf = None tmp_minos = 99999999. tmp_minss = 99999999. tmp_minossf = 99999999. tmp_minsssf = 99999999. tmp_maxos = 0 tmp_maxss = 0 tmp_maxossf = 0 tmp_maxsssf = 0 tmp_Zossf = 0 for i1 in xrange(3): for i2 in xrange(3): if i2 <= i1: continue tmp_mass = (lVec[i1] + lVec[i2]).M() if new_chain.l_charge[i1] == new_chain.l_charge[i2]: if tmp_mass < tmp_minss: min_ss = [i1, i2] tmp_minss = tmp_mass if tmp_mass > tmp_maxss: max_ss = [i1, i2] tmp_maxss = tmp_mass if new_chain.l_flavor[i1] == new_chain.l_flavor[i2]: if tmp_mass < tmp_minsssf: min_sssf = [i1, i2] tmp_minsssf = tmp_mass if tmp_mass > tmp_maxsssf: max_sssf = [i1, i2] tmp_maxsssf = tmp_mass else: # print "OS" if tmp_mass < tmp_minos: min_os = [i1, i2] tmp_minos = tmp_mass if tmp_mass > tmp_maxos: max_os = [i1, i2] tmp_maxos = tmp_mass if new_chain.l_flavor[i1] == new_chain.l_flavor[i2]: # print "SF" if tmp_mass < tmp_minossf: min_ossf = [i1, i2] tmp_minossf = tmp_mass if massDiff(tmp_mass, MZ) < massDiff(tmp_Zossf, MZ): z_ossf = [i1, i2] tmp_Zossf = tmp_mass if tmp_mass > tmp_maxossf: max_ossf = [i1, i2] tmp_maxossf = tmp_mass #Mass variables # print min_os new_chain.minMos = (lVec[min_os[0]] + lVec[min_os[1]]).M() if min_os is not None else -1 new_chain.maxMos = (lVec[max_os[0]] + lVec[max_os[1]]).M() if max_os is not None else -1 new_chain.minMss = (lVec[min_ss[0]] + lVec[min_ss[1]]).M() if min_ss is not None else -1 new_chain.maxMss = (lVec[max_ss[0]] + lVec[max_ss[1]]).M() if max_ss is not None else -1 new_chain.minMossf = ( lVec[min_ossf[0]] + lVec[min_ossf[1]]).M() if min_ossf is not None else -1 new_chain.maxMossf = ( lVec[max_ossf[0]] + lVec[max_ossf[1]]).M() if max_ossf is not None else -1 new_chain.minMsssf = ( lVec[min_sssf[0]] + lVec[min_sssf[1]]).M() if min_sssf is not None else -1 new_chain.maxMsssf = ( lVec[max_sssf[0]] + lVec[max_sssf[1]]).M() if max_sssf is not None else -1 new_chain.MZossf = (lVec[z_ossf[0]] + lVec[z_ossf[1]]).M() if z_ossf is not None else -1 #MTother new_chain.index_other = [item for item in [0, 1, 2] if item not in min_os ][0] if min_os is not None else None if new_chain.index_other is not None: if is_reco_level: new_chain.mtOther = np.sqrt( 2 * chain._met * chain.l_pt[new_chain.index_other] * (1 - np.cos( deltaPhi(chain.l_phi[new_chain.index_other], chain._metPhi)))) leading_os = min_os[0] if chain.l_pt[min_os[0]] > chain.l_pt[ min_os[1]] else min_os[1] subleading_os = min_os[0] if chain.l_pt[min_os[0]] < chain.l_pt[ min_os[1]] else min_os[1] new_chain.mtl1 = np.sqrt( 2 * chain._met * chain.l_pt[leading_os] * (1 - np.cos(deltaPhi(chain.l_phi[leading_os], chain._metPhi)))) new_chain.mtl2 = np.sqrt( 2 * chain._met * chain.l_pt[subleading_os] * (1 - np.cos(deltaPhi(chain.l_phi[subleading_os], chain._metPhi)))) else: new_chain.mtOther = np.sqrt( 2 * chain._gen_met * chain.l_pt[new_chain.index_other] * (1 - np.cos( deltaPhi(chain.l_phi[new_chain.index_other], chain._gen_metPhi)))) leading_os = min_os[0] if chain.l_pt[min_os[0]] > chain.l_pt[ min_os[1]] else min_os[1] subleading_os = min_os[0] if chain.l_pt[min_os[0]] < chain.l_pt[ min_os[1]] else min_os[1] new_chain.mtl1 = np.sqrt( 2 * chain._gen_met * chain.l_pt[leading_os] * (1 - np.cos(deltaPhi(chain.l_phi[leading_os], chain._gen_metPhi)))) new_chain.mtl2 = np.sqrt( 2 * chain._gen_met * chain.l_pt[subleading_os] * (1 - np.cos( deltaPhi(chain.l_phi[subleading_os], chain._gen_metPhi)))) else: new_chain.mtOther = -1 new_chain.mtl1 = -1 new_chain.mtl2 = -1 #MT3 new_chain.mt3 = (l1Vec + l2Vec + l3Vec + metVec).Mt() # # dR variables # new_chain.dr_l1l2 = l1Vec.DeltaR(l2Vec) new_chain.dr_l1l3 = l1Vec.DeltaR(l3Vec) new_chain.dr_l2l3 = l2Vec.DeltaR(l3Vec) new_chain.dr_minOS = lVec[min_os[0]].DeltaR( lVec[min_os[1]]) if min_os is not None else -1. new_chain.dr_maxOS = lVec[max_os[0]].DeltaR( lVec[max_os[1]]) if max_os is not None else -1. new_chain.dr_minSS = lVec[min_ss[0]].DeltaR( lVec[min_ss[1]]) if min_ss is not None else -1. new_chain.dr_maxSS = lVec[max_ss[0]].DeltaR( lVec[max_ss[1]]) if max_ss is not None else -1. new_chain.dr_minOSSF = lVec[min_ossf[0]].DeltaR( lVec[min_ossf[1]]) if min_ossf is not None else -1. new_chain.dr_maxOSSF = lVec[max_ossf[0]].DeltaR( lVec[max_ossf[1]]) if max_ossf is not None else -1. new_chain.dr_minSSSF = lVec[min_sssf[0]].DeltaR( lVec[min_sssf[1]]) if min_sssf is not None else -1. new_chain.dr_maxSSSF = lVec[max_sssf[0]].DeltaR( lVec[max_sssf[1]]) if max_sssf is not None else -1. new_chain.mindr_l1 = min(new_chain.dr_l1l2, new_chain.dr_l1l3) new_chain.maxdr_l1 = max(new_chain.dr_l1l2, new_chain.dr_l1l3) new_chain.mindr_l2 = min(new_chain.dr_l1l2, new_chain.dr_l2l3) new_chain.maxdr_l2 = max(new_chain.dr_l1l2, new_chain.dr_l2l3) new_chain.mindr_l3 = min(new_chain.dr_l1l3, new_chain.dr_l2l3) new_chain.maxdr_l3 = max(new_chain.dr_l1l3, new_chain.dr_l2l3)
def calculateThreeLepVariables(chain, new_chain, is_reco_level=True): # print "NEW" l1Vec = getFourVec(new_chain.l_pt[l1], new_chain.l_eta[l1], new_chain.l_phi[l1], new_chain.l_e[l1]) l2Vec = getFourVec(new_chain.l_pt[l2], new_chain.l_eta[l2], new_chain.l_phi[l2], new_chain.l_e[l2]) l3Vec = getFourVec(new_chain.l_pt[l3], new_chain.l_eta[l3], new_chain.l_phi[l3], new_chain.l_e[l3]) lVec = [l1Vec, l2Vec, l3Vec] # print "l1" # printFourVec(l1Vec) # print "l2" # printFourVec(l2Vec) # print "l3" # printFourVec(l3Vec) #M3l new_chain.M3l = (l1Vec + l2Vec + l3Vec).M() # print "m3l", new_chain.M3l #All combinations of dilepton masses new_chain.Ml12 = (l1Vec + l2Vec).M() new_chain.Ml23 = (l2Vec + l3Vec).M() new_chain.Ml13 = (l1Vec + l3Vec).M() # # Get OS, OSSF, SS, SSSF variables # min_os = None max_os = None min_ss = None max_ss = None min_ossf = None max_ossf = None min_sssf = None max_sssf = None Z_ossf = None tmp_minos = 99999999. tmp_minss = 99999999. tmp_minossf = 99999999. tmp_minsssf = 99999999. tmp_maxos = 0 tmp_maxss = 0 tmp_maxossf = 0 tmp_maxsssf = 0 tmp_Zossf = 0 for i1, l in enumerate([new_chain.l1, new_chain.l2, new_chain.l3]): for i2, sl in enumerate([new_chain.l1, new_chain.l2, new_chain.l3]): if i2 <= i1: continue # print i1, i2 # print chain.l_flavor[i1], chain.l_flavor[i2] # print chain.l_charge[i1], chain.l_charge[i2] # print chain._lMomPdgId[l], chain._lMomPdgId[sl] tmp_mass = (lVec[i1] + lVec[i2]).M() # print tmp_mass if new_chain.l_charge[i1] == new_chain.l_charge[i2]: if tmp_mass < tmp_minss: min_ss = [i1, i2] tmp_minss = tmp_mass if tmp_mass > tmp_maxss: max_ss = [i1, i2] tmp_maxss = tmp_mass if new_chain.l_flavor[i1] == new_chain.l_flavor[i2]: if tmp_mass < tmp_minsssf: min_sssf = [i1, i2] tmp_minsssf = tmp_mass if tmp_mass > tmp_maxsssf: max_sssf = [i1, i2] tmp_maxsssf = tmp_mass else: # print "OS" if tmp_mass < tmp_minos: min_os = [i1, i2] tmp_minos = tmp_mass if tmp_mass > tmp_maxos: max_os = [i1, i2] tmp_maxos = tmp_mass if new_chain.l_flavor[i1] == new_chain.l_flavor[i2]: # print "SF" if tmp_mass < tmp_minossf: min_ossf = [i1, i2] tmp_minossf = tmp_mass if massDiff(tmp_mass, MZ) < massDiff(tmp_Zossf, MZ): Z_ossf = [i1, i2] tmp_Zossf = tmp_mass if tmp_mass > tmp_maxossf: max_ossf = [i1, i2] tmp_maxossf = tmp_mass #Mass variables # print min_os chain.minMos = (lVec[min_os[0]] + lVec[min_os[1]]).M() if min_os is not None else -1 chain.maxMos = (lVec[max_os[0]] + lVec[max_os[1]]).M() if max_os is not None else -1 chain.minMss = (lVec[min_ss[0]] + lVec[min_ss[1]]).M() if min_ss is not None else -1 chain.maxMss = (lVec[max_ss[0]] + lVec[max_ss[1]]).M() if max_ss is not None else -1 chain.minMossf = (lVec[min_ossf[0]] + lVec[min_ossf[1]]).M() if min_ossf is not None else -1 chain.maxMossf = (lVec[max_ossf[0]] + lVec[max_ossf[1]]).M() if max_ossf is not None else -1 chain.minMsssf = (lVec[min_sssf[0]] + lVec[min_sssf[1]]).M() if min_sssf is not None else -1 chain.maxMsssf = (lVec[max_sssf[0]] + lVec[max_sssf[1]]).M() if max_sssf is not None else -1 chain.MZossf = (lVec[Z_ossf[0]] + lVec[Z_ossf[1]]).M() if Z_ossf is not None else -1 # print "END CHOICES" # print "tmp_minos", tmp_minos, chain.minMos # print 'tmp_minss', tmp_minss, chain.maxMss # print 'tmp_maxos', tmp_maxos, chain.maxMos # print 'tmp_maxss', tmp_maxss, chain.maxMss # print 'tmp_minossf', tmp_minossf, chain.minMossf # print 'tmp_minssff', tmp_minsssf, chain.minMsssf # print 'tmp_maxossf', tmp_maxossf, chain.maxMossf # print 'tmp_maxsssf', tmp_maxsssf, chain.maxMsssf # print 'tmp_Zossf', tmp_Zossf, chain.MZossf #MTother # print chain.l1, chain.l2, chain.l3 # print 'min_os_ind', min_os index_other = [item for item in [0, 1, 2] if item not in min_os][0] if min_os is not None else None new_chain.index_other = new_chain.l_indices[ index_other] if index_other is not None else -1 # print [item for item in [new_chain.l1, new_chain.l2, new_chain.l3] if item not in min_os][0] if min_os is not None else -1 # print 'ind_other', index_other, new_chain.index_other if new_chain.index_other != -1: if is_reco_level: new_chain.mtOther = np.sqrt( 2 * chain._met * chain._lPt[new_chain.index_other] * (1 - np.cos( deltaPhi(chain._lPhi[new_chain.index_other], chain._metPhi)))) else: new_chain.mtOther = np.sqrt( 2 * chain._gen_met * chain._gen_lPt[new_chain.index_other] * (1 - np.cos( deltaPhi(chain._gen_lPhi[new_chain.index_other], chain._gen_metPhi)))) else: new_chain.mtOther = -1 # # dR variables # new_chain.dr_l1l2 = l1Vec.DeltaR(l2Vec) new_chain.dr_l1l3 = l1Vec.DeltaR(l2Vec) new_chain.dr_l2l3 = l1Vec.DeltaR(l2Vec) new_chain.dr_minOS = lVec[min_os[0]].DeltaR( lVec[min_os[1]]) if min_os is not None else -999. new_chain.dr_maxOS = lVec[max_os[0]].DeltaR( lVec[max_os[1]]) if max_os is not None else -999. new_chain.dr_minSS = lVec[min_ss[0]].DeltaR( lVec[min_ss[1]]) if min_ss is not None else -999. new_chain.dr_maxSS = lVec[max_ss[0]].DeltaR( lVec[max_ss[1]]) if max_ss is not None else -999. new_chain.dr_minOSSF = lVec[min_ossf[0]].DeltaR( lVec[min_ossf[1]]) if min_ossf is not None else -999. new_chain.dr_maxOSSF = lVec[max_ossf[0]].DeltaR( lVec[max_ossf[1]]) if max_ossf is not None else -999. new_chain.dr_minSSSF = lVec[min_sssf[0]].DeltaR( lVec[min_sssf[1]]) if min_sssf is not None else -999. new_chain.dr_maxSSSF = lVec[max_sssf[0]].DeltaR( lVec[max_sssf[1]]) if max_sssf is not None else -999. new_chain.mindr_l1 = min(new_chain.dr_l1l2, new_chain.dr_l1l3) new_chain.maxdr_l1 = max(new_chain.dr_l1l2, new_chain.dr_l1l3) new_chain.mindr_l2 = min(new_chain.dr_l1l2, new_chain.dr_l2l3) new_chain.maxdr_l2 = max(new_chain.dr_l1l2, new_chain.dr_l2l3) new_chain.mindr_l3 = min(new_chain.dr_l1l3, new_chain.dr_l2l3) new_chain.maxdr_l3 = max(new_chain.dr_l1l3, new_chain.dr_l2l3)