CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
objects.METAnalyzer Namespace Reference

Classes

class  METAnalyzer
 

Functions

def makeGenTkMet
 
def makeMETNoEle
 
def makeMETNoMu
 
def makeMETNoPhoton
 
def makeMETs
 
def process
 
def sumXY
 

Variables

 applyJetSmearing = True,
 
string candidates = 'packedPFCandidates'
 
string candidatesTypes = 'std::vector<pat::PackedCandidate>'
 
 class_object = METAnalyzer,
 
string collectionPostFix = ""
 
 copyMETsByValue = False,
 
 doMetNoEle = False,
 
 doMetNoMu = False,
 
 doMetNoPhoton = False,
 
 doMetNoPU = False,
 
 doTkMet = False,
 
float dzMax = 0.1
 
 includeTkMetCHS = True,
 
 includeTkMetPVLoose = True,
 
 includeTkMetPVTight = True,
 
string jetAnalyzerPostFix = ""
 
 makeShiftedMETs = True,
 
 met
 
 met_raw
 
 met_sig
 
 met_sumet
 
string metCollection = "slimmedMETs"
 
 metNoEle
 
 metNoEleNoPU
 
 metNoMu
 
 metNoMuNoPU
 
 metNoPhoton
 
 metNoPhotonNoPU
 
 metNoPU
 
string noPUMetCollection = "slimmedMETs"
 
 old74XMiniAODs = False,
 
tuple pvflag = pfcand.fromPV()
 ===> require the Track Candidate charge and with a minimum dz More...
 
tuple pxy = pfcand.px()
 
 recalibrate = True,
 
 recalibrateMET
 

Function Documentation

def objects.METAnalyzer.makeGenTkMet (   self,
  event 
)

Definition at line 109 of file METAnalyzer.py.

References funct.abs().

110  def makeGenTkMet(self, event):
111  genCharged = [ (x.px(),x.py()) for x in self.mchandles['packedGen'].product() if x.charge() != 0 and abs(x.eta()) < 2.4 ]
112  px, py = sum(x[0] for x in genCharged), sum(x[1] for x in genCharged)
113  setattr(event,"tkGenMet"+self.cfg_ana.collectionPostFix, ROOT.reco.Particle.LorentzVector(-px , -py, 0, hypot(px,py)))
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def objects.METAnalyzer.makeMETNoEle (   self,
  event 
)

Definition at line 134 of file METAnalyzer.py.

135  def makeMETNoEle(self, event):
136  self.metNoEle = copy.deepcopy(self.met)
137  if self.cfg_ana.doMetNoPU: self.metNoEleNoPU = copy.deepcopy(self.metNoPU)
138 
139  elepx = 0
140  elepy = 0
141  #sum electron momentum
142  for ele in event.selectedElectrons:
143  elepx += ele.px()
144  elepy += ele.py()
145 
146  #subtract electron momentum and construct met
147  px,py = self.metNoEle.px()+elepx, self.metNoEle.py()+elepy
148  self.metNoEle.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, hypot(px,py)))
149 
150  px,py = self.metNoEleNoPU.px()+elepx, self.metNoEleNoPU.py()+elepy
151  self.metNoEleNoPU.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, hypot(px,py)))
152  setattr(event, "metNoEle"+self.cfg_ana.collectionPostFix, self.metNoEle)
153  if self.cfg_ana.doMetNoPU: setattr(event, "metNoEleNoPU"+self.cfg_ana.collectionPostFix, self.metNoEleNoPU)
def objects.METAnalyzer.makeMETNoMu (   self,
  event 
)

Definition at line 114 of file METAnalyzer.py.

115  def makeMETNoMu(self, event):
116  self.metNoMu = copy.deepcopy(self.met)
117  if self.cfg_ana.doMetNoPU: self.metNoMuNoPU = copy.deepcopy(self.metNoPU)
118 
119  mupx = 0
120  mupy = 0
121  #sum muon momentum
122  for mu in event.selectedMuons:
123  mupx += mu.px()
124  mupy += mu.py()
125 
126  #subtract muon momentum and construct met
127  px,py = self.metNoMu.px()+mupx, self.metNoMu.py()+mupy
128  self.metNoMu.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, hypot(px,py)))
129  px,py = self.metNoMuNoPU.px()+mupx, self.metNoMuNoPU.py()+mupy
130  self.metNoMuNoPU.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, hypot(px,py)))
131  setattr(event, "metNoMu"+self.cfg_ana.collectionPostFix, self.metNoMu)
132  if self.cfg_ana.doMetNoPU: setattr(event, "metNoMuNoPU"+self.cfg_ana.collectionPostFix, self.metNoMuNoPU)
133 
def objects.METAnalyzer.makeMETNoPhoton (   self,
  event 
)

Definition at line 154 of file METAnalyzer.py.

155  def makeMETNoPhoton(self, event):
156  self.metNoPhoton = copy.deepcopy(self.met)
157 
158  phopx = 0
159  phopy = 0
160  #sum photon momentum
161  for pho in event.selectedPhotons:
162  phopx += pho.px()
163  phopy += pho.py()
164 
165  #subtract photon momentum and construct met
166  px,py = self.metNoPhoton.px()+phopx, self.metNoPhoton.py()+phopy
167  self.metNoPhoton.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, hypot(px,py)))
168  setattr(event, "metNoPhoton"+self.cfg_ana.collectionPostFix, self.metNoPhoton)
169  if self.cfg_ana.doMetNoPU:
170  self.metNoPhotonNoPU = copy.deepcopy(self.metNoPU)
171  px,py = self.metNoPhotonNoPU.px()+phopx, self.metNoPhotonNoPU.py()+phopy
172  self.metNoPhotonNoPU.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, hypot(px,py)))
173  setattr(event, "metNoPhotonNoPU"+self.cfg_ana.collectionPostFix, self.metNoPhotonNoPU)
174 
def objects.METAnalyzer.makeMETs (   self,
  event 
)

Definition at line 175 of file METAnalyzer.py.

176  def makeMETs(self, event):
177  import ROOT
178  if self.cfg_ana.copyMETsByValue:
179  self.met = ROOT.pat.MET(self.handles['met'].product()[0])
180  if self.cfg_ana.doMetNoPU: self.metNoPU = ROOT.pat.MET(self.handles['nopumet'].product()[0])
181  else:
182  self.met = self.handles['met'].product()[0]
183  if self.cfg_ana.doMetNoPU: self.metNoPU = self.handles['nopumet'].product()[0]
185  if self.recalibrateMET == "type1":
186  type1METCorr = getattr(event, 'type1METCorr'+self.jetAnalyzerPostFix)
187  self.type1METCorrector.correct(self.met, type1METCorr)
188  elif self.recalibrateMET == True:
189  deltaMetJEC = getattr(event, 'deltaMetFromJEC'+self.jetAnalyzerPostFix)
190  self.applyDeltaMet(self.met, deltaMetJEC)
191  if self.applyJetSmearing:
192  deltaMetSmear = getattr(event, 'deltaMetFromJetSmearing'+self.jetAnalyzerPostFix)
193  self.applyDeltaMet(self.met, deltaMetSmear)
194 
195 
196  if (not self.cfg_ana.copyMETsByValue) and getattr(self.cfg_ana, 'makeShiftedMETs', True):
197  shifts = []
198  for obj in 'JetEn', 'JetRes', 'MuonEn', 'ElectronEn', 'PhotonEn', 'TauEn', 'UnclusteredEn':
199  for sh in 'Up', 'Down':
200  shifts.append( (obj+sh, getattr(self.met,obj+sh)) )
201  shifts.append( ('NoShift', self.met.NoShift) )
202  for name,i in shifts:
203  key = i
204  m = ROOT.pat.MET(self.met)
205  if self.old74XMiniAODs:
206  if key > 12: key = 12
207  elif key <= 3: key = { 'JetEnUp':0, 'JetEnDown':1, 'JetResUp':2, 'JetResDown':3 }[name]
208  m.setP4(self.met.shiftedP4(key))
209  setattr(event, "met{0}_shifted_{1}".format(self.cfg_ana.collectionPostFix, i),m)
210  setattr(event, "met{0}_shifted_{1}".format(self.cfg_ana.collectionPostFix, name),m)
212  self.met_sig = self.met.significance()
213  self.met_sumet = self.met.sumEt()
214 
215  if self.old74XMiniAODs and self.recalibrateMET != "type1":
216  oldraw = self.met.shiftedP2_74x(12,0);
217  setFakeRawMETOnOldMiniAODs( self.met, oldraw.px, oldraw.py, self.met.shiftedSumEt_74x(12,0) )
218  px, py = oldraw.px, oldraw.py
219  else:
220  px, py = self.met.uncorPx(), self.met.uncorPy()
221  self.met_raw = ROOT.reco.Particle.LorentzVector(px,py,0,hypot(px,py))
222 
223  if hasattr(event,'zll_p4'):
224  self.adduParaPerp(self.met,event.zll_p4,"_zll")
225  self.adduParaPerp(self.met_raw, event.zll_p4,"_zll")
226  setattr(event,"met_raw"+self.cfg_ana.collectionPostFix, self.met_raw)
227  setattr(event,"met_raw.upara_zll"+self.cfg_ana.collectionPostFix, self.met_raw.upara_zll)
228  setattr(event,"met_raw.uperp_zll"+self.cfg_ana.collectionPostFix, self.met_raw.uperp_zll)
229 
230  if hasattr(event,'gamma_p4'):
231  self.adduParaPerp(self.met,event.gamma_p4,"_gamma")
232  self.adduParaPerp(self.met_raw, event.gamma_p4,"_gamma")
233  setattr(event,"met_raw"+self.cfg_ana.collectionPostFix, self.met_raw)
234  setattr(event,"met_raw.upara_gamma"+self.cfg_ana.collectionPostFix, self.met_raw.upara_gamma)
235  setattr(event,"met_raw.uperp_gamma"+self.cfg_ana.collectionPostFix, self.met_raw.uperp_gamma)
236 
237  if hasattr(event,"met"+self.cfg_ana.collectionPostFix): raise RuntimeError, "Event already contains met with the following postfix: "+self.cfg_ana.collectionPostFix
238  setattr(event, "met"+self.cfg_ana.collectionPostFix, self.met)
239  if self.cfg_ana.doMetNoPU: setattr(event, "metNoPU"+self.cfg_ana.collectionPostFix, self.metNoPU)
240  setattr(event, "met_sig"+self.cfg_ana.collectionPostFix, self.met_sig)
241  setattr(event, "met_sumet"+self.cfg_ana.collectionPostFix, self.met_sumet)
242 
243  genMET = self.met.genMET()
244  if genMET:
245  setattr(event, "met_genPt"+self.cfg_ana.collectionPostFix, genMET.pt())
246  setattr(event, "met_genPhi"+self.cfg_ana.collectionPostFix, genMET.phi())
247  else:
248  setattr(event, "met_genPt"+self.cfg_ana.collectionPostFix, float('nan'))
249  setattr(event, "met_genPhi"+self.cfg_ana.collectionPostFix, float('nan'))
250 
251  if self.cfg_ana.doMetNoMu and hasattr(event, 'selectedMuons'):
252  self.makeMETNoMu(event)
253 
254  if self.cfg_ana.doMetNoEle and hasattr(event, 'selectedElectrons'):
255  self.makeMETNoEle(event)
256 
257  if self.cfg_ana.doMetNoPhoton and hasattr(event, 'selectedPhotons'):
258  self.makeMETNoPhoton(event)
def objects.METAnalyzer.process (   self,
  event 
)

Definition at line 259 of file METAnalyzer.py.

260  def process(self, event):
261  self.readCollections( event.input)
262  self.counters.counter('events').inc('all events')
263 
264  self.makeMETs(event)
265 
266  if self.cfg_ana.doTkMet:
267  self.makeTkMETs(event);
268 
269  if getattr(self.cfg_ana,"doTkGenMet",self.cfg_ana.doTkMet) and self.cfg_comp.isMC and hasattr(event, 'genParticles'):
270  self.makeGenTkMet(event)
271 
272  return True
273 
274 
setattr(METAnalyzer,"defaultConfig", cfg.Analyzer(
def objects.METAnalyzer.sumXY (   pxys)

Definition at line 90 of file METAnalyzer.py.

90 
91  def sumXY(pxys):
92  px, py = sum(x[0] for x in pxys), sum(x[1] for x in pxys)
return ROOT.reco.Particle.LorentzVector(-px, -py, 0, hypot(px,py))

Variable Documentation

objects.METAnalyzer.applyJetSmearing = True,

Definition at line 280 of file METAnalyzer.py.

string objects.METAnalyzer.candidates = 'packedPFCandidates'

Definition at line 292 of file METAnalyzer.py.

string objects.METAnalyzer.candidatesTypes = 'std::vector<pat::PackedCandidate>'

Definition at line 293 of file METAnalyzer.py.

objects.METAnalyzer.class_object = METAnalyzer,

Definition at line 275 of file METAnalyzer.py.

string objects.METAnalyzer.collectionPostFix = ""

Definition at line 295 of file METAnalyzer.py.

objects.METAnalyzer.copyMETsByValue = False,

Definition at line 278 of file METAnalyzer.py.

objects.METAnalyzer.doMetNoEle = False,

Definition at line 290 of file METAnalyzer.py.

objects.METAnalyzer.doMetNoMu = False,

Definition at line 289 of file METAnalyzer.py.

objects.METAnalyzer.doMetNoPhoton = False,

Definition at line 291 of file METAnalyzer.py.

objects.METAnalyzer.doMetNoPU = False,

Definition at line 288 of file METAnalyzer.py.

objects.METAnalyzer.doTkMet = False,

Definition at line 284 of file METAnalyzer.py.

float objects.METAnalyzer.dzMax = 0.1

Definition at line 294 of file METAnalyzer.py.

objects.METAnalyzer.includeTkMetCHS = True,

Definition at line 285 of file METAnalyzer.py.

objects.METAnalyzer.includeTkMetPVLoose = True,

Definition at line 286 of file METAnalyzer.py.

objects.METAnalyzer.includeTkMetPVTight = True,

Definition at line 287 of file METAnalyzer.py.

string objects.METAnalyzer.jetAnalyzerPostFix = ""

Definition at line 281 of file METAnalyzer.py.

objects.METAnalyzer.makeShiftedMETs = True,

Definition at line 283 of file METAnalyzer.py.

objects.METAnalyzer.met

Definition at line 178 of file METAnalyzer.py.

Referenced by CaloSpecificAlgo.addInfo(), StKinFitter.addKinFitInfo(), QcdHighPtDQM.analyze(), PatTopSelectionAnalyzer.analyze(), L1THIonImp.analyze(), EwkMuDQM.analyze(), HLTTauDQMPathPlotter.analyze(), TtSemiLepJetCombMVATrainer.analyze(), EwkElecDQM.analyze(), CaloTowersValidation.analyze(), CaloTowersAnalyzer.analyze(), EwkMuLumiMonitorDQM.analyze(), GctTimingAnalyzer.analyze(), WenuPlots.analyze(), HotlineDQM.analyze(), METTester.analyze(), JetAnalyzer.analyze(), METAnalyzer.analyze(), L1TGCT.analyze(), RazorVarProducer.CalcR(), HLTRFilter.CalcR(), SUSY_HLT_Razor.CalcR(), TCMETAlgo.CalculateTCMET(), AlignmentTwoBodyDecayTrackSelector.checkMETMass(), DumpGctDigis.doEnergySums(), HLTTauRefProducer.doMET(), l1t::Stage1Layer2EtSumAlgorithmImpHW.doSumAndMET(), l1t::Stage1Layer2EtSumAlgorithmImpHI.doSumAndMET(), JetMETHLTOfflineSource.dqmBeginRun(), SingleTopTChannelLepton_miniAOD::MonitorEnsemble.fill(), TopSingleLepton_miniAOD::MonitorEnsemble.fill(), HLTOfflineDQMTopSingleLepton::MonitorSingleLepton.fill(), HLTOfflineDQMTopDiLepton::MonitorDiLepton.fill(), TopSingleLepton::MonitorEnsemble.fill(), SingleTopTChannelLepton::MonitorEnsemble.fill(), TopDiLeptonOffline::MonitorEnsemble.fill(), JetMETHLTOfflineSource.fillMEforEffAllTrigger(), JetMETHLTOfflineSource.fillMEforMonAllTrigger(), JetMETHLTOfflineSource.fillMEforTriggerNTfired(), PFMETFilter.filter(), WMuNuValidator.filter(), WMuNuSelector.filter(), aod2patFilterZee.filter(), ZeeCandidateFilter.filter(), HepMCValidationHelper.genMet(), WtoLNuSelector.getMt(), HLTHcalNoiseFilter.hltFilter(), HLTElectronPFMTFilter< T >.hltFilter(), HLTTauRefProducer.HLTTauRefProducer(), tnp::BaseTreeFiller.init(), HLTOfflineDQMTopDiLepton::MonitorDiLepton.MonitorDiLepton(), HLTOfflineDQMTopSingleLepton::MonitorSingleLepton.MonitorSingleLepton(), QcdHighPtDQM.moverl(), QcdHighPtDQM.movers(), PFCandidateChecker.printMet(), l1t::Stage2Layer2DemuxSumsAlgoFirmwareImp1.processEvent(), DistortedMETProducer.produce(), pat::PATMETSlimmer.produce(), TtSemiLepJetCombMVAComputer.produce(), pat::RecoMETExtractor.produce(), SysShiftMETcorrInputProducer.produce(), cms::ElseMETProducer.produce(), HLTMETCleanerUsingJetID.produce(), WMuNuProducer.produce(), L1ExtraParticleMapProd.produce(), JetEnergyShift.produce(), AlCaHcalNoiseProducer.produce(), cms::METSignificanceProducer.produce(), CaloJetMETcorrInputProducerT< T, Textractor >.produce(), METAlgo.run(), TtDilepEvtSolution.setMET(), TtSemiLepHypothesis.setNeutrino(), StEvtSolution.setNeutrino(), TtSemiEvtSolution.setNeutrino(), l1t::stage1::MissEtUnpacker.unpack(), l1t::stage1::legacy::EtSumUnpacker.unpack(), and l1t::stage2::EtSumUnpacker.unpack().

objects.METAnalyzer.met_raw

Definition at line 220 of file METAnalyzer.py.

objects.METAnalyzer.met_sig

Definition at line 211 of file METAnalyzer.py.

objects.METAnalyzer.met_sumet

Definition at line 212 of file METAnalyzer.py.

string objects.METAnalyzer.metCollection = "slimmedMETs"

Definition at line 276 of file METAnalyzer.py.

objects.METAnalyzer.metNoEle

Definition at line 135 of file METAnalyzer.py.

objects.METAnalyzer.metNoEleNoPU

Definition at line 136 of file METAnalyzer.py.

objects.METAnalyzer.metNoMu

Definition at line 115 of file METAnalyzer.py.

objects.METAnalyzer.metNoMuNoPU

Definition at line 116 of file METAnalyzer.py.

objects.METAnalyzer.metNoPhoton

Definition at line 155 of file METAnalyzer.py.

objects.METAnalyzer.metNoPhotonNoPU

Definition at line 169 of file METAnalyzer.py.

objects.METAnalyzer.metNoPU

Definition at line 179 of file METAnalyzer.py.

string objects.METAnalyzer.noPUMetCollection = "slimmedMETs"

Definition at line 277 of file METAnalyzer.py.

objects.METAnalyzer.old74XMiniAODs = False,

Definition at line 282 of file METAnalyzer.py.

tuple objects.METAnalyzer.pvflag = pfcand.fromPV()

===> require the Track Candidate charge and with a minimum dz

Definition at line 75 of file METAnalyzer.py.

tuple objects.METAnalyzer.pxy = pfcand.px()

Definition at line 76 of file METAnalyzer.py.

objects.METAnalyzer.recalibrate = True,

Definition at line 279 of file METAnalyzer.py.

objects.METAnalyzer.recalibrateMET

Definition at line 184 of file METAnalyzer.py.