7 from ROOT
import TLorentzVector, TVector3, TVectorD
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
16 from ROOT.heppy
import Megajet
17 from ROOT.heppy
import ReclusterJets
24 def __init__(self, cfg_ana, cfg_comp, looperName ):
25 super(RazorAnalyzer,self).
__init__(cfg_ana,cfg_comp,looperName)
30 self.handles[
'genJets'] = AutoHandle(
'slimmedGenJets',
'std::vector<reco::GenJet>')
33 super(RazorAnalyzer,self).
beginLoop(setup)
34 self.counters.addCounter(
'pairs')
35 count = self.counters.counter(
'pairs')
36 count.register(
'all events')
43 mr =
sqrt((A+B)*(A+B)-(az+bz)*(az+bz));
48 mtr = met.Vect().Mag()*(ja.Pt()+jb.Pt()) - met.Vect().Dot(ja.Vect()+jb.Vect());
56 r = 999999.
if mr <= 0
else mtr/mr
70 (met, metphi) = event.met.pt(), event.met.phi()
71 metp4 = ROOT.TLorentzVector()
72 metp4.SetPtEtaPhiM(met,0,metphi,0)
74 objects40jc = [ j
for j
in event.cleanJets
if j.pt() > 40
and abs(j.eta())<2.5 ]
78 if len(objects40jc)>=2:
80 pxvec = ROOT.std.vector(float)()
81 pyvec = ROOT.std.vector(float)()
82 pzvec = ROOT.std.vector(float)()
83 Evec = ROOT.std.vector(float)()
84 grouping = ROOT.std.vector(int)()
86 for jet
in objects40jc:
87 pxvec.push_back(jet.px())
88 pyvec.push_back(jet.py())
89 pzvec.push_back(jet.pz())
90 Evec.push_back(jet.energy())
92 megajet = Megajet(pxvec, pyvec, pzvec, Evec, 1)
94 pseudoJet1px = megajet.getAxis1()[0] * megajet.getAxis1()[3]
95 pseudoJet1py = megajet.getAxis1()[1] * megajet.getAxis1()[3]
96 pseudoJet1pz = megajet.getAxis1()[2] * megajet.getAxis1()[3]
97 pseudoJet1energy = megajet.getAxis1()[4]
99 pseudoJet2px = megajet.getAxis2()[0] * megajet.getAxis2()[3]
100 pseudoJet2py = megajet.getAxis2()[1] * megajet.getAxis2()[3]
101 pseudoJet2pz = megajet.getAxis2()[2] * megajet.getAxis2()[3]
102 pseudoJet2energy = megajet.getAxis2()[4]
104 pseudoJet1pt2 = pseudoJet1px*pseudoJet1px + pseudoJet1py*pseudoJet1py
105 pseudoJet2pt2 = pseudoJet2px*pseudoJet2px + pseudoJet2py*pseudoJet2py
107 if pseudoJet1pt2 >= pseudoJet2pt2:
108 event.pseudoJet1_had = ROOT.TLorentzVector( pseudoJet1px, pseudoJet1py, pseudoJet1pz, pseudoJet1energy)
109 event.pseudoJet2_had = ROOT.TLorentzVector( pseudoJet2px, pseudoJet2py, pseudoJet2pz, pseudoJet2energy)
111 event.pseudoJet2_had = ROOT.TLorentzVector( pseudoJet1px, pseudoJet1py, pseudoJet1pz, pseudoJet1energy)
112 event.pseudoJet1_had = ROOT.TLorentzVector( pseudoJet2px, pseudoJet2py, pseudoJet2pz, pseudoJet2energy)
114 event.mr_had = self.computeMR(event.pseudoJet1_had, event.pseudoJet2_had)
115 event.mtr_had = self.computeMTR(event.pseudoJet1_had, event.pseudoJet2_had, metp4)
116 event.r_had = self.computeR(event.pseudoJet1_had, event.pseudoJet2_had, metp4)
120 if self.cfg_comp.isMC:
121 (genmet, genmetphi) = event.met.genMET().
pt(), event.met.genMET().phi()
122 genmetp4 = ROOT.TLorentzVector()
123 genmetp4.SetPtEtaPhiM(genmet,0,genmetphi,0)
125 allGenJets = [ x
for x
in self.handles[
'genJets'].product() ]
126 objects40jc_Gen = [ j
for j
in allGenJets
if j.pt() > 40
and abs(j.eta())<2.5 ]
128 if len(objects40jc_Gen)>=2:
130 pxvec = ROOT.std.vector(float)()
131 pyvec = ROOT.std.vector(float)()
132 pzvec = ROOT.std.vector(float)()
133 Evec = ROOT.std.vector(float)()
134 grouping = ROOT.std.vector(int)()
136 for jet
in objects40jc_Gen:
137 pxvec.push_back(jet.px())
138 pyvec.push_back(jet.py())
139 pzvec.push_back(jet.pz())
140 Evec.push_back(jet.energy())
142 megajet = Megajet(pxvec, pyvec, pzvec, Evec, 1)
144 pseudoJet1px = megajet.getAxis1()[0] * megajet.getAxis1()[3]
145 pseudoJet1py = megajet.getAxis1()[1] * megajet.getAxis1()[3]
146 pseudoJet1pz = megajet.getAxis1()[2] * megajet.getAxis1()[3]
147 pseudoJet1energy = megajet.getAxis1()[4]
149 pseudoJet2px = megajet.getAxis2()[0] * megajet.getAxis2()[3]
150 pseudoJet2py = megajet.getAxis2()[1] * megajet.getAxis2()[3]
151 pseudoJet2pz = megajet.getAxis2()[2] * megajet.getAxis2()[3]
152 pseudoJet2energy = megajet.getAxis2()[4]
154 pseudoJet1pt2 = pseudoJet1px*pseudoJet1px + pseudoJet1py*pseudoJet1py
155 pseudoJet2pt2 = pseudoJet2px*pseudoJet2px + pseudoJet2py*pseudoJet2py
157 if pseudoJet1pt2 >= pseudoJet2pt2:
158 pseudoJet1_gen = ROOT.TLorentzVector( pseudoJet1px, pseudoJet1py, pseudoJet1pz, pseudoJet1energy)
159 pseudoJet2_gen = ROOT.TLorentzVector( pseudoJet2px, pseudoJet2py, pseudoJet2pz, pseudoJet2energy)
161 pseudoJet2_gen = ROOT.TLorentzVector( pseudoJet1px, pseudoJet1py, pseudoJet1pz, pseudoJet1energy)
162 pseudoJet1_gen = ROOT.TLorentzVector( pseudoJet2px, pseudoJet2py, pseudoJet2pz, pseudoJet2energy)
164 event.mr_gen = self.computeMR(pseudoJet1_gen, pseudoJet2_gen)
165 event.mtr_gen = self.computeMTR(pseudoJet1_gen, pseudoJet2_gen, genmetp4)
166 event.r_gen = self.computeR(pseudoJet1_gen, pseudoJet2_gen, genmetp4)
174 objects10lc = [ l
for l
in event.selectedLeptons
if l.pt() > 10
and abs(l.eta())<2.5 ]
175 if hasattr(event,
'selectedIsoCleanTrack'):
176 objects10lc = [ l
for l
in event.selectedLeptons
if l.pt() > 10
and abs(l.eta())<2.5 ] + [ t
for t
in event.selectedIsoCleanTrack ]
178 objects40j10lc = objects40jc + objects10lc
180 objects40j10lc.sort(key =
lambda obj : obj.pt(), reverse =
True)
182 if len(objects40j10lc)>=2:
184 pxvec = ROOT.std.vector(float)()
185 pyvec = ROOT.std.vector(float)()
186 pzvec = ROOT.std.vector(float)()
187 Evec = ROOT.std.vector(float)()
188 grouping = ROOT.std.vector(int)()
190 for obj
in objects40j10lc:
191 pxvec.push_back(obj.px())
192 pyvec.push_back(obj.py())
193 pzvec.push_back(obj.pz())
194 Evec.push_back(obj.energy())
201 megajet = Megajet(pxvec, pyvec, pzvec, Evec, 1)
203 pseudoJet1px = megajet.getAxis1()[0] * megajet.getAxis1()[3]
204 pseudoJet1py = megajet.getAxis1()[1] * megajet.getAxis1()[3]
205 pseudoJet1pz = megajet.getAxis1()[2] * megajet.getAxis1()[3]
206 pseudoJet1energy = megajet.getAxis1()[4]
208 pseudoJet2px = megajet.getAxis2()[0] * megajet.getAxis2()[3]
209 pseudoJet2py = megajet.getAxis2()[1] * megajet.getAxis2()[3]
210 pseudoJet2pz = megajet.getAxis2()[2] * megajet.getAxis2()[3]
211 pseudoJet2energy = megajet.getAxis2()[4]
213 pseudoJet1pt2 = pseudoJet1px*pseudoJet1px + pseudoJet1py*pseudoJet1py
214 pseudoJet2pt2 = pseudoJet2px*pseudoJet2px + pseudoJet2py*pseudoJet2py
216 if pseudoJet1pt2 >= pseudoJet2pt2:
217 event.pseudoJet1 = ROOT.TLorentzVector( pseudoJet1px, pseudoJet1py, pseudoJet1pz, pseudoJet1energy)
218 event.pseudoJet2 = ROOT.TLorentzVector( pseudoJet2px, pseudoJet2py, pseudoJet2pz, pseudoJet2energy)
220 event.pseudoJet2 = ROOT.TLorentzVector( pseudoJet1px, pseudoJet1py, pseudoJet1pz, pseudoJet1energy)
221 event.pseudoJet1 = ROOT.TLorentzVector( pseudoJet2px, pseudoJet2py, pseudoJet2pz, pseudoJet2energy)
225 event.mr = self.computeMR(event.pseudoJet1, event.pseudoJet2)
226 event.mtr = self.computeMTR(event.pseudoJet1, event.pseudoJet2, metp4)
227 event.r = self.computeR(event.pseudoJet1, event.pseudoJet2, metp4)
232 if len(event.bjetsMedium)>=2:
234 bJet1 = ROOT.TLorentzVector(event.bjetsMedium[0].px(), event.bjetsMedium[0].py(), event.bjetsMedium[0].pz(), event.bjetsMedium[0].
energy())
235 bJet2 = ROOT.TLorentzVector(event.bjetsMedium[1].px(), event.bjetsMedium[1].py(), event.bjetsMedium[1].pz(), event.bjetsMedium[1].
energy())
237 event.mr_bb = self.computeMR(bJet1, bJet2)
238 event.mtr_bb = self.computeMTR(bJet1, bJet2, metp4)
239 event.r_bb = self.computeR(bJet1, bJet2, metp4)
242 if len(event.bjetsMedium)==1:
244 objects40jcCSV = [ j
for j
in event.cleanJets
if j.pt() > 40
and abs(j.eta())<2.5
and j.p4()!=event.bjetsMedium[0].
p4() ]
245 objects40jcCSV.sort(key =
lambda l : l.btag(
'combinedInclusiveSecondaryVertexV2BJetTags'), reverse =
True)
247 if len(objects40jcCSV)>0:
249 bJet1 = ROOT.TLorentzVector(event.bjetsMedium[0].px(), event.bjetsMedium[0].py(), event.bjetsMedium[0].pz(), event.bjetsMedium[0].
energy())
250 bJet2 = ROOT.TLorentzVector(objects40jcCSV[0].px(), objects40jcCSV[0].py(), objects40jcCSV[0].pz(), objects40jcCSV[0].
energy())
252 event.mr_bb = self.computeMR(bJet1, bJet2)
253 event.mtr_bb = self.computeMTR(bJet1, bJet2, metp4)
254 event.r_bb = self.computeR(bJet1, bJet2, metp4)
258 if not self.cfg_ana.doOnlyDefault:
259 if len(event.selectedLeptons)>=2:
261 lep1 = ROOT.TLorentzVector(event.selectedLeptons[0].px(), event.selectedLeptons[0].py(), event.selectedLeptons[0].pz(), event.selectedLeptons[0].
energy())
262 lep2 = ROOT.TLorentzVector(event.selectedLeptons[1].px(), event.selectedLeptons[1].py(), event.selectedLeptons[1].pz(), event.selectedLeptons[1].
energy())
264 event.mr_lept = self.computeMR(lep1, lep2)
265 event.mtr_lept = self.computeMTR(lep1, lep2, metp4)
266 event.r_lept = self.computeR(lep1, lep2, metp4)
273 self.readCollections( event.input )
295 event.pseudoJet1 = ROOT.TLorentzVector( 0, 0, 0, 0 )
296 event.pseudoJet2 = ROOT.TLorentzVector( 0, 0, 0, 0 )
300 self.makeRAZOR(event)
Abs< T >::type abs(const T &t)