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

Variables

string candidates = 'packedPFCandidates'
 
string candidatesTypes = 'std::vector<pat::PackedCandidate>'
 
 class_object = METAnalyzer,
 
 doMetNoMu = False,
 
 doMetNoPhoton = False,
 
 doTkMet = False,
 
float dzMax = 0.1
 
 recalibrate = True,
 

Function Documentation

def objects.METAnalyzer.makeMETNoMu (   self,
  event 
)

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

Definition at line 72 of file METAnalyzer.py.

72 
73  def makeMETNoMu(self, event):
74  event.metNoMu = copy.deepcopy(event.met)
75  event.metNoMuNoPU = copy.deepcopy(event.metNoPU)
76 
77  mupx = 0
78  mupy = 0
79  #sum muon momentum
80  for mu in event.selectedMuons:
81  mupx += mu.px()
82  mupy += mu.py()
83 
84  #subtract muon momentum and construct met
85  px,py = event.metNoMu.px()-mupx, event.metNoMu.py()-mupy
86  event.metNoMu.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
87  px,py = event.metNoMuNoPU.px()-mupx, event.metNoMuNoPU.py()-mupy
88  event.metNoMuNoPU.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
def makeMETNoMu
print &#39;tkmet&#39;,event.tkMet.pt(),&#39;tkmetphi&#39;,event.tkMet.phi()
Definition: METAnalyzer.py:72
def objects.METAnalyzer.makeMETNoPhoton (   self,
  event 
)

Definition at line 89 of file METAnalyzer.py.

89 
90  def makeMETNoPhoton(self, event):
91  event.metNoPhoton = copy.deepcopy(event.met)
92  event.metNoPhotonNoPU = copy.deepcopy(event.metNoPU)
93 
94  phopx = 0
95  phopy = 0
96  #sum photon momentum
97  for pho in event.selectedPhotons:
98  phopx += pho.px()
99  phopy += pho.py()
100 
101  #subtract photon momentum and construct met
102  px,py = event.metNoPhoton.px()-phopx, event.metNoPhoton.py()-phopy
103  event.metNoPhoton.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
104  px,py = event.metNoPhotonNoPU.px()-phopx, event.metNoPhotonNoPU.py()-phopy
105  event.metNoPhotonNoPU.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
106 
def objects.METAnalyzer.makeMETs (   self,
  event 
)

Definition at line 107 of file METAnalyzer.py.

108  def makeMETs(self, event):
109  event.met = self.handles['met'].product()[0]
110  event.metNoPU = self.handles['nopumet'].product()[0]
111 
112  #Shifted METs
113  #Uncertainties defined in https://github.com/cms-sw/cmssw/blob/CMSSW_7_2_X/DataFormats/PatCandidates/interface/MET.h#L168
114  for i in range(event.met.METUncertaintySize):
115  m = ROOT.pat.MET(event.met)
116  px = m.shiftedPx(i);
117  py = m.shiftedPy(i);
118  m.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
119  setattr(event, "met_shifted_{0}".format(i), m)
120  event.met_sig = event.met.significance()
121  event.met_sumet = event.met.sumEt()
122  #event.met_sigm = event.met.getSignificanceMatrix()
123 
124  ###https://github.com/cms-sw/cmssw/blob/CMSSW_7_2_X/DataFormats/PatCandidates/interface/MET.h
125  event.metraw = event.met.shiftedPt(12, 0)
126  event.metType1chs = event.met.shiftedPt(12, 1)
127 
128  if self.cfg_ana.recalibrate and hasattr(event, 'deltaMetFromJetSmearing'):
129  px,py = event.met.px()+event.deltaMetFromJetSmearing[0], event.met.py()+event.deltaMetFromJetSmearing[1]
130  event.met.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
131  px,py = event.metNoPU.px()+event.deltaMetFromJetSmearing[0], event.metNoPU.py()+event.deltaMetFromJetSmearing[1]
132  event.metNoPU.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
133  if self.cfg_ana.recalibrate and hasattr(event, 'deltaMetFromJEC') and event.deltaMetFromJEC[0] != 0 and event.deltaMetFromJEC[1] != 0:
134  px,py = event.met.px()+event.deltaMetFromJEC[0], event.met.py()+event.deltaMetFromJEC[1]
135  event.met.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
136  px,py = event.metNoPU.px()+event.deltaMetFromJEC[0], event.metNoPU.py()+event.deltaMetFromJEC[1]
137  event.metNoPU.setP4(ROOT.reco.Particle.LorentzVector(px,py, 0, math.hypot(px,py)))
138 
139  if self.cfg_ana.doMetNoMu and hasattr(event, 'selectedMuons'):
140  self.makeMETNoMu(event)
141 
142  if self.cfg_ana.doMetNoPhoton and hasattr(event, 'selectedPhotons'):
143  self.makeMETNoPhoton(event)
def objects.METAnalyzer.process (   self,
  event 
)

Definition at line 144 of file METAnalyzer.py.

145  def process(self, event):
146  self.readCollections( event.input)
147  self.counters.counter('events').inc('all events')
148 
149  self.makeMETs(event)
150  event.tkMet = 0
151 
152  if self.cfg_ana.doTkMet:
153  self.makeTkMETs(event);
154 
155 
156 
157  return True
158 
159 
setattr(METAnalyzer,"defaultConfig", cfg.Analyzer(

Variable Documentation

string objects.METAnalyzer.candidates = 'packedPFCandidates'

Definition at line 165 of file METAnalyzer.py.

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

Definition at line 166 of file METAnalyzer.py.

objects.METAnalyzer.class_object = METAnalyzer,

Definition at line 160 of file METAnalyzer.py.

objects.METAnalyzer.doMetNoMu = False,

Definition at line 163 of file METAnalyzer.py.

objects.METAnalyzer.doMetNoPhoton = False,

Definition at line 164 of file METAnalyzer.py.

objects.METAnalyzer.doTkMet = False,

Definition at line 162 of file METAnalyzer.py.

float objects.METAnalyzer.dzMax = 0.1

Definition at line 167 of file METAnalyzer.py.

objects.METAnalyzer.recalibrate = True,

Definition at line 161 of file METAnalyzer.py.