1 |
#include "LJMet/MultivariateAnalysis/interface/LJetsTopoVars.h"
|
2 |
#include "LJMet/MultivariateAnalysis/interface/TopTopologicalVariables.h"
|
3 |
#include "LJMet/MultivariateAnalysis/interface/AnglesUtil.h"
|
4 |
|
5 |
#include "TMatrixDSymEigen.h"
|
6 |
|
7 |
#include <stdexcept>
|
8 |
|
9 |
#include "DataFormats/PatCandidates/interface/Jet.h"
|
10 |
#include "DataFormats/PatCandidates/interface/Electron.h"
|
11 |
#include "DataFormats/PatCandidates/interface/Muon.h"
|
12 |
#include "DataFormats/PatCandidates/interface/MET.h"
|
13 |
|
14 |
using namespace std;
|
15 |
//using namespace cafe;
|
16 |
using namespace top_cafe;
|
17 |
|
18 |
|
19 |
namespace
|
20 |
{
|
21 |
bool moreThan(const pat::Jet& a, const pat::Jet& b)
|
22 |
{
|
23 |
return a.pt() > b.pt();
|
24 |
}
|
25 |
}
|
26 |
|
27 |
|
28 |
//###################################################################################################
|
29 |
//##
|
30 |
//## Initiate LJetsTopoVars using one lepton, one MET and the 4 leading jets momentum. This initiation is
|
31 |
//## used for Lepton to Neutrino switch.
|
32 |
//##
|
33 |
//###################################################################################################
|
34 |
|
35 |
|
36 |
//For 4 Jets
|
37 |
int LJetsTopoVars::setEventMetFixed(TLorentzVector& Jet1, TLorentzVector& Jet2, TLorentzVector& Jet3, TLorentzVector& Jet4, TLorentzVector& NewMet,TLorentzVector& Lepton1, double min_dr_jet_lepton)
|
38 |
{
|
39 |
|
40 |
using namespace edm;
|
41 |
int removed_jets = 0;
|
42 |
|
43 |
m_jets.clear();
|
44 |
eigenval.ResizeTo(3);
|
45 |
eigenval.Zero();
|
46 |
|
47 |
//Fill m_met, m_lepton, m_jets with inputed values
|
48 |
|
49 |
m_met = TMBLorentzVector(NewMet[0],NewMet[1],NewMet[2],NewMet[3],TMBLorentzVector::kXYZE);
|
50 |
m_lepton = TMBLorentzVector(Lepton1[0],Lepton1[1],Lepton1[2],Lepton1[3],TMBLorentzVector::kXYZE);
|
51 |
TMBLorentzVector jets[4] = {Jet1,Jet2,Jet3,Jet4};
|
52 |
|
53 |
for (int i = 0; i<4; i++)
|
54 |
{
|
55 |
TMBLorentzVector _j(jets[i][0],jets[i][1],jets[i][2],jets[i][3],TMBLorentzVector::kXYZE);
|
56 |
if (m_lepton.DeltaR(_j) > min_dr_jet_lepton){
|
57 |
m_jets.push_back(_j);
|
58 |
}
|
59 |
else{
|
60 |
removed_jets++;
|
61 |
}
|
62 |
}
|
63 |
|
64 |
//Output all the values for m_met, m_lepton, m_jets
|
65 |
|
66 |
cout<< "From inside LJetsTopoVars"<<endl;
|
67 |
cout<<"!!!!!!!!"<<endl;
|
68 |
cout<< "m_met.Pt() = "<<m_met.Pt()<<endl;
|
69 |
cout<< "m_lepton.px, py, pz, energy = "<<m_lepton[0] <<", "<<m_lepton[1] <<", " <<m_lepton[2]<<", "<<m_lepton[3]<<endl;
|
70 |
cout<< "m_met.px, py, pz, energy = "<<m_met[0] <<", "<<m_met[1] <<", " <<m_met[2]<<", "<<m_met[3]<<endl;
|
71 |
cout<< "m_jet1.px, py, pz, energy = " <<m_jets[0][0]<<", "<<m_jets[0][1]<<", "<<m_jets[0][2]<<", "<<m_jets[0][3]<<endl;
|
72 |
cout<< "m_jet2.px, py, pz, energy = " <<m_jets[1][0]<<", "<<m_jets[1][1]<<", "<<m_jets[1][2]<<", "<<m_jets[1][3]<<endl;
|
73 |
cout<< "m_jet3.px, py, pz, energy = " <<m_jets[2][0]<<", "<<m_jets[2][1]<<", "<<m_jets[2][2]<<", "<<m_jets[2][3]<<endl;
|
74 |
cout<< "m_jet4.px, py, pz, energy = " <<m_jets[3][0]<<", "<<m_jets[3][1]<<", "<<m_jets[3][2]<<", "<<m_jets[3][3]<<endl;
|
75 |
|
76 |
|
77 |
double nu_px = m_met.Px();
|
78 |
double nu_py = m_met.Py();
|
79 |
|
80 |
cout<<"nu_px, nu_py = "<<nu_px<<", "<<nu_py<<endl;
|
81 |
|
82 |
//set all OK flags to FALSE;
|
83 |
_htOK = false;
|
84 |
_evtTopoOK = false;
|
85 |
_ktOK = false;
|
86 |
_mtOK = false;
|
87 |
|
88 |
//
|
89 |
// calculate neutrino lorentz vector (from Tobi's TopSvtAnalysis)
|
90 |
//
|
91 |
double nu_pz = 0.;
|
92 |
double nu_e = sqrt(pow(nu_px,2)+pow(nu_py,2));
|
93 |
|
94 |
double Mw = 80.43; // NGO fix this!(read from one place)
|
95 |
double l_px = m_lepton.Px();
|
96 |
double l_py = m_lepton.Py();
|
97 |
double l_pz = m_lepton.Pz();
|
98 |
double l_pt = m_lepton.Pt();
|
99 |
double l_e = m_lepton.E();
|
100 |
double Mt = sqrt(pow(l_pt+nu_e ,2)-
|
101 |
pow(l_px+nu_px,2)-
|
102 |
pow(l_py+nu_py,2));
|
103 |
|
104 |
double A;
|
105 |
if (Mt<Mw) A = pow(Mw,2)/2.;
|
106 |
else { // assume Mt=Mw, rescale MET accordingly (NGO???)
|
107 |
A = pow(Mt,2)/2.;
|
108 |
double k = nu_e*l_pt - nu_px*l_px - nu_py*l_py;
|
109 |
k = (k == 0. ? 0.00001 : k);
|
110 |
double scf = 0.5*pow(Mw,2)/k ;
|
111 |
nu_px *= scf;
|
112 |
nu_py *= scf;
|
113 |
nu_e = sqrt(pow(nu_px,2)+pow(nu_py,2));
|
114 |
}
|
115 |
double B = nu_px*l_px + nu_py*l_py;
|
116 |
double C = TMath::Max(1. + pow(nu_e,2) * (pow(l_pz,2)-pow(l_e,2)) / pow(A+B,2) , 0.);
|
117 |
C = sqrt(C);
|
118 |
double S1= (-(A+B)*l_pz + (A+B)*l_e*C) / (pow(l_pz,2)-pow(l_e,2));
|
119 |
double S2= (-(A+B)*l_pz - (A+B)*l_e*C) / (pow(l_pz,2)-pow(l_e,2));
|
120 |
|
121 |
// choose solution with smallest |l_pz| a la Run I
|
122 |
nu_pz = fabs (S1) < fabs (S2) ? S1 : S2 ;
|
123 |
|
124 |
//NGO: NOTE: neutrino PX, PY are not necessarily metPX, metPY any more!!!
|
125 |
_neutrino.SetPxPyPzE(nu_px,nu_py,nu_pz,nu_e);
|
126 |
|
127 |
return removed_jets;
|
128 |
|
129 |
}
|
130 |
|
131 |
//For 3 Jets
|
132 |
int LJetsTopoVars::setEventMetFixed(TLorentzVector& Jet1, TLorentzVector& Jet2, TLorentzVector& Jet3, TLorentzVector& NewMet,TLorentzVector& Lepton1, double min_dr_jet_lepton)
|
133 |
{
|
134 |
|
135 |
using namespace edm;
|
136 |
int removed_jets = 0;
|
137 |
|
138 |
m_jets.clear();
|
139 |
eigenval.ResizeTo(3);
|
140 |
eigenval.Zero();
|
141 |
|
142 |
//Fill m_met, m_lepton, m_jets with inputed values
|
143 |
|
144 |
m_met = TMBLorentzVector(NewMet[0],NewMet[1],NewMet[2],NewMet[3],TMBLorentzVector::kXYZE);
|
145 |
m_lepton = TMBLorentzVector(Lepton1[0],Lepton1[1],Lepton1[2],Lepton1[3],TMBLorentzVector::kXYZE);
|
146 |
TMBLorentzVector jets[3] = {Jet1,Jet2,Jet3};
|
147 |
for (int i = 0; i<3; i++)
|
148 |
{
|
149 |
TMBLorentzVector _j(jets[i][0],jets[i][1],jets[i][2],jets[i][3],TMBLorentzVector::kXYZE);
|
150 |
if (m_lepton.DeltaR(_j) > min_dr_jet_lepton){
|
151 |
m_jets.push_back(_j);
|
152 |
}
|
153 |
else{
|
154 |
removed_jets++;
|
155 |
}
|
156 |
}
|
157 |
|
158 |
//Output all the values for m_met, m_lepton, m_jets
|
159 |
|
160 |
cout<< "From inside LJetsTopoVars"<<endl;
|
161 |
cout<<"!!!!!!!!"<<endl;
|
162 |
cout<< "m_met.Pt() = "<<m_met.Pt()<<endl;
|
163 |
cout<< "m_lepton.px, py, pz, energy = "<<m_lepton[0] <<", "<<m_lepton[1] <<", " <<m_lepton[2]<<", "<<m_lepton[3]<<endl;
|
164 |
cout<< "m_met.px, py, pz, energy = "<<m_met[0] <<", "<<m_met[1] <<", " <<m_met[2]<<", "<<m_met[3]<<endl;
|
165 |
cout<< "m_jet1.px, py, pz, energy = " <<m_jets[0][0]<<", "<<m_jets[0][1]<<", "<<m_jets[0][2]<<", "<<m_jets[0][3]<<endl;
|
166 |
cout<< "m_jet2.px, py, pz, energy = " <<m_jets[1][0]<<", "<<m_jets[1][1]<<", "<<m_jets[1][2]<<", "<<m_jets[1][3]<<endl;
|
167 |
cout<< "m_jet3.px, py, pz, energy = " <<m_jets[2][0]<<", "<<m_jets[2][1]<<", "<<m_jets[2][2]<<", "<<m_jets[2][3]<<endl;
|
168 |
|
169 |
|
170 |
double nu_px = m_met.Px();
|
171 |
double nu_py = m_met.Py();
|
172 |
|
173 |
cout<<"nu_px, nu_py = "<<nu_px<<", "<<nu_py<<endl;
|
174 |
|
175 |
//set all OK flags to FALSE;
|
176 |
_htOK = false;
|
177 |
_evtTopoOK = false;
|
178 |
_ktOK = false;
|
179 |
_mtOK = false;
|
180 |
|
181 |
//
|
182 |
// calculate neutrino lorentz vector (from Tobi's TopSvtAnalysis)
|
183 |
//
|
184 |
double nu_pz = 0.;
|
185 |
double nu_e = sqrt(pow(nu_px,2)+pow(nu_py,2));
|
186 |
|
187 |
double Mw = 80.43; // NGO fix this!(read from one place)
|
188 |
double l_px = m_lepton.Px();
|
189 |
double l_py = m_lepton.Py();
|
190 |
double l_pz = m_lepton.Pz();
|
191 |
double l_pt = m_lepton.Pt();
|
192 |
double l_e = m_lepton.E();
|
193 |
double Mt = sqrt(pow(l_pt+nu_e ,2)-
|
194 |
pow(l_px+nu_px,2)-
|
195 |
pow(l_py+nu_py,2));
|
196 |
|
197 |
double A;
|
198 |
if (Mt<Mw) A = pow(Mw,2)/2.;
|
199 |
else { // assume Mt=Mw, rescale MET accordingly (NGO???)
|
200 |
A = pow(Mt,2)/2.;
|
201 |
double k = nu_e*l_pt - nu_px*l_px - nu_py*l_py;
|
202 |
k = (k == 0. ? 0.00001 : k);
|
203 |
double scf = 0.5*pow(Mw,2)/k ;
|
204 |
nu_px *= scf;
|
205 |
nu_py *= scf;
|
206 |
nu_e = sqrt(pow(nu_px,2)+pow(nu_py,2));
|
207 |
}
|
208 |
double B = nu_px*l_px + nu_py*l_py;
|
209 |
double C = TMath::Max(1. + pow(nu_e,2) * (pow(l_pz,2)-pow(l_e,2)) / pow(A+B,2) , 0.);
|
210 |
C = sqrt(C);
|
211 |
double S1= (-(A+B)*l_pz + (A+B)*l_e*C) / (pow(l_pz,2)-pow(l_e,2));
|
212 |
double S2= (-(A+B)*l_pz - (A+B)*l_e*C) / (pow(l_pz,2)-pow(l_e,2));
|
213 |
|
214 |
// choose solution with smallest |l_pz| a la Run I
|
215 |
nu_pz = fabs (S1) < fabs (S2) ? S1 : S2 ;
|
216 |
|
217 |
//NGO: NOTE: neutrino PX, PY are not necessarily metPX, metPY any more!!!
|
218 |
_neutrino.SetPxPyPzE(nu_px,nu_py,nu_pz,nu_e);
|
219 |
|
220 |
return removed_jets;
|
221 |
|
222 |
}
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
//For 2 Jets
|
228 |
int LJetsTopoVars::setEventMetFixed(TLorentzVector& Jet1, TLorentzVector& Jet2, TLorentzVector& NewMet,TLorentzVector& Lepton1, double min_dr_jet_lepton)
|
229 |
{
|
230 |
|
231 |
using namespace edm;
|
232 |
int removed_jets = 0;
|
233 |
|
234 |
m_jets.clear();
|
235 |
eigenval.ResizeTo(3);
|
236 |
eigenval.Zero();
|
237 |
|
238 |
//Fill m_met, m_lepton, m_jets with inputed values
|
239 |
|
240 |
m_met = TMBLorentzVector(NewMet[0],NewMet[1],NewMet[2],NewMet[3],TMBLorentzVector::kXYZE);
|
241 |
m_lepton = TMBLorentzVector(Lepton1[0],Lepton1[1],Lepton1[2],Lepton1[3],TMBLorentzVector::kXYZE);
|
242 |
TMBLorentzVector jets[3] = {Jet1,Jet2};
|
243 |
for (int i = 0; i<2; i++)
|
244 |
{
|
245 |
TMBLorentzVector _j(jets[i][0],jets[i][1],jets[i][2],jets[i][3],TMBLorentzVector::kXYZE);
|
246 |
if (m_lepton.DeltaR(_j) > min_dr_jet_lepton){
|
247 |
m_jets.push_back(_j);
|
248 |
}
|
249 |
else{
|
250 |
removed_jets++;
|
251 |
}
|
252 |
}
|
253 |
|
254 |
//Output all the values for m_met, m_lepton, m_jets
|
255 |
|
256 |
cout<< "From inside LJetsTopoVars"<<endl;
|
257 |
cout<<"!!!!!!!!"<<endl;
|
258 |
cout<< "m_met.Pt() = "<<m_met.Pt()<<endl;
|
259 |
cout<< "m_lepton.px, py, pz, energy = "<<m_lepton[0] <<", "<<m_lepton[1] <<", " <<m_lepton[2]<<", "<<m_lepton[3]<<endl;
|
260 |
cout<< "m_met.px, py, pz, energy = "<<m_met[0] <<", "<<m_met[1] <<", " <<m_met[2]<<", "<<m_met[3]<<endl;
|
261 |
cout<< "m_jet1.px, py, pz, energy = " <<m_jets[0][0]<<", "<<m_jets[0][1]<<", "<<m_jets[0][2]<<", "<<m_jets[0][3]<<endl;
|
262 |
cout<< "m_jet2.px, py, pz, energy = " <<m_jets[1][0]<<", "<<m_jets[1][1]<<", "<<m_jets[1][2]<<", "<<m_jets[1][3]<<endl;
|
263 |
|
264 |
|
265 |
double nu_px = m_met.Px();
|
266 |
double nu_py = m_met.Py();
|
267 |
|
268 |
cout<<"nu_px, nu_py = "<<nu_px<<", "<<nu_py<<endl;
|
269 |
|
270 |
//set all OK flags to FALSE;
|
271 |
_htOK = false;
|
272 |
_evtTopoOK = false;
|
273 |
_ktOK = false;
|
274 |
_mtOK = false;
|
275 |
|
276 |
//
|
277 |
// calculate neutrino lorentz vector (from Tobi's TopSvtAnalysis)
|
278 |
//
|
279 |
double nu_pz = 0.;
|
280 |
double nu_e = sqrt(pow(nu_px,2)+pow(nu_py,2));
|
281 |
|
282 |
double Mw = 80.43; // NGO fix this!(read from one place)
|
283 |
double l_px = m_lepton.Px();
|
284 |
double l_py = m_lepton.Py();
|
285 |
double l_pz = m_lepton.Pz();
|
286 |
double l_pt = m_lepton.Pt();
|
287 |
double l_e = m_lepton.E();
|
288 |
double Mt = sqrt(pow(l_pt+nu_e ,2)-
|
289 |
pow(l_px+nu_px,2)-
|
290 |
pow(l_py+nu_py,2));
|
291 |
|
292 |
double A;
|
293 |
if (Mt<Mw) A = pow(Mw,2)/2.;
|
294 |
else { // assume Mt=Mw, rescale MET accordingly (NGO???)
|
295 |
A = pow(Mt,2)/2.;
|
296 |
double k = nu_e*l_pt - nu_px*l_px - nu_py*l_py;
|
297 |
k = (k == 0. ? 0.00001 : k);
|
298 |
double scf = 0.5*pow(Mw,2)/k ;
|
299 |
nu_px *= scf;
|
300 |
nu_py *= scf;
|
301 |
nu_e = sqrt(pow(nu_px,2)+pow(nu_py,2));
|
302 |
}
|
303 |
double B = nu_px*l_px + nu_py*l_py;
|
304 |
double C = TMath::Max(1. + pow(nu_e,2) * (pow(l_pz,2)-pow(l_e,2)) / pow(A+B,2) , 0.);
|
305 |
C = sqrt(C);
|
306 |
double S1= (-(A+B)*l_pz + (A+B)*l_e*C) / (pow(l_pz,2)-pow(l_e,2));
|
307 |
double S2= (-(A+B)*l_pz - (A+B)*l_e*C) / (pow(l_pz,2)-pow(l_e,2));
|
308 |
|
309 |
// choose solution with smallest |l_pz| a la Run I
|
310 |
nu_pz = fabs (S1) < fabs (S2) ? S1 : S2 ;
|
311 |
|
312 |
//NGO: NOTE: neutrino PX, PY are not necessarily metPX, metPY any more!!!
|
313 |
_neutrino.SetPxPyPzE(nu_px,nu_py,nu_pz,nu_e);
|
314 |
|
315 |
return removed_jets;
|
316 |
|
317 |
}
|
318 |
|
319 |
|
320 |
|
321 |
//For 1 Jets
|
322 |
int LJetsTopoVars::setEventMetFixed(TLorentzVector& Jet1, TLorentzVector& NewMet,TLorentzVector& Lepton1, double min_dr_jet_lepton)
|
323 |
{
|
324 |
|
325 |
using namespace edm;
|
326 |
int removed_jets = 0;
|
327 |
|
328 |
m_jets.clear();
|
329 |
eigenval.ResizeTo(3);
|
330 |
eigenval.Zero();
|
331 |
|
332 |
//Fill m_met, m_lepton, m_jets with inputed values
|
333 |
|
334 |
m_met = TMBLorentzVector(NewMet[0],NewMet[1],NewMet[2],NewMet[3],TMBLorentzVector::kXYZE);
|
335 |
m_lepton = TMBLorentzVector(Lepton1[0],Lepton1[1],Lepton1[2],Lepton1[3],TMBLorentzVector::kXYZE);
|
336 |
TMBLorentzVector jets[1] = {Jet1};
|
337 |
for (int i = 0; i<1; i++)
|
338 |
{
|
339 |
TMBLorentzVector _j(jets[i][0],jets[i][1],jets[i][2],jets[i][3],TMBLorentzVector::kXYZE);
|
340 |
if (m_lepton.DeltaR(_j) > min_dr_jet_lepton){
|
341 |
m_jets.push_back(_j);
|
342 |
}
|
343 |
else{
|
344 |
removed_jets++;
|
345 |
}
|
346 |
}
|
347 |
|
348 |
//Output all the values for m_met, m_lepton, m_jets
|
349 |
cout<< "From inside LJetsTopoVars"<<endl;
|
350 |
cout<<"!!!!!!!!"<<endl;
|
351 |
cout<< "m_met.Pt() = "<<m_met.Pt()<<endl;
|
352 |
cout<< "m_lepton.px, py, pz, energy = "<<m_lepton[0] <<", "<<m_lepton[1] <<", " <<m_lepton[2]<<", "<<m_lepton[3]<<endl;
|
353 |
cout<< "m_met.px, py, pz, energy = "<<m_met[0] <<", "<<m_met[1] <<", " <<m_met[2]<<", "<<m_met[3]<<endl;
|
354 |
cout<< "m_jet1.px, py, pz, energy = " <<m_jets[0][0]<<", "<<m_jets[0][1]<<", "<<m_jets[0][2]<<", "<<m_jets[0][3]<<endl;
|
355 |
|
356 |
double nu_px = m_met.Px();
|
357 |
double nu_py = m_met.Py();
|
358 |
|
359 |
cout<<"nu_px, nu_py = "<<nu_px<<", "<<nu_py<<endl;
|
360 |
|
361 |
//set all OK flags to FALSE;
|
362 |
_htOK = false;
|
363 |
_evtTopoOK = false;
|
364 |
_ktOK = false;
|
365 |
_mtOK = false;
|
366 |
|
367 |
//
|
368 |
// calculate neutrino lorentz vector (from Tobi's TopSvtAnalysis)
|
369 |
//
|
370 |
double nu_pz = 0.;
|
371 |
double nu_e = sqrt(pow(nu_px,2)+pow(nu_py,2));
|
372 |
|
373 |
double Mw = 80.43; // NGO fix this!(read from one place)
|
374 |
double l_px = m_lepton.Px();
|
375 |
double l_py = m_lepton.Py();
|
376 |
double l_pz = m_lepton.Pz();
|
377 |
double l_pt = m_lepton.Pt();
|
378 |
double l_e = m_lepton.E();
|
379 |
double Mt = sqrt(pow(l_pt+nu_e ,2)-
|
380 |
pow(l_px+nu_px,2)-
|
381 |
pow(l_py+nu_py,2));
|
382 |
|
383 |
|
384 |
double A;
|
385 |
if (Mt<Mw) A = pow(Mw,2)/2.;
|
386 |
else { // assume Mt=Mw, rescale MET accordingly (NGO???)
|
387 |
A = pow(Mt,2)/2.;
|
388 |
double k = nu_e*l_pt - nu_px*l_px - nu_py*l_py;
|
389 |
k = (k == 0. ? 0.00001 : k);
|
390 |
double scf = 0.5*pow(Mw,2)/k ;
|
391 |
nu_px *= scf;
|
392 |
nu_py *= scf;
|
393 |
nu_e = sqrt(pow(nu_px,2)+pow(nu_py,2));
|
394 |
}
|
395 |
double B = nu_px*l_px + nu_py*l_py;
|
396 |
double C = TMath::Max(1. + pow(nu_e,2) * (pow(l_pz,2)-pow(l_e,2)) / pow(A+B,2) , 0.);
|
397 |
C = sqrt(C);
|
398 |
double S1= (-(A+B)*l_pz + (A+B)*l_e*C) / (pow(l_pz,2)-pow(l_e,2));
|
399 |
double S2= (-(A+B)*l_pz - (A+B)*l_e*C) / (pow(l_pz,2)-pow(l_e,2));
|
400 |
|
401 |
// choose solution with smallest |l_pz| a la Run I
|
402 |
nu_pz = fabs (S1) < fabs (S2) ? S1 : S2 ;
|
403 |
|
404 |
//NGO: NOTE: neutrino PX, PY are not necessarily metPX, metPY any more!!!
|
405 |
_neutrino.SetPxPyPzE(nu_px,nu_py,nu_pz,nu_e);
|
406 |
|
407 |
return removed_jets;
|
408 |
|
409 |
}
|
410 |
|
411 |
/*
|
412 |
//For 0 Jets
|
413 |
int LJetsTopoVars::setEventMetFixed(TLorentzVector& NewMet,TLorentzVector& Lepton1, double min_dr_jet_lepton)
|
414 |
{
|
415 |
|
416 |
using namespace edm;
|
417 |
int removed_jets = 0;
|
418 |
|
419 |
m_jets.clear();
|
420 |
eigenval.ResizeTo(3);
|
421 |
eigenval.Zero();
|
422 |
|
423 |
//Fill m_met, m_lepton, m_jets with inputed values
|
424 |
|
425 |
m_met = TMBLorentzVector(NewMet[0],NewMet[1],NewMet[2],NewMet[3],TMBLorentzVector::kXYZE);
|
426 |
m_lepton = TMBLorentzVector(Lepton1[0],Lepton1[1],Lepton1[2],Lepton1[3],TMBLorentzVector::kXYZE);
|
427 |
TMBLorentzVector jets[0] = {0};
|
428 |
for (int i = 0; i<0; i++)
|
429 |
{
|
430 |
TMBLorentzVector _j(jets[i][0],jets[i][1],jets[i][2],jets[i][3],TMBLorentzVector::kXYZE);
|
431 |
if (m_lepton.DeltaR(_j) > min_dr_jet_lepton){
|
432 |
m_jets.push_back(_j);
|
433 |
}
|
434 |
else{
|
435 |
removed_jets++;
|
436 |
}
|
437 |
}
|
438 |
|
439 |
//Output all the values for m_met, m_lepton, m_jets
|
440 |
cout<< "From inside LJetsTopoVars"<<endl;
|
441 |
cout<<"!!!!!!!!"<<endl;
|
442 |
cout<< "m_met.Pt() = "<<m_met.Pt()<<endl;
|
443 |
cout<< "m_lepton.px, py, pz, energy = "<<m_lepton[0] <<", "<<m_lepton[1] <<", " <<m_lepton[2]<<", "<<m_lepton[3]<<endl;
|
444 |
cout<< "m_met.px, py, pz, energy = "<<m_met[0] <<", "<<m_met[1] <<", " <<m_met[2]<<", "<<m_met[3]<<endl;
|
445 |
|
446 |
double nu_px = m_met.Px();
|
447 |
double nu_py = m_met.Py();
|
448 |
cout<<"nu_px, nu_py = "<<nu_px<<", "<<nu_py<<endl;
|
449 |
|
450 |
//set all OK flags to FALSE;
|
451 |
_htOK = false;
|
452 |
_evtTopoOK = false;
|
453 |
_ktOK = false;
|
454 |
_mtOK = false;
|
455 |
|
456 |
//
|
457 |
// calculate neutrino lorentz vector (from Tobi's TopSvtAnalysis)
|
458 |
//
|
459 |
double nu_pz = 0.;
|
460 |
double nu_e = sqrt(pow(nu_px,2)+pow(nu_py,2));
|
461 |
|
462 |
double Mw = 80.43; // NGO fix this!(read from one place)
|
463 |
double l_px = m_lepton.Px();
|
464 |
double l_py = m_lepton.Py();
|
465 |
double l_pz = m_lepton.Pz();
|
466 |
double l_pt = m_lepton.Pt();
|
467 |
double l_e = m_lepton.E();
|
468 |
double Mt = sqrt(pow(l_pt+nu_e ,2)-
|
469 |
pow(l_px+nu_px,2)-
|
470 |
pow(l_py+nu_py,2));
|
471 |
|
472 |
|
473 |
double A;
|
474 |
if (Mt<Mw) A = pow(Mw,2)/2.;
|
475 |
else { // assume Mt=Mw, rescale MET accordingly (NGO???)
|
476 |
A = pow(Mt,2)/2.;
|
477 |
double k = nu_e*l_pt - nu_px*l_px - nu_py*l_py;
|
478 |
k = (k == 0. ? 0.00001 : k);
|
479 |
double scf = 0.5*pow(Mw,2)/k ;
|
480 |
nu_px *= scf;
|
481 |
nu_py *= scf;
|
482 |
nu_e = sqrt(pow(nu_px,2)+pow(nu_py,2));
|
483 |
}
|
484 |
double B = nu_px*l_px + nu_py*l_py;
|
485 |
double C = TMath::Max(1. + pow(nu_e,2) * (pow(l_pz,2)-pow(l_e,2)) / pow(A+B,2) , 0.);
|
486 |
C = sqrt(C);
|
487 |
double S1= (-(A+B)*l_pz + (A+B)*l_e*C) / (pow(l_pz,2)-pow(l_e,2));
|
488 |
double S2= (-(A+B)*l_pz - (A+B)*l_e*C) / (pow(l_pz,2)-pow(l_e,2));
|
489 |
|
490 |
// choose solution with smallest |l_pz| a la Run I
|
491 |
nu_pz = fabs (S1) < fabs (S2) ? S1 : S2 ;
|
492 |
|
493 |
//NGO: NOTE: neutrino PX, PY are not necessarily metPX, metPY any more!!!
|
494 |
_neutrino.SetPxPyPzE(nu_px,nu_py,nu_pz,nu_e);
|
495 |
|
496 |
return removed_jets;
|
497 |
|
498 |
}
|
499 |
|
500 |
*/
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
int LJetsTopoVars::setEvent(const edm::Event& event, double _met_pt, double min_dr_jet_lepton)
|
506 |
{
|
507 |
using namespace edm;
|
508 |
|
509 |
int removed_jets = 0;
|
510 |
|
511 |
Handle< vector< pat::Jet > > jets;
|
512 |
Handle< vector< pat::MET > > met;
|
513 |
//Handle< vector<reco::CaloMET> > met;
|
514 |
Handle< vector< pat::Electron > > electrons;
|
515 |
Handle< vector< pat::Muon > > muons;
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
event . getByLabel( m_jetBranch, jets );
|
521 |
event . getByLabel( m_metBranch, met );
|
522 |
if (m_isMuon) event . getByLabel( m_leptonBranch, muons );
|
523 |
else event . getByLabel( m_leptonBranch, electrons );
|
524 |
|
525 |
//cout << endl << "=====> LJetsTopoVars::setEvent(): number of jets = " << jets -> size() << endl;
|
526 |
|
527 |
m_jets.clear();
|
528 |
|
529 |
eigenval.ResizeTo(3);
|
530 |
eigenval.Zero();
|
531 |
|
532 |
|
533 |
if (met->size()>0){
|
534 |
//m_met = TMBLorentzVector(met->begin()->pt(),met->begin()->eta(),met->begin()->phi(),met->begin()->energy(),TMBLorentzVector::kPtEtaPhiE);
|
535 |
|
536 |
//###################################################################################################
|
537 |
//##
|
538 |
//___Here we use the inputed _met_pt since it has changes due to JES. This is for Lepton to Neutrino Switch
|
539 |
//##
|
540 |
//###################################################################################################
|
541 |
|
542 |
m_met = TMBLorentzVector(_met_pt,met->begin()->eta(),met->begin()->phi(),met->begin()->energy(),TMBLorentzVector::kPtEtaPhiE);
|
543 |
}
|
544 |
else{
|
545 |
cout << "LJetsTopoVars::setEvent(): no MET in this event!" << endl;
|
546 |
}
|
547 |
|
548 |
if(m_isMuon){
|
549 |
if (muons->size()>0){
|
550 |
m_lepton = TMBLorentzVector(muons->begin()->pt(),muons->begin()->eta(),muons->begin()->phi(),muons->begin()->energy(),TMBLorentzVector::kPtEtaPhiE);
|
551 |
//_muon = &(event.getCollection<TMBMuon>(m_leptonBranch.c_str())[0]);
|
552 |
}
|
553 |
}
|
554 |
else{
|
555 |
if (electrons->size()>0){
|
556 |
m_lepton = TMBLorentzVector(electrons->begin()->pt(),electrons->begin()->eta(),electrons->begin()->phi(),electrons->begin()->energy(),TMBLorentzVector::kPtEtaPhiE);
|
557 |
//_electron = &(event.getCollection<TMBEMCluster>(m_leptonBranch.c_str())[0]);
|
558 |
}
|
559 |
}
|
560 |
|
561 |
|
562 |
// loop over first four jets (that are not too close to the lepton!!!)
|
563 |
//vector<pat::Jet>::const_iterator jet;
|
564 |
//int nMax = jets->size() > 4 ? 4 : jets->size();
|
565 |
//jet = jets->begin();
|
566 |
//for (int i=0; i<nMax; ++i){
|
567 |
cout<<"Jet size = "<<jets->size()<<endl;
|
568 |
if (jets->size()>0){
|
569 |
for (vector<pat::Jet>::const_iterator jet=jets->begin(); (jet!=jets->end()) && (m_jets.size()!=4); jet++){
|
570 |
//cout << "LJetsTopoVars::setEvent(): jet pt() = " << jet -> pt() << endl;
|
571 |
TMBLorentzVector _j(jet->pt(),jet->eta(),jet->phi(),jet->energy(),TMBLorentzVector::kPtEtaPhiE);
|
572 |
if (m_lepton.DeltaR(_j) > min_dr_jet_lepton){
|
573 |
m_jets.push_back(_j);
|
574 |
//jet++;
|
575 |
}
|
576 |
else{
|
577 |
removed_jets++;
|
578 |
}
|
579 |
}
|
580 |
}
|
581 |
//original method had as given:
|
582 |
// std::vector<TheJetClass*> selectedJets,
|
583 |
// TLorentzVector selectedLepton,
|
584 |
// double nu_px (MET px OK?)
|
585 |
// double nu_py (MET py OK?)
|
586 |
double nu_px = m_met.Px();
|
587 |
double nu_py = m_met.Py();
|
588 |
|
589 |
//set all OK flags to FALSE;
|
590 |
_htOK = false;
|
591 |
_evtTopoOK = false;
|
592 |
_ktOK = false;
|
593 |
_mtOK = false;
|
594 |
|
595 |
//
|
596 |
// calculate neutrino lorentz vector (from Tobi's TopSvtAnalysis)
|
597 |
//
|
598 |
double nu_pz = 0.;
|
599 |
double nu_e = sqrt(pow(nu_px,2)+pow(nu_py,2));
|
600 |
|
601 |
double Mw = 80.43; // NGO fix this!(read from one place)
|
602 |
double l_px = m_lepton.Px();
|
603 |
double l_py = m_lepton.Py();
|
604 |
double l_pz = m_lepton.Pz();
|
605 |
double l_pt = m_lepton.Pt();
|
606 |
double l_e = m_lepton.E();
|
607 |
double Mt = sqrt(pow(l_pt+nu_e ,2)-
|
608 |
pow(l_px+nu_px,2)-
|
609 |
pow(l_py+nu_py,2));
|
610 |
|
611 |
double A;
|
612 |
if (Mt<Mw) A = pow(Mw,2)/2.;
|
613 |
else { // assume Mt=Mw, rescale MET accordingly (NGO???)
|
614 |
A = pow(Mt,2)/2.;
|
615 |
double k = nu_e*l_pt - nu_px*l_px - nu_py*l_py;
|
616 |
k = (k == 0. ? 0.00001 : k);
|
617 |
double scf = 0.5*pow(Mw,2)/k ;
|
618 |
nu_px *= scf;
|
619 |
nu_py *= scf;
|
620 |
nu_e = sqrt(pow(nu_px,2)+pow(nu_py,2));
|
621 |
}
|
622 |
|
623 |
double B = nu_px*l_px + nu_py*l_py;
|
624 |
double C = TMath::Max(1. + pow(nu_e,2) * (pow(l_pz,2)-pow(l_e,2)) / pow(A+B,2) , 0.);
|
625 |
C = sqrt(C);
|
626 |
double S1= (-(A+B)*l_pz + (A+B)*l_e*C) / (pow(l_pz,2)-pow(l_e,2));
|
627 |
double S2= (-(A+B)*l_pz - (A+B)*l_e*C) / (pow(l_pz,2)-pow(l_e,2));
|
628 |
|
629 |
// choose solution with smallest |l_pz| a la Run I
|
630 |
nu_pz = fabs (S1) < fabs (S2) ? S1 : S2 ;
|
631 |
|
632 |
//NGO: NOTE: neutrino PX, PY are not necessarily metPX, metPY any more!!!
|
633 |
_neutrino.SetPxPyPzE(nu_px,nu_py,nu_pz,nu_e);
|
634 |
|
635 |
/*****
|
636 |
*****/
|
637 |
return removed_jets;
|
638 |
}
|
639 |
|
640 |
double LJetsTopoVars::aplanarity() const
|
641 |
{
|
642 |
vector<TMBLorentzVector> objects(m_jets);
|
643 |
objects.push_back(m_lepton);
|
644 |
TopTopologicalVariables jetsPlusLepton(objects);
|
645 |
return jetsPlusLepton.Aplanarity();
|
646 |
}
|
647 |
|
648 |
double LJetsTopoVars::centrality() const
|
649 |
{
|
650 |
TopTopologicalVariables jets(m_jets);
|
651 |
return jets.Centrality();
|
652 |
}
|
653 |
|
654 |
double LJetsTopoVars::sphericity() const
|
655 |
{
|
656 |
vector<TMBLorentzVector> objects(m_jets);
|
657 |
objects.push_back(m_lepton);
|
658 |
TopTopologicalVariables jetsPlusLepton(objects);
|
659 |
return jetsPlusLepton.Sphericity();
|
660 |
}
|
661 |
|
662 |
double LJetsTopoVars::ht() const
|
663 |
{
|
664 |
TopTopologicalVariables jets(m_jets);
|
665 |
return jets.Ht();
|
666 |
}
|
667 |
|
668 |
double LJetsTopoVars::htpluslepton() const
|
669 |
{
|
670 |
vector<TMBLorentzVector> objects(m_jets);
|
671 |
objects.push_back(m_lepton);
|
672 |
TopTopologicalVariables jetsPlusLepton(objects);
|
673 |
return jetsPlusLepton.Ht();
|
674 |
}
|
675 |
|
676 |
double LJetsTopoVars::methtpluslepton() const
|
677 |
{
|
678 |
vector<TMBLorentzVector> objects(m_jets);
|
679 |
objects.push_back(m_lepton);
|
680 |
objects.push_back(m_met);
|
681 |
TopTopologicalVariables metjetsPlusLepton(objects);
|
682 |
return metjetsPlusLepton.Ht();
|
683 |
}
|
684 |
|
685 |
double LJetsTopoVars::h() const
|
686 |
{
|
687 |
TopTopologicalVariables jets(m_jets);
|
688 |
return jets.H();
|
689 |
}
|
690 |
|
691 |
|
692 |
double LJetsTopoVars::ktMinPrime() const
|
693 |
{
|
694 |
TopTopologicalVariables jets(m_jets);
|
695 |
float ktmin = jets.KtMin();
|
696 |
float etw = m_met.Pt() + m_lepton.Pt();
|
697 |
return ktmin/etw;
|
698 |
}
|
699 |
|
700 |
double LJetsTopoVars::dphiLepMet() const
|
701 |
{
|
702 |
return kinem::delta_phi(m_met.Phi(), m_lepton.Phi());
|
703 |
}
|
704 |
|
705 |
double LJetsTopoVars::minDijetMass() const
|
706 |
{
|
707 |
TopTopologicalVariables jets(m_jets);
|
708 |
return jets.MinimumPairMass();
|
709 |
}
|
710 |
|
711 |
double LJetsTopoVars::maxJetEta() const
|
712 |
{
|
713 |
double jetEta = 0;
|
714 |
for (unsigned int i=0; i<m_jets.size(); i++) {
|
715 |
if(TMath::Abs(m_jets.at(i).Eta()) > TMath::Abs(jetEta) ) jetEta = TMath::Abs(m_jets.at(i).Eta());
|
716 |
}
|
717 |
return jetEta;
|
718 |
}
|
719 |
|
720 |
|
721 |
double LJetsTopoVars::Et3() const
|
722 |
{
|
723 |
double Et3 = 0;
|
724 |
for (unsigned int i=2; i<m_jets.size(); i++) {
|
725 |
Et3+=m_jets.at(i).Pt();
|
726 |
}
|
727 |
return Et3;
|
728 |
}
|
729 |
|
730 |
double LJetsTopoVars::minDijetDeltaR() const
|
731 |
{
|
732 |
|
733 |
int nJet = m_jets.size();
|
734 |
|
735 |
double dRmin = 9999.;
|
736 |
double eTmin = 9999.;
|
737 |
for(int i=0;i<nJet-1;i++){
|
738 |
for(int j=i+1;j<nJet;j++){
|
739 |
double dR = m_jets[i].DeltaR(m_jets[j]);
|
740 |
if(dR<dRmin){
|
741 |
dRmin = dR;
|
742 |
eTmin = std::min(m_jets[i].Pt(),m_jets[j].Pt());
|
743 |
}
|
744 |
}
|
745 |
}
|
746 |
if(dRmin>100.) {dRmin=0.;}
|
747 |
|
748 |
return dRmin;
|
749 |
}
|
750 |
|
751 |
|
752 |
double LJetsTopoVars::Hz() {
|
753 |
vector<TMBLorentzVector> objects;
|
754 |
objects.assign(m_jets.begin(), m_jets.end());
|
755 |
objects.push_back(m_lepton);
|
756 |
objects.push_back(_neutrino);
|
757 |
double pz = 0;
|
758 |
for (vector<TMBLorentzVector>::iterator obj = objects.begin(); obj!=objects.end(); ++obj) pz += abs((*obj).Pz());
|
759 |
return pz;
|
760 |
}
|
761 |
|
762 |
double LJetsTopoVars::HT2() {
|
763 |
vector<TMBLorentzVector> objects;
|
764 |
objects.assign(++m_jets.begin(), m_jets.end());
|
765 |
TopTopologicalVariables topo(objects);
|
766 |
return topo.Ht();
|
767 |
}
|
768 |
|
769 |
double LJetsTopoVars::HT2prime() {
|
770 |
return HT2()/Hz();
|
771 |
}
|
772 |
|
773 |
double LJetsTopoVars::W_MT() {
|
774 |
vector<TMBLorentzVector> objects;
|
775 |
//objects.push_back(_neutrino); //_neutrino was made with W mass constraint; use MET instead
|
776 |
objects.push_back(m_met);
|
777 |
objects.push_back(m_lepton);
|
778 |
TopTopologicalVariables topo(objects);
|
779 |
return topo.TransverseMass();
|
780 |
}
|
781 |
|
782 |
double LJetsTopoVars::W_Pt() {
|
783 |
vector<TMBLorentzVector> objects;
|
784 |
//objects.push_back(_neutrino); //_neutrino was made with W mass constraint; use MET instead
|
785 |
objects.push_back(m_met);
|
786 |
objects.push_back(m_lepton);
|
787 |
TopTopologicalVariables topo(objects);
|
788 |
return topo.Pt();
|
789 |
}
|
790 |
|
791 |
double LJetsTopoVars::W_M() {
|
792 |
vector<TMBLorentzVector> objects;
|
793 |
objects.push_back(_neutrino); //_neutrino was made with W mass constraint; use MET instead
|
794 |
// objects.push_back(m_met);
|
795 |
objects.push_back(m_lepton);
|
796 |
TopTopologicalVariables topo(objects);
|
797 |
return topo.M();
|
798 |
}
|
799 |
|
800 |
double LJetsTopoVars::Jet1Jet2_M() {
|
801 |
if(m_jets.size()>=2) {
|
802 |
vector<TMBLorentzVector> objects;
|
803 |
objects.push_back(m_jets.at(0));
|
804 |
objects.push_back(m_jets.at(1));
|
805 |
TopTopologicalVariables topo(objects);
|
806 |
return topo.M();
|
807 |
} else return -1;
|
808 |
}
|
809 |
|
810 |
double LJetsTopoVars::Jet1Jet2_Pt() {
|
811 |
if(m_jets.size()>=2) {
|
812 |
vector<TMBLorentzVector> objects;
|
813 |
objects.push_back(m_jets.at(0));
|
814 |
objects.push_back(m_jets.at(1));
|
815 |
TopTopologicalVariables topo(objects);
|
816 |
return topo.Pt();
|
817 |
} else return -1;
|
818 |
}
|
819 |
|
820 |
double LJetsTopoVars::Jet1Jet2_DeltaR() {
|
821 |
if(m_jets.size()>=2) {
|
822 |
return m_jets.at(0).DeltaR(m_jets.at(1));
|
823 |
} else return -1;
|
824 |
}
|
825 |
|
826 |
double LJetsTopoVars::Jet1Jet2_DeltaPhi() {
|
827 |
if(m_jets.size()>=2) {
|
828 |
return TMath::Abs(m_jets.at(0).DeltaPhi(m_jets.at(1)));
|
829 |
} else return -1;
|
830 |
}
|
831 |
|
832 |
|
833 |
|
834 |
double LJetsTopoVars::Jet1Jet2W_M() {
|
835 |
if(m_jets.size()>=2) {
|
836 |
vector<TMBLorentzVector> objects;
|
837 |
objects.push_back(_neutrino); //_neutrino was made with W mass constraint; use MET instead
|
838 |
// objects.push_back(m_met);
|
839 |
objects.push_back(m_lepton);
|
840 |
objects.push_back(m_jets.at(0));
|
841 |
objects.push_back(m_jets.at(1));
|
842 |
TopTopologicalVariables topo(objects);
|
843 |
return topo.M();
|
844 |
} else return -1;
|
845 |
}
|
846 |
|
847 |
double LJetsTopoVars::Jet1Jet2W_Pt() {
|
848 |
if(m_jets.size()>=2) {
|
849 |
vector<TMBLorentzVector> objects;
|
850 |
objects.push_back(_neutrino); //_neutrino was made with W mass constraint; use MET instead
|
851 |
// objects.push_back(m_met);
|
852 |
objects.push_back(m_lepton);
|
853 |
objects.push_back(m_jets.at(0));
|
854 |
objects.push_back(m_jets.at(1));
|
855 |
TopTopologicalVariables topo(objects);
|
856 |
return topo.Pt();
|
857 |
} else return -1;
|
858 |
}
|
859 |
|
860 |
double LJetsTopoVars::DphiJMET() {
|
861 |
return kinem::delta_phi(m_met.Phi(), m_jets.at(0).Phi());
|
862 |
}
|
863 |
|
864 |
double LJetsTopoVars::LeptonJet_DeltaR() {
|
865 |
if(m_jets.size()>=2) {
|
866 |
return m_lepton.DeltaR(m_jets.at(0))< m_lepton.DeltaR(m_jets.at(1)) ? m_lepton.DeltaR(m_jets.at(0)) : m_lepton.DeltaR(m_jets.at(1));
|
867 |
} else {
|
868 |
return m_lepton.DeltaR(m_jets.at(0));
|
869 |
}
|
870 |
}
|
871 |
|
872 |
double LJetsTopoVars::Muon_DeltaR() {
|
873 |
//is this already stored in the muon somewhere?
|
874 |
double DeltaR = 1e99;
|
875 |
for (unsigned int i=0; i<m_jets.size(); i++) DeltaR = min(DeltaR, m_lepton.DeltaR(m_jets.at(i)));
|
876 |
return DeltaR;
|
877 |
}
|
878 |
|
879 |
|
880 |
/***** removed temoprarily
|
881 |
double LJetsTopoVars::Muon_etHaloScaled() {
|
882 |
if (!m_isMuon) throw runtime_error("LJetsTopoVars: Muon_etHaloScaled: event is not mu+jets");
|
883 |
//TMBMuon* muon = dynamic_cast<TMBMuon*>(&m_lepton);
|
884 |
return _muon->etHalo()/_muon->Pt();
|
885 |
}
|
886 |
|
887 |
double LJetsTopoVars::Muon_etTrkConeScaled() {
|
888 |
if (!m_isMuon) throw runtime_error("LJetsTopoVars: Muon_etHaloScaled: event is not mu+jets");
|
889 |
//TMBMuon* muon = dynamic_cast<TMBMuon*>(&m_lepton);
|
890 |
return _muon->etTrkCone5()/_muon->Pt();
|
891 |
}
|
892 |
|
893 |
double LJetsTopoVars::Electron_iso() {
|
894 |
if (m_isMuon) throw runtime_error("LJetsTopoVars: Electron_iso: event is not e+jets");
|
895 |
return _electron->iso();
|
896 |
}
|
897 |
|
898 |
double LJetsTopoVars::Electron_lhood() {
|
899 |
if (m_isMuon) throw runtime_error("LJetsTopoVars: Electron_iso: event is not e+jets");
|
900 |
return _electron->Lhood8();
|
901 |
}
|
902 |
*****/
|
903 |
|
904 |
//
|
905 |
//_____________________________________________________________________
|
906 |
void LJetsTopoVars::calcHt(){
|
907 |
|
908 |
//ht[ 0] = Ht
|
909 |
//ht[ 1] = Htp
|
910 |
//ht[ 2] = Htpp
|
911 |
//ht[ 3] = Ht2
|
912 |
//ht[ 4] = Ht2p
|
913 |
//ht[ 5] = Ht2pp
|
914 |
//ht[ 6] = Ht3
|
915 |
//ht[ 7] = Ht3p
|
916 |
//ht[ 8] = Ht3pp
|
917 |
//ht[ 9] = centrality
|
918 |
//ht[10] = NJW;
|
919 |
//ht[11] = eta_max
|
920 |
//ht[12] = MdijetMin
|
921 |
//ht[13] = Mtjets (definition from Jean-Roche)
|
922 |
//ht[14] = sqrtsT (=Tobi's M_{T} in Note) from Tobi
|
923 |
//ht[15] = MtAurelio
|
924 |
//ht[16] = pZoverHT
|
925 |
//ht[17] = Mevent
|
926 |
//ht[18] = M123inv
|
927 |
//ht[19] = Eta2Sum (Eta^2 sum)
|
928 |
//ht[20] = mWrec
|
929 |
//ht[21] = H = sum(jetE)
|
930 |
|
931 |
//reset
|
932 |
for(unsigned int i=0;i<_ht.size();i++) _ht[i]=0.;
|
933 |
|
934 |
|
935 |
double h = 0.;
|
936 |
double hz = 0.;
|
937 |
double hx = 0.;
|
938 |
double hy = 0.;
|
939 |
double hzSigned = 0.;
|
940 |
_ht[12] =-1.;
|
941 |
double mtjets = 0.;
|
942 |
TMBLorentzVector Mevent;
|
943 |
int nJet = m_jets.size();
|
944 |
for(int i=0;i<nJet;i++){
|
945 |
hz += TMath::Abs(m_jets[i].Pz());
|
946 |
hx += m_jets[i].Px();
|
947 |
hy += m_jets[i].Py();
|
948 |
h += m_jets[i].E();
|
949 |
_ht[0] += m_jets[i].Pt();
|
950 |
Mevent += m_jets[i];
|
951 |
hzSigned += m_jets[i].Pz();
|
952 |
if(i>0) _ht[3] += m_jets[i].Pt();
|
953 |
if(i>1) _ht[6] += m_jets[i].Pt();
|
954 |
if(TMath::Abs(m_jets[i].Eta())>_ht[11] && i<4){
|
955 |
_ht[11] = TMath::Abs(m_jets[i].Eta());
|
956 |
}
|
957 |
for(int j=i+1; j<nJet; j++){
|
958 |
double mDijet = (m_jets[i]+m_jets[j]).Mag();
|
959 |
if(_ht[12]<0. || mDijet<_ht[12]){ _ht[12]=mDijet; }
|
960 |
}
|
961 |
mtjets +=
|
962 |
TMath::Power(m_jets[i].E(),2) -
|
963 |
TMath::Power(m_jets[i].Px(),2) -
|
964 |
TMath::Power(m_jets[i].Py(),2);
|
965 |
|
966 |
_ht[19] += m_jets[i].Eta()*m_jets[i].Eta();
|
967 |
}
|
968 |
_ht[21] = h;
|
969 |
|
970 |
// the "M_T"s
|
971 |
if(mtjets > 0.){ _ht[13]=TMath::Sqrt(mtjets); }
|
972 |
_ht[14] = _ht[0]*_ht[0] - hx*hx - hy*hy;
|
973 |
if(_ht[14]>0.) _ht[14] = TMath::Sqrt(_ht[14]);
|
974 |
_ht[15] = h*h - hzSigned*hzSigned;
|
975 |
if(_ht[15]>0.) _ht[15] = TMath::Sqrt(_ht[15]);
|
976 |
|
977 |
if(_ht[0]>0.) _ht[16] = hzSigned/_ht[0];
|
978 |
|
979 |
double hzNoLep = hz;
|
980 |
hz += TMath::Abs(m_lepton.Pz());
|
981 |
hz += TMath::Abs(_neutrino.Pz());
|
982 |
if(hz!=0.){
|
983 |
_ht[1]=_ht[0]/hz;
|
984 |
_ht[4]=_ht[3]/hz;
|
985 |
_ht[7]=_ht[6]/hz;
|
986 |
}
|
987 |
if(hzNoLep!=0.){
|
988 |
_ht[2]=_ht[0]/hzNoLep;
|
989 |
_ht[5]=_ht[3]/hzNoLep;
|
990 |
_ht[8]=_ht[6]/hzNoLep;
|
991 |
}
|
992 |
if(h>0.){
|
993 |
_ht[9] = _ht[0]/h;
|
994 |
}
|
995 |
|
996 |
//
|
997 |
// NJW
|
998 |
//
|
999 |
double NJW=0;
|
1000 |
for(Int_t ijet=0; ijet<nJet-1; ijet++){
|
1001 |
double emin=55.;
|
1002 |
double emax=55.;
|
1003 |
if(m_jets[ijet ].Pt() < 55.){emax=m_jets[ijet ].Pt();}
|
1004 |
if(m_jets[ijet+1].Pt() < 55.){emin=m_jets[ijet+1].Pt();}
|
1005 |
NJW += 0.5*(emax*emax-emin*emin)*(ijet+1);
|
1006 |
}
|
1007 |
double elo=15.;
|
1008 |
if(m_jets[nJet-1].Pt() > elo){elo=m_jets[nJet-1].Pt();}
|
1009 |
NJW += 0.5*(elo*elo-(15.*15.))*(nJet);
|
1010 |
NJW /= ((55*55)-100.)/2.0;
|
1011 |
_ht[10] = NJW;
|
1012 |
|
1013 |
|
1014 |
// total event invariant mass
|
1015 |
Mevent += m_lepton;
|
1016 |
Mevent += _neutrino;
|
1017 |
_ht[17] = Mevent.Mag();
|
1018 |
|
1019 |
// sum of dijet invariant masses for three highest jets
|
1020 |
// and mWrec
|
1021 |
if(nJet>2){
|
1022 |
double min=1e10;
|
1023 |
for(int i=0;i<2;i++){
|
1024 |
for(int j=i+1; j<3; j++){
|
1025 |
double m = (m_jets[i]+m_jets[j]).Mag();
|
1026 |
_ht[18] += m;
|
1027 |
double diff = TMath::Abs(80.4-m);
|
1028 |
if(diff<min){
|
1029 |
min = diff;
|
1030 |
_ht[20] = m;
|
1031 |
}
|
1032 |
}
|
1033 |
}
|
1034 |
}
|
1035 |
|
1036 |
_htOK = true;
|
1037 |
}
|
1038 |
|
1039 |
//
|
1040 |
//_____________________________________________________________________
|
1041 |
void LJetsTopoVars::calcEvtTopo(){
|
1042 |
|
1043 |
//evtTopo[0] = sphericity
|
1044 |
//evtTopo[1] = aplanarity
|
1045 |
//evtTopo[2] = aplanarity including muon
|
1046 |
|
1047 |
int nJet = m_jets.size();
|
1048 |
|
1049 |
// calculate tensor
|
1050 |
//
|
1051 |
double psum = 0.;
|
1052 |
for(int k=0;k<nJet;k++){
|
1053 |
psum += m_jets[k].Vect().Mag32();
|
1054 |
}
|
1055 |
|
1056 |
TMatrixDSym M(3);
|
1057 |
for(int i=0;i<3;i++){
|
1058 |
for(int j=i;j<3;j++){
|
1059 |
M(i,j)=0.;
|
1060 |
for(int k=0;k<nJet;k++){
|
1061 |
M(i,j) += m_jets[k](i) * m_jets[k](j);
|
1062 |
}
|
1063 |
M(i,j)/=psum;
|
1064 |
if(i!=j){M(j,i) = M(i,j);}
|
1065 |
}
|
1066 |
}
|
1067 |
|
1068 |
//
|
1069 |
// get eigenvalues
|
1070 |
//
|
1071 |
TMatrixDSymEigen eigenMatrix(M);
|
1072 |
const TVectorD *eigen = &eigenMatrix.GetEigenValues();
|
1073 |
|
1074 |
eigenval.ResizeTo(eigen->GetNrows());
|
1075 |
eigenval = *eigen;
|
1076 |
|
1077 |
//NGO fix eigenvalues to zero if too small
|
1078 |
//otherwise ev might be marginally below zero!
|
1079 |
for(int i=0;i<3;i++){
|
1080 |
if(fabs(eigenval[i])<1e-10) eigenval[i]=0.;
|
1081 |
}
|
1082 |
|
1083 |
_evtTopo[0] = (3./2.) * (eigenval[1]+eigenval[2]);
|
1084 |
_evtTopo[1] = (3./2.) * eigenval[2];
|
1085 |
|
1086 |
|
1087 |
//
|
1088 |
// some consistency checks
|
1089 |
//
|
1090 |
if( eigenval[0]<eigenval[1] ||
|
1091 |
eigenval[0]<eigenval[2] ||
|
1092 |
eigenval[1]<eigenval[2]){
|
1093 |
cout << "ERROR: Eigenvals not ordered!" << endl;
|
1094 |
std::exit(1);
|
1095 |
}
|
1096 |
if(_evtTopo[0]<0. || _evtTopo[1]<0.){
|
1097 |
cout << "ERROR: SPHERICITY: " << _evtTopo[0] << endl;
|
1098 |
cout << "ERROR: APLANARITY: " << _evtTopo[1] << endl;
|
1099 |
M.Print();
|
1100 |
}
|
1101 |
|
1102 |
|
1103 |
//
|
1104 |
//
|
1105 |
// include muon in calculation
|
1106 |
//
|
1107 |
// ------------------------------------------------------
|
1108 |
std::vector<TMBLorentzVector> jetMu(m_jets);
|
1109 |
jetMu.push_back(m_lepton);
|
1110 |
nJet = jetMu.size();
|
1111 |
|
1112 |
// calculate tensor
|
1113 |
psum = 0.;
|
1114 |
for(int k=0;k<nJet;k++){
|
1115 |
psum += jetMu[k].Vect().Mag32();
|
1116 |
}
|
1117 |
|
1118 |
for(int i=0;i<3;i++){
|
1119 |
for(int j=i;j<3;j++){
|
1120 |
M(i,j)=0.;
|
1121 |
for(int k=0;k<nJet;k++){
|
1122 |
M(i,j) += jetMu[k](i) * jetMu[k](j);
|
1123 |
}
|
1124 |
M(i,j)/=psum;
|
1125 |
if(i!=j){M(j,i) = M(i,j);}
|
1126 |
}
|
1127 |
}
|
1128 |
|
1129 |
// get eigenvalues
|
1130 |
TMatrixDSymEigen eigenMatrix_01(M);
|
1131 |
TVectorD eigenval_01 = eigenMatrix_01.GetEigenValues();
|
1132 |
for(int i=0;i<3;i++){
|
1133 |
if(fabs(eigenval_01[i])<1e-10) eigenval_01[i]=0.;
|
1134 |
}
|
1135 |
_evtTopo[2] = (3./2.) * eigenval_01[2];
|
1136 |
|
1137 |
|
1138 |
_evtTopoOK = true;
|
1139 |
}
|
1140 |
|
1141 |
|
1142 |
//
|
1143 |
//_____________________________________________________________________
|
1144 |
void LJetsTopoVars::calcKt()
|
1145 |
{
|
1146 |
|
1147 |
//kt[0] = Ktminp
|
1148 |
//kt[1] = Ktminpreduced
|
1149 |
//kt[2] = dRmin(jet,jet);
|
1150 |
|
1151 |
int nJet = m_jets.size();
|
1152 |
|
1153 |
double dRmin = 9999.;
|
1154 |
double eTmin = 9999.;
|
1155 |
for(int i=0;i<nJet-1;i++){
|
1156 |
for(int j=i+1;j<nJet;j++){
|
1157 |
double dR = m_jets[i].DeltaR(m_jets[j]);
|
1158 |
if(dR<dRmin){
|
1159 |
dRmin = dR;
|
1160 |
eTmin = std::min(m_jets[i].Pt(),m_jets[j].Pt());
|
1161 |
}
|
1162 |
}
|
1163 |
}
|
1164 |
if(dRmin>100.) {dRmin=0.;}
|
1165 |
|
1166 |
_kt[0] = dRmin*eTmin/(m_lepton.Pt()+_neutrino.Pt());
|
1167 |
_kt[1] = dRmin*eTmin;
|
1168 |
_kt[2] = dRmin;
|
1169 |
|
1170 |
_ktOK = true;
|
1171 |
}
|
1172 |
|
1173 |
|
1174 |
//
|
1175 |
//_____________________________________________________________________
|
1176 |
void LJetsTopoVars::calcMt()
|
1177 |
{
|
1178 |
|
1179 |
//mt[0] = dPhi(muon,MET)
|
1180 |
//mt[1] = mT
|
1181 |
|
1182 |
//
|
1183 |
// NGO: which met should be used in calculating the mt??
|
1184 |
// the raw or the one form the neutrino pz calculation, which
|
1185 |
// might be scaled???
|
1186 |
//
|
1187 |
double met = TMath::Sqrt(TMath::Power(_neutrino.Px(),2.)+
|
1188 |
TMath::Power(_neutrino.Py(),2));
|
1189 |
|
1190 |
|
1191 |
_mt[0] = TMath::Abs(m_lepton.DeltaPhi(_neutrino));
|
1192 |
_mt[1] = TMath::Sqrt(2*m_lepton.Pt()*met*(1.-TMath::Cos(_mt[0])));
|
1193 |
|
1194 |
_mtOK = true;
|
1195 |
}
|