CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
JetReCalibrator.Type1METCorrector Class Reference

Public Member Functions

def __init__ (self, old74XMiniAODs)
 
def correct (self, met, type1METCorrections)
 

Public Attributes

 oldMC
 

Detailed Description

Definition at line 156 of file JetReCalibrator.py.

Constructor & Destructor Documentation

def JetReCalibrator.Type1METCorrector.__init__ (   self,
  old74XMiniAODs 
)
Object to apply type1 corrections computed by the JetReCalibrator to the MET.
   old74XMiniAODs should be True if using inputs produced with CMSSW_7_4_11 or earlier.

Definition at line 157 of file JetReCalibrator.py.

157  def __init__(self, old74XMiniAODs):
158  """Object to apply type1 corrections computed by the JetReCalibrator to the MET.
159  old74XMiniAODs should be True if using inputs produced with CMSSW_7_4_11 or earlier."""
160  self.oldMC = old74XMiniAODs
def __init__(self, old74XMiniAODs)

Member Function Documentation

def JetReCalibrator.Type1METCorrector.correct (   self,
  met,
  type1METCorrections 
)

Definition at line 161 of file JetReCalibrator.py.

References JetReCalibrator.Type1METCorrector.oldMC, and JetReCalibrator.setFakeRawMETOnOldMiniAODs().

Referenced by KalmanMuonCorrector.KalmanMuonCorrector.correct_all().

161  def correct(self,met,type1METCorrections):
162  oldpx, oldpy = met.px(), met.py()
163  #print "old met: px %+10.5f, py %+10.5f" % (oldpx, oldpy)
164  if self.oldMC:
165  raw = met.shiftedP2_74x(12,0);
166  rawsumet = met.shiftedSumEt_74x(12,0);
167  else:
168  raw = met.uncorP2()
169  rawsumet = met.uncorSumEt();
170  rawpx, rawpy = raw.px, raw.py
171  #print "raw met: px %+10.5f, py %+10.5f" % (rawpx, rawpy)
172  corrpx = rawpx + type1METCorrections[0]
173  corrpy = rawpy + type1METCorrections[1]
174  corrsumet = rawsumet + type1METCorrections[2]
175  #print "done met: px %+10.5f, py %+10.5f\n" % (corrpx,corrpy)
176  met.setP4(ROOT.reco.Particle.LorentzVector(corrpx,corrpy,0,hypot(corrpx,corrpy)))
177  ## workaround for missing setSumEt in reco::MET and pat::MET
178  met._sumEt = corrsumet
179  met.sumEt = types.MethodType(lambda myself : myself._sumEt, met, met.__class__)
180  if not self.oldMC:
181  met.setCorShift(rawpx, rawpy, rawsumet, met.Raw)
182  else:
183  # to avoid segfauls in pat::MET, I need a more ugly solution
184  setFakeRawMETOnOldMiniAODs(met, rawpx,rawpy, rawsumet)
185 
def correct(self, met, type1METCorrections)
def setFakeRawMETOnOldMiniAODs(met, rawpx, rawpy, rawsumet)

Member Data Documentation

JetReCalibrator.Type1METCorrector.oldMC

Definition at line 160 of file JetReCalibrator.py.

Referenced by JetReCalibrator.Type1METCorrector.correct().