def makeLeps(event, sample, level): ''' Add important leptons (no full list of leptons is required for now) ''' preTag = 'reco' if level == 'reco' else 'gen' tag = 'reco' if level == 'reco' else 'genLep' # Define W leptons event.W_l0 = getObjDict(event, '%sLep_' % preTag, ['pt', 'eta', 'phi', 'pdgId'], 0) event.W_l1 = getObjDict(event, '%sLep_' % preTag, ['pt', 'eta', 'phi', 'pdgId'], 1) # Add extra vectors for p in [event.W_l0, event.W_l1]: addTransverseVector(p) addTLorentzVector(p) # Import additional functions/classes specified for the level of reconstruction if level == 'reco': from TTXPheno.Tools.objectSelection import isGoodRecoLepton as isGoodLepton else: from TTXPheno.Tools.objectSelection import isGoodGenLepton as isGoodLepton # We may loose some events by cross-cleaning or by thresholds. event.foundWl0 = isGoodLepton(event.W_l0) event.foundWl1 = isGoodLepton(event.W_l1) event.found2lep = event.W_l0['pdgId'] * event.W_l1['pdgId'] > 0 # choose your selection on leptons event.passing_leptons = event.found2lep and event.foundWl0 and event.foundWl1
def makeLeps( event, sample, level, flavorCheck ): ''' Add important leptons (no full list of leptons is required for now) ''' preTag = 'reco' if level == 'reco' else 'gen' tag = 'reco' if level == 'reco' else 'genLep' if level == 'reco': leptonList = ['pt', 'eta', 'phi', 'pdgId', 'isolationVar', 'isolationVarRhoCorr', 'sumPtCharged', 'sumPtNeutral', 'sumPtChargedPU', 'sumPt', 'ehadOverEem', 'genIndex'] else: leptonList = ['pt', 'eta', 'phi', 'pdgId', 'motherPdgId'] event.leps = getCollection( event, '%sLep'%preTag, leptonList, 'n%sLep'%preTag ) # Define hardest leptons event.l0 = event.leps[0] addTransverseVector( event.l0 ) addTLorentzVector( event.l0 ) if level == 'reco': addIDeltaBeta( event.l0 ) # Import additional functions/classes specified for the level of reconstruction if level == 'reco': from TTXPheno.Tools.objectSelection import isGoodRecoLepton as isGoodLepton else: from TTXPheno.Tools.objectSelection import isGoodGenLepton as isGoodLepton # We may loose some events by cross-cleaning or by thresholds. event.found1lep = isGoodLepton( event.l0 ) and len(event.leps) == 1 if flavorCheck == 'e': event.found1lep = event.found1lep and abs(event.l0['pdgId'])==11 elif flavorCheck == 'mu': event.found1lep = event.found1lep and abs(event.l0['pdgId'])==13 # choose your selection on leptons event.passing_leptons = event.found1lep
def makeLeps( event, sample, level, leptonFlavor ): ''' Add important leptons (no full list of leptons is required for now) ''' preTag = 'reco' if level == 'reco' else 'gen' tag = 'reco' if level == 'reco' else 'genLep' if level == 'reco': leptonList = ['pt', 'eta', 'phi', 'pdgId', 'isolationVar', 'isolationVarRhoCorr', 'sumPtCharged', 'sumPtNeutral', 'sumPtChargedPU', 'sumPt', 'ehadOverEem', 'genIndex'] else: leptonList = ['pt', 'eta', 'phi', 'pdgId'] # Define Z leptons event.Z_l0 = getObjDict( event, '%sLep_'%preTag, leptonList, getattr( event, '%sZ_l1_index'%tag ) ) if getattr( event, '%sZ_l1_index'%tag ) >= 0 else nanLepton() event.Z_l1 = getObjDict( event, '%sLep_'%preTag, leptonList, getattr( event, '%sZ_l2_index'%tag ) ) if getattr( event, '%sZ_l2_index'%tag ) >= 0 else nanLepton() # Define non-Z leptons event.NonZ_l0 = getObjDict( event, '%sLep_'%preTag, leptonList, getattr( event, '%sNonZ_l1_index'%tag ) ) if getattr( event, '%sNonZ_l1_index'%tag ) >= 0 else nanLepton() event.NonZ_l1 = getObjDict( event, '%sLep_'%preTag, leptonList, getattr( event, '%sNonZ_l2_index'%tag ) ) if getattr( event, '%sNonZ_l2_index'%tag ) >= 0 else nanLepton() # Add extra vectors for p in [ event.Z_l0, event.Z_l1, event.NonZ_l0, event.NonZ_l1 ]: addTransverseVector( p ) addTLorentzVector( p ) if level == 'reco': addIDeltaBeta( p ) # Import additional functions/classes specified for the level of reconstruction if level == 'reco': from TTXPheno.Tools.objectSelection import isGoodRecoLepton as isGoodLepton else: from TTXPheno.Tools.objectSelection import isGoodGenLepton as isGoodLepton # We may loose some events by cross-cleaning or by thresholds. event.foundZl0 = getattr( event, '%sZ_l1_index'%tag ) >= 0 and isGoodLepton( event.Z_l0 ) event.foundZl1 = getattr( event, '%sZ_l2_index'%tag ) >= 0 and isGoodLepton( event.Z_l1 ) event.foundZ = event.Z_l0['pdgId'] * event.Z_l1['pdgId'] < 0 and abs(event.Z_l0['pdgId']) == abs(event.Z_l1['pdgId']) event.found3lep = getattr( event, '%sNonZ_l1_index'%tag ) >= 0 and isGoodLepton( event.NonZ_l0 ) # choose your selection on leptons event.passing_leptons = event.found3lep and event.foundZl0 and event.foundZl1 and event.foundZ lepFlavors = [ abs(event.NonZ_l0['pdgId']), abs(event.Z_l0['pdgId']), abs(event.Z_l1['pdgId']) ] if leptonFlavor == 'e': event.passing_leptons = event.passing_leptons and abs(event.NonZ_l0['pdgId'])==11 elif leptonFlavor == 'mu': event.passing_leptons = event.passing_leptons and abs(event.NonZ_l0['pdgId'])==13 elif leptonFlavor == 'mumumu': event.passing_leptons = event.passing_leptons and lepFlavors.count(13)==3 elif leptonFlavor == 'mumue': event.passing_leptons = event.passing_leptons and lepFlavors.count(13)==2 and lepFlavors.count(11)==1 elif leptonFlavor == 'muee': event.passing_leptons = event.passing_leptons and lepFlavors.count(13)==1 and lepFlavors.count(11)==2 elif leptonFlavor == 'eee': event.passing_leptons = event.passing_leptons and lepFlavors.count(11)==3
def makeLeps( event, sample, level ): ''' Add important leptons (no full list of leptons is required for now) ''' event.leps = getCollection( event, '%sLep'%preTag, ['pt', 'eta', 'phi', 'pdgId'], 'n%sLep'%preTag ) # Define hardest leptons event.l0 = event.leps[0] event.l1 = event.leps[1] # event.l2 = event.leps[2] # Add extra vectors for p in [ event.l0, event.l1]: addTransverseVector( p ) addTLorentzVector( p ) # Import additional functions/classes specified for the level of reconstruction if level == 'reco': from TTXPheno.Tools.objectSelection import isGoodRecoLepton as isGoodLepton else: from TTXPheno.Tools.objectSelection import isGoodGenLepton as isGoodLepton # We may loose some events by cross-cleaning or by thresholds event.foundLep0 = isGoodLepton( event.l0 ) event.foundLep1 = isGoodLepton( event.l1 ) event.found2Leps = len(event.leps) == 2 event.mll = (get4DVec(event.l0) + get4DVec(event.l1)).M() if( event.l0['pdgId'] * event.l1['pdgId'] > 0 ): event.sign = 1 else: event.sign = -1 if( event.l0['pdgId'] == -13 and event.l1['pdgId'] == -13 ): event.index = 0 elif( event.l0['pdgId'] == -11 and event.l1['pdgId'] == -11 ): event.index = 2 elif( event.l0['pdgId'] == 13 and event.l1['pdgId'] == 13 ): event.index = 3 elif( event.l0['pdgId'] == 11 and event.l1['pdgId'] == 11 ): event.index = 5 elif( (event.l0['pdgId'] == -11 and event.l1['pdgId'] == -13) or (event.l0['pdgId'] == -13 and event.l1['pdgId'] == -11) ): event.index = 1 elif( (event.l0['pdgId'] == 11 and event.l1['pdgId'] == 13) or (event.l0['pdgId'] == 13 and event.l1['pdgId'] == 11) ): event.index = 4 # event.mll = (get4DVec(event.l0) + get4DVec(event.l1) + get4DVec(event.l2)).M() # event.found3Leps = len(event.leps) == 3 # event.foundLep2 = isGoodLepton( event.l2 ) # if( event.l0['pdgId']*event.l1['pdgId'] < 0 and abs(event.l0['pdgId']) == abs(event.l1['pdgId']) and abs((get4DVec(event.l0)+get4DVec(event.l1)).M() - 91.2) < 10 ): # event.OSSF = True # elif( event.l0['pdgId']*event.l2['pdgId'] < 0 and abs(event.l0['pdgId']) == abs(event.l2['pdgId']) and abs((get4DVec(event.l0)+get4DVec(event.l2)).M() - 91.2) < 10 ): # event.OSSF = True # elif( event.l1['pdgId']*event.l2['pdgId'] < 0 and abs(event.l1['pdgId']) == abs(event.l2['pdgId']) and abs((get4DVec(event.l1)+get4DVec(event.l2)).M() - 91.2) < 10): # event.OSSF = True # else: # event.OSSF = False #event.sameSign = event.l0['pdgId']*event.l1['pdgId'] > 0 #event.oppositeSign = event.l0['pdgId']*event.l1['pdgId'] <0 #event.sameFlavor = abs(event.l0['pdgId']) == abs(event.l1['pdgId']) # choose your selection on leptons event.passing_leptons = event.foundLep0 and event.foundLep1 and event.mll > 12 and abs(event.mll-91.2) > 15 and event.found2Leps