Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:27

0001 from __future__ import print_function
0002 from PhysicsTools.Heppy.analyzers.DiLeptonAnalyzer import DiLeptonAnalyzer
0003 from PhysicsTools.Heppy.analyzers.AutoHandle import AutoHandle
0004 from PhysicsTools.Heppy.physicsobjects.DiObject import DiMuon
0005 from PhysicsTools.Heppy.physicsobjects.PhysicsObjects import Muon
0006 
0007 
0008 class ZMuMuAnalyzer( DiLeptonAnalyzer ):
0009 
0010     DiObjectClass = DiMuon
0011     LeptonClass = Muon
0012 
0013     def declareHandles(self):
0014         super(ZMuMuAnalyzer, self).declareHandles()
0015         print('ZMuMuAnalyzer.declareHandles')
0016         self.handles['diLeptons'] = AutoHandle(
0017             'cmgDiMuonSel',
0018             'std::vector<cmg::DiObject<cmg::Muon,cmg::Muon>>'
0019             )
0020         self.handles['leptons'] = AutoHandle(
0021             'cmgMuonSel',
0022             'std::vector<cmg::Muon>'
0023             )
0024         self.handles['otherLeptons'] = AutoHandle(
0025             'cmgElectronSel',
0026             'std::vector<cmg::Electron>'
0027             )
0028 
0029 
0030     def buildDiLeptons(self, cmgDiLeptons, event):
0031         '''Build di-leptons, associate best vertex to both legs,
0032         select di-leptons with a tight ID muon.
0033         The tight ID selection is done so that dxy and dz can be computed
0034         (the muon must not be standalone).
0035         '''
0036         diLeptons = []
0037         for index, dil in enumerate(cmgDiLeptons):
0038             pydil = self.__class__.DiObjectClass(dil)
0039             pydil.leg1().associatedVertex = event.goodVertices[0]
0040             pydil.leg2().associatedVertex = event.goodVertices[0]
0041             diLeptons.append( pydil )
0042         return diLeptons
0043 
0044 
0045     def buildLeptons(self, cmgLeptons, event):
0046         return []
0047 
0048 
0049     def buildOtherLeptons(self, cmgLeptons, event):
0050         return []
0051     
0052 
0053     def testVertex(self, lepton):
0054         '''Tests vertex constraints, for mu and tau'''
0055         return abs(lepton.dxy()) < 0.045 and \
0056                abs(lepton.dz()) < 0.2 
0057 
0058 
0059     def testMuonIso(self, muon, isocut ):
0060         '''dbeta corrected pf isolation with all charged particles instead of
0061         charged hadrons'''
0062         return muon.relIsoAllChargedDB05()<isocut
0063 
0064     testLeg1Iso = testMuonIso
0065     testLeg2Iso = testMuonIso
0066 
0067     def testMuonID(self, muon):
0068         '''Tight muon selection, no isolation requirement'''
0069         # import pdb; pdb.set_trace()
0070         return muon.tightId() and \
0071                self.testVertex( muon )          
0072 
0073 
0074     testLeg1ID = testMuonID
0075     testLeg2ID = testMuonID