CMS 3D CMS Logo

MT2Analyzer.py
Go to the documentation of this file.
1 from builtins import range
2 import operator
3 import itertools
4 import copy
5 from math import *
6 
7 from ROOT import std
8 from ROOT import TLorentzVector, TVectorD
9 
10 from PhysicsTools.Heppy.analyzers.core.Analyzer import Analyzer
11 from PhysicsTools.HeppyCore.framework.event import Event
12 from PhysicsTools.HeppyCore.statistics.counter import Counter, Counters
13 from PhysicsTools.Heppy.analyzers.core.AutoHandle import AutoHandle
14 
15 import PhysicsTools.HeppyCore.framework.config as cfg
16 
17 from PhysicsTools.HeppyCore.utils.deltar import deltaR
18 
19 from ROOT.heppy import Hemisphere
20 from ROOT.heppy import ReclusterJets
21 
22 from ROOT.heppy import Davismt2
23 davismt2 = Davismt2()
24 
25 from ROOT.heppy import mt2w_bisect
26 mt2wSNT = mt2w_bisect.mt2w()
27 
28 import ROOT
29 
30 import os
31 
32 
34  def __init__(self, cfg_ana, cfg_comp, looperName ):
35  super(MT2Analyzer,self).__init__(cfg_ana,cfg_comp,looperName)
36  self.jetPt = cfg_ana.jetPt
37 
38  def declareHandles(self):
39  super(MT2Analyzer, self).declareHandles()
40  #genJets
41  self.handles['genJets'] = AutoHandle( 'slimmedGenJets','std::vector<reco::GenJet>')
42  self.handles['met'] = AutoHandle( self.cfg_ana.metCollection, 'std::vector<pat::MET>' )
43 
44  def beginLoop(self, setup):
45  super(MT2Analyzer,self).beginLoop(setup)
46  self.counters.addCounter('pairs')
47  count = self.counters.counter('pairs')
48  count.register('all events')
49 
50  def computeMT2(self, visaVec, visbVec, metVec):
51 
52  import array
53  import numpy
54 
55  metVector = array.array('d',[0.,metVec.px(), metVec.py()])
56  visaVector = array.array('d',[0.,visaVec.px(), visaVec.py()])
57  visbVector = array.array('d',[0.,visbVec.px(), visbVec.py()])
58 
59  davismt2.set_momenta(visaVector,visbVector,metVector);
60  davismt2.set_mn(0);
61 
62  return davismt2.get_mt2()
63 
64  def getMT2AKT(self, event, TMPobjects40jc, met , collectionPostFix, postFix):
65 
66 
67  if len(TMPobjects40jc)>=2:
68 
69  objects = ROOT.std.vector(ROOT.reco.Particle.LorentzVector)()
70  for jet in TMPobjects40jc:
71  objects.push_back(jet.p4())
72 
73  hemisphereViaKt = ReclusterJets(objects, 1.,50.0)
74  groupingViaKt=hemisphereViaKt.getGroupingExclusive(2)
75 
76  if len(groupingViaKt)>=2:
77  setattr(event, "pseudoViaKtJet1"+collectionPostFix+postFix, ROOT.reco.Particle.LorentzVector(groupingViaKt[0]) )
78  setattr(event, "pseudoViaKtJet2"+collectionPostFix+postFix, ROOT.reco.Particle.LorentzVector(groupingViaKt[1]) )
79  setattr(event, "mt2ViaAKt"+collectionPostFix+postFix, self.computeMT2(getattr(event,'pseudoViaKtJet1'+collectionPostFix+postFix), getattr(event,'pseudoViaKtJet2'+collectionPostFix+postFix), met) )
80  return self.computeMT2(getattr(event,'pseudoViaKtJet1'+collectionPostFix+postFix), getattr(event,'pseudoViaKtJet2'+collectionPostFix+postFix), met)
81 
82  if not self.cfg_ana.doOnlyDefault:
83  hemisphereViaAKt = ReclusterJets(objects, -1.,50.0)
84  groupingViaAKt=hemisphereViaAKt.getGroupingExclusive(2)
85 
86  if len(groupingViaAKt)>=2:
87  setattr(event, "pseudoViaAKtJet1"+collectionPostFix+postFix, ROOT.reco.Particle.LorentzVector(groupingViaAKt[0]) )
88  setattr(event, "pseudoViaAKtJet2"+collectionPostFix+postFix, ROOT.reco.Particle.LorentzVector(groupingViaAKt[1]) )
89  setattr(event, "mt2ViaAKt"+collectionPostFix+postFix, self.computeMT2(getattr(event,'pseudoViaAKtJet1'+collectionPostFix+postFix), getattr(event,'pseudoViaAKtJet2'+collectionPostFix+postFix), met) )
90  return self.computeMT2(getattr(event,'pseudoViaAKtJet1'+collectionPostFix+postFix), getattr(event,'pseudoViaAKtJet2'+collectionPostFix+postFix), met)
91 
92  def getMT2Hemi(self, event, TMPobjects40jc, met, collectionPostFix, postFix):
93 
94  if len(TMPobjects40jc)>=2:
95 
96  pxvec = ROOT.std.vector(float)()
97  pyvec = ROOT.std.vector(float)()
98  pzvec = ROOT.std.vector(float)()
99  Evec = ROOT.std.vector(float)()
100  grouping = ROOT.std.vector(int)()
101 
102  for jet in TMPobjects40jc:
103  pxvec.push_back(jet.px())
104  pyvec.push_back(jet.py())
105  pzvec.push_back(jet.pz())
106  Evec.push_back(jet.energy())
107 
108  hemisphere = Hemisphere(pxvec, pyvec, pzvec, Evec, 2, 3)
109  grouping=hemisphere.getGrouping()
110 
111  pseudoJet1px = 0
112  pseudoJet1py = 0
113  pseudoJet1pz = 0
114  pseudoJet1energy = 0
115  multPSJ1 = 0
116 
117  pseudoJet2px = 0
118  pseudoJet2py = 0
119  pseudoJet2pz = 0
120  pseudoJet2energy = 0
121  multPSJ2 = 0
122 
123  for index in range(0, len(pxvec)):
124  if(grouping[index]==1):
125  pseudoJet1px += pxvec[index]
126  pseudoJet1py += pyvec[index]
127  pseudoJet1pz += pzvec[index]
128  pseudoJet1energy += Evec[index]
129  multPSJ1 += 1
130  if(grouping[index]==2):
131  pseudoJet2px += pxvec[index]
132  pseudoJet2py += pyvec[index]
133  pseudoJet2pz += pzvec[index]
134  pseudoJet2energy += Evec[index]
135  multPSJ2 += 1
136 
137  pseudoJet1pt2 = pseudoJet1px*pseudoJet1px + pseudoJet1py*pseudoJet1py
138  pseudoJet2pt2 = pseudoJet2px*pseudoJet2px + pseudoJet2py*pseudoJet2py
139 
140  if pseudoJet1pt2 >= pseudoJet2pt2:
141  setattr(event, "pseudoJet1"+collectionPostFix+postFix, ROOT.reco.Particle.LorentzVector( pseudoJet1px, pseudoJet1py, pseudoJet1pz, pseudoJet1energy ))
142  setattr(event, "pseudoJet2"+collectionPostFix+postFix, ROOT.reco.Particle.LorentzVector( pseudoJet2px, pseudoJet2py, pseudoJet2pz, pseudoJet2energy ))
143  setattr(event, "multPseudoJet1"+collectionPostFix+postFix, multPSJ1 )
144  setattr(event, "multPseudoJet2"+collectionPostFix+postFix, multPSJ2 )
145  else:
146  setattr(event, "pseudoJet2"+collectionPostFix+postFix, ROOT.reco.Particle.LorentzVector( pseudoJet1px, pseudoJet1py, pseudoJet1pz, pseudoJet1energy ))
147  setattr(event, "pseudoJet1"+collectionPostFix+postFix, ROOT.reco.Particle.LorentzVector( pseudoJet2px, pseudoJet2py, pseudoJet2pz, pseudoJet2energy ))
148  setattr(event, "multPseudoJet1"+collectionPostFix+postFix, multPSJ2 )
149  setattr(event, "multPseudoJet2"+collectionPostFix+postFix, multPSJ1 )
150 
151  setattr(event, "mt2"+collectionPostFix+postFix, self.computeMT2(getattr(event,'pseudoJet1'+collectionPostFix+postFix), getattr(event,'pseudoJet2'+collectionPostFix+postFix), met) )
152  return self.computeMT2(getattr(event,'pseudoJet1'+collectionPostFix+postFix), getattr(event,'pseudoJet2'+collectionPostFix+postFix), met)
153 
154 
155  def makeMT2(self, event):
156 # print '==> INSIDE THE PRINT MT2'
157 # print 'MET=',event.met.pt()
158 
159  self.met = ROOT.pat.MET(self.handles['met'].product()[0])
160 
161  import array
162  import numpy
163 
164  objects40jc = [ j for j in event.cleanJets if j.pt() > 40 and abs(j.eta())<2.5 ]
165  objectsXjc = [ j for j in event.cleanJets if j.pt() > self.jetPt and abs(j.eta())<2.5 ]
166 
167  setattr(event, "mt2ViaKt"+self.cfg_ana.collectionPostFix+"had", -999)
168  setattr(event, "mt2ViaKt"+self.cfg_ana.collectionPostFix+"_Xj_had", -999)
169  setattr(event, "pseudoViaKtJet1"+self.cfg_ana.collectionPostFix+"_had", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
170  setattr(event, "pseudoViaKtJet2"+self.cfg_ana.collectionPostFix+"_had", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
171  setattr(event, "pseudoViaKtJet1"+self.cfg_ana.collectionPostFix+"_Xj_had", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
172  setattr(event, "pseudoViaKtJet2"+self.cfg_ana.collectionPostFix+"_Xj_had", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
173 
174  setattr(event, "mt2ViaAKt"+self.cfg_ana.collectionPostFix+"had", -999)
175  setattr(event, "mt2ViaAKt"+self.cfg_ana.collectionPostFix+"_Xj_had", -999)
176  setattr(event, "pseudoViaAKtJet1"+self.cfg_ana.collectionPostFix+"_had", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
177  setattr(event, "pseudoViaAKtJet2"+self.cfg_ana.collectionPostFix+"_had", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
178  setattr(event, "pseudoViaAKtJet1"+self.cfg_ana.collectionPostFix+"_Xj_had", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
179  setattr(event, "pseudoViaAKtJet2"+self.cfg_ana.collectionPostFix+"_Xj_had", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
180 
181 
182  if len(objects40jc)>=2:
183 
184  self.mt2ViaKt_had=self.getMT2AKT(event, objects40jc, self.met, self.cfg_ana.collectionPostFix, "_had")
185 
186  if len(objectsXjc)>=2:
187 
188  self.mt2ViaKt_Xj_had=self.getMT2AKT(event, objectsXjc, self.met, self.cfg_ana.collectionPostFix, "_Xj_had")
189 
190 
192 
193  setattr(event, "mt2"+self.cfg_ana.collectionPostFix+"_had", -999)
194  setattr(event, "mt2"+self.cfg_ana.collectionPostFix+"_Xj_had", -999)
195 
196  setattr(event, "pseudoJet1"+self.cfg_ana.collectionPostFix+"_had", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
197  setattr(event, "pseudoJet2"+self.cfg_ana.collectionPostFix+"_had", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
198  setattr(event, "pseudoJet1"+self.cfg_ana.collectionPostFix+"_Xj_had", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
199  setattr(event, "pseudoJet2"+self.cfg_ana.collectionPostFix+"_Xj_had", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
200 
201  if len(objects40jc)>=2:
202 
203  self.mt2_had = self.getMT2Hemi(event,objects40jc, self.met, self.cfg_ana.collectionPostFix, "_had")
204 
205  if len(objectsXjc)>=2:
206 
207  self.mt2_Xj_had = self.getMT2Hemi(event,objectsXjc, self.met, self.cfg_ana.collectionPostFix, "_Xj_had")
208 
209 
210 
211  setattr(event, "mt2"+self.cfg_ana.collectionPostFix+"_gen", -999)
212  setattr(event, "mt2"+self.cfg_ana.collectionPostFix+"_Xj_gen", -999)
213 
214  if self.cfg_comp.isMC and self.met.genMET():
215  allGenJets = [ x for x in self.handles['genJets'].product() ]
216  objects40jc_Gen = [ j for j in allGenJets if j.pt() > 40 and abs(j.eta())<2.5 ]
217  objectsXjc_Gen = [ j for j in allGenJets if j.pt() > self.jetPt and abs(j.eta())<2.5 ]
218 
219  if len(objects40jc_Gen)>=2:
220  self.mt2_gen = self.getMT2Hemi(event,objects40jc_Gen, self.met.genMET(), self.cfg_ana.collectionPostFix, "_gen")
221 
222  if len(objectsXjc_Gen)>=2:
223  self.mt2_Xj_gen = self.getMT2Hemi(event,objectsXjc_Gen, self.met.genMET(), self.cfg_ana.collectionPostFix, "_Xj_gen")
224 
225  else:
226  self.mt2_gen = -999.
227 
228 
229 
230 
231  objects10lc = [ l for l in event.selectedLeptons if l.pt() > 10 and abs(l.eta())<2.5 ]
232  if hasattr(event, 'selectedIsoCleanTrack'):
233  objects10lc = [ l for l in event.selectedLeptons if l.pt() > 10 and abs(l.eta())<2.5 ] + [ t for t in event.selectedIsoCleanTrack ]
234 
235  objects40j10lc = objects40jc + objects10lc
236  objects40j10lc.sort(key = lambda obj : obj.pt(), reverse = True)
237 
238  objectsXj10lc = objectsXjc + objects10lc
239  objectsXj10lc.sort(key = lambda obj : obj.pt(), reverse = True)
240 
241  setattr(event, "mt2"+self.cfg_ana.collectionPostFix+"", -999)
242  setattr(event, "mt2"+self.cfg_ana.collectionPostFix+"_Xj", -999)
243 
244  setattr(event, "pseudoJet1"+self.cfg_ana.collectionPostFix+"", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
245  setattr(event, "pseudoJet2"+self.cfg_ana.collectionPostFix+"", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
246  setattr(event, "pseudoJet1"+self.cfg_ana.collectionPostFix+"_Xj", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
247  setattr(event, "pseudoJet2"+self.cfg_ana.collectionPostFix+"_Xj", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
248 
249  if len(objects40j10lc)>=2:
250 
251  self.mt2 = self.getMT2Hemi(event,objects40j10lc,self.met,self.cfg_ana.collectionPostFix,"") # no postfit since this is the nominal MT2
252 
253  if len(objectsXj10lc)>=2:
254 
255  self.mt2_Xj = self.getMT2Hemi(event,objectsXj10lc,self.met,self.cfg_ana.collectionPostFix,"_Xj") # no postfit since this is the nominal MT2
256 
257 
258 
259  setattr(event, "mt2"+self.cfg_ana.collectionPostFix+"_gamma", -999)
260 
261  setattr(event, "pseudoJet1"+self.cfg_ana.collectionPostFix+"_gamma", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
262  setattr(event, "pseudoJet2"+self.cfg_ana.collectionPostFix+"_gamma", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
263 
264  if hasattr(event, 'gamma_met'):
265 
266  gamma_objects40jc = [ j for j in event.gamma_cleanJets if j.pt() > 40 and abs(j.eta())<2.5 ]
267 
268  gamma_objects40j10lc = gamma_objects40jc + objects10lc
269 
270  gamma_objects40j10lc.sort(key = lambda obj : obj.pt(), reverse = True)
271 
272 
273  if len(gamma_objects40jc)>=2:
274 
275  self.gamma_mt2 = self.getMT2Hemi(event,gamma_objects40jc,event.gamma_met,self.cfg_ana.collectionPostFix,"_gamma")
276 
277  setattr(event, "mt2"+self.cfg_ana.collectionPostFix+"_Xj_gamma", -999)
278  setattr(event, "pseudoJet1"+self.cfg_ana.collectionPostFix+"_Xj_gamma", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
279  setattr(event, "pseudoJet2"+self.cfg_ana.collectionPostFix+"_Xj_gamma", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
280 
281  if hasattr(event, 'gamma_met'):
282 
283  gamma_objectsXjc = [ j for j in event.gamma_cleanJets if j.pt() > self.jetPt and abs(j.eta())<2.5 ]
284 
285  gamma_objectsXj10lc = gamma_objectsXjc + objects10lc
286 
287  gamma_objectsXj10lc.sort(key = lambda obj : obj.pt(), reverse = True)
288 
289  if len(gamma_objectsXjc)>=2:
290 
291  self.gamma_mt2_Xj = self.getMT2Hemi(event,gamma_objectsXjc,event.gamma_met,self.cfg_ana.collectionPostFix,"_Xj_gamma")
292 
293 
294 
295 
296 
297  setattr(event, "mt2"+self.cfg_ana.collectionPostFix+"_zll", -999)
298  setattr(event, "pseudoJet1"+self.cfg_ana.collectionPostFix+"_zll", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
299  setattr(event, "pseudoJet2"+self.cfg_ana.collectionPostFix+"_zll", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
300 
301  if hasattr(event, 'zll_met'):
302 
303  csLeptons = [ l for l in event.selectedLeptons if l.pt() > 10 and abs(l.eta()) < 2.5 ]
304 
305  if len(csLeptons)==2 and len(objects40jc)>=2:
306 
307  self.zll_mt2 = self.getMT2Hemi(event,objects40jc,event.zll_met,self.cfg_ana.collectionPostFix,"_zll")
308 
309  setattr(event, "mt2"+self.cfg_ana.collectionPostFix+"_Xj_zll", -999)
310  setattr(event, "pseudoJet1"+self.cfg_ana.collectionPostFix+"_Xj_zll", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
311  setattr(event, "pseudoJet2"+self.cfg_ana.collectionPostFix+"_Xj_zll", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
312 
313  if hasattr(event, 'zll_met'):
314 
315  csLeptons = [ l for l in event.selectedLeptons if l.pt() > 10 and abs(l.eta()) < 2.5 ]
316 
317  if len(csLeptons)==2 and len(objectsXjc)>=2:
318 
319  self.zll_mt2_Xj = self.getMT2Hemi(event,objectsXjc,event.zll_met,self.cfg_ana.collectionPostFix,"_Xj_zll")
320 
321 
346 
347 
348 
349 
350  setattr(event, "mt2"+self.cfg_ana.collectionPostFix+"_rl", -999)
351  setattr(event, "pseudoJet1"+self.cfg_ana.collectionPostFix+"_rl", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
352  setattr(event, "pseudoJet2"+self.cfg_ana.collectionPostFix+"_rl", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
353 
354  if hasattr(event, 'rl_met'):
355 
356  csLeptons = [ l for l in event.selectedLeptons if l.pt() > 10 and abs(l.eta()) < 2.5 ]
357 
358  if len(csLeptons)==1 and len(objects40jc)>=2:
359 
360  self.rl_mt2 = self.getMT2Hemi(event,objects40jc,event.rl_met,self.cfg_ana.collectionPostFix,"_rl")
361 
362  setattr(event, "mt2"+self.cfg_ana.collectionPostFix+"_Xj_rl", -999)
363  setattr(event, "pseudoJet1"+self.cfg_ana.collectionPostFix+"_Xj_rl", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
364  setattr(event, "pseudoJet2"+self.cfg_ana.collectionPostFix+"_Xj_rl", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
365 
366  if hasattr(event, 'rl_met'):
367 
368  csLeptons = [ l for l in event.selectedLeptons if l.pt() > 10 and abs(l.eta()) < 2.5 ]
369 
370  if len(csLeptons)==1 and len(objectsXjc)>=2:
371 
372  self.rl_mt2_Xj = self.getMT2Hemi(event,objectsXjc,event.rl_met,self.cfg_ana.collectionPostFix,"_Xj_rl")
373 
374 
375 
376 
377  setattr(event, "mt2"+self.cfg_ana.collectionPostFix+"_zllmt", -999)
378  setattr(event, "pseudoJet1"+self.cfg_ana.collectionPostFix+"_zllmt", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
379  setattr(event, "pseudoJet2"+self.cfg_ana.collectionPostFix+"_zllmt", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
380 
381  if hasattr(event, 'zllmt_met'):
382 
383  csLeptons = [ l for l in event.selectedLeptons if l.pt() > 10 and abs(l.eta()) < 2.5 ]
384 
385  if len(csLeptons)==2 and len(objects40jc)>=2:
386 
387  self.zllmt_mt2 = self.getMT2Hemi(event,objects40jc,event.zllmt_met,self.cfg_ana.collectionPostFix,"_zllmt")
388 
389  setattr(event, "mt2"+self.cfg_ana.collectionPostFix+"_Xj_zllmt", -999)
390  setattr(event, "pseudoJet1"+self.cfg_ana.collectionPostFix+"_Xj_zllmt", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
391  setattr(event, "pseudoJet2"+self.cfg_ana.collectionPostFix+"_Xj_zllmt", ROOT.reco.Particle.LorentzVector( 0, 0, 0, 0 ))
392 
393  if hasattr(event, 'zllmt_met'):
394 
395  csLeptons = [ l for l in event.selectedLeptons if l.pt() > 10 and abs(l.eta()) < 2.5 ]
396 
397  if len(csLeptons)==2 and len(objectsXjc)>=1:
398 
399  csLeptons_mt = []
400  if (event.eventId%2):
401  csLeptons_mt.append(csLeptons[1])
402  else:
403  csLeptons_mt.append(csLeptons[0])
404 
405  self.zllmt_mt2_Xj = self.getMT2Hemi(event,objectsXjc+[l for l in csLeptons if l not in csLeptons_mt],event.zllmt_met,self.cfg_ana.collectionPostFix,"_Xj_zllmt")
406 
407 
408 
409  if len(event.bjetsMedium)>=2:
410 
411  event.mt2bb = self.computeMT2(event.bjetsMedium[0], event.bjetsMedium[1], self.met)
412  event.mt2bb_Xj = self.computeMT2(event.bjetsMedium[0], event.bjetsMedium[1], self.met)
413 # print 'MT2bb(2b)',event.mt2bb
414  if len(event.bjetsMedium)==1:
415 
416  objects40jcCSV = [ j for j in event.cleanJets if j.pt() > 40 and abs(j.eta())<2.5 and j.p4()!=event.bjetsMedium[0].p4() ]
417  objects40jcCSV.sort(key = lambda l : l.btag('pfCombinedInclusiveSecondaryVertexV2BJetTags'), reverse = True)
418 
419  objectsXjcCSV = [ j for j in event.cleanJets if j.pt() > self.jetPt and abs(j.eta())<2.5 and j.p4()!=event.bjetsMedium[0].p4() ]
420  objectsXjcCSV.sort(key = lambda l : l.btag('pfCombinedInclusiveSecondaryVertexV2BJetTags'), reverse = True)
421 
422  if len(objects40jcCSV)>0:
423  self.mt2bb = self.computeMT2(event.bjetsMedium[0], objects40jcCSV[0], self.met)
424  setattr(event, "mt2bb"+self.cfg_ana.collectionPostFix, self.mt2bb)
425 
426  if len(objectsXjcCSV)>0:
427  self.mt2bb_Xj = self.computeMT2(event.bjetsMedium[0], objectsXjcCSV[0], self.met)
428  setattr(event, "mt2bb_Xj"+self.cfg_ana.collectionPostFix, self.mt2bb_Xj)
429 
430 
431 
432 
433  if not self.cfg_ana.doOnlyDefault:
434  if len(event.selectedLeptons)>=2:
435  self.mt2lep = self.computeMT2(event.selectedLeptons[0], event.selectedLeptons[1], self.met)
436  setattr(event, "mt2lep"+self.cfg_ana.collectionPostFix, self.mt2lep)
437 
438 
439 
440  def process(self, event):
441  self.readCollections( event.input )
442 
443  event.mt2bb=-999
444  event.mt2bb_Xj=-999
445  event.mt2lept=-999
446 
447  event.multPseudoJet1_had=0
448  event.multPseudoJet2_had=0
449 
450  event.multPseudoJet1_Xj_had=0
451  event.multPseudoJet2_Xj_had=0
452 
453 
454 
455  self.makeMT2(event)
456 
457 # print 'variables computed: MT=',event.mtw,'MT2=',event.mt2,'MT2W=',event.mt2w
458 # print 'pseudoJet1 px=',event.pseudoJet1.px(),' py=',event.pseudoJet1.py(),' pz=',event.pseudoJet1.pz()
459 # print 'pseudoJet2 px=',event.pseudoJet2.px(),' py=',event.pseudoJet2.py(),' pz=',event.pseudoJet2.pz()
460 
461  return True
462 
463 
464 
465 setattr(MT2Analyzer,"defaultConfig", cfg.Analyzer(
466  class_object = MT2Analyzer,
467  metCollection = "slimmedMETs",
468  collectionPostFix = "",
469  doOnlyDefault = True,
470  )
471 )
MT2Analyzer.MT2Analyzer.mt2ViaKt_had
mt2ViaKt_had
get hemispheres via AntiKT -1 antikt, 1 kt, 0 CA
Definition: MT2Analyzer.py:184
counter
Definition: counter.py:1
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
MT2Analyzer.MT2Analyzer.makeMT2
def makeMT2(self, event)
Definition: MT2Analyzer.py:155
MT2Analyzer.MT2Analyzer.jetPt
jetPt
Definition: MT2Analyzer.py:36
MT2Analyzer.MT2Analyzer.getMT2AKT
def getMT2AKT(self, event, TMPobjects40jc, met, collectionPostFix, postFix)
Definition: MT2Analyzer.py:64
MT2Analyzer.MT2Analyzer.mt2ViaKt_Xj_had
mt2ViaKt_Xj_had
Definition: MT2Analyzer.py:188
MT2Analyzer.MT2Analyzer.declareHandles
def declareHandles(self)
Definition: MT2Analyzer.py:38
remoteMonitoring_LED_IterMethod_cfg.Analyzer
Analyzer
Definition: remoteMonitoring_LED_IterMethod_cfg.py:32
MT2Analyzer.MT2Analyzer.getMT2Hemi
def getMT2Hemi(self, event, TMPobjects40jc, met, collectionPostFix, postFix)
Definition: MT2Analyzer.py:92
p4
double p4[4]
Definition: TauolaWrapper.h:92
MT2Analyzer.process
def process(self, event)
Definition: MT2Analyzer.py:440
MT2Analyzer.MT2Analyzer
Definition: MT2Analyzer.py:33
MT2Analyzer.MT2Analyzer.computeMT2
def computeMT2(self, visaVec, visbVec, metVec)
Definition: MT2Analyzer.py:50
MT2Analyzer.MT2Analyzer.beginLoop
def beginLoop(self, setup)
Definition: MT2Analyzer.py:44
MT2Analyzer.MT2Analyzer.met
met
Definition: MT2Analyzer.py:159
deltar
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MT2Analyzer.MT2Analyzer.__init__
def __init__(self, cfg_ana, cfg_comp, looperName)
Definition: MT2Analyzer.py:34