-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclusteringToolbox.cc
More file actions
461 lines (387 loc) · 21.5 KB
/
Copy pathclusteringToolbox.cc
File metadata and controls
461 lines (387 loc) · 21.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
#include "analyzers/analyzers/src/BESTtoolbox.cc"
using namespace reco;
typedef math::XYZTLorentzVector LorentzVector;
typedef math::XYZVector Vector;
double calc_mag(double px,double py, double pz)
{
return sqrt(pow(px,2)+pow(py,2)+pow(pz,2));
}
const reco::Candidate* parse_chain(const reco::Candidate* cand)
{
for (unsigned int iii=0; iii<cand->numberOfDaughters(); iii++)
{
if(cand->daughter(iii)->pdgId() == cand->pdgId()) return parse_chain(cand->daughter(iii));
}
return cand;
}
bool isgoodjet(const float eta, const float NHF,const float NEMF, const size_t NumConst,const float CHF,const int CHM, const float MUF, const float CEMF)
{
if( (abs(eta) > 2.5)) return false;
if ((NHF>0.9) || (NEMF>0.9) || (NumConst<1) || (CHF<0.) || (CHM<0) || (MUF > 0.8) || (CEMF > 0.8))
{
return false;
}
else{ return true;}
}
bool isgoodjet(const float eta, const float NHF,const float NEMF, const size_t NumConst,const float CHF,const int CHM, const float MUF, const float CEMF, int nfatjets)
{
if ( (nfatjets < 2) && (abs(eta) > 2.4) ) return false;
else if ( (nfatjets >= 2) && (abs(eta) > 1.9) ) return false;
if ((NHF>0.9) || (NEMF>0.9) || (NumConst<1) || (CHF<0.) || (CHM<0) || (MUF > 0.8) || (CEMF > 0.8))
{
return false;
}
else{ return true;}
}
double calcMPP(TLorentzVector superJetTLV )
{
Vector jet_axis(superJetTLV.Px()/superJetTLV.P(),superJetTLV.Py()/superJetTLV.P(),superJetTLV.Pz()/superJetTLV.P());
double min_pp = 99999999999999.;
double min_boost = 0.;
for(int iii=0;iii<10000;iii++)
{
TLorentzVector superJetTLV_ = superJetTLV;
double beta_cand = iii/10000.;
superJetTLV_.Boost(-beta_cand*jet_axis.X(),-beta_cand*jet_axis.Y(),-beta_cand*jet_axis.Z());
if(abs( ( superJetTLV_.Px()*superJetTLV.Px()+superJetTLV_.Py()*superJetTLV.Py() +superJetTLV_.Pz()*superJetTLV.Pz() )/superJetTLV.P() ) < min_pp)
{
min_boost = beta_cand;
min_pp = abs( ( superJetTLV_.Px()*superJetTLV.Px()+superJetTLV_.Py()*superJetTLV.Py() +superJetTLV_.Pz()*superJetTLV.Pz() )/superJetTLV.P() ) ;
}
}
return min_boost;
}
double calc_mass(std::vector<TLorentzVector> candSuperJet)
{
double px_tot = 0., py_tot = 0., pz_tot= 0.,E_tot = 0.;
for(auto _iJet = candSuperJet.begin(); _iJet!=candSuperJet.end();_iJet++)
{
px_tot+=_iJet->Px();py_tot+=_iJet->Py();pz_tot+=_iJet->Pz();E_tot+=_iJet->E();
}
return sqrt(pow(E_tot,2) - pow(px_tot,2) - pow(py_tot,2) - pow(pz_tot,2));
}
bool isMatchedtoSJ(std::vector<TLorentzVector> superJetTLVs, TLorentzVector candJet)
{
for(auto iJet = superJetTLVs.begin(); iJet!=superJetTLVs.end(); iJet++)
{
if( abs(candJet.Angle(iJet->Vect())) < 0.001) return true;
}
return false;
}
bool fillSJVars(std::map<std::string, float> &treeVars, std::vector<fastjet::PseudoJet> iSJ )
{
int nSuperJets = 0;
double superJetpx=0,superJetpy=0,superJetpz=0,superJetE=0;
for(auto iP = iSJ.begin();iP != iSJ.end();iP++)
{
superJetpx+=iP->px();superJetpy+=iP->py();superJetpz+=iP->pz();superJetE +=iP->E();
}
TLorentzVector superJetTLV(superJetpx,superJetpy,superJetpz,superJetE); //Lorentz vector representing jet axis -> now minimize the parallel momentum
//boost COM
std::vector<fastjet::PseudoJet> boostedSuperJetPart;
//boost particles in SuperJet to COM frame
for(auto iP = iSJ.begin();iP != iSJ.end();iP++)
{
TLorentzVector iP_(iP->px(),iP->py(),iP->pz(),iP->E());
iP_.Boost(-superJetTLV.Px()/superJetTLV.E(),-superJetTLV.Py()/superJetTLV.E(),-superJetTLV.Pz()/superJetTLV.E());
boostedSuperJetPart.push_back(fastjet::PseudoJet(iP_.Px(),iP_.Py(),iP_.Pz(),iP_.E()));
}
///////////get a bunch of versions of SJ particle collection to calclate BES variables
std::vector<TLorentzVector> boostedSuperJetPart_TLV;
std::vector<reco::LeafCandidate> boostedSuperJetPart_LC;
std::vector<math::XYZVector> boostedSuperJetPart_XYZ;
double sumPz = 0, sumP = 0;
for(auto iP_= boostedSuperJetPart.begin(); iP_ !=boostedSuperJetPart.end(); iP_++)
{
boostedSuperJetPart_TLV.push_back(TLorentzVector(iP_->px(),iP_->py(),iP_->pz(),iP_->E()));
boostedSuperJetPart_LC.push_back(reco::LeafCandidate(+1, reco::Candidate::LorentzVector(iP_->px(),iP_->py(),iP_->pz(),iP_->E())));
boostedSuperJetPart_XYZ.push_back(math::XYZVector( iP_->px(),iP_->py(),iP_->pz() ));
sumPz += iP_->pz();
sumP += abs(sqrt(pow(iP_->pz(),2) + pow(iP_->px(),2)+ pow(iP_->py(),2)));
}
///reclustering SuperJet that is now boosted into the SJ COM frame
double R = 0.4;
//fastjet::JetDefinition jet_def(fastjet::antikt_algorithm, R);
fastjet::JetDefinition jet_def(fastjet::cambridge_algorithm, R);
fastjet::ClusterSequence cs_jet(boostedSuperJetPart, jet_def);
std::vector<fastjet::PseudoJet> jetsFJ_jet = fastjet::sorted_by_E(cs_jet.inclusive_jets(0.0));
double SJ_25_px = 0, SJ_25_py=0,SJ_25_pz=0,SJ_25_E=0;
double SJ_50_px = 0, SJ_50_py=0,SJ_50_pz=0,SJ_50_E=0;
double SJ_100_px = 0, SJ_100_py=0,SJ_100_pz=0,SJ_100_E=0;
double SJ_150_px = 0, SJ_150_py=0,SJ_150_pz=0,SJ_150_E=0;
double SJ_200_px = 0, SJ_200_py=0,SJ_200_pz=0,SJ_200_E=0;
double SJ_300_px = 0, SJ_300_py=0,SJ_300_pz=0,SJ_300_E=0;
int SJ_nAK4_25_ = 0;
int SJ_nAK4_50_ = 0,SJ_nAK4_100_ = 0,SJ_nAK4_150_ = 0,SJ_nAK4_200_ = 0,SJ_nAK4_300_ = 0;
std::vector<TLorentzVector> AK41_parts;
std::vector<TLorentzVector> AK42_parts;
std::vector<TLorentzVector> AK43_parts;
std::vector<TLorentzVector> AK44_parts;
double AK41_px = 0, AK41_py=0,AK41_pz = 0, AK41_E = 0;
double AK42_px = 0, AK42_py=0,AK42_pz = 0, AK42_E = 0;
double AK43_px = 0, AK43_py=0,AK43_pz = 0, AK43_E = 0;
double AK44_px = 0, AK44_py=0,AK44_pz = 0, AK44_E = 0;
if (jetsFJ_jet.size() < 4)
{
std::cout << "A pseudojet vector has a size smaller than 4 - not reclustering many jets from whole pool of particles - " << jetsFJ_jet.size() << std::endl;
return false;
}
int pseudoJetNum = 0;
for (auto iPJ=jetsFJ_jet.begin(); iPJ<jetsFJ_jet.end(); iPJ++)
{
// do calculations of AK4 btagged particle ratios for leading 4 AK4 jets
std::vector<fastjet::PseudoJet> iPJ_daughters = iPJ->constituents();
if(pseudoJetNum == 0)
{
for(auto iPart = iPJ_daughters.begin(); iPart != iPJ_daughters.end(); iPart++)
{
AK41_parts.push_back(TLorentzVector(iPart->px(),iPart->py(),iPart->pz(),iPart->E()));
AK41_px+=iPart->px();AK41_py+=iPart->py();AK41_pz+=iPart->pz();AK41_E+=iPart->E();
}
}
else if(pseudoJetNum == 1)
{
for(auto iPart = iPJ_daughters.begin(); iPart != iPJ_daughters.end(); iPart++)
{
AK42_parts.push_back(TLorentzVector(iPart->px(),iPart->py(),iPart->pz(),iPart->E()));
AK42_px+=iPart->px();AK42_py+=iPart->py();AK42_pz+=iPart->pz();AK42_E+=iPart->E();
}
}
else if(pseudoJetNum == 2)
{
for(auto iPart = iPJ_daughters.begin(); iPart != iPJ_daughters.end(); iPart++)
{
AK43_parts.push_back(TLorentzVector(iPart->px(),iPart->py(),iPart->pz(),iPart->E()));
AK43_px+=iPart->px();AK43_py+=iPart->py();AK43_pz+=iPart->pz();AK43_E+=iPart->E();
}
}
else if(pseudoJetNum == 3)
{
for(auto iPart = iPJ_daughters.begin(); iPart != iPJ_daughters.end(); iPart++)
{
AK44_parts.push_back(TLorentzVector(iPart->px(),iPart->py(),iPart->pz(),iPart->E()));
AK44_px+=iPart->px();AK44_py+=iPart->py();AK44_pz+=iPart->pz();AK44_E+=iPart->E();
}
}
if(iPJ->E()>25.)
{
SJ_25_px+=iPJ->px();SJ_25_py+=iPJ->py();SJ_25_pz+=iPJ->pz();SJ_25_E+=iPJ->E();
SJ_nAK4_25_++;
}
if(iPJ->E()>50.)
{
SJ_50_px+=iPJ->px();SJ_50_py+=iPJ->py();SJ_50_pz+=iPJ->pz();SJ_50_E+=iPJ->E();
SJ_nAK4_50_++;
}
if(iPJ->E()>100)
{
SJ_100_px+=iPJ->px();SJ_100_py+=iPJ->py();SJ_100_pz+=iPJ->pz();SJ_100_E+=iPJ->E();
SJ_nAK4_100_++;
}
if(iPJ->E()>150)
{
SJ_150_px+=iPJ->px();SJ_150_py+=iPJ->py();SJ_150_pz+=iPJ->pz();SJ_150_E+=iPJ->E();
SJ_nAK4_150_++;
}
if(iPJ->E()>200)
{
SJ_200_px+=iPJ->px();SJ_200_py+=iPJ->py();SJ_200_pz+=iPJ->pz();SJ_200_E+=iPJ->E();
SJ_nAK4_200_++;
}
if(iPJ->E()>300)
{
SJ_300_px+=iPJ->px();SJ_300_py+=iPJ->py();SJ_300_pz+=iPJ->pz();SJ_300_E+=iPJ->E();
SJ_nAK4_300_++;
}
pseudoJetNum++;
}
boostedSuperJetPart.clear(); //shouldn't be needed, just in case
/////annoying process of getting the BES information for the reclustered AK4 jets
TVector3 AK41_boost(AK41_px/AK41_E,AK41_py/AK41_E,AK41_pz/AK41_E);
TVector3 AK42_boost(AK42_px/AK42_E,AK42_py/AK42_E,AK42_pz/AK42_E);
TVector3 AK43_boost(AK43_px/AK43_E,AK43_py/AK43_E,AK43_pz/AK43_E);
TVector3 AK44_boost(AK44_px/AK44_E,AK44_py/AK44_E,AK44_pz/AK44_E);
std::vector<TLorentzVector> boostedAK41_Part_TLV;
std::vector<reco::LeafCandidate> boostedAK41_Part_LC;
std::vector<math::XYZVector> boostedAK41_Part_XYZ;
std::vector<TLorentzVector> boostedAK42_Part_TLV;
std::vector<reco::LeafCandidate> boostedAK42_Part_LC;
std::vector<math::XYZVector> boostedAK42_Part_XYZ;
std::vector<TLorentzVector> boostedAK43_Part_TLV;
std::vector<reco::LeafCandidate> boostedAK43_Part_LC;
std::vector<math::XYZVector> boostedAK43_Part_XYZ;
std::vector<TLorentzVector> boostedAK44_Part_TLV;
std::vector<reco::LeafCandidate> boostedAK44_Part_LC;
std::vector<math::XYZVector> boostedAK44_Part_XYZ;
double sumPz_AK41 =0,sumPz_AK42 = 0,sumPz_AK43 = 0,sumPz_AK44 = 0;
double sumP_AK41 = 0,sumP_AK42 = 0,sumP_AK43 = 0, sumP_AK44 = 0;
for(auto iP = AK41_parts.begin(); iP != AK41_parts.end(); iP++)
{
iP->Boost(-AK41_boost.X(),-AK41_boost.Y(), -AK41_boost.Z());
boostedAK41_Part_TLV.push_back(TLorentzVector(iP->Px(),iP->Py(),iP->Pz(),iP->E()));
boostedAK41_Part_LC.push_back(reco::LeafCandidate(+1, reco::Candidate::LorentzVector(iP->Px(),iP->Py(),iP->Pz(),iP->E())));
boostedAK41_Part_XYZ.push_back(math::XYZVector( iP->Px(),iP->Py(),iP->Pz() ));
sumPz_AK41+=iP->Pz(); sumP_AK41+= abs(iP->P());
}
for(auto iP = AK42_parts.begin(); iP != AK42_parts.end(); iP++)
{
iP->Boost(-AK42_boost.X(),-AK42_boost.Y(), -AK42_boost.Z());
boostedAK42_Part_TLV.push_back(TLorentzVector(iP->Px(),iP->Py(),iP->Pz(),iP->E()));
boostedAK42_Part_LC.push_back(reco::LeafCandidate(+1, reco::Candidate::LorentzVector(iP->Px(),iP->Py(),iP->Pz(),iP->E())));
boostedAK42_Part_XYZ.push_back(math::XYZVector( iP->Px(),iP->Py(),iP->Pz() ));
sumPz_AK42+=iP->Pz(); sumP_AK42+= abs(iP->P());
}
for(auto iP = AK43_parts.begin(); iP != AK43_parts.end(); iP++)
{
iP->Boost(-AK43_boost.X(),-AK43_boost.Y(), -AK43_boost.Z());
boostedAK43_Part_TLV.push_back(TLorentzVector(iP->Px(),iP->Py(),iP->Pz(),iP->E()));
boostedAK43_Part_LC.push_back(reco::LeafCandidate(+1, reco::Candidate::LorentzVector(iP->Px(),iP->Py(),iP->Pz(),iP->E())));
boostedAK43_Part_XYZ.push_back(math::XYZVector( iP->Px(),iP->Py(),iP->Pz() ));
sumPz_AK43 += iP->Pz(); sumP_AK43 += abs(iP->P());
}
for(auto iP = AK44_parts.begin(); iP != AK44_parts.end(); iP++)
{
iP->Boost(-AK44_boost.X(),-AK44_boost.Y(), -AK44_boost.Z());
boostedAK44_Part_TLV.push_back(TLorentzVector(iP->Px(),iP->Py(),iP->Pz(),iP->E()));
boostedAK44_Part_LC.push_back(reco::LeafCandidate(+1, reco::Candidate::LorentzVector(iP->Px(),iP->Py(),iP->Pz(),iP->E())));
boostedAK44_Part_XYZ.push_back(math::XYZVector( iP->Px(),iP->Py(),iP->Pz() ));
sumPz_AK44 += iP->Pz(); sumP_AK44 += abs(iP->P());
}
////vectors to get angles
TVector3 AK4_jet1(jetsFJ_jet[0].px(),jetsFJ_jet[0].py(),jetsFJ_jet[0].pz());
TVector3 AK4_jet2(jetsFJ_jet[1].px(),jetsFJ_jet[1].py(),jetsFJ_jet[1].pz());
TVector3 AK4_jet3(jetsFJ_jet[2].px(),jetsFJ_jet[2].py(),jetsFJ_jet[2].pz());
TVector3 AK4_jet4(jetsFJ_jet[3].px(),jetsFJ_jet[3].py(),jetsFJ_jet[3].pz());
//fill superjet variables here ...
//SJ mass variables
treeVars["SJ_mass"] = sqrt(pow(superJetE,2)-pow(superJetpx,2)-pow(superJetpy,2)-pow(superJetpz,2));
treeVars["SJ_mass_25"] = sqrt(pow(SJ_25_E,2)-pow(SJ_25_px,2)-pow(SJ_25_py,2)-pow(SJ_25_pz,2));
treeVars["SJ_mass_50"] = sqrt(pow(SJ_50_E,2)-pow(SJ_50_px,2)-pow(SJ_50_py,2)-pow(SJ_50_pz,2));
treeVars["SJ_mass_100"] = sqrt(pow(SJ_100_E,2)-pow(SJ_100_px,2)-pow(SJ_100_py,2)-pow(SJ_100_pz,2));
treeVars["SJ_mass_150"] = sqrt(pow(SJ_150_E,2)-pow(SJ_150_px,2)-pow(SJ_150_py,2)-pow(SJ_150_pz,2));
treeVars["SJ_mass_200"] = sqrt(pow(SJ_200_E,2)-pow(SJ_200_px,2)-pow(SJ_200_py,2)-pow(SJ_200_pz,2));
treeVars["SJ_mass_300"] = sqrt(pow(SJ_300_E,2)-pow(SJ_300_px,2)-pow(SJ_300_py,2)-pow(SJ_300_pz,2));
//SJ nAK4 variables
treeVars["SJ_nAK4_25"] = SJ_nAK4_25_;
treeVars["SJ_nAK4_50"] = SJ_nAK4_50_;
treeVars["SJ_nAK4_100"] = SJ_nAK4_100_;
treeVars["SJ_nAK4_150"] = SJ_nAK4_150_;
treeVars["SJ_nAK4_200"] = SJ_nAK4_200_;
treeVars["SJ_nAK4_300"] = SJ_nAK4_300_;
//softdrop mass???
//bjet particle percentages
//AK4 jet mass combinations
treeVars["AK4_m1"] = jetsFJ_jet[0].m();
treeVars["AK4_m2"] = jetsFJ_jet[1].m();
treeVars["AK4_m3"] = jetsFJ_jet[2].m();
treeVars["AK4_m4"] = jetsFJ_jet[3].m();
treeVars["AK41_E"] = jetsFJ_jet[0].E();
treeVars["AK42_E"] = jetsFJ_jet[1].E();
treeVars["AK43_E"] = jetsFJ_jet[2].E();
treeVars["AK44_E"] = jetsFJ_jet[3].E();
treeVars["AK4_m12"] = sqrt( pow(jetsFJ_jet[0].E() + jetsFJ_jet[1].E() ,2) - pow(jetsFJ_jet[0].px() + jetsFJ_jet[1].px(),2) - pow(jetsFJ_jet[0].py() + jetsFJ_jet[1].py(),2)- pow(jetsFJ_jet[0].pz() + jetsFJ_jet[1].pz(),2));
treeVars["AK4_m13"] = sqrt( pow(jetsFJ_jet[0].E() + jetsFJ_jet[2].E() ,2) - pow(jetsFJ_jet[0].px() + jetsFJ_jet[2].px(),2) - pow(jetsFJ_jet[0].py() + jetsFJ_jet[2].py(),2)- pow(jetsFJ_jet[0].pz() + jetsFJ_jet[2].pz(),2));
treeVars["AK4_m14"] = sqrt( pow(jetsFJ_jet[0].E() + jetsFJ_jet[3].E() ,2) - pow(jetsFJ_jet[0].px() + jetsFJ_jet[3].px(),2) - pow(jetsFJ_jet[0].py() + jetsFJ_jet[3].py(),2)- pow(jetsFJ_jet[0].pz() + jetsFJ_jet[3].pz(),2));
treeVars["AK4_m23"] = sqrt( pow(jetsFJ_jet[2].E() + jetsFJ_jet[1].E() ,2) - pow(jetsFJ_jet[2].px() + jetsFJ_jet[1].px(),2) - pow(jetsFJ_jet[2].py() + jetsFJ_jet[1].py(),2)- pow(jetsFJ_jet[2].pz() + jetsFJ_jet[1].pz(),2));
treeVars["AK4_m24"] = sqrt( pow(jetsFJ_jet[3].E() + jetsFJ_jet[1].E() ,2) - pow(jetsFJ_jet[3].px() + jetsFJ_jet[1].px(),2) - pow(jetsFJ_jet[3].py() + jetsFJ_jet[1].py(),2)- pow(jetsFJ_jet[3].pz() + jetsFJ_jet[1].pz(),2));
treeVars["AK4_m34"] = sqrt( pow(jetsFJ_jet[2].E() + jetsFJ_jet[3].E() ,2) - pow(jetsFJ_jet[2].px() + jetsFJ_jet[3].px(),2) - pow(jetsFJ_jet[2].py() + jetsFJ_jet[3].py(),2)- pow(jetsFJ_jet[2].pz() + jetsFJ_jet[3].pz(),2));
treeVars["AK4_m123"] =sqrt( pow(jetsFJ_jet[0].E() + jetsFJ_jet[1].E() + jetsFJ_jet[2].E() ,2) - pow(jetsFJ_jet[0].px() + jetsFJ_jet[1].px() + jetsFJ_jet[2].px(),2) - pow(jetsFJ_jet[0].py() + jetsFJ_jet[1].py() + jetsFJ_jet[2].py(),2)- pow(jetsFJ_jet[0].pz() + jetsFJ_jet[1].pz() + jetsFJ_jet[2].pz(),2));
treeVars["AK4_m124"] =sqrt( pow(jetsFJ_jet[0].E() + jetsFJ_jet[1].E() + jetsFJ_jet[3].E() ,2) - pow(jetsFJ_jet[0].px() + jetsFJ_jet[1].px() + jetsFJ_jet[3].px(),2) - pow(jetsFJ_jet[0].py() + jetsFJ_jet[1].py() + jetsFJ_jet[3].py(),2)- pow(jetsFJ_jet[0].pz() + jetsFJ_jet[1].pz() + jetsFJ_jet[3].pz(),2));
treeVars["AK4_m134"] =sqrt( pow(jetsFJ_jet[0].E() + jetsFJ_jet[2].E() + jetsFJ_jet[3].E() ,2) - pow(jetsFJ_jet[0].px() + jetsFJ_jet[2].px() + jetsFJ_jet[3].px(),2) - pow(jetsFJ_jet[0].py() + jetsFJ_jet[2].py() + jetsFJ_jet[3].py(),2)- pow(jetsFJ_jet[0].pz() + jetsFJ_jet[2].pz() + jetsFJ_jet[3].pz(),2));
treeVars["AK4_m234"] =sqrt( pow(jetsFJ_jet[1].E() + jetsFJ_jet[2].E() + jetsFJ_jet[3].E() ,2) - pow(jetsFJ_jet[1].px() + jetsFJ_jet[2].px() + jetsFJ_jet[3].px(),2) - pow(jetsFJ_jet[1].py() + jetsFJ_jet[2].py() + jetsFJ_jet[3].py(),2)- pow(jetsFJ_jet[1].pz() + jetsFJ_jet[2].pz() + jetsFJ_jet[3].pz(),2));
treeVars["AK4_m1234"] =sqrt( pow(jetsFJ_jet[0].E() + jetsFJ_jet[1].E() + jetsFJ_jet[2].E()+jetsFJ_jet[3].E() ,2) - pow(jetsFJ_jet[0].px() + jetsFJ_jet[1].px() + jetsFJ_jet[2].px()+jetsFJ_jet[3].px(),2) - pow(jetsFJ_jet[0].py() + jetsFJ_jet[1].py() + jetsFJ_jet[2].py()+jetsFJ_jet[3].py(),2)- pow(jetsFJ_jet[0].pz() + jetsFJ_jet[1].pz() + jetsFJ_jet[2].pz()+jetsFJ_jet[3].pz(),2));
//AK4 jet angles
treeVars["AK4_theta12"] = abs(AK4_jet1.Angle(AK4_jet2));
treeVars["AK4_theta13"] = abs(AK4_jet1.Angle(AK4_jet3));
treeVars["AK4_theta14"] = abs(AK4_jet1.Angle(AK4_jet4));
treeVars["AK4_theta23"] = abs(AK4_jet2.Angle(AK4_jet3));
treeVars["AK4_theta24"] = abs(AK4_jet2.Angle(AK4_jet4));
treeVars["AK4_theta34"] = abs(AK4_jet3.Angle(AK4_jet4));
EventShapeVariables eventShapesAK41( boostedAK41_Part_XYZ );
Thrust thrustCalculatorAK41( boostedAK41_Part_LC.begin(), boostedAK41_Part_LC.end() );
double fwmAK41[5] = { 0.0, 0.0 ,0.0 ,0.0,0.0};
FWMoments( boostedAK41_Part_TLV, fwmAK41);
EventShapeVariables eventShapesAK42( boostedAK42_Part_XYZ );
Thrust thrustCalculatorAK42( boostedAK42_Part_LC.begin(), boostedAK42_Part_LC.end() );
double fwmAK42[5] = { 0.0, 0.0 ,0.0 ,0.0,0.0};
FWMoments( boostedAK42_Part_TLV, fwmAK42);
EventShapeVariables eventShapesAK43( boostedAK43_Part_XYZ );
Thrust thrustCalculatorAK43( boostedAK43_Part_LC.begin(), boostedAK43_Part_LC.end() );
double fwmAK43[5] = { 0.0, 0.0 ,0.0 ,0.0,0.0};
FWMoments( boostedAK43_Part_TLV, fwmAK43);
EventShapeVariables eventShapesAK44( boostedAK44_Part_XYZ );
Thrust thrustCalculatorAK44( boostedAK44_Part_LC.begin(), boostedAK44_Part_LC.end() );
double fwmAK44[5] = { 0.0, 0.0 ,0.0 ,0.0,0.0};
FWMoments( boostedAK44_Part_TLV, fwmAK44);
//AK4 jet boosted information - boost reclustered AK4 jets into their COM and look at BES variables, ndaughters, nsubjettiness
treeVars["AK41_ndaughters"] = jetsFJ_jet[0].constituents().size();
treeVars["AK41_nsubjets"] = jetsFJ_jet[0].n_exclusive_subjets(0.2);
treeVars["AK41_thrust"] = thrustCalculatorAK41.thrust();
treeVars["AK41_sphericity"] = eventShapesAK41.sphericity();
treeVars["AK41_asymmetry"] = sumPz_AK41/sumP_AK41;
treeVars["AK41_isotropy"] = eventShapesAK41.isotropy();
treeVars["AK41_aplanarity"] = eventShapesAK41.aplanarity();
treeVars["AK41_FW1"] = fwmAK41[1];
treeVars["AK41_FW2"] = fwmAK41[2];
treeVars["AK41_FW3"] = fwmAK41[3];
treeVars["AK41_FW4"] = fwmAK41[4];
treeVars["AK42_ndaughters"] = jetsFJ_jet[1].constituents().size();
treeVars["AK42_nsubjets"] = jetsFJ_jet[1].exclusive_subjets(0.2).size();
treeVars["AK42_thrust"] = thrustCalculatorAK42.thrust();
treeVars["AK42_sphericity"] = eventShapesAK42.sphericity();
treeVars["AK42_asymmetry"] = sumPz_AK42/sumP_AK42;
treeVars["AK42_isotropy"] = eventShapesAK42.isotropy();
treeVars["AK42_aplanarity"] = eventShapesAK42.aplanarity();
treeVars["AK42_FW1"] = fwmAK42[1];
treeVars["AK42_FW2"] = fwmAK42[2];
treeVars["AK42_FW3"] = fwmAK42[3];
treeVars["AK42_FW4"] = fwmAK42[4];
treeVars["AK43_ndaughters"] = jetsFJ_jet[2].constituents().size();
treeVars["AK43_nsubjets"] = jetsFJ_jet[2].exclusive_subjets(0.2).size();
treeVars["AK43_thrust"] = thrustCalculatorAK43.thrust();
treeVars["AK43_sphericity"] = eventShapesAK43.sphericity();
treeVars["AK43_asymmetry"] = sumPz_AK43/sumP_AK43;
treeVars["AK43_isotropy"] = eventShapesAK43.isotropy();
treeVars["AK43_aplanarity"] = eventShapesAK43.aplanarity();
treeVars["AK43_FW1"] = fwmAK43[1];
treeVars["AK43_FW2"] = fwmAK43[2];
treeVars["AK43_FW3"] = fwmAK43[3];
treeVars["AK43_FW4"] = fwmAK43[4];
//treeVars["AK44_ndaughters"] = jetsFJ_jet[3].constituents().size();
//treeVars["AK43_Tau32"] = ;
//treeVars["AK43_Tau21"] = ;
//treeVars["AK44_nsubjets"] = jetsFJ_jet[3].exclusive_subjets(0.2).size();
//treeVars["AK44_thrust"] = thrustCalculatorAK44.thrust();
//treeVars["AK44_sphericity"] = eventShapesAK44.sphericity();
//treeVars["AK44_asymmetry"] = sumPz_AK44/sumP_AK44;
//treeVars["AK44_isotropy"] = eventShapesAK44.isotropy();
//treeVars["AK44_aplanarity"] = eventShapesAK44.aplanarity();
//treeVars["AK44_FW1"] = fwmAK44[1];
//treeVars["AK44_FW2"] = fwmAK44[2];
//treeVars["AK44_FW3"] = fwmAK44[3];
//treeVars["AK44_FW4"] = fwmAK44[4];
//Full SJ BES variablesf
EventShapeVariables eventShapes( boostedSuperJetPart_XYZ );
Thrust thrustCalculator( boostedSuperJetPart_LC.begin(), boostedSuperJetPart_LC.end() );
double fwm[5] = { 0.0, 0.0 ,0.0 ,0.0,0.0};
FWMoments( boostedSuperJetPart_TLV, fwm);
treeVars["SJ_thrust"] = thrustCalculator.thrust();
treeVars["SJ_sphericity"] = eventShapes.sphericity();
treeVars["SJ_asymmetry"] = sumPz/sumP;
treeVars["SJ_isotropy"] = eventShapes.isotropy();
treeVars["SJ_aplanarity"] = eventShapes.aplanarity();
treeVars["SJ_FW1"] = fwm[1];
treeVars["SJ_FW2"] = fwm[2];
treeVars["SJ_FW3"] = fwm[3];
treeVars["SJ_FW4"] = fwm[4];
for (auto i = treeVars.begin(); i!=treeVars.end(); i++)
{
if ( (i->second != i->second ) || ( isinf(i->second ) ) )
{
//std::cout << "Skipped Event " << std::endl;
return false;
}
else if ( abs( i->second+999.99 ) < 1.0e-10 ) return false;
}
return true;
}