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
 print 'tkmet',self.tkMet.pt(),'tkmetphi',self.tkMet.phi() More...
 
def makeMETNoEle
 
def makeMETNoMu
 
def makeMETNoPhoton
 
def makeMETs
 
def process
 

Variables

string candidates = 'packedPFCandidates'
 
string candidatesTypes = 'std::vector<pat::PackedCandidate>'
 
 class_object = METAnalyzer,
 
string collectionPostFix = ""
 
 copyMETsByValue = False,
 
 doMetNoEle = False,
 
 doMetNoMu = False,
 
 doMetNoPhoton = False,
 
 doMetNoPU = True,
 
 doTkMet = False,
 
float dzMax = 0.1
 
string jetAnalyzerCalibrationPostFix = ""
 
 met
 
 met_sig
 
 met_sumet
 
string metCollection = "slimmedMETs"
 
 metNoEle
 
 metNoEleNoPU
 
 metNoMu
 
 metNoMuNoPU
 
 metNoPhoton
 
 metNoPhotonNoPU
 
 metNoPU
 
 metraw
 https://github.com/cms-sw/cmssw/blob/CMSSW_7_2_X/DataFormats/PatCandidates/interface/MET.h More...
 
 metType1chs
 
string noPUMetCollection = "slimmedMETs"
 
 recalibrate = True,
 

Function Documentation

def objects.METAnalyzer.makeGenTkMet (   self,
  event 
)

print 'tkmet',self.tkMet.pt(),'tkmetphi',self.tkMet.phi()

Definition at line 86 of file METAnalyzer.py.

References funct.abs().

86 
87  def makeGenTkMet(self, event):
88  genCharged = [ x for x in self.mchandles['packedGen'].product() if x.charge() != 0 and abs(x.eta()) < 2.4 ]
89  event.tkGenMet = ROOT.reco.Particle.LorentzVector(-1.*(sum([x.px() for x in genCharged])) , -1.*(sum([x.py() for x in genCharged])), 0, math.hypot((sum([x.px() for x in genCharged])),(sum([x.py() for x in genCharged]))) )
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def makeGenTkMet
print &#39;tkmet&#39;,self.tkMet.pt(),&#39;tkmetphi&#39;,self.tkMet.phi()
Definition: METAnalyzer.py:86
def objects.METAnalyzer.makeMETNoEle (   self,
  event 
)

Definition at line 110 of file METAnalyzer.py.

111  def makeMETNoEle(self, event):
112  self.metNoEle = copy.deepcopy(self.met)
113  if self.cfg_ana.doMetNoPU: self.metNoEleNoPU = copy.deepcopy(self.metNoPU)
114 
115  elepx = 0
116  elepy = 0
117  #sum electron momentum
118  for ele in event.selectedElectrons:
119  elepx += ele.px()
120  elepy += ele.py()
121 
122  #subtract electron momentum and construct met
123  px,py = self.metNoEle.px()+elepx, self.metNoEle.py()+elepy
124  self.metNoEle.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
125 
126  px,py = self.metNoEleNoPU.px()+elepx, self.metNoEleNoPU.py()+elepy
127  self.metNoEleNoPU.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
128  setattr(event, "metNoEle"+self.cfg_ana.collectionPostFix, self.metNoEle)
129  if self.cfg_ana.doMetNoPU: setattr(event, "metNoEleNoPU"+self.cfg_ana.collectionPostFix, self.metNoEleNoPU)
def objects.METAnalyzer.makeMETNoMu (   self,
  event 
)

Definition at line 90 of file METAnalyzer.py.

90 
91  def makeMETNoMu(self, event):
92  self.metNoMu = copy.deepcopy(self.met)
93  if self.cfg_ana.doMetNoPU: self.metNoMuNoPU = copy.deepcopy(self.metNoPU)
94 
95  mupx = 0
96  mupy = 0
97  #sum muon momentum
98  for mu in event.selectedMuons:
99  mupx += mu.px()
100  mupy += mu.py()
101 
102  #subtract muon momentum and construct met
103  px,py = self.metNoMu.px()+mupx, self.metNoMu.py()+mupy
104  self.metNoMu.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
105  px,py = self.metNoMuNoPU.px()+mupx, self.metNoMuNoPU.py()+mupy
106  self.metNoMuNoPU.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
107  setattr(event, "metNoMu"+self.cfg_ana.collectionPostFix, self.metNoMu)
108  if self.cfg_ana.doMetNoPU: setattr(event, "metNoMuNoPU"+self.cfg_ana.collectionPostFix, self.metNoMuNoPU)
109 
def objects.METAnalyzer.makeMETNoPhoton (   self,
  event 
)

Definition at line 130 of file METAnalyzer.py.

131  def makeMETNoPhoton(self, event):
132  self.metNoPhoton = copy.deepcopy(self.met)
133 
134  phopx = 0
135  phopy = 0
136  #sum photon momentum
137  for pho in event.selectedPhotons:
138  phopx += pho.px()
139  phopy += pho.py()
140 
141  #subtract photon momentum and construct met
142  px,py = self.metNoPhoton.px()+phopx, self.metNoPhoton.py()+phopy
143  self.metNoPhoton.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
144  setattr(event, "metNoPhoton"+self.cfg_ana.collectionPostFix, self.metNoPhoton)
145  if self.cfg_ana.doMetNoPU:
146  self.metNoPhotonNoPU = copy.deepcopy(self.metNoPU)
147  px,py = self.metNoPhotonNoPU.px()+phopx, self.metNoPhotonNoPU.py()+phopy
148  self.metNoPhotonNoPU.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
149  setattr(event, "metNoPhotonNoPU"+self.cfg_ana.collectionPostFix, self.metNoPhotonNoPU)
150 
def objects.METAnalyzer.makeMETs (   self,
  event 
)

Definition at line 151 of file METAnalyzer.py.

152  def makeMETs(self, event):
153  import ROOT
154  if self.cfg_ana.copyMETsByValue:
155  self.met = ROOT.pat.MET(self.handles['met'].product()[0])
156  if self.cfg_ana.doMetNoPU: self.metNoPU = ROOT.pat.MET(self.handles['nopumet'].product()[0])
157  else:
158  self.met = self.handles['met'].product()[0]
159  if self.cfg_ana.doMetNoPU: self.metNoPU = self.handles['nopumet'].product()[0]
160 
161  #Shifted METs
162  #Uncertainties defined in https://github.com/cms-sw/cmssw/blob/CMSSW_7_2_X/DataFormats/PatCandidates/interface/MET.h#L168
163  #event.met_shifted = []
164  if not self.cfg_ana.copyMETsByValue:
165  for i in range(self.met.METUncertaintySize):
166  m = ROOT.pat.MET(self.met)
167  px = m.shiftedPx(i);
168  py = m.shiftedPy(i);
169  m.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
170  #event.met_shifted += [m]
171  setattr(event, "met{0}_shifted_{1}".format(self.cfg_ana.collectionPostFix, i), m)
173  self.met_sig = self.met.significance()
174  self.met_sumet = self.met.sumEt()
175 
176 
177  ###https://github.com/cms-sw/cmssw/blob/CMSSW_7_2_X/DataFormats/PatCandidates/interface/MET.h
178  if not self.cfg_ana.copyMETsByValue:
179  self.metraw = self.met.shiftedPt(12, 0)
180  self.metType1chs = self.met.shiftedPt(12, 1)
181  setattr(event, "metraw"+self.cfg_ana.collectionPostFix, self.metraw)
182  setattr(event, "metType1chs"+self.cfg_ana.collectionPostFix, self.metType1chs)
183 
184  if self.cfg_ana.recalibrate and hasattr(event, 'deltaMetFromJetSmearing'+self.cfg_ana.jetAnalyzerCalibrationPostFix):
185  deltaMetSmear = getattr(event, 'deltaMetFromJetSmearing'+self.cfg_ana.jetAnalyzerCalibrationPostFix)
186  self.applyDeltaMet(self.met, deltaMetSmear)
187  if self.cfg_ana.doMetNoPU:
188  self.applyDeltaMet(self.metNoPU, deltaMetSmear)
189  if self.cfg_ana.recalibrate and hasattr(event, 'deltaMetFromJEC'+self.cfg_ana.jetAnalyzerCalibrationPostFix):
190  deltaMetJEC = getattr(event, 'deltaMetFromJEC'+self.cfg_ana.jetAnalyzerCalibrationPostFix)
191 # print 'before JEC', self.cfg_ana.collectionPostFix, self.met.px(),self.met.py(), 'deltaMetFromJEC'+self.cfg_ana.jetAnalyzerCalibrationPostFix, deltaMetJEC
192  self.applyDeltaMet(self.met, deltaMetJEC)
193  if self.cfg_ana.doMetNoPU:
194  self.applyDeltaMet(self.metNoPU, deltaMetJEC)
195 # print 'after JEC', self.cfg_ana.collectionPostFix, self.met.px(),self.met.py(), 'deltaMetFromJEC'+self.cfg_ana.jetAnalyzerCalibrationPostFix, deltaMetJEC
196 
197  setattr(event, "met"+self.cfg_ana.collectionPostFix, self.met)
198  if self.cfg_ana.doMetNoPU: setattr(event, "metNoPU"+self.cfg_ana.collectionPostFix, self.metNoPU)
199  setattr(event, "met_sig"+self.cfg_ana.collectionPostFix, self.met_sig)
200  setattr(event, "met_sumet"+self.cfg_ana.collectionPostFix, self.met_sumet)
201 
202  if self.cfg_ana.doMetNoMu and hasattr(event, 'selectedMuons'):
203  self.makeMETNoMu(event)
204 
205  if self.cfg_ana.doMetNoEle and hasattr(event, 'selectedElectrons'):
206  self.makeMETNoEle(event)
207 
208  if self.cfg_ana.doMetNoPhoton and hasattr(event, 'selectedPhotons'):
209  self.makeMETNoPhoton(event)
def objects.METAnalyzer.process (   self,
  event 
)

Definition at line 210 of file METAnalyzer.py.

211  def process(self, event):
212  self.readCollections( event.input)
213  self.counters.counter('events').inc('all events')
214 
215  self.makeMETs(event)
216 
217  if self.cfg_ana.doTkMet:
218  self.makeTkMETs(event);
219 
220  if self.cfg_comp.isMC and hasattr(event, 'genParticles'):
221  self.makeGenTkMet(event)
222 
223  return True
224 
225 
setattr(METAnalyzer,"defaultConfig", cfg.Analyzer(

Variable Documentation

string objects.METAnalyzer.candidates = 'packedPFCandidates'

Definition at line 237 of file METAnalyzer.py.

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

Definition at line 238 of file METAnalyzer.py.

objects.METAnalyzer.class_object = METAnalyzer,

Definition at line 226 of file METAnalyzer.py.

string objects.METAnalyzer.collectionPostFix = ""

Definition at line 240 of file METAnalyzer.py.

objects.METAnalyzer.copyMETsByValue = False,

Definition at line 229 of file METAnalyzer.py.

objects.METAnalyzer.doMetNoEle = False,

Definition at line 235 of file METAnalyzer.py.

objects.METAnalyzer.doMetNoMu = False,

Definition at line 234 of file METAnalyzer.py.

objects.METAnalyzer.doMetNoPhoton = False,

Definition at line 236 of file METAnalyzer.py.

objects.METAnalyzer.doMetNoPU = True,

Definition at line 233 of file METAnalyzer.py.

objects.METAnalyzer.doTkMet = False,

Definition at line 232 of file METAnalyzer.py.

float objects.METAnalyzer.dzMax = 0.1

Definition at line 239 of file METAnalyzer.py.

string objects.METAnalyzer.jetAnalyzerCalibrationPostFix = ""

Definition at line 231 of file METAnalyzer.py.

objects.METAnalyzer.met

Definition at line 154 of file METAnalyzer.py.

Referenced by CaloSpecificAlgo.addInfo(), StKinFitter.addKinFitInfo(), QcdHighPtDQM.analyze(), PatTopSelectionAnalyzer.analyze(), EwkMuDQM.analyze(), TtSemiLepJetCombMVATrainer.analyze(), EwkElecDQM.analyze(), CaloTowersAnalyzer.analyze(), CaloTowersValidation.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(), l1t::Stage1Layer2EtSumAlgorithmImpHW.doSumAndMET(), JetMETHLTOfflineSource.dqmBeginRun(), 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(), 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(), SysShiftMETcorrInputProducer.produce(), cms::ElseMETProducer.produce(), HLTMETCleanerUsingJetID.produce(), WMuNuProducer.produce(), L1ExtraParticleMapProd.produce(), JetEnergyShift.produce(), AlCaHcalNoiseProducer.produce(), cms::METSignificanceProducer.produce(), CaloJetMETcorrInputProducerT< T, Textractor >.produce(), HWWFunctions.projectedMet(), METAlgo.run(), TtDilepEvtSolution.setMET(), TtSemiLepHypothesis.setNeutrino(), StEvtSolution.setNeutrino(), TtSemiEvtSolution.setNeutrino(), l1t::stage1::MissEtUnpacker.unpack(), l1t::stage2::EtSumUnpacker.unpack(), and l1t::stage1::legacy::EtSumUnpacker.unpack().

objects.METAnalyzer.met_sig

Definition at line 172 of file METAnalyzer.py.

objects.METAnalyzer.met_sumet

Definition at line 173 of file METAnalyzer.py.

string objects.METAnalyzer.metCollection = "slimmedMETs"

Definition at line 227 of file METAnalyzer.py.

Referenced by PFMETDQMAnalyzer.analyze(), EwkMuDQM.analyze(), EwkElecDQM.analyze(), EwkMuLumiMonitorDQM.analyze(), WMuNuValidator.filter(), DistortedMETProducer.produce(), WMuNuProducer.produce(), HLTScoutingCaloProducer.produce(), and HLTScoutingPFProducer.produce().

objects.METAnalyzer.metNoEle

Definition at line 111 of file METAnalyzer.py.

objects.METAnalyzer.metNoEleNoPU

Definition at line 112 of file METAnalyzer.py.

objects.METAnalyzer.metNoMu

Definition at line 91 of file METAnalyzer.py.

objects.METAnalyzer.metNoMuNoPU

Definition at line 92 of file METAnalyzer.py.

objects.METAnalyzer.metNoPhoton

Definition at line 131 of file METAnalyzer.py.

objects.METAnalyzer.metNoPhotonNoPU

Definition at line 145 of file METAnalyzer.py.

objects.METAnalyzer.metNoPU

Definition at line 155 of file METAnalyzer.py.

objects.METAnalyzer.metraw

https://github.com/cms-sw/cmssw/blob/CMSSW_7_2_X/DataFormats/PatCandidates/interface/MET.h

Definition at line 178 of file METAnalyzer.py.

objects.METAnalyzer.metType1chs

Definition at line 179 of file METAnalyzer.py.

string objects.METAnalyzer.noPUMetCollection = "slimmedMETs"

Definition at line 228 of file METAnalyzer.py.

objects.METAnalyzer.recalibrate = True,

Definition at line 230 of file METAnalyzer.py.