CMS 3D CMS Logo

ZMuMuRochCorAnalyzer.py
Go to the documentation of this file.
1 import copy
2 
3 from PhysicsTools.HeppyCore.framework.analyzer import Analyzer
4 from PhysicsTools.HeppyCore.statistics.counter import Counter, Counters
5 from PhysicsTools.Heppy.analyzers.AutoHandle import AutoHandle
6 
7 from PhysicsTools.Heppy.physicsobjects.RochesterCorrections import rochcor
8 from PhysicsTools.Heppy.physicsobjects.Particle import Particle
9 from PhysicsTools.Heppy.physicsobjects.Muon import Muon
10 
11 from ROOT import gSystem
12 gSystem.Load("libDataFormatsRecoCandidate.so")
13 from ROOT import reco
14 
16  """ Simple DiMuon object
17 
18  using the LeafCandidate (~simple particle ) dataformat from CMSSW as a base.
19  this class is made in such a way that it behaves almost exactly
20  as physicsobjects.DiObjects.DiMuon.
21  """
22 
23  def __init__(self, l1, l2, diLepton):
24  '''l1 and l2 are the legs, possibly recalibrated.
25  diLepton is the original diLepton, used only in the met function'''
26  self.diLepton = diLepton
27  self.l1 = l1
28  self.l2 = l2
29  self.sumpt = l1.pt() + l2.pt()
30  super(DiMuon, self).__init__(0, l1.p4()+l2.p4())
31 
32  def __str__(self):
33  return 'DiMuon: mass={mass:5.2f}, sumpt={sumpt:5.2f}, pt={pt:5.2f}'.format(
34  mass = self.mass(),
35  sumpt = self.sumpt,
36  pt = self.pt()
37  )
38 
39  def met(self):
40  '''this is going to be needed to compute VBF related quantities.
41  just giving the met associated to the original di-lepton
42  '''
43  return self.diLepton.met()
44 
45  def leg1(self):
46  return self.l1
47 
48  def leg2(self):
49  return self.l2
50 
51 
52 class ZMuMuRochCorAnalyzer( Analyzer ):
53 
54  def process(self, iEvent, event):
55 
56  def correctDiLepton( diLepton ):
57  '''Corrects a di-lepton.
58 
59  This function is defined within the process function to have
60  access to the variables available there, namely event.run.
61  The goal of this function is to be able to call it with map,
62  to get very compact code.
63  '''
64  p4_1 = rochcor.corrected_p4( diLepton.leg1(), event.run )
65  p4_2 = rochcor.corrected_p4( diLepton.leg2(), event.run )
66  # l1 = copy.copy( diLepton.leg1() )
67  # l2 = copy.copy( diLepton.leg2() )
68  l1 = diLepton.leg1()
69  l2 = diLepton.leg2()
70  l1.setP4(p4_1)
71  l2.setP4(p4_2)
72  diLeptonCor = DiMuon( l1, l2, diLepton)
73  return diLeptonCor
74 
75  event.diLeptonRaw = copy.copy(event.diLepton)
76  event.diLepton = correctDiLepton( event.diLeptonRaw )
virtual double pt() const =0
transverse momentum
virtual double mass() const =0
mass
def __init__(self, l1, l2, diLepton)