示例#1
0
class TriggerBitFilter( Analyzer ):
    def __init__(self, cfg_ana, cfg_comp, looperName ):
        super(TriggerBitFilter,self).__init__(cfg_ana,cfg_comp,looperName)
        triggers = cfg_comp.triggers
        self.autoAccept = True if len(triggers) == 0 else False
        vetoTriggers = cfg_comp.vetoTriggers if hasattr(cfg_comp, 'vetoTriggers') else []
        import ROOT
        trigVec = ROOT.vector(ROOT.string)()
        for t in triggers: trigVec.push_back(t)
        self.mainFilter = TriggerBitChecker(trigVec)
        if len(vetoTriggers):
            vetoVec = ROOT.vector(ROOT.string)()
            for t in vetoTriggers: vetoVec.push_back(t)
            self.vetoFilter = TriggerBitChecker(vetoVec)
        else:
            self.vetoFilter = None 
        
    def declareHandles(self):
        super(TriggerBitFilter, self).declareHandles()
        self.handles['TriggerResults'] = AutoHandle( ('TriggerResults','','HLT'), 'edm::TriggerResults' )

    def beginLoop(self):
        super(TriggerBitFilter,self).beginLoop()

    def process(self, iEvent, event):
        if self.autoAccept: return True
        self.readCollections( iEvent )
        if not self.mainFilter.check(iEvent.object(), self.handles['TriggerResults'].product()):
            return False
        if self.vetoFilter != None and self.vetoFilter.check(iEvent.object(), self.handles['TriggerResults'].product()):
            return False
        return True
示例#2
0
class triggerBitFilter( Analyzer ):
    def __init__(self, cfg_ana, cfg_comp, looperName ):
        super(triggerBitFilter,self).__init__(cfg_ana,cfg_comp,looperName)
        triggers = cfg_comp.triggers
        vetoTriggers = cfg_comp.vetoTriggers if hasattr(cfg_comp, 'vetoTriggers') else []
        import ROOT
        trigVec = ROOT.vector(ROOT.string)()
        for t in triggers: trigVec.push_back(t)
        self.mainFilter = TriggerBitChecker(trigVec)
        if len(vetoTriggers):
            vetoVec = ROOT.vector(ROOT.string)()
            for t in vetoTriggers: vetoVec.push_back(t)
            self.vetoFilter = TriggerBitChecker(vetoVec)
        else:
            self.vetoFilter = None 
        
    def declareHandles(self):
        super(triggerBitFilter, self).declareHandles()
        self.handles['TriggerResults'] = AutoHandle( ('TriggerResults','','HLT'), 'edm::TriggerResults' )

    def beginLoop(self):
        super(triggerBitFilter,self).beginLoop()

    def process(self, iEvent, event):
        self.readCollections( iEvent )
        if not self.mainFilter.check(iEvent.object(), self.handles['TriggerResults'].product()):
            return False
        if self.vetoFilter != None and self.vetoFilter.check(iEvent.object(), self.handles['TriggerResults'].product()):
            return False
        return True
示例#3
0
 def __init__(self, cfg_ana, cfg_comp, looperName ):
     super(triggerBitFilter,self).__init__(cfg_ana,cfg_comp,looperName)
     triggers = cfg_comp.triggers
     vetoTriggers = cfg_comp.vetoTriggers if hasattr(cfg_comp, 'vetoTriggers') else []
     import ROOT
     trigVec = ROOT.vector(ROOT.string)()
     for t in triggers: trigVec.push_back(t)
     self.mainFilter = TriggerBitChecker(trigVec)
     if len(vetoTriggers):
         vetoVec = ROOT.vector(ROOT.string)()
         for t in vetoTriggers: vetoVec.push_back(t)
         self.vetoFilter = TriggerBitChecker(vetoVec)
     else:
         self.vetoFilter = None 
示例#4
0
 def __init__(self, cfg_ana, cfg_comp, looperName ):
     super(TriggerBitFilter,self).__init__(cfg_ana,cfg_comp,looperName)
     triggers = cfg_comp.triggers
     self.autoAccept = True if len(triggers) == 0 else False
     vetoTriggers = cfg_comp.vetoTriggers if hasattr(cfg_comp, 'vetoTriggers') else []
     import ROOT
     trigVec = ROOT.vector(ROOT.string)()
     for t in triggers: trigVec.push_back(t)
     self.mainFilter = TriggerBitChecker(trigVec)
     if len(vetoTriggers):
         vetoVec = ROOT.vector(ROOT.string)()
         for t in vetoTriggers: vetoVec.push_back(t)
         self.vetoFilter = TriggerBitChecker(vetoVec)
     else:
         self.vetoFilter = None 
    def declareCoreVariables(self, tr, isMC):
        """Here we declare the variables that we always want and that are hard-coded"""

        tr.var('run', int)
        tr.var('lumi', int)
        tr.var('evt', int)

        self.triggerBitCheckers = []
        if hasattr(self.cfg_ana, 'triggerBits'):
            for T, TL in self.cfg_ana.triggerBits.iteritems():
                trigVec = ROOT.vector(ROOT.string)()
                for TP in TL:
                    trigVec.push_back(TP)
                tr.var('HLT_' + T, int)
                self.triggerBitCheckers.append((T, TriggerBitChecker(trigVec)))

        if isMC:
            ## PU weights
            tr.var("puWeight")
            ## PDF weights
            self.pdfWeights = []
            if hasattr(self.cfg_ana,
                       "PDFWeights") and len(self.cfg_ana.PDFWeights) > 0:
                self.pdfWeights = self.cfg_ana.PDFWeights
                for (pdf, nvals) in self.pdfWeights:
                    if self.scalar:
                        for i in range(nvals):
                            tr.var('pdfWeight_%s_%d' % (pdf, i))
                    else:
                        tr.vector('pdfWeight_%s' % pdf, nvals)
示例#6
0
 def __init__(self, cfg_ana, cfg_comp, looperName ):
     super(ttHLepFRAnalyzer,self).__init__(cfg_ana,cfg_comp,looperName) 
     self.leptonMVA = LeptonMVA("%s/src/CMGTools/TTHAnalysis/data/leptonMVA/%%s_BDTG.weights.xml" % os.environ['CMSSW_BASE'], self.cfg_comp.isMC)
     self.triggerCheckers = []
     import ROOT
     for T in self.cfg_ana.triggers:
         trigVec = ROOT.vector(ROOT.string)()
         trigVec.push_back("HLT_%s_v*" % T)
         self.triggerCheckers.append( (T.replace("_eta2p1",""), TriggerBitChecker(trigVec)) )
示例#7
0
    def declareVariables(self):

        isMC = self.cfg_comp.isMC 

        tr = self.tree
        var( tr, 'run', int)
        var( tr, 'lumi', int)
        var( tr, 'evt', int)
        var( tr, 'nVert')
        
        ## --- LEPTONS ---
        var( tr, 'nLepGood', int)
        for i in range(8):
            bookLepton(tr,"LepGood%d"%(i+1), isMC)
        ## --- LOOSE LEPTONS (OPTIONAL) ---
        if self.cfg_ana.doLooseLeptons:
            var( tr, 'nLepLoose', int)
            for i in range(8):
                bookLepton(tr,"LepLoose%d"%(i+1))
        ## --- INCLUSIVE LEPTONS (OPTIONAL) ---
        if hasattr(self.cfg_ana, 'doInclusiveLeptons') and self.cfg_ana.doInclusiveLeptons:
            var( tr, 'nLep', int)
            for i in range(8):
                bookLepton(tr,"Lep%d"%(i+1), isMC)
        ## --- PHOTONS ---
        for i in range(8):            
            bookPhoton(tr,"Photon%d"%(i+1))     
        ## --- JETS ---
        var( tr, 'nJet25', int)
        var( tr, 'nJet30', int)       
        var( tr, 'nJet25Fwd', int)
        var( tr, 'nJet30Fwd', int)       
        self.saveJetId = (self.cfg_ana.saveJetId if hasattr(self.cfg_ana,'saveJetId') else False)
        for i in range(8):
            bookJet(tr,"Jet%d"%(i+1), isMC, saveID=self.saveJetId)
        for i in range(6):
            bookJet(tr,"FwdJet%d"%(i+1), isMC, saveID=self.saveJetId)
        if hasattr(self.cfg_ana, 'doJetsFailId') and self.cfg_ana.doJetsFailId:
            for i in range(8):
                bookJet(tr,"JetFailId%d"%(i+1), isMC, saveID=True)
        var( tr, 'nBJetLoose25', int )
        var( tr, 'nBJetMedium25', int )
        var( tr, 'nBJetLoose30', int )
        var( tr, 'nBJetMedium30', int )
        ## --- MET, HT, MHT ---
        var( tr, 'met' )
        var( tr, 'met_phi' )
        var( tr, 'metNoPU' )
        var( tr, 'metNoPU_phi' )
        #var( tr, 'metSignificance' )
        #var( tr, 'projMetAll1S' )
        #var( tr, 'projMetAll2S' )
        #var( tr, 'projMetJet1S' )
        #var( tr, 'projMetJet2S' )
        ## --- HT, MHT ---
        var( tr, 'htJet30' )
        var( tr, 'htJet25' )
        var( tr, 'mhtJet30' )
        var( tr, 'mhtJet25' )
        #var( tr, 'htJet30A' )
        var( tr, 'htJet25A' )
        #var( tr, 'mhtJet30A' )
        var( tr, 'mhtJet25A' )
        ## --- DILEPTON MASSES ---
        var( tr, 'mZ1' )
        var( tr, 'mZ1SFSS' )
        var( tr, 'mZ2' )
        var( tr, 'minMllSFOS' )
        var( tr, 'minMllAFOS' )
        var( tr, 'minMllAFSS' )
        var( tr, 'minMllAFAS' )
        var( tr, 'maxMllAFOS' )
        var( tr, 'maxMllAFSS' )
        var( tr, 'minDrllAFOS' )
        var( tr, 'maxDrllAFOS' )
        var( tr, 'minDrllAFSS' )
        var( tr, 'maxDrllAFSS' )
        var( tr, 'minPtllAFOS' )
        var( tr, 'maxPtllAFOS' )
        var( tr, 'minPtllAFSS' )
        var( tr, 'maxPtllAFSS' )
        var( tr, 'q3l', int )
        var( tr, 'q4l', int )
        var( tr, 'm2l' )
        var( tr, 'm3l' )
        var( tr, 'm4l' )
        var( tr, 'pt2l' )
        var( tr, 'pt3l' )
        var( tr, 'pt4l' )
        var( tr, 'ht3l' )
        var( tr, 'ht4l' )
        var( tr, 'vtx2l_chi2' )
        var( tr, 'vtx2l_ndf' )
         
        var( tr, 'minMWjj' )
        var( tr, 'minMWjjPt' )
        var( tr, 'bestMWjj' )
        var( tr, 'bestMWjjPt' )
        var( tr, 'bestMTopHad' )
        var( tr, 'bestMTopHadPt' )
        
        ## --- TAUS LEPTONS (OPTIONAL) ---
        if hasattr(self.cfg_ana, 'doTaus') and self.cfg_ana.doTaus:
            var( tr, 'nTau', int)
            for i in range(4):
                bookTau(tr,"Tau%d"%(i+1),isMC=True)

        ## --- LEP EFFICIENCY WEIGHT ---
        if self.cfg_comp.isMC:
            var(tr, 'Eff_4lep')
            var(tr, 'EffUp_4lep')
            var(tr, 'EffDwn_4lep')
            var(tr, 'Eff_3lep')
            var(tr, 'EffUp_3lep')
            var(tr, 'EffDwn_3lep')
            var(tr, 'Eff_2lep')
            var(tr, 'EffUp_2lep')
            var(tr, 'EffDwn_2lep')    
        

        if self.cfg_comp.isMC: 
            var( tr, 'puWeight' )
            self.declareMCVariables()

        self.triggerBitCheckers = []
        if hasattr(self.cfg_ana, 'triggerBits'):
            for T, TL in self.cfg_ana.triggerBits.iteritems():
                trigVec = ROOT.vector(ROOT.string)()
                for TP in TL:
                    trigVec.push_back(TP)
                var( tr, 'HLT_'+T, int )
                self.triggerBitCheckers.append( (T, TriggerBitChecker(trigVec)) )