示例#1
0
def lorentzVecsLeps(nom, is3l):

    '''
    Higgs decays to two jets and one lepton, or two leptons. This returns lorentzVectors for each decay product candidate
    For H -> 2j, 1l case (not isF): returns jet0, jet1, met, lep0, lep1, (lep2 if is3l)
    For H -> 2l case (isF): Return met, lep0, lep1, lep2 
    '''

    met = LorentzVector()
    met.SetPtEtaPhiE(nom.met_met, 0, nom.met_phi, nom.met_met)

    lep0 = LorentzVector()
    lep0.SetPtEtaPhiE(nom.lep_Pt_0, nom.lep_Eta_0, nom.lep_Phi_0, nom.lep_E_0)

    lep1 = LorentzVector()
    lep1.SetPtEtaPhiE(nom.lep_Pt_1, nom.lep_Eta_1, nom.lep_Phi_1, nom.lep_E_1)

    if is3l:
        lep2 = LorentzVector()
        lep2.SetPtEtaPhiE(nom.lep_Pt_2, nom.lep_Eta_2, nom.lep_Phi_2, nom.lep_E_2)


    if is3l:
        return (lep0, lep1, lep2, met)
    else:
        return (lep0, lep1, met)
示例#2
0
def lorentzVecsTop(nom, topIdx0, topIdx1):
    '''
    Takes the indices of two jets identified to be bjets from top decay, return their LorentzVectors 
    '''

    top0 = LorentzVector()                                                                                                   
    top0.SetPtEtaPhiE(nom.jet_pt[topIdx0], nom.jet_eta[topIdx0], nom.jet_phi[topIdx0], nom.jet_e[topIdx0])
    top1 = LorentzVector()                                                                                         
    top1.SetPtEtaPhiE(nom.jet_pt[topIdx1], nom.jet_eta[topIdx1], nom.jet_phi[topIdx1], nom.jet_e[topIdx1])

    return (top0, top1)
示例#3
0
def calcTopMass(nom, topMasses):
    current = 0
    for e in nom:
        current += 1
        if current % 10000 == 0:
            print(current)
        #if current==200000:
        #    break

        if e.nJets_OR != 1:
            continue
        if e.nJets_OR_DL1_70 != 1:
            continue
        if abs(e.Mll01 - 91.2e3) > 10e3 and abs(e.Mll02 - 91.2e3) > 10e3:
            continue
        if e.trilep_type == 0: continue

        lep = LorentzVector()

        if abs(e.Mll02 - 91.2e3) < abs(e.Mll01 - 91.2e3):
            lep.SetPtEtaPhiE(e.lep_Pt_1, e.lep_Eta_1, e.lep_Phi_1, e.lep_E_1)
        else:
            lep.SetPtEtaPhiE(e.lep_Pt_2, e.lep_Eta_2, e.lep_Phi_2, e.lep_E_2)

        met = neutrinoPz(lep, e.met_met, e.met_phi)

        w = lep + met

        #w_eta = np.arccosh( abs( np.sqrt(wt.E()**2 - 80e3**2)/ wt.Pt() ) )
        #w = LorentzVector()
        #w.SetPtEtaPhiE(wt.Pt(), w_eta, wt.Phi(), wt.E())
        #print('M', w.M())

        jet = LorentzVector()
        jet.SetPtEtaPhiE(e.jets_Pt_0, e.jets_Eta_0, e.jets_Phi_0, e.jets_E_0)

        top = LorentzVector()

        top = w + jet

        topMasses.append(top.M())

        if top.M() < 0:
            print(top.M(), w.M())
示例#4
0
def lorentzVecs(nom, jetIdx0, jetIdx1, is3l):
    '''
    Initialize met, lepton, and jet lorentz vectors       
    Return jet0, jet1, met, lep0, lep1, (lep2 if is3l)
    '''

    met = LorentzVector()
    met.SetPtEtaPhiE(nom.met_met, 0, nom.met_phi, nom.met_met)

    lep0 = LorentzVector()
    lep0.SetPtEtaPhiE(nom.lep_Pt_0, nom.lep_Eta_0, nom.lep_Phi_0, nom.lep_E_0)

    lep1 = LorentzVector()
    lep1.SetPtEtaPhiE(nom.lep_Pt_1, nom.lep_Eta_1, nom.lep_Phi_1, nom.lep_E_1)

    if is3l:
        lep2 = LorentzVector()
        lep2.SetPtEtaPhiE(nom.lep_Pt_2, nom.lep_Eta_2, nom.lep_Phi_2, nom.lep_E_2)

    jet0 = LorentzVector()                                                                                                
    jet0.SetPtEtaPhiE(nom.jet_pt[jetIdx0], nom.jet_eta[jetIdx0], nom.jet_phi[jetIdx0], nom.jet_e[jetIdx0])

    jet1 = LorentzVector()                                                                                                   
    jet1.SetPtEtaPhiE(nom.jet_pt[jetIdx1], nom.jet_eta[jetIdx1], nom.jet_phi[jetIdx1], nom.jet_e[jetIdx1])

    if is3l:
        return (jet0, jet1, met, lep0, lep1, lep2)
    else:
        return (jet0, jet1, met, lep0, lep1)
示例#5
0
    def fourvect(self):
        if ((self.nSCTHits + self.nPixHits) < 4):
            # electron with low number of tracker hits
            eta = self.cl_eta
            phi = self.cl_phi
            et  = self.cl_E / math.cosh(self.cl_eta)
        else:
            eta = self.tracketa
            phi = self.trackphi
            et  = self.cl_E / math.cosh(self.tracketa)

        vect = LorentzVector()
        vect.SetPtEtaPhiE(et, eta, phi, self.cl_E)
        return vect
示例#6
0
def create_dict(nom):
    current = 0

    events = []
    bestScores = []

    nEntries = nom.GetEntries()
    print(nEntries)
    for idx in range(nEntries):
        if idx % 10000 == 0:
            print(str(idx) + '/' + str(nEntries))

        nom.GetEntry(idx)

        higgCand = LorentzVector()

        lep4Vecs = []
        jet4Vecs = []

        btags = []

        met = LorentzVector()
        met.SetPtEtaPhiE(nom.MET_RefFinal_et, 0, nom.MET_RefFinal_phi,
                         nom.MET_RefFinal_et)

        #for i in range(2):
        lep_Pt_0 = nom.lep_Pt_0
        lep_Eta_0 = nom.lep_Eta_0
        lep_Phi_0 = nom.lep_Phi_0
        lep_E_0 = nom.lep_E_0

        lepVec_0 = LorentzVector()
        lepVec_0.SetPtEtaPhiE(lep_Pt_0, lep_Eta_0, lep_Phi_0, lep_E_0)
        lep4Vecs.append(lepVec_0)

        lep_Pt_1 = nom.lep_Pt_1
        lep_Eta_1 = nom.lep_Eta_1
        lep_Phi_1 = nom.lep_Phi_1
        lep_E_1 = nom.lep_E_1

        lepVec_1 = LorentzVector()
        lepVec_1.SetPtEtaPhiE(lep_Pt_1, lep_Eta_1, lep_Phi_1, lep_E_1)
        lep4Vecs.append(lepVec_1)

        for j in range(len(nom.m_pflow_jet_pt)):  #nom.selected_jets'][i]:
            jetVec = LorentzVector()
            jetVec.SetPtEtaPhiM(nom.m_pflow_jet_pt[j], nom.m_pflow_jet_eta[j],
                                nom.m_pflow_jet_phi[j], nom.m_pflow_jet_m[j])
            jet4Vecs.append(jetVec)

            btags.append(nom.m_pflow_jet_flavor_weight_MV2c10[j])

        combos = []
        combosTop = []

        for l in range(len(lep4Vecs)):
            for i in range(len(jet4Vecs) - 1):
                for j in range(i + 1, len(jet4Vecs)):
                    comb = [l, i, j]

                    t = topDict(jet4Vecs[i], jet4Vecs[j], lep4Vecs[0],
                                lep4Vecs[1], met, btags[i], btags[j],
                                nom.m_pflow_jet_jvt[i], nom.m_pflow_jet_jvt[j],
                                nom.m_pflow_jet_numTrk[i],
                                nom.m_pflow_jet_numTrk[j])

                    combosTop.append([t, comb])

        #loop over combinations, score them in the BDT, figure out the best result
        topDF = pd.DataFrame.from_dict([x[0] for x in combosTop])
        topMat = xgb.DMatrix(topDF, feature_names=list(topDF))

        topPred = topModel.predict(topMat)
        topBest = np.argmax(topPred)

        bestTopComb = combosTop[topBest][1]
        topMatches = bestTopComb[1:]

        for l in range(len(lep4Vecs)):
            for i in range(len(jet4Vecs) - 1):
                for j in range(i + 1, len(jet4Vecs)):
                    comb = [l, i, j]

                    if l == 0:
                        k = higgsDict(jet4Vecs[i], jet4Vecs[j], lep4Vecs[l],
                                      met, btags[i], btags[j], lep4Vecs[1],
                                      nom.m_pflow_jet_jvt[i],
                                      nom.m_pflow_jet_jvt[j],
                                      nom.m_pflow_jet_numTrk[i],
                                      nom.m_pflow_jet_numTrk[j])
                    else:
                        k = higgsDict(jet4Vecs[i], jet4Vecs[j], lep4Vecs[l],
                                      met, btags[i], btags[j], lep4Vecs[0],
                                      nom.m_pflow_jet_jvt[i],
                                      nom.m_pflow_jet_jvt[j],
                                      nom.m_pflow_jet_numTrk[i],
                                      nom.m_pflow_jet_numTrk[j])

                    combos.append([k, comb])

        ###Evaluate higgsTop BDT
        df = pd.DataFrame.from_dict([x[0] for x in combos])
        xgbMat = xgb.DMatrix(df, feature_names=list(df))

        pred = xgbModel.predict(xgbMat)
        best = np.argmax(pred)

        bestScores.append(pred[best])

        bestComb = combos[best][1]
        lepMatch = bestComb[0]
        jetMatches = bestComb[1:]

        k = {}
        #k['higgs_pt'] = nom.higgs_pt
        k['comboScore'] = pred[best]
        k['topScore'] = topPred[topBest]

        if lepMatch == 0:
            k['lep_Pt_H'] = nom.lep_Pt_0
            k['lep_Eta_H'] = nom.lep_Eta_0
            phi_0 = nom.lep_Phi_0
            k['lep_E_H'] = nom.lep_E_0

            k['lep_Pt_O'] = nom.lep_Pt_1
            k['lep_Eta_O'] = nom.lep_Eta_1
            k['lep_Phi_O'] = calc_phi(phi_0, nom.lep_Phi_1)
            k['lep_E_O'] = nom.lep_E_1

        elif lepMatch == 1:
            k['lep_Pt_H'] = nom.lep_Pt_1
            k['lep_Eta_H'] = nom.lep_Eta_1
            phi_0 = nom.lep_Phi_1
            k['lep_E_H'] = nom.lep_E_1

            k['lep_Pt_O'] = nom.lep_Pt_0
            k['lep_Eta_O'] = nom.lep_Eta_0
            k['lep_Phi_O'] = calc_phi(phi_0, nom.lep_Phi_0)
            k['lep_E_O'] = nom.lep_E_0

        n = 0
        for i in jetMatches:  #nom.nJets_OR_T):

            k['jet_Pt_h' + str(n)] = nom.m_pflow_jet_pt[i]
            k['jet_Eta_h' + str(n)] = nom.m_pflow_jet_eta[i]
            k['jet_E_h' + str(n)] = jet4Vecs[i].E()  #nom.m_pflow_jet_E[i]
            k['jet_Phi_h' + str(n)] = calc_phi(phi_0, nom.m_pflow_jet_phi[i])
            k['jet_MV2c10_h' +
              str(n)] = nom.m_pflow_jet_flavor_weight_MV2c10[i]

            n += 1

        btags = np.array(btags)

        btags[jetMatches[0]] = 0
        btags[jetMatches[1]] = 0
        bestBtags = np.argpartition(btags, -2)[-2:]

        n = 0
        for i in topMatches:  #bestBtags:#nom.nJets_OR_T):
            k['top_Pt_' + str(n)] = nom.m_pflow_jet_pt[i]
            k['top_Eta_' + str(n)] = nom.m_pflow_jet_eta[i]
            k['top_E_' + str(n)] = jet4Vecs[i].E()  #nom.m_pflow_jet_E[i]
            k['top_Phi_' + str(n)] = calc_phi(phi_0, nom.m_pflow_jet_phi[i])
            k['top_MV2c10_' + str(n)] = nom.m_pflow_jet_flavor_weight_MV2c10[i]

            n += 1

        k['MET'] = nom.MET_RefFinal_et
        k['MET_phi'] = calc_phi(phi_0, nom.MET_RefFinal_phi)

        events.append(k)

    return events
示例#7
0
def run_top_mass(inputPath):

    topMassesWZ = []
    topMassestZ = []
    topMassReco = []

    f = TFile(inputPath, "READ")
    dsid = inputPath.split('/')[-1]
    dsid = dsid.replace('.root', '')
    #print(inputPath)
    nom = f.Get('nominal')

    try:
        nom.GetEntries()
    except:
        print('failed for ' + inputPath)
        return 0

    try:
        nom.Mll01
    except:
        print('failed for ' + inputPath)
        return 0

    if nom.GetEntries() == 0:
        return 0

    if hasattr(nom, "topMassReco"):
        print('already there', inputPath)
        return 0

    nEntries = nom.GetEntries()
    for idx in range(nEntries):
        if idx % 10000 == 0:
            print(str(idx) + '/' + str(nEntries))

        nom.GetEntry(idx)

        lep = LorentzVector()

        if abs(nom.Mll02 - 91.2e3) < abs(nom.Mll01 - 91.2e3):
            lep.SetPtEtaPhiE(nom.lep_Pt_1, nom.lep_Eta_1, nom.lep_Phi_1,
                             nom.lep_E_1)
        else:
            lep.SetPtEtaPhiE(nom.lep_Pt_2, nom.lep_Eta_2, nom.lep_Phi_2,
                             nom.lep_E_2)

        met = neutrinoPz(lep, nom.met_met, nom.met_phi)

        w = lep + met

        jet = LorentzVector()
        #jet.SetPtEtaPhiE( nom.jet_Pt_0, nom.jet_Eta_0, nom.jet_Phi_0, nom.jet_E_0 )
        if len(nom.jet_pt):
            jet.SetPtEtaPhiE(nom.jet_pt[0], nom.jet_eta[0], nom.jet_phi[0],
                             nom.jet_e[0])
        else:
            jet.SetPtEtaPhiE(0, 0, 0, 0)

        top = LorentzVector()

        top = w + jet

        topMassReco.append(top.M())

    f.Close()

    with root_open(inputPath, mode='a') as myfile:
        topMassReco = np.asarray(topMassReco)
        topMassReco.dtype = [('topMassReco', 'float64')]
        topMassReco.dtype.names = ['topMassReco']
        root_numpy.array2tree(topMassReco, tree=myfile.nominal)
        myfile.write()
        myfile.Close()
示例#8
0
        print(current)
        #if current==200000:
        #    break
        
        #if e.nJets_OR_T!=1: 
        #    continue
        #if e.nJets_OR_T_MV2c10_70!=1:
        #    continue
        #if abs(e.Mll01 - 91.2e3) > 10e3 and abs(e.Mll02 - 91.2e3) > 10e3:
        #    continue
        #if e.trilep_type==0: continue

    lep = LorentzVector()
    
    if abs(e.Mll02 - 91.2e3) < abs(e.Mll01 - 91.2e3):
        lep.SetPtEtaPhiE( e.lep_Pt_1, e.lep_Eta_1, e.lep_Phi_1, e.lep_E_1 )
    else:
        lep.SetPtEtaPhiE( e.lep_Pt_2, e.lep_Eta_2, e.lep_Phi_2, e.lep_E_2 ) 
        
    met = neutrinoPz(lep, e.met_met, e.met_phi)
    
    w = lep+met
    
    jet = LorentzVector()
    jet.SetPtEtaPhiE( e.jets_Pt_0, e.jets_Eta_0, e.jets_Phi_0, e.jets_E_0 )
    
    top = LorentzVector()
    
    top = w+jet

    topMassReco.append(top.M())
示例#9
0
def create_dict(nom):
    current = 0

    events1l = []
    events2l = []
    decayDicts = []
    bestScores = []

    nEntries = nom.GetEntries()
    for idx in range(nEntries):
        if idx % 10000 == 0:
            print(str(idx) + '/' + str(nEntries))
            #if current%100000==0:
            #break
        nom.GetEntry(idx)

        higgCand = LorentzVector()

        lep4Vecs = []
        jet4Vecs = []

        btags = []

        met = LorentzVector()
        met.SetPtEtaPhiE(nom.MET_RefFinal_et, 0, nom.MET_RefFinal_phi,
                         nom.MET_RefFinal_et)

        lepVec_0 = LorentzVector()
        lepVec_0.SetPtEtaPhiE(nom.lep_Pt_0, nom.lep_Eta_0, nom.lep_Phi_0,
                              nom.lep_E_0)
        lep4Vecs.append(lepVec_0)

        lepVec_1 = LorentzVector()
        lepVec_1.SetPtEtaPhiE(nom.lep_Pt_1, nom.lep_Eta_1, nom.lep_Phi_1,
                              nom.lep_E_1)
        lep4Vecs.append(lepVec_1)

        lepVec_2 = LorentzVector()
        lepVec_2.SetPtEtaPhiE(nom.lep_Pt_2, nom.lep_Eta_2, nom.lep_Phi_2,
                              nom.lep_E_2)
        lep4Vecs.append(lepVec_2)

        for j in range(len(nom.m_pflow_jet_pt)):  #nom.selected_jets'][i]:
            jetVec = LorentzVector()
            jetVec.SetPtEtaPhiM(nom.m_pflow_jet_pt[j], nom.m_pflow_jet_eta[j],
                                nom.m_pflow_jet_phi[j], nom.m_pflow_jet_m[j])
            jet4Vecs.append(jetVec)

            btags.append(nom.m_pflow_jet_flavor_weight_MV2c10[j])

        combosTop = []

        for l in range(len(lep4Vecs)):
            for i in range(len(jet4Vecs) - 1):
                for j in range(i + 1, len(jet4Vecs)):
                    comb = [l, i, j]

                    t = topDict(jet4Vecs[i], jet4Vecs[j], lep4Vecs[0],
                                lep4Vecs[1], lep4Vecs[2], met, btags[i],
                                btags[j], nom.m_pflow_jet_jvt[i],
                                nom.m_pflow_jet_jvt[j],
                                nom.m_pflow_jet_numTrk[i],
                                nom.m_pflow_jet_numTrk[j])

                    combosTop.append([t, comb])

        #loop over combinations, score them in the BDT, figure out the best result
        topDF = pd.DataFrame.from_dict([x[0] for x in combosTop])
        topMat = xgb.DMatrix(topDF, feature_names=list(topDF))

        topPred = topModel.predict(topMat)
        topBest = np.argmax(topPred)

        bestTopComb = combosTop[topBest][1]
        topMatches = bestTopComb[1:]

        combos1l = []

        for l in range(1, len(lep4Vecs)):
            for i in range(len(jet4Vecs) - 1):
                for j in range(i + 1, len(jet4Vecs)):
                    comb = [l, i, j]
                    if l == 1:
                        k = higgs1lDict(
                            jet4Vecs[i], jet4Vecs[j], lep4Vecs[l], met,
                            nom.m_pflow_jet_flavor_weight_MV2c10[i],
                            nom.m_pflow_jet_flavor_weight_MV2c10[j],
                            lep4Vecs[0], lep4Vecs[2], nom.m_pflow_jet_jvt[i],
                            nom.m_pflow_jet_jvt[j], nom.m_pflow_jet_numTrk[i],
                            nom.m_pflow_jet_numTrk[j])
                    else:
                        k = higgs1lDict(
                            jet4Vecs[i], jet4Vecs[j], lep4Vecs[l], met,
                            nom.m_pflow_jet_flavor_weight_MV2c10[i],
                            nom.m_pflow_jet_flavor_weight_MV2c10[j],
                            lep4Vecs[0], lep4Vecs[1], nom.m_pflow_jet_jvt[i],
                            nom.m_pflow_jet_jvt[j], nom.m_pflow_jet_numTrk[i],
                            nom.m_pflow_jet_numTrk[j])

                    combos1l.append([k, comb])

        combos2l = []

        possCombs = [[0, 1, 2], [0, 2, 1]]
        for comb in possCombs:
            k = higgs2lDict(lep4Vecs[comb[0]], lep4Vecs[comb[1]],
                            lep4Vecs[comb[2]], met)
            combos2l.append([k, [comb[0], comb[1]]])

        #Run 2l XGB, find best match
        df2l = pd.DataFrame.from_dict([x[0] for x in combos2l])
        xgbMat2l = xgb.DMatrix(df2l, feature_names=list(df2l))

        pred2l = higgs2lModel.predict(xgbMat2l)
        best2l = np.argmax(pred2l)

        bestComb2l = combos2l[best2l][1]
        lepMatch2l = bestComb2l[1]

        #Run 1l XGB, find best match
        df1l = pd.DataFrame.from_dict([x[0] for x in combos1l])
        xgbMat1l = xgb.DMatrix(df1l, feature_names=list(df1l))

        pred1l = higgs1lModel.predict(xgbMat1l)
        best1l = np.argmax(pred1l)

        bestComb1l = combos1l[best1l][1]
        lepMatch1l = bestComb1l[0]
        jetMatches1l = bestComb1l[1:]

        ### Add decay dict

        k = decayDict(lep4Vecs[0], lep4Vecs[1], lep4Vecs[2], met,
                      jet4Vecs[topMatches[0]], jet4Vecs[topMatches[1]])
        k['nJets'] = nom.nJets_OR_T
        k['nJets_MV2c10_70'] = nom.nJets_OR_T_MV2c10_70
        k['higgs2l_score'] = pred2l[best2l]
        k['higgs1l_score'] = pred1l[best1l]
        decayDicts.append(k)

        ### Add 2l pt prediction dict

        q = {}
        q['comboScore'] = pred2l[best2l]

        if lepMatch2l == 1:
            q['lep_Pt_0'] = nom.lep_Pt_0
            q['lep_Eta_0'] = nom.lep_Eta_0
            phi_0 = nom.lep_Phi_0
            q['lep_E_0'] = nom.lep_E_0

            q['lep_Pt_1'] = nom.lep_Pt_1
            q['lep_Eta_1'] = nom.lep_Eta_1
            q['lep_Phi_1'] = calc_phi(phi_0, nom.lep_Phi_1)
            q['lep_E_1'] = nom.lep_E_1

            q['lep_Pt_2'] = nom.lep_Pt_2
            q['lep_Eta_2'] = nom.lep_Eta_2
            q['lep_Phi_2'] = calc_phi(phi_0, nom.lep_Phi_2)
            q['lep_E_2'] = nom.lep_E_2

        elif lepMatch2l == 2:
            q['lep_Pt_0'] = nom.lep_Pt_0
            q['lep_Eta_0'] = nom.lep_Eta_0
            phi_0 = nom.lep_Phi_0
            q['lep_E_0'] = nom.lep_E_0

            q['lep_Pt_1'] = nom.lep_Pt_2
            q['lep_Eta_1'] = nom.lep_Eta_2
            q['lep_Phi_1'] = calc_phi(phi_0, nom.lep_Phi_2)
            q['lep_E_1'] = nom.lep_E_2

            q['lep_Pt_2'] = nom.lep_Pt_1
            q['lep_Eta_2'] = nom.lep_Eta_1
            q['lep_Phi_2'] = calc_phi(phi_0, nom.lep_Phi_1)
            q['lep_E_2'] = nom.lep_E_1

        n = 0
        for i in topMatches:
            q['top_Pt_' + str(n)] = nom.m_pflow_jet_pt[i]
            q['top_Eta_' + str(n)] = nom.m_pflow_jet_eta[i]
            q['top_E_' + str(n)] = jet4Vecs[i].E()  #nom.m_pflow_jet_E[i]
            q['top_Phi_' + str(n)] = calc_phi(phi_0, nom.m_pflow_jet_phi[i])
            q['top_MV2c10_' + str(n)] = nom.m_pflow_jet_flavor_weight_MV2c10[i]

            n += 1

        q['MET'] = nom.MET_RefFinal_et
        q['MET_phi'] = calc_phi(phi_0, nom.MET_RefFinal_phi)

        events2l.append(q)

        ### Add 1l Pt prediction dict

        y = {}
        #y['higgs_pt'] = nom.higgs_pt
        y['comboScore'] = pred1l[best1l]

        if lepMatch1l == 1:
            y['lep_Pt_H'] = nom.lep_Pt_1
            y['lep_Eta_H'] = nom.lep_Eta_1
            phi_0 = nom.lep_Phi_1
            y['lep_E_H'] = nom.lep_E_1

            y['lep_Pt_0'] = nom.lep_Pt_0
            y['lep_Eta_0'] = nom.lep_Eta_0
            y['lep_Phi_0'] = calc_phi(phi_0, nom.lep_Phi_0)
            y['lep_E_0'] = nom.lep_E_0

            y['lep_Pt_1'] = nom.lep_Pt_2
            y['lep_Eta_1'] = nom.lep_Eta_2
            y['lep_Phi_1'] = calc_phi(phi_0, nom.lep_Phi_2)
            y['lep_E_1'] = nom.lep_E_2

        elif lepMatch1l == 2:
            y['lep_Pt_H'] = nom.lep_Pt_2
            y['lep_Eta_H'] = nom.lep_Eta_2
            phi_0 = nom.lep_Phi_2
            y['lep_E_H'] = nom.lep_E_2

            y['lep_Pt_0'] = nom.lep_Pt_0
            y['lep_Eta_0'] = nom.lep_Eta_0
            y['lep_Phi_0'] = calc_phi(phi_0, nom.lep_Phi_0)
            y['lep_E_0'] = nom.lep_E_0

            y['lep_Pt_1'] = nom.lep_Pt_1
            y['lep_Eta_1'] = nom.lep_Eta_1
            y['lep_Phi_1'] = calc_phi(phi_0, nom.lep_Phi_1)
            y['lep_E_1'] = nom.lep_E_1

        n = 0
        for i in jetMatches1l:  #nom.nJets_OR_T):

            y['jet_Pt_h' + str(n)] = nom.m_pflow_jet_pt[i]
            y['jet_Eta_h' + str(n)] = nom.m_pflow_jet_eta[i]
            y['jet_E_h' + str(n)] = jet4Vecs[i].E()  #nom.m_pflow_jet_E[i]
            y['jet_Phi_h' + str(n)] = calc_phi(phi_0, nom.m_pflow_jet_phi[i])
            y['jet_MV2c10_h' +
              str(n)] = nom.m_pflow_jet_flavor_weight_MV2c10[i]

            n += 1

        n = 0
        for i in topMatches:  #bestBtags:#nom.nJets_OR_T):
            y['top_Pt_' + str(n)] = nom.m_pflow_jet_pt[i]
            y['top_Eta_' + str(n)] = nom.m_pflow_jet_eta[i]
            y['top_E_' + str(n)] = jet4Vecs[i].E()  #nom.m_pflow_jet_E[i]
            y['top_Phi_' + str(n)] = calc_phi(phi_0, nom.m_pflow_jet_phi[i])
            y['top_MV2c10_' + str(n)] = nom.m_pflow_jet_flavor_weight_MV2c10[i]

            n += 1

        y['MET'] = nom.MET_RefFinal_et
        y['MET_phi'] = calc_phi(phi_0, nom.MET_RefFinal_phi)

        events1l.append(y)

    return decayDicts, events1l, events2l