CMS 3D CMS Logo

ZMuMuAnalyzer.py
Go to the documentation of this file.
1 from __future__ import print_function
2 from PhysicsTools.Heppy.analyzers.DiLeptonAnalyzer import DiLeptonAnalyzer
3 from PhysicsTools.Heppy.analyzers.AutoHandle import AutoHandle
4 from PhysicsTools.Heppy.physicsobjects.DiObject import DiMuon
5 from PhysicsTools.Heppy.physicsobjects.PhysicsObjects import Muon
6 
7 
9 
10  DiObjectClass = DiMuon
11  LeptonClass = Muon
12 
13  def declareHandles(self):
14  super(ZMuMuAnalyzer, self).declareHandles()
15  print('ZMuMuAnalyzer.declareHandles')
16  self.handles['diLeptons'] = AutoHandle(
17  'cmgDiMuonSel',
18  'std::vector<cmg::DiObject<cmg::Muon,cmg::Muon>>'
19  )
20  self.handles['leptons'] = AutoHandle(
21  'cmgMuonSel',
22  'std::vector<cmg::Muon>'
23  )
24  self.handles['otherLeptons'] = AutoHandle(
25  'cmgElectronSel',
26  'std::vector<cmg::Electron>'
27  )
28 
29 
30  def buildDiLeptons(self, cmgDiLeptons, event):
31  '''Build di-leptons, associate best vertex to both legs,
32  select di-leptons with a tight ID muon.
33  The tight ID selection is done so that dxy and dz can be computed
34  (the muon must not be standalone).
35  '''
36  diLeptons = []
37  for index, dil in enumerate(cmgDiLeptons):
38  pydil = self.__class__.DiObjectClass(dil)
39  pydil.leg1().associatedVertex = event.goodVertices[0]
40  pydil.leg2().associatedVertex = event.goodVertices[0]
41  diLeptons.append( pydil )
42  return diLeptons
43 
44 
45  def buildLeptons(self, cmgLeptons, event):
46  return []
47 
48 
49  def buildOtherLeptons(self, cmgLeptons, event):
50  return []
51 
52 
53  def testVertex(self, lepton):
54  '''Tests vertex constraints, for mu and tau'''
55  return abs(lepton.dxy()) < 0.045 and \
56  abs(lepton.dz()) < 0.2
57 
58 
59  def testMuonIso(self, muon, isocut ):
60  '''dbeta corrected pf isolation with all charged particles instead of
61  charged hadrons'''
62  return muon.relIsoAllChargedDB05()<isocut
63 
64  testLeg1Iso = testMuonIso
65  testLeg2Iso = testMuonIso
66 
67  def testMuonID(self, muon):
68  '''Tight muon selection, no isolation requirement'''
69  # import pdb; pdb.set_trace()
70  return muon.tightId() and \
71  self.testVertex( muon )
72 
73 
74  testLeg1ID = testMuonID
75  testLeg2ID = testMuonID
def buildLeptons(self, cmgLeptons, event)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def testVertex(self, lepton)
def testMuonID(self, muon)
def testMuonIso(self, muon, isocut)
def buildDiLeptons(self, cmgDiLeptons, event)
def buildOtherLeptons(self, cmgLeptons, event)