Beispiel #1
0
    def process(self, iEvent, event):
        self.readCollections( iEvent )
        
        event.triggerObject = self.handles['cmgTriggerObjectSel'].product()[0]
        run = iEvent.eventAuxiliary().id().run()
        lumi = iEvent.eventAuxiliary().id().luminosityBlock()
        eventId = iEvent.eventAuxiliary().id().event()

        event.run = run
        event.lumi = lumi
        event.eventId = eventId

##        if self.cfg_ana.verbose:
##            self.printTriggerObject( event.triggerObject )
        
        self.counters.counter('Trigger').inc('All events')
        # import pdb; pdb.set_trace()
        usePrescaled = False
        if hasattr( self.cfg_ana, 'usePrescaled'):
            usePrescaled = self.cfg_ana.usePrescaled

        # import pdb; pdb.set_trace()
        passed, hltPath = self.triggerList.triggerPassed(event.triggerObject,
                                                         run, lumi, self.cfg_comp.isData,
                                                         usePrescaled = usePrescaled)



        #Check the veto!
        veto=False
        if self.vetoTriggerList is not None:
            veto,hltVetoPath = self.vetoTriggerList.triggerPassed(event.triggerObject,
                                                         run,lumi,self.cfg_comp.isData,
                                                         usePrescaled = usePrescaled)

        # Check if events needs to be skipped if no trigger is found (useful for generator level studies)
        keepFailingEvents = False
        if hasattr( self.cfg_ana, 'keepFailingEvents'):
            keepFailingEvents = self.cfg_ana.keepFailingEvents
        if not passed or (passed and veto):
            event.passedTriggerAnalyzer = False
            if not keepFailingEvents:
                return False
        else:
            event.passedTriggerAnalyzer = True

        event.hltPath = hltPath 

        if hltPath is not None:
            trigObjs = map( TriggerObject,
                            self.handles['cmgTriggerObjectListSel'].product())
            # selecting the trigger objects used in this path
            event.triggerObjects = selTriggerObjects( trigObjs, hltPath )
            
        self.counters.counter('Trigger').inc('HLT')
        event.TriggerFired = 1
        return True
Beispiel #2
0
    def process(self, iEvent, event):
        self.readCollections( iEvent )

        #if iEvent.eventAuxiliary().id().event() in notPassed :
        #  print 'before anything'
        #  import pdb ; pdb.set_trace()


        #event.triggerObject = self.handles['cmgTriggerObjectSel'].product()[0] ## for <5_18_0 releases
        event.triggerObject = self.handles['cmgTriggerObjectListSel'].product()[0]
        run = iEvent.eventAuxiliary().id().run()
        lumi = iEvent.eventAuxiliary().id().luminosityBlock()
        eventId = iEvent.eventAuxiliary().id().event()

        event.run = run
        event.lumi = lumi
        event.eventId = eventId

        ## if component is embed return (has no trigger obj) RHEMB will have trigger!
        if self.cfg_comp.isEmbed and len(self.cfg_comp.triggers)==0 :
          return True

##        if self.cfg_ana.verbose:
##            self.printTriggerObject( event.triggerObject )

        self.counters.counter('Trigger').inc('All events')
        # import pdb; pdb.set_trace()
        usePrescaled = False
        if hasattr( self.cfg_ana, 'usePrescaled'):
            usePrescaled = self.cfg_ana.usePrescaled

        ### want to check whether more than one unprescaled trigger has been fired
        hltPathVec = []

        self.triggerList = TriggerList( self.cfg_comp.triggers )

        passed, hltPath = self.triggerList.triggerPassed(event.triggerObject,
                                                         run, lumi, self.cfg_comp.isData,
                                                         self.cfg_comp.isEmbed,
                                                         usePrescaled = usePrescaled)

        if passed and not hltPath == None:
          hltPathVec.append(hltPath)


        if passed and not hltPath == None:
          for tr in self.cfg_comp.triggers :
            if tr in hltPathVec :
              for triggerToRemove in self.triggerList.triggerList :
                if triggerToRemove.name == tr :
                  self.triggerList.triggerList.remove(triggerToRemove)

              passed2, hltPath2 = self.triggerList.triggerPassed(event.triggerObject,
                                                               run, lumi, self.cfg_comp.isData,
                                                               self.cfg_comp.isEmbed,
                                                               usePrescaled = usePrescaled)
              if passed2 and not hltPath2 == None:
                hltPathVec.append(hltPath2)

        event.hltPaths = set(hltPathVec)
#        import pdb; pdb.set_trace()


        #Check the veto!
        veto=False
        if self.vetoTriggerList is not None:
            veto,hltVetoPath = self.vetoTriggerList.triggerPassed(event.triggerObject,
                                                         run,lumi,self.cfg_comp.isData,
                                                         self.cfg_comp.isEmbed,
                                                         usePrescaled = usePrescaled)

        # Check if events needs to be skipped if no trigger is found (useful for generator level studies)
        keepFailingEvents = False
        #keepFailingEvents = True
        if hasattr( self.cfg_ana, 'keepFailingEvents'):
            keepFailingEvents = self.cfg_ana.keepFailingEvents
        if not passed or (passed and veto):
            event.passedTriggerAnalyzer = False
            if not keepFailingEvents:
                #if iEvent.eventAuxiliary().id().event() in notPassed :
                #  print 'before anything'
                #  import pdb ; pdb.set_trace()
                return False
        else:
            event.passedTriggerAnalyzer = True

        #import pdb ; pdb.set_trace()
        event.hltPath = hltPath


        ### Riccardo: I want the trigger objects corresponding to the trigger I want to fire even if it has not been fired
        if hltPath is not None :
          trigObjs = map( TriggerObject, self.handles['cmgTriggerObjectListSel'].product())
          # selecting the trigger objects used in this path
          event.triggerObjects = selTriggerObjects( trigObjs, hltPath )
        elif keepFailingEvents :
          event.triggerObjects = []
          for hltPath in self.cfg_comp.triggers :
            trigObjs = map( TriggerObject, self.handles['cmgTriggerObjectListSel'].product())
            event.triggerObjects.extend( selTriggerObjects( trigObjs, hltPath, skipPath=True ) )
          hltPath = None
          #import pdb ; pdb.set_trace()

#         if hltPath is not None:
#             trigObjs = map( TriggerObject,
#                             self.handles['cmgTriggerObjectListSel'].product())
#             # selecting the trigger objects used in this path
#             event.triggerObjects = selTriggerObjects( trigObjs, hltPath )

        self.counters.counter('Trigger').inc('HLT')
        event.TriggerFired = 1
        return True
Beispiel #3
0
    def process(self, iEvent, event):
        self.readCollections(iEvent)

        #if iEvent.eventAuxiliary().id().event() in notPassed :
        #  print 'before anything'
        #  import pdb ; pdb.set_trace()

        event.triggerObject = self.handles['cmgTriggerObjectSel'].product()[0]
        run = iEvent.eventAuxiliary().id().run()
        lumi = iEvent.eventAuxiliary().id().luminosityBlock()
        eventId = iEvent.eventAuxiliary().id().event()

        event.run = run
        event.lumi = lumi
        event.eventId = eventId

        ## if component is embed return (has no trigger obj) RHEMB will have trigger!
        if self.cfg_comp.isEmbed and len(self.cfg_comp.triggers) == 0:
            return True

##        if self.cfg_ana.verbose:
##            self.printTriggerObject( event.triggerObject )

        self.counters.counter('Trigger').inc('All events')
        # import pdb; pdb.set_trace()
        usePrescaled = False
        if hasattr(self.cfg_ana, 'usePrescaled'):
            usePrescaled = self.cfg_ana.usePrescaled

        # import pdb; pdb.set_trace()

        ### want to check whether more than one unprescaled trigger has been fired
        hltPathVec = []

        self.triggerList = TriggerList(self.cfg_comp.triggers)

        passed, hltPath = self.triggerList.triggerPassed(
            event.triggerObject,
            run,
            lumi,
            self.cfg_comp.isData,
            self.cfg_comp.isEmbed,
            usePrescaled=usePrescaled)

        if passed and not hltPath == None:
            hltPathVec.append(hltPath)

        if passed and not hltPath == None:
            for tr in self.cfg_comp.triggers:
                if tr in hltPathVec:
                    for triggerToRemove in self.triggerList.triggerList:
                        if triggerToRemove.name == tr:
                            self.triggerList.triggerList.remove(
                                triggerToRemove)

                    passed2, hltPath2 = self.triggerList.triggerPassed(
                        event.triggerObject,
                        run,
                        lumi,
                        self.cfg_comp.isData,
                        self.cfg_comp.isEmbed,
                        usePrescaled=usePrescaled)
                    if passed2 and not hltPath2 == None:
                        hltPathVec.append(hltPath2)

        event.hltPaths = set(hltPathVec)

        #Check the veto!
        veto = False
        if self.vetoTriggerList is not None:
            veto, hltVetoPath = self.vetoTriggerList.triggerPassed(
                event.triggerObject,
                run,
                lumi,
                self.cfg_comp.isData,
                self.cfg_comp.isEmbed,
                usePrescaled=usePrescaled)

        # Check if events needs to be skipped if no trigger is found (useful for generator level studies)
        keepFailingEvents = False
        #keepFailingEvents = True
        if hasattr(self.cfg_ana, 'keepFailingEvents'):
            keepFailingEvents = self.cfg_ana.keepFailingEvents
        if not passed or (passed and veto):
            event.passedTriggerAnalyzer = False
            if not keepFailingEvents:
                #if iEvent.eventAuxiliary().id().event() in notPassed :
                #  print 'before anything'
                #  import pdb ; pdb.set_trace()
                return False
        else:
            event.passedTriggerAnalyzer = True

        #import pdb ; pdb.set_trace()
        event.hltPath = hltPath

        ### Riccardo: I want the trigger objects corresponding to the trigger I want to fire even if it has not been fired
        if hltPath is not None:
            trigObjs = map(TriggerObject,
                           self.handles['cmgTriggerObjectListSel'].product())
            # selecting the trigger objects used in this path
            event.triggerObjects = selTriggerObjects(trigObjs, hltPath)
        elif keepFailingEvents:
            event.triggerObjects = []
            for hltPath in self.cfg_comp.triggers:
                trigObjs = map(
                    TriggerObject,
                    self.handles['cmgTriggerObjectListSel'].product())
                event.triggerObjects.extend(
                    selTriggerObjects(trigObjs, hltPath, skipPath=True))
            hltPath = None
            #import pdb ; pdb.set_trace()

#         if hltPath is not None:
#             trigObjs = map( TriggerObject,
#                             self.handles['cmgTriggerObjectListSel'].product())
#             # selecting the trigger objects used in this path
#             event.triggerObjects = selTriggerObjects( trigObjs, hltPath )

        self.counters.counter('Trigger').inc('HLT')
        event.TriggerFired = 1
        return True
Beispiel #4
0
    def process(self, iEvent, event):
        self.readCollections( iEvent )

        event.pusi = map( PileUpSummaryInfo, self.mchandles['pusi'].product() )
        event.vertices = self.handles['vertices'].product()
        
        event.rec = self.handles['rec'].product()
        event.gen = self.mchandles['gen'].product()

        # if refselFun is given, this function is applied to select reconstructed objects
        # to be used as a reference
        refselFun = None
        if hasattr( self.cfg_ana, 'refselFun'):
            refselFun = self.cfg_ana.refselFun
        if refselFun is not None:
            event.refsel = [ PhysicsObject(obj) for obj in event.rec if refselFun(obj)]
        else:
            event.refsel = event.gen


        # if recselfun is given, this function is applied to select reconstructed objects
        # for which we want to measure the efficiency w/r to the reference
        recselFun = None
        if hasattr( self.cfg_ana, 'recselFun'):
            recselFun = self.cfg_ana.recselFun
        if recselFun is not None:
            if recselFun == 'trigObjs':
                event.recsel = selTriggerObjects( event.triggerObjects,
                                                  event.hltPath,
                                                  self.filterForPath( event.hltPath ))
            else:
                event.recsel = [ PhysicsObject(obj) for obj in event.rec if recselFun(obj)]
        else:
            event.recsel = event.rec


        # selecting gen objects
        genpdgid = self.cfg_ana.genPdgId
        event.gensel = []
        for obj in event.gen:
            # print obj.pdgId()
            if abs(obj.pdgId())!=genpdgid: continue
            if self.cfg_ana.genTrigMatch and \
               not self.trigMatched( obj, event): continue
            event.gensel.append( obj )

        if len(event.gensel ) == 0:
            return False
            
        # gen objects matched to a reference lepton
        # DON'T NEED THIS MATCHING IF NO REFSEL
        event.genmatchedRef = event.gen
        if event.refsel is not None:
            pairs = matchObjectCollection( event.gensel, event.refsel, 0.1)
            event.genmatchedRef = [ gen for gen,ref in pairs.iteritems() if ref is not None]

        # and gen objects wich are in addition matched to a
        # selected lepton
        pairs = matchObjectCollection( event.genmatchedRef, event.recsel, 0.1)
        event.genmatched = [ gen for gen,rec in pairs.iteritems() if rec is not None]

        # reweighting OOTPU in chamonix samples to the OOTPU observed in Fall11 samples
        weight = 1
        if self.cfg_comp.name.find('Chamonix')!=-1:
            weight = ootPUReweighter.getWeight( event.pusi[1].nPU(), event.pusi[2].nPU())
        
        for space in self.phaseSpaces:        
            space.denomHistos.fillParticles( event.genmatchedRef, event, weight)
            space.numHistos.fillParticles( event.genmatched, event, weight)
            # space.counter.inc('passed')

        self.counters.counter( self.name ).inc( 'All particles', len(event.genmatchedRef) )
        self.counters.counter( self.name ).inc( 'Passing particles', len(event.genmatched) )
Beispiel #5
0
    def process(self, iEvent, event):

        #if event.eventId == 70370:
        #    print 'EVENT', event.eventId
        result = super(TauMuAnalyzer, self).process(iEvent, event)

        # import pdb; pdb.set_trace()

        if result is False:
            # trying to get a dilepton from the control region.
            # it must have well id'ed and trig matched legs,
            # di-lepton and tri-lepton veto must pass
            result = self.selectionSequence(event, fillCounter=False,
                                            leg1IsoCut = -9999,
                                            leg2IsoCut = 9999)
            if result is False:
                # really no way to find a suitable di-lepton,
                # even in the control region
                return False
            event.isSignal = False
        else:
            event.isSignal = True
       
        event.genMatched = None
        if self.cfg_comp.isMC:
            # print event.eventId
            genParticles = self.mchandles['genParticles'].product()
            event.genParticles = map( GenParticle, genParticles)
            leg1DeltaR, leg2DeltaR = event.diLepton.match( event.genParticles ) 
            if leg1DeltaR>-1 and leg1DeltaR < 0.1 and \
               leg2DeltaR>-1 and leg2DeltaR < 0.1:
                event.genMatched = True
            else:
                event.genMatched = False
       
        cross = False
        
	triggerResults = self.handles['triggerResults'].product()
        triggerNames = iEvent._event.triggerNames(triggerResults)
	for trig in self.triggers:
          index = triggerNames.triggerIndex(trig)
          if index >= triggerNames.size():
            trigres = -1
          else:
            trigres = triggerResults.accept(index)
            if trig == 'HLT_IsoMu18_eta2p1_MediumIsoPFTau25_Trk5_eta2p1_v7' and trigres:
              trigObjs = map( TriggerObject, self.handles['cmgTriggerObjectListSel'].product())
              event.monitorTriggerObjects = selTriggerObjects( trigObjs, trig )
              #for obj in self.handles['cmgTriggerObjectListSel'].product() : 
              #  print obj.pt()
              #  for name in obj.getSelectionNames() :
              #    print name
              ## leg1 Tau leg2 Mu 
              #import pdb ; pdb.set_trace()
              l1match, index1 = self.trigMatched2(event, event.diLepton.leg1() , 'leg1', trig, trigObj=event.monitorTriggerObjects)
              l2match, index2 = self.trigMatched2(event, event.diLepton.leg2() , 'leg2', trig, trigObj=event.monitorTriggerObjects)
              import pdb ; pdb.set_trace()

              if (not l1match or not l2match or event.monitorTriggerObjects[index1].pt()<35 ) :
                trigres = False

            if trig == 'HLT_IsoMu24_eta2p1_v13' and trigres:
              #import pdb ; pdb.set_trace()
              #l2match, dummy = self.trigMatched2(event, event.diLepton.leg2() , 'leg1', trig)
              #import pdb ; pdb.set_trace()
              #if (not l2match) :
              #  trigres = False
              pass
              
          setattr(event,trig,trigres)
        
        
        
                
        return True
Beispiel #6
0
    def process(self, iEvent, event):
        self.readCollections(iEvent)

        event.triggerObject = self.handles['cmgTriggerObjectSel'].product()[0]
        run = iEvent.eventAuxiliary().id().run()
        lumi = iEvent.eventAuxiliary().id().luminosityBlock()
        eventId = iEvent.eventAuxiliary().id().event()

        event.run = run
        event.lumi = lumi
        event.eventId = eventId

        ##        if self.cfg_ana.verbose:
        ##            self.printTriggerObject( event.triggerObject )

        self.counters.counter('Trigger').inc('All events')
        # import pdb; pdb.set_trace()
        usePrescaled = False
        if hasattr(self.cfg_ana, 'usePrescaled'):
            usePrescaled = self.cfg_ana.usePrescaled

        # import pdb; pdb.set_trace()
        passed, hltPath = self.triggerList.triggerPassed(
            event.triggerObject,
            run,
            lumi,
            self.cfg_comp.isData,
            usePrescaled=usePrescaled)

        #Check the veto!
        veto = False
        if self.vetoTriggerList is not None:
            veto, hltVetoPath = self.vetoTriggerList.triggerPassed(
                event.triggerObject,
                run,
                lumi,
                self.cfg_comp.isData,
                usePrescaled=usePrescaled)

        # Check if events needs to be skipped if no trigger is found (useful for generator level studies)
        keepFailingEvents = False
        if hasattr(self.cfg_ana, 'keepFailingEvents'):
            keepFailingEvents = self.cfg_ana.keepFailingEvents
        if not passed or (passed and veto):
            event.passedTriggerAnalyzer = False
            if not keepFailingEvents:
                return False
        else:
            event.passedTriggerAnalyzer = True

        event.hltPath = hltPath

        if hltPath is not None:
            trigObjs = map(TriggerObject,
                           self.handles['cmgTriggerObjectListSel'].product())
            # selecting the trigger objects used in this path
            event.triggerObjects = selTriggerObjects(trigObjs, hltPath)

        self.counters.counter('Trigger').inc('HLT')
        event.TriggerFired = 1
        return True