CMS 3D CMS Logo

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, particle, run ):
37  '''Correct a particles. '''
38  corp4 = corrected_p4(particle, run)
39  ptc.setP4( corp4 )
40 
41  def correct_all( self, particles, run ):
42  '''Correct a list of particles.
43 
44  The p4 of each particle will change '''
45  for ptc in particles:
46  corp4 = corrected_p4(ptc, run)
47  ptc.setP4( corp4 )
48 
49 
50 
51 
53 
54 
def isNewerThan(release1, release2=None)
Definition: cmsswRelease.py:53