CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RochesterCorrections.py
Go to the documentation of this file.
1 import copy
2 from ROOT import heppy
3 from PhysicsTools.Heppy.utils.cmsswRelease import isNewerThan
4 
5 is2012 = isNewerThan('CMSSW_5_2_0')
6 
8 
9  def __init__(self):
10  self.cor = heppy.RochCor()
12 
13  def corrected_p4( self, particle, run ):
14  '''Returns the corrected p4 for a particle.
15 
16  The particle remains unchanged.
17  '''
18  ptc = particle
19  p4 = ptc.p4()
20  tlp4 = TLorentzVector( p4.px(), p4.py(), p4.pz(), p4.energy() )
21  cortlp4 = copy.copy(tlp4)
22  if run<100:
23  if is2012:
24  self.cor2012.momcor_mc( cortlp4, ptc.charge(), 0.0, 0 )
25  else:
26  self.cor.momcor_mc( cortlp4, ptc.charge(), 0.0, 0 )
27  else: # data
28  if is2012:
29  self.cor2012.momcor_data( cortlp4, ptc.charge(), 0.0, 0 )
30  else:
31  self.cor.momcor_data( cortlp4, ptc.charge(), 0.0, int(run>173692) )
32  corp4 = p4.__class__( cortlp4.Px(), cortlp4.Py(), cortlp4.Pz(), cortlp4.Energy() )
33  return corp4
34 
35 
36  def correct( self, particles, run ):
37  '''Correct a list of particles.
38 
39  The p4 of each particle will change
40  '''
41  for ptc in particles:
42  corp4 = corrected_p4(ptc, run)
43  ptc.setP4( corp4 )
44 
45 
47 
48 
list object
Definition: dbtoconf.py:77