CMS 3D CMS Logo

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