Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:49

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