Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:29

0001 import copy
0002 from ROOT import heppy
0003 from PhysicsTools.Heppy.utils.cmsswRelease import isNewerThan
0004 
0005 is2012 = isNewerThan('CMSSW_5_2_0')
0006 
0007 class RochesterCorrections(object):
0008     
0009     def __init__(self):
0010         self.cor = heppy.RochCor()
0011         self.cor2012 = heppy.RochCor2012()
0012 
0013     def corrected_p4( self, particle, run ):
0014         '''Returns the corrected p4 for a particle.
0015 
0016         The particle remains unchanged. 
0017         '''
0018         ptc = particle
0019         p4 = ptc.p4()
0020         tlp4 = TLorentzVector( p4.px(), p4.py(), p4.pz(), p4.energy() )
0021         cortlp4 = copy.copy(tlp4)
0022         if run<100:
0023             if is2012:
0024                 self.cor2012.momcor_mc( cortlp4, ptc.charge(), 0.0, 0 )
0025             else:
0026                 self.cor.momcor_mc( cortlp4, ptc.charge(), 0.0, 0 )
0027         else: # data
0028             if is2012:
0029                 self.cor2012.momcor_data( cortlp4, ptc.charge(), 0.0, 0 )
0030             else:
0031                 self.cor.momcor_data( cortlp4, ptc.charge(), 0.0, int(run>173692) )
0032         corp4 = p4.__class__( cortlp4.Px(), cortlp4.Py(), cortlp4.Pz(), cortlp4.Energy() )        
0033         return corp4
0034 
0035         
0036     def correct( self, particle, run ):
0037         '''Correct a particles.  '''
0038         corp4 = corrected_p4(particle, run) 
0039         ptc.setP4( corp4 )
0040 
0041     def correct_all( self, particles, run ):
0042         '''Correct a list of particles.
0043 
0044         The p4 of each particle will change '''
0045         for ptc in particles: 
0046             corp4 = corrected_p4(ptc, run) 
0047             ptc.setP4( corp4 )
0048 
0049 
0050 
0051 
0052 rochcor = RochesterCorrections() 
0053         
0054