Example #1
0
def test_layout(err, xpi, mandatory, whitelisted,
                white_extensions=None, pack_type='Unknown Addon'):
    """Tests the layout of a package. Pass in the various types of files
    and their levels of requirement and this guy will figure out which
    files should and should not be in the package."""

    # A shortcut to prevent excessive lookups

    for file_ in xpi:

        if file_ == '.DS_Store' or file_.startswith('__MACOSX/'):
            continue

        # Remove the file from the mandatory file list.
        #if file_ in mandatory_files:
        mfile_list = [mf for mf in mandatory if fnm(file_, mf)]
        if mfile_list:
            # Isolate the mandatory file pattern and remove it.
            mfile = mfile_list[0]
            mandatory.remove(mfile)
            continue

        # Test if the file is in the whitelist.
        if any(fnm(file_, wlfile) for wlfile in whitelisted):
            continue

        # Is it a directory?
        if file_.endswith('/'):
            continue

        # Is the file a sketch file?
        if test_unknown_file(err, file_):
            continue

        # Is it a whitelisted file type?
        if white_extensions is None or file_.split('.')[-1] in white_extensions:
            continue

        # Otherwise, report an error.
        err.warning(('testcases_packagelayout',
                     'test_layout',
                     'unknown_file'),
                    'Unknown file found in add-on',
                    ['Files have been detected that are not allowed within '
                     'this type of add-on. Remove the file or use an '
                     'alternative, supported file format instead.',
                     'Detected file: %s' % file_],
                    file_)

    # If there's anything left over, it means there's files missing
    if mandatory:
        err.warning(('testcases_packagelayout',
                     'test_layout',
                     'missing_required'),
                    'Required file missing',
                    ['This add-on is missing required files. Consult the '
                     'documentation for a full list of required files.',
                     "Add-ons of type '%s' require files: %s" %
                          (pack_type, ', '.join(mandatory))])
Example #2
0
def test_layout(err, xpi, mandatory, whitelisted,
                white_extensions=None, pack_type='Unknown Addon'):
    """Tests the layout of a package. Pass in the various types of files
    and their levels of requirement and this guy will figure out which
    files should and should not be in the package."""

    # A shortcut to prevent excessive lookups

    for file_ in xpi:

        if file_ == '.DS_Store' or file_.startswith('__MACOSX/'):
            continue

        # Remove the file from the mandatory file list.
        #if file_ in mandatory_files:
        mfile_list = [mf for mf in mandatory if fnm(file_, mf)]
        if mfile_list:
            # Isolate the mandatory file pattern and remove it.
            mfile = mfile_list[0]
            mandatory.remove(mfile)
            continue

        # Test if the file is in the whitelist.
        if any(fnm(file_, wlfile) for wlfile in whitelisted):
            continue

        # Is it a directory?
        if file_.endswith('/'):
            continue

        # Is the file a sketch file?
        if test_unknown_file(err, file_):
            continue

        # Is it a whitelisted file type?
        if white_extensions is None or file_.split('.')[-1] in white_extensions:
            continue

        # Otherwise, report an error.
        err.warning(('testcases_packagelayout',
                     'test_layout',
                     'unknown_file'),
                    'Unknown file found in add-on',
                    ['Files have been detected that are not allowed within '
                     'this type of add-on. Remove the file or use an '
                     'alternative, supported file format instead.',
                     'Detected file: %s' % file_],
                    file_)

    # If there's anything left over, it means there's files missing
    if mandatory:
        err.warning(('testcases_packagelayout',
                     'test_layout',
                     'missing_required'),
                    'Required file missing',
                    ['This add-on is missing required files. Consult the '
                     'documentation for a full list of required files.',
                     "Add-ons of type '%s' require files: %s" %
                          (pack_type, ', '.join(mandatory))])
Example #3
0
    def selectionSequence(self, event, fillCounter, leg1IsoCut=None, leg2IsoCut=None):

        if fillCounter: self.counters.counter('DiLepton').inc('all events')
            
        if len(event.diLeptons) == 0:
            return False
        if fillCounter: self.counters.counter('DiLepton').inc('> 0 di-lepton')

        # testing di-lepton itself
        selDiLeptons = event.diLeptons
        
        if not self.leptonAccept( event.leptons ):
            return False
        if fillCounter: self.counters.counter('DiLepton').inc('lepton accept')

        if not hasattr( event, 'hltPaths'):
            event.hltPaths = []

        #import pdb ; pdb.set_trace() 
        
        matching = {}
        for trig in event.hltPaths :
          matching.update({trig:[-99,-99,-99]}) # {trigName:leg1,leg2,jet}
                
        event.diLeptonsTrigMatched = []
        
        for trig in event.hltPaths :
          if self.cfg_comp.isEmbed : continue   ## no matching for the embed
          selDiLeptons = event.diLeptons
          if len(self.cfg_comp.triggers)>0:
              # trigger matching leg1
              selDiLeptons = [diL for diL in selDiLeptons if self.trigMatched(event, diL.leg1(), 'leg1', trig)]
              if len(selDiLeptons) == 0:
                  matching[trig][0]=0
              else:
                  if fillCounter: self.counters.counter('DiLepton').inc('leg1 trig matched')
                  matching[trig][0]=1
  
          if len(self.cfg_comp.triggers)>0:
              # trigger matching leg2
              selDiLeptons = [diL for diL in selDiLeptons if self.trigMatched(event, diL.leg2(), 'leg2', trig)]
              if len(selDiLeptons) == 0:
                  matching[trig][1]=0
              else:
                  if fillCounter: self.counters.counter('DiLepton').inc('leg2 trig matched')
                  matching[trig][1]=1
  
          if len(self.cfg_comp.triggers)>0 and len(self.cfg_ana.triggerMap[ trig ])>2:
              # trigger matching jet
              cmgJets = self.handles['jets'].product()
	      jets=[]
              for cmgJet in cmgJets:
                  jet = Jet( cmgJet )
                  if self.testJet( jet ):
                      jets.append(jet)
  
	      selDiLeptonsNew=[]
	      for diL in selDiLeptons:
                  cleanJets, dummy = cleanObjectCollection( jets, masks = [ diL.leg1(), diL.leg2() ], deltaRMin = 0.5 )
                  if len(cleanJets)>0 and self.trigMatched(event, cleanJets[0], 'jet', trig):
                      selDiLeptonsNew += [diL]
	      selDiLeptons = selDiLeptonsNew
              if len(selDiLeptons) == 0:
                  matching[trig][2]=0
              else:
                  if fillCounter: self.counters.counter('DiLepton').inc('jet trig matched')
                  matching[trig][2]=1
              
          event.diLeptonsTrigMatched += selDiLeptons
        
        event.diLeptonsTrigMatched = set(event.diLeptonsTrigMatched)
        
        ### need unix style wild card to macth different trigger versions in data
        for trig in matching.keys() :
          if fnm(trig,'HLT_DoubleMediumIsoPFTau35_Trk*_eta2p1_v*') :
            event.l1TrigMatched_diTau = matching[trig][0]
            event.l2TrigMatched_diTau = matching[trig][1]      
          if fnm(trig,'HLT_DoubleMediumIsoPFTau*_Trk*_eta2p1_Jet30_v*') :
            event.l1TrigMatched_diTauJet  = matching[trig][0]
            event.l2TrigMatched_diTauJet  = matching[trig][1]
            event.jetTrigMatched_diTauJet = matching[trig][2]        
        
        # testing leg1
        selDiLeptons = [ diL for diL in selDiLeptons if self.testLeg( diL.leg1() ) ]
        if len(selDiLeptons) == 0:
            return False
        else:
            if fillCounter: self.counters.counter('DiLepton').inc('leg1 offline cuts passed')

        # testing leg2 
        selDiLeptons = [ diL for diL in selDiLeptons if self.testLeg( diL.leg2() ) ]
        if len(selDiLeptons) == 0:
            return False
        else:
            if fillCounter: self.counters.counter('DiLepton').inc('leg2 offline cuts passed')

 
        # mass cut 
        selDiLeptons = [ diL for diL in selDiLeptons if self.testMass(diL) ]
        if len(selDiLeptons)==0:
            return False
        else:
            if fillCounter: self.counters.counter('DiLepton').inc('{min:3.1f} < m < {max:3.1f}'.format( min = self.cfg_ana.m_min, max = self.cfg_ana.m_max ))

        # exactly one? 
        if len(selDiLeptons)==0:
            return False
        elif len(selDiLeptons)==1:
            if fillCounter: self.counters.counter('DiLepton').inc('exactly 1 di-lepton')
        
        event.diLepton = self.bestDiLepton( selDiLeptons )
        event.leg1 = event.diLepton.leg1()
        event.leg2 = event.diLepton.leg2()
        
        # match with L1 particles, whether Central Jets or Taus
        L1Taus = self.handles['L1JetsTau'].product()
        L1Jets = self.handles['L1JetsCentral'].product()
        L1dR1T, L1dR2T, index1T, index2T = self.match(event.diLepton, L1Taus)
        L1dR1J, L1dR2J, index1J, index2J = self.match(event.diLepton, L1Jets)
        if L1dR1T < L1dR1J and L1dR1T<=0.5 :
          if L1Taus[index1T].pt()>44. and abs(L1Taus[index1T].eta())<2.1 :
            event.leg1.L1particle = L1Taus[index1T]
        if L1dR1J < L1dR1T and L1dR1J<=0.5 :
          if L1Jets[index1J].pt()>64. :
            event.leg1.L1particle = L1Jets[index1J]
        if L1dR2T < L1dR2J and L1dR2T<=0.5 :
          if L1Taus[index2T].pt()>44. and abs(L1Taus[index2T].eta())<2.1 :
            event.leg2.L1particle = L1Taus[index2T]
        if L1dR2J < L1dR2T and L1dR2J<=0.5 :
          if L1Jets[index2J].pt()>64. :
            event.leg2.L1particle = L1Jets[index2J]

        ### require trigger bit in Embedded RecHit
        if self.cfg_comp.isEmbed :
          #if len(event.hltPath)==0 : return False
          if not event.hltPath : return False
        
        #import pdb ; pdb.set_trace()
        return True
Example #4
0
    def selectionSequence(self,
                          event,
                          fillCounter,
                          leg1IsoCut=None,
                          leg2IsoCut=None):

        if fillCounter: self.counters.counter('DiLepton').inc('all events')

        if len(event.diLeptons) == 0:
            return False
        if fillCounter: self.counters.counter('DiLepton').inc('> 0 di-lepton')

        # testing di-lepton itself
        selDiLeptons = event.diLeptons

        if not self.leptonAccept(event.leptons):
            return False
        if fillCounter: self.counters.counter('DiLepton').inc('lepton accept')

        if not hasattr(event, 'hltPaths'):
            event.hltPaths = []

        #import pdb ; pdb.set_trace()

        matching = {}
        for trig in event.hltPaths:
            matching.update({trig: [-99, -99,
                                    -99]})  # {trigName:leg1,leg2,jet}

        event.diLeptonsTrigMatched = []

        for trig in event.hltPaths:
            if self.cfg_comp.isEmbed: continue  ## no matching for the embed
            selDiLeptons = event.diLeptons
            if len(self.cfg_comp.triggers) > 0:
                # trigger matching leg1
                selDiLeptons = [
                    diL for diL in selDiLeptons
                    if self.trigMatched(event, diL.leg1(), 'leg1', trig)
                ]
                if len(selDiLeptons) == 0:
                    matching[trig][0] = 0
                else:
                    if fillCounter:
                        self.counters.counter('DiLepton').inc(
                            'leg1 trig matched')
                    matching[trig][0] = 1

            if len(self.cfg_comp.triggers) > 0:
                # trigger matching leg2
                selDiLeptons = [
                    diL for diL in selDiLeptons
                    if self.trigMatched(event, diL.leg2(), 'leg2', trig)
                ]
                if len(selDiLeptons) == 0:
                    matching[trig][1] = 0
                else:
                    if fillCounter:
                        self.counters.counter('DiLepton').inc(
                            'leg2 trig matched')
                    matching[trig][1] = 1

            if len(self.cfg_comp.triggers) > 0 and len(
                    self.cfg_ana.triggerMap[trig]) > 2:
                # trigger matching jet
                cmgJets = self.handles['jets'].product()
                jets = []
                for cmgJet in cmgJets:
                    jet = Jet(cmgJet)
                    if self.testJet(jet):
                        jets.append(jet)

                selDiLeptonsNew = []
                for diL in selDiLeptons:
                    cleanJets, dummy = cleanObjectCollection(
                        jets, masks=[diL.leg1(), diL.leg2()], deltaRMin=0.5)
                    if len(cleanJets) > 0 and self.trigMatched(
                            event, cleanJets[0], 'jet', trig):
                        selDiLeptonsNew += [diL]
                selDiLeptons = selDiLeptonsNew
                if len(selDiLeptons) == 0:
                    matching[trig][2] = 0
                else:
                    if fillCounter:
                        self.counters.counter('DiLepton').inc(
                            'jet trig matched')
                    matching[trig][2] = 1

            event.diLeptonsTrigMatched += selDiLeptons

        event.diLeptonsTrigMatched = set(event.diLeptonsTrigMatched)

        ### need unix style wild card to macth different trigger versions in data
        for trig in matching.keys():
            if fnm(trig, 'HLT_DoubleMediumIsoPFTau35_Trk*_eta2p1_v*'):
                event.l1TrigMatched_diTau = matching[trig][0]
                event.l2TrigMatched_diTau = matching[trig][1]
            if fnm(trig, 'HLT_DoubleMediumIsoPFTau*_Trk*_eta2p1_Jet30_v*'):
                event.l1TrigMatched_diTauJet = matching[trig][0]
                event.l2TrigMatched_diTauJet = matching[trig][1]
                event.jetTrigMatched_diTauJet = matching[trig][2]

        # testing leg1
        selDiLeptons = [
            diL for diL in selDiLeptons if self.testLeg(diL.leg1())
        ]
        if len(selDiLeptons) == 0:
            return False
        else:
            if fillCounter:
                self.counters.counter('DiLepton').inc(
                    'leg1 offline cuts passed')

        # testing leg2
        selDiLeptons = [
            diL for diL in selDiLeptons if self.testLeg(diL.leg2())
        ]
        if len(selDiLeptons) == 0:
            return False
        else:
            if fillCounter:
                self.counters.counter('DiLepton').inc(
                    'leg2 offline cuts passed')

        # mass cut
        selDiLeptons = [diL for diL in selDiLeptons if self.testMass(diL)]
        if len(selDiLeptons) == 0:
            return False
        else:
            if fillCounter:
                self.counters.counter('DiLepton').inc(
                    '{min:3.1f} < m < {max:3.1f}'.format(
                        min=self.cfg_ana.m_min, max=self.cfg_ana.m_max))

        # exactly one?
        if len(selDiLeptons) == 0:
            return False
        elif len(selDiLeptons) == 1:
            if fillCounter:
                self.counters.counter('DiLepton').inc('exactly 1 di-lepton')

        event.diLepton = self.bestDiLepton(selDiLeptons)
        event.leg1 = event.diLepton.leg1()
        event.leg2 = event.diLepton.leg2()

        # match with L1 particles, whether Central Jets or Taus
        L1Taus = self.handles['L1JetsTau'].product()
        L1Jets = self.handles['L1JetsCentral'].product()
        L1dR1T, L1dR2T, index1T, index2T = self.match(event.diLepton, L1Taus)
        L1dR1J, L1dR2J, index1J, index2J = self.match(event.diLepton, L1Jets)
        if L1dR1T < L1dR1J and L1dR1T <= 0.5:
            if L1Taus[index1T].pt() > 44. and abs(L1Taus[index1T].eta()) < 2.1:
                event.leg1.L1particle = L1Taus[index1T]
        if L1dR1J < L1dR1T and L1dR1J <= 0.5:
            if L1Jets[index1J].pt() > 64.:
                event.leg1.L1particle = L1Jets[index1J]
        if L1dR2T < L1dR2J and L1dR2T <= 0.5:
            if L1Taus[index2T].pt() > 44. and abs(L1Taus[index2T].eta()) < 2.1:
                event.leg2.L1particle = L1Taus[index2T]
        if L1dR2J < L1dR2T and L1dR2J <= 0.5:
            if L1Jets[index2J].pt() > 64.:
                event.leg2.L1particle = L1Jets[index2J]

        ### require trigger bit in Embedded RecHit
        if self.cfg_comp.isEmbed:
            #if len(event.hltPath)==0 : return False
            if not event.hltPath: return False

        #import pdb ; pdb.set_trace()
        return True
Example #5
0
def get_all_active_aovs(wildcard='*'):
    """
    Usage:
        get_all_active_aovs(wildcard='*id*')
    """
    return [aov for aov in mc.ls(type='aiAOV') if fnm(aov, wildcard)]
Example #6
0
    def selectionSequence(self,
                          event,
                          fillCounter,
                          leg1IsoCut=None,
                          leg2IsoCut=None):

        if fillCounter: self.counters.counter('DiLepton').inc('all events')

        if len(event.diLeptons) == 0:
            return False
        if fillCounter: self.counters.counter('DiLepton').inc('> 0 di-lepton')

        # testing di-lepton itself
        selDiLeptons = event.diLeptons

        if not self.leptonAccept(event.leptons):
            return False
        if fillCounter: self.counters.counter('DiLepton').inc('lepton accept')

        ## for embedded no hltPaths (for now)
        if not hasattr(event, 'hltPaths'):
            event.hltPaths = []

        matching = {}
        for trig in event.hltPaths:
            matching.update({trig: [-99, -99,
                                    -99]})  # {trigName:leg1,leg2,jet}

        event.diLeptonsTrigMatched = []

        for trig in event.hltPaths:
            if self.cfg_comp.isEmbed: continue  ## no matching for the embed
            selDiLeptons = event.diLeptons
            if len(self.cfg_comp.triggers) > 0:
                # trigger matching leg1
                selDiLeptons = [
                    diL for diL in selDiLeptons
                    if self.trigMatched(event, diL.leg1(), 'leg1', trig)
                ]
                if len(selDiLeptons) == 0:
                    matching[trig][0] = 0
                else:
                    if fillCounter:
                        self.counters.counter('DiLepton').inc(
                            'leg1 trig matched')
                    matching[trig][0] = 1

            if len(self.cfg_comp.triggers) > 0:
                # trigger matching leg2
                selDiLeptons = [
                    diL for diL in selDiLeptons
                    if self.trigMatched(event, diL.leg2(), 'leg2', trig)
                ]
                if len(selDiLeptons) == 0:
                    matching[trig][1] = 0
                else:
                    if fillCounter:
                        self.counters.counter('DiLepton').inc(
                            'leg2 trig matched')
                    matching[trig][1] = 1

            if len(self.cfg_comp.triggers) > 0 and len(
                    self.cfg_ana.triggerMap[trig]) > 2:
                # trigger matching jet
                cmgJets = self.handles['jets'].product()
                jets = []
                for cmgJet in cmgJets:
                    jet = Jet(cmgJet)
                    if self.testJet(jet):
                        jets.append(jet)

                selDiLeptonsNew = []
                for diL in selDiLeptons:
                    cleanJets, dummy = cleanObjectCollection(
                        jets, masks=[diL.leg1(), diL.leg2()], deltaRMin=0.5)
                    if len(cleanJets) > 0 and self.trigMatched(
                            event, cleanJets[0], 'jet', trig):
                        selDiLeptonsNew += [diL]
                selDiLeptons = selDiLeptonsNew
                if len(selDiLeptons) == 0:
                    matching[trig][2] = 0
                else:
                    if fillCounter:
                        self.counters.counter('DiLepton').inc(
                            'jet trig matched')
                    matching[trig][2] = 1

            event.diLeptonsTrigMatched += selDiLeptons

        event.diLeptonsTrigMatched = set(event.diLeptonsTrigMatched)

        ### need unix style wild card to macth different trigger versions in data
        for trig in matching.keys():
            if fnm(trig, 'HLT_DoubleMediumIsoPFTau35_Trk*_eta2p1_v*'):
                event.l1TrigMatched_diTau = matching[trig][0]
                event.l2TrigMatched_diTau = matching[trig][1]
            if fnm(trig, 'HLT_DoubleMediumIsoPFTau*_Trk*_eta2p1_Jet30_v*'):
                event.l1TrigMatched_diTauJet = matching[trig][0]
                event.l2TrigMatched_diTauJet = matching[trig][1]
                event.jetTrigMatched_diTauJet = matching[trig][2]

        # testing leg1
        selDiLeptons = [
            diL for diL in selDiLeptons if self.testLeg(diL.leg1())
        ]
        if len(selDiLeptons) == 0:
            return False
        else:
            if fillCounter:
                self.counters.counter('DiLepton').inc(
                    'leg1 offline cuts passed')

        # testing leg2
        selDiLeptons = [
            diL for diL in selDiLeptons if self.testLeg(diL.leg2())
        ]
        if len(selDiLeptons) == 0:
            return False
        else:
            if fillCounter:
                self.counters.counter('DiLepton').inc(
                    'leg2 offline cuts passed')

        # mass cut
        selDiLeptons = [diL for diL in selDiLeptons if self.testMass(diL)]
        if len(selDiLeptons) == 0:
            return False
        else:
            if fillCounter:
                self.counters.counter('DiLepton').inc(
                    '{min:3.1f} < m < {max:3.1f}'.format(
                        min=self.cfg_ana.m_min, max=self.cfg_ana.m_max))

        # exactly one?
        if len(selDiLeptons) == 0:
            return False
        elif len(selDiLeptons) == 1:
            if fillCounter:
                self.counters.counter('DiLepton').inc('exactly 1 di-lepton')

        event.diLepton = self.bestDiLepton(selDiLeptons)
        event.leg1 = event.diLepton.leg1()
        event.leg2 = event.diLepton.leg2()

        ### require trigger bit in Embedded RecHit
        if self.cfg_comp.isEmbed:
            if not event.hltPath: return False

        if "DY" in self.cfg_comp.name or "Higgs" in self.cfg_comp.name or self.cfg_comp.isEmbed:
            if event.leg1.decayMode() == 0:
                event.leg1.prongWeight = 0.88
            else:
                event.leg1.prongWeight = 1.
            if event.leg2.decayMode() == 0:
                event.leg2.prongWeight = 0.88
            else:
                event.leg2.prongWeight = 1.
        #import pdb ; pdb.set_trace()
        return True
Example #7
0
    def selectionSequence(self, event, fillCounter, leg1IsoCut=None, leg2IsoCut=None):

        if fillCounter: self.counters.counter('DiLepton').inc('all events')
            
        if len(event.diLeptons) == 0:
            return False
        if fillCounter: self.counters.counter('DiLepton').inc('> 0 di-lepton')

        # testing di-lepton itself
        selDiLeptons = event.diLeptons
        
        if not self.leptonAccept( event.leptons ):
            return False
        if fillCounter: self.counters.counter('DiLepton').inc('lepton accept')

        ## for embedded no hltPaths (for now)
        if not hasattr( event, 'hltPaths'):
            event.hltPaths = []

        matching = {}
        for trig in event.hltPaths :
          matching.update({trig:[-99,-99,-99]}) # {trigName:leg1,leg2,jet}
                
        event.diLeptonsTrigMatched = []
        
        for trig in event.hltPaths :
          if self.cfg_comp.isEmbed : continue   ## no matching for the embed
          selDiLeptons = event.diLeptons
          if len(self.cfg_comp.triggers)>0:
              # trigger matching leg1
              selDiLeptons = [diL for diL in selDiLeptons if self.trigMatched(event, diL.leg1(), 'leg1', trig)]
              if len(selDiLeptons) == 0:
                  matching[trig][0]=0
              else:
                  if fillCounter: self.counters.counter('DiLepton').inc('leg1 trig matched')
                  matching[trig][0]=1
  
          if len(self.cfg_comp.triggers)>0:
              # trigger matching leg2
              selDiLeptons = [diL for diL in selDiLeptons if self.trigMatched(event, diL.leg2(), 'leg2', trig)]
              if len(selDiLeptons) == 0:
                  matching[trig][1]=0
              else:
                  if fillCounter: self.counters.counter('DiLepton').inc('leg2 trig matched')
                  matching[trig][1]=1
  
          if len(self.cfg_comp.triggers)>0 and len(self.cfg_ana.triggerMap[ trig ])>2:
              # trigger matching jet
              cmgJets = self.handles['jets'].product()
	      jets=[]
              for cmgJet in cmgJets:
                  jet = Jet( cmgJet )
                  if self.testJet( jet ):
                      jets.append(jet)
  
	      selDiLeptonsNew=[]
	      for diL in selDiLeptons:
                  cleanJets, dummy = cleanObjectCollection( jets, masks = [ diL.leg1(), diL.leg2() ], deltaRMin = 0.5 )
                  if len(cleanJets)>0 and self.trigMatched(event, cleanJets[0], 'jet', trig):
                      selDiLeptonsNew += [diL]
	      selDiLeptons = selDiLeptonsNew
              if len(selDiLeptons) == 0:
                  matching[trig][2]=0
              else:
                  if fillCounter: self.counters.counter('DiLepton').inc('jet trig matched')
                  matching[trig][2]=1
              
              
          event.diLeptonsTrigMatched += selDiLeptons
        
        event.diLeptonsTrigMatched = set(event.diLeptonsTrigMatched)
        
        ### need unix style wild card to macth different trigger versions in data
        for trig in matching.keys() :
          if fnm(trig,'HLT_DoubleMediumIsoPFTau35_Trk*_eta2p1_v*') :
            event.l1TrigMatched_diTau = matching[trig][0]
            event.l2TrigMatched_diTau = matching[trig][1]      
          if fnm(trig,'HLT_DoubleMediumIsoPFTau*_Trk*_eta2p1_Jet30_v*') :
            event.l1TrigMatched_diTauJet  = matching[trig][0]
            event.l2TrigMatched_diTauJet  = matching[trig][1]
            event.jetTrigMatched_diTauJet = matching[trig][2]        
        
        # testing leg1
        selDiLeptons = [ diL for diL in selDiLeptons if self.testLeg( diL.leg1() ) ]
        if len(selDiLeptons) == 0:
            return False
        else:
            if fillCounter: self.counters.counter('DiLepton').inc('leg1 offline cuts passed')

        # testing leg2 
        selDiLeptons = [ diL for diL in selDiLeptons if self.testLeg( diL.leg2() ) ]
        if len(selDiLeptons) == 0:
            return False
        else:
            if fillCounter: self.counters.counter('DiLepton').inc('leg2 offline cuts passed')

 
        # mass cut 
        selDiLeptons = [ diL for diL in selDiLeptons if self.testMass(diL) ]
        if len(selDiLeptons)==0:
            return False
        else:
            if fillCounter: self.counters.counter('DiLepton').inc('{min:3.1f} < m < {max:3.1f}'.format( min = self.cfg_ana.m_min, max = self.cfg_ana.m_max ))

        # exactly one? 
        if len(selDiLeptons)==0:
            return False
        elif len(selDiLeptons)==1:
            if fillCounter: self.counters.counter('DiLepton').inc('exactly 1 di-lepton')
        
        event.diLepton = self.bestDiLepton( selDiLeptons )
        event.leg1 = event.diLepton.leg1()
        event.leg2 = event.diLepton.leg2()
        
        
        ### require trigger bit in Embedded RecHit
        if self.cfg_comp.isEmbed :
          if not event.hltPath : return False
        
        if "DY" in self.cfg_comp.name or "Higgs" in self.cfg_comp.name or self.cfg_comp.isEmbed:
          if event.leg1.decayMode() == 0 :
            event.leg1.prongWeight = 0.88
          else :
            event.leg1.prongWeight = 1.
          if event.leg2.decayMode() == 0 :
            event.leg2.prongWeight = 0.88
          else :
            event.leg2.prongWeight = 1.
        #import pdb ; pdb.set_trace()
        return True