-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHEPTopTagger.cc
645 lines (573 loc) · 30.3 KB
/
HEPTopTagger.cc
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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
#include "HEPTopTagger.hh"
FASTJET_BEGIN_NAMESPACE
namespace HEPTopTagger
{
// optimal_R fit
double R_opt_calc_funct(double pt_filt)
{
return 327. / pt_filt;
}
bool HEPTopTagger_fixed_R::_first_time = true;
void HEPTopTagger_fixed_R::print_banner()
{
if (!_first_time)
{
return;
}
_first_time = false;
std::cout << " <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>" << std::endl;
std::cout << " <> HEPTopTagger 2.0 <>" << std::endl;
std::cout << " <> <>" << std::endl;
std::cout << " <> Please cite JHEP 1506 (2015) 203 [arXiv:1503.05921 [hep-ph]] <>" << std::endl;
std::cout << " <> and JHEP 1010 (2010) 078 [arXiv:1006.2833 [hep-ph]] <>" << std::endl;
std::cout << " <> This code is provided without warranty. <>" << std::endl;
std::cout << " <> <>" << std::endl;
std::cout << " <> For MadAnalysis 5 implementation <>" << std::endl;
std::cout << " <> please cite arXiv:2303.03427 [hep-ph] <>" << std::endl;
std::cout << " <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>" << std::endl;
}
// pt wrt a reference vector
double HEPTopTagger_fixed_R::perp(const fastjet::PseudoJet &vec, const fastjet::PseudoJet &ref)
{
double ref_ref = ref.px() * ref.px() + ref.py() * ref.py() + ref.pz() * ref.pz();
double vec_ref = vec.px() * ref.px() + vec.py() * ref.py() + vec.pz() * ref.pz();
double per_per = vec.px() * vec.px() + vec.py() * vec.py() + vec.pz() * vec.pz();
if (ref_ref > 0.)
per_per -= vec_ref * vec_ref / ref_ref;
if (per_per < 0.)
per_per = 0.;
return sqrt(per_per);
}
// modified Jade distance
double HEPTopTagger_fixed_R::djademod(const fastjet::PseudoJet &subjet_i, const fastjet::PseudoJet &subjet_j, const fastjet::PseudoJet &ref)
{
double dj = -1.0;
double delta_phi = subjet_i.delta_phi_to(subjet_j);
double delta_eta = subjet_i.eta() - subjet_j.eta();
double delta_R = sqrt(delta_eta * delta_eta + delta_phi * delta_phi);
dj = perp(subjet_i, ref) * perp(subjet_j, ref) * pow(delta_R, 4.);
return dj;
}
// minimal |(m_ij / m_123) / (m_w/ m_t) - 1|
double HEPTopTagger_fixed_R::f_rec()
{
double m12 = (_top_subs[0] + _top_subs[1]).m();
double m13 = (_top_subs[0] + _top_subs[2]).m();
double m23 = (_top_subs[1] + _top_subs[2]).m();
double m123 = (_top_subs[0] + _top_subs[1] + _top_subs[2]).m();
double fw12 = fabs((m12 / m123) / (_mwmass / _mtmass) - 1);
double fw13 = fabs((m13 / m123) / (_mwmass / _mtmass) - 1);
double fw23 = fabs((m23 / m123) / (_mwmass / _mtmass) - 1);
return std::min(fw12, std::min(fw13, fw23));
}
// find hard substructures
void HEPTopTagger_fixed_R::FindHardSubst(const PseudoJet &this_jet, std::vector<fastjet::PseudoJet> &t_parts)
{
PseudoJet parent1(0, 0, 0, 0), parent2(0, 0, 0, 0);
if (this_jet.m() < _max_subjet_mass || !this_jet.validated_cs()->has_parents(this_jet, parent1, parent2))
{
t_parts.push_back(this_jet);
}
else
{
if (parent1.m() < parent2.m())
std::swap(parent1, parent2);
FindHardSubst(parent1, t_parts);
if (parent1.m() < _mass_drop_threshold * this_jet.m())
FindHardSubst(parent2, t_parts);
}
}
// store subjets as vector<PseudoJet> with [0]->b [1]->W-jet 1 [2]->W-jet 2
void HEPTopTagger_fixed_R::store_topsubjets(const std::vector<PseudoJet> &top_subs)
{
_top_subjets.resize(0);
double m12 = (top_subs[0] + top_subs[1]).m();
double m13 = (top_subs[0] + top_subs[2]).m();
double m23 = (top_subs[1] + top_subs[2]).m();
double dm12 = fabs(m12 - _mwmass);
double dm13 = fabs(m13 - _mwmass);
double dm23 = fabs(m23 - _mwmass);
if (dm23 <= dm12 && dm23 <= dm13)
{
_top_subjets.push_back(top_subs[0]);
_top_subjets.push_back(top_subs[1]);
_top_subjets.push_back(top_subs[2]);
}
else if (dm13 <= dm12 && dm13 < dm23)
{
_top_subjets.push_back(top_subs[1]);
_top_subjets.push_back(top_subs[0]);
_top_subjets.push_back(top_subs[2]);
}
else if (dm12 < dm23 && dm12 < dm13)
{
_top_subjets.push_back(top_subs[2]);
_top_subjets.push_back(top_subs[0]);
_top_subjets.push_back(top_subs[1]);
}
_W = _top_subjets[1] + _top_subjets[2];
return;
}
// check mass plane cuts
bool HEPTopTagger_fixed_R::check_mass_criteria(const std::vector<PseudoJet> &top_subs) const
{
bool is_passed = false;
double m12 = (top_subs[0] + top_subs[1]).m();
double m13 = (top_subs[0] + top_subs[2]).m();
double m23 = (top_subs[1] + top_subs[2]).m();
double m123 = (top_subs[0] + top_subs[1] + top_subs[2]).m();
if (
(atan(m13 / m12) > _m13cutmin && _m13cutmax > atan(m13 / m12) && (m23 / m123 > _rmin && _rmax > m23 / m123)) ||
(((m23 / m123) * (m23 / m123) < 1 - _rmin * _rmin * (1 + (m13 / m12) * (m13 / m12))) &&
((m23 / m123) * (m23 / m123) > 1 - _rmax * _rmax * (1 + (m13 / m12) * (m13 / m12))) &&
(m23 / m123 > _m23cut)) ||
(((m23 / m123) * (m23 / m123) < 1 - _rmin * _rmin * (1 + (m12 / m13) * (m12 / m13))) &&
((m23 / m123) * (m23 / m123) > 1 - _rmax * _rmax * (1 + (m12 / m13) * (m12 / m13))) &&
(m23 / m123 > _m23cut)))
{
is_passed = true;
}
return is_passed;
}
double HEPTopTagger_fixed_R::nsub(fastjet::PseudoJet jet, int order, fastjet::contrib::Njettiness::AxesMode axes, double beta, double R0)
{
fastjet::contrib::Nsubjettiness nsub(order, axes, beta, R0);
return nsub.result(jet);
}
HEPTopTagger_fixed_R::HEPTopTagger_fixed_R() : _mass_drop_threshold(0.8), _max_subjet_mass(30.),
_mode(Mode(0)), _mtmass(172.9), _mwmass(80.379), _mtmin(150.), _mtmax(200.), _rmin(0.85 * 80.379 / 172.9), _rmax(1.15 * 80.379 / 172.9),
_m23cut(0.35), _m13cutmin(0.2), _m13cutmax(1.3), _minpt_tag(200.),
_nfilt(5), _Rfilt(0.3), _jet_algorithm_filter(fastjet::cambridge_algorithm), _minpt_subjet(0.),
_jet_algorithm_recluster(fastjet::cambridge_algorithm),
_zcut(0.1), _rcut_factor(0.5),
_debug(false)
{
_djsum = 0.;
_delta_top = 1000000000000.0;
_pruned_mass = 0.;
_unfiltered_mass = 0.;
_top_candidate.reset(0., 0., 0., 0.);
_parts_size = 0;
_is_maybe_top = _is_masscut_passed = _is_ptmincut_passed = false;
_top_subs.clear();
_top_subjets.clear();
_top_hadrons.clear();
_top_parts.clear();
}
HEPTopTagger_fixed_R::HEPTopTagger_fixed_R(const fastjet::PseudoJet jet) : _jet(jet), _initial_jet(jet),
_mass_drop_threshold(0.8), _max_subjet_mass(30.),
_mode(Mode(0)), _mtmass(172.9), _mwmass(80.379), _mtmin(150.), _mtmax(200.), _rmin(0.85 * 80.379 / 172.9), _rmax(1.15 * 80.379 / 172.9),
_m23cut(0.35), _m13cutmin(0.2), _m13cutmax(1.3), _minpt_tag(200.),
_nfilt(5), _Rfilt(0.3), _jet_algorithm_filter(fastjet::cambridge_algorithm), _minpt_subjet(0.),
_jet_algorithm_recluster(fastjet::cambridge_algorithm),
_zcut(0.1), _rcut_factor(0.5),
_fat(jet),
_debug(false)
{
}
HEPTopTagger_fixed_R::HEPTopTagger_fixed_R(const fastjet::PseudoJet jet,
double mtmass, double mwmass) : _jet(jet), _initial_jet(jet),
_mass_drop_threshold(0.8), _max_subjet_mass(30.),
_mode(Mode(0)), _mtmass(mtmass), _mwmass(mwmass), _rmin(0.85 * 80.379 / 172.9), _rmax(1.15 * 80.379 / 172.9),
_m23cut(0.35), _m13cutmin(0.2), _m13cutmax(1.3), _minpt_tag(200.),
_nfilt(5), _Rfilt(0.3), _jet_algorithm_filter(fastjet::cambridge_algorithm), _minpt_subjet(0.),
_jet_algorithm_recluster(fastjet::cambridge_algorithm),
_zcut(0.1), _rcut_factor(0.5),
_fat(jet),
_debug(false)
{
}
void HEPTopTagger_fixed_R::run()
{
print_banner();
if ((_mode != EARLY_MASSRATIO_SORT_MASS) && (_mode != LATE_MASSRATIO_SORT_MASS) && (_mode != EARLY_MASSRATIO_SORT_MODDJADE) && (_mode != LATE_MASSRATIO_SORT_MODDJADE) && (_mode != TWO_STEP_FILTER))
{
std::cout << "ERROR: UNKNOWN MODE" << std::endl;
return;
}
// initialization
_djsum = 0.;
_delta_top = 1000000000000.0;
_pruned_mass = 0.;
_unfiltered_mass = 0.;
_top_candidate.reset(0., 0., 0., 0.);
_parts_size = 0;
_is_maybe_top = _is_masscut_passed = _is_ptmincut_passed = false;
_top_subs.clear();
_top_subjets.clear();
_top_hadrons.clear();
_top_parts.clear();
// find hard substructures
FindHardSubst(_jet, _top_parts);
if (_top_parts.size() < 3)
{
if (_debug)
{
std::cout << "< 3 hard substructures " << std::endl;
}
return; // such events are not interesting
}
// Sort subjets-after-unclustering by pT.
// Necessary so that two-step-filtering can use the leading-three.
_top_parts = sorted_by_pt(_top_parts);
// loop over triples
_top_parts = sorted_by_pt(_top_parts);
for (unsigned rr = 0; rr < _top_parts.size(); rr++)
{
for (unsigned ll = rr + 1; ll < _top_parts.size(); ll++)
{
for (unsigned kk = ll + 1; kk < _top_parts.size(); kk++)
{
// two-step filtering
// This means that we only look at the triplet formed by the
// three leading-in-pT subjets-after-unclustering.
if ((_mode == TWO_STEP_FILTER) && rr > 0)
continue;
if ((_mode == TWO_STEP_FILTER) && ll > 1)
continue;
if ((_mode == TWO_STEP_FILTER) && kk > 2)
continue;
// pick triple
PseudoJet triple = join(_top_parts[rr], _top_parts[ll], _top_parts[kk]);
// filtering
double filt_top_R = std::min(_Rfilt, 0.5 * sqrt(std::min(_top_parts[kk].squared_distance(_top_parts[ll]),
std::min(_top_parts[rr].squared_distance(_top_parts[ll]),
_top_parts[kk].squared_distance(_top_parts[rr])))));
JetDefinition filtering_def(_jet_algorithm_filter, filt_top_R);
fastjet::Filter filter(filtering_def, fastjet::SelectorNHardest(_nfilt) * fastjet::SelectorPtMin(_minpt_subjet));
PseudoJet topcandidate = filter(triple);
// mass window cut
if (topcandidate.m() < _mtmin || _mtmax < topcandidate.m())
continue;
// Sanity cut: can't recluster less than 3 objects into three subjets
if (topcandidate.pieces().size() < 3)
continue;
// Recluster to 3 subjets and apply mass plane cuts
JetDefinition reclustering(_jet_algorithm_recluster, 3.14);
ClusterSequence *cs_top_sub = new ClusterSequence(topcandidate.pieces(), reclustering);
std::vector<PseudoJet> top_subs = sorted_by_pt(cs_top_sub->exclusive_jets(3));
cs_top_sub->delete_self_when_unused();
// Require the third subjet to be above the pT threshold
if (top_subs[2].perp() < _minpt_subjet)
continue;
// Modes with early 2d-massplane cuts
if (_mode == EARLY_MASSRATIO_SORT_MASS && !check_mass_criteria(top_subs))
{
continue;
}
if (_mode == EARLY_MASSRATIO_SORT_MODDJADE && !check_mass_criteria(top_subs))
{
continue;
}
// is this candidate better than the other? -> update
double deltatop = fabs(topcandidate.m() - _mtmass);
double djsum = djademod(top_subs[0], top_subs[1], topcandidate) + djademod(top_subs[0], top_subs[2], topcandidate) + djademod(top_subs[1], top_subs[2], topcandidate);
bool better = false;
// Modes 0 and 1 sort by top mass
if ((_mode == EARLY_MASSRATIO_SORT_MASS) || (_mode == LATE_MASSRATIO_SORT_MASS))
{
if (deltatop < _delta_top)
better = true;
}
// Modes 2 and 3 sort by modified jade distance
else if ((_mode == EARLY_MASSRATIO_SORT_MODDJADE) || (_mode == LATE_MASSRATIO_SORT_MODDJADE))
{
if (djsum > _djsum)
better = true;
}
// Mode 4 is the two-step filtering. No sorting necessary as
// we just look at the triplet of highest pT objects after
// unclustering
else if (_mode == TWO_STEP_FILTER)
{
better = true;
}
else
{
std::cout << "ERROR: UNKNOWN MODE (IN DISTANCE MEASURE SELECTION)" << std::endl;
return;
}
if (better)
{
_djsum = djsum;
_delta_top = deltatop;
_is_maybe_top = true;
_top_candidate = topcandidate;
_top_subs = top_subs;
store_topsubjets(top_subs);
_top_hadrons = topcandidate.constituents();
// Pruning
double _Rprun = _initial_jet.validated_cluster_sequence()->jet_def().R();
JetDefinition jet_def_prune(fastjet::cambridge_algorithm, _Rprun);
fastjet::Pruner pruner(jet_def_prune, _zcut, _rcut_factor);
PseudoJet prunedjet = pruner(triple);
_pruned_mass = prunedjet.m();
_unfiltered_mass = triple.m();
// are all criteria fulfilled?
_is_masscut_passed = false;
if (check_mass_criteria(top_subs))
{
_is_masscut_passed = true;
}
_is_ptmincut_passed = false;
if (_top_candidate.pt() > _minpt_tag)
{
_is_ptmincut_passed = true;
}
} // end better
} // end kk
} // end ll
} // end rr
return;
}
void HEPTopTagger_fixed_R::get_info() const
{
std::cout << "#--------------------------------------------------------------------------\n";
std::cout << "# HEPTopTagger Result" << std::endl;
std::cout << "#" << std::endl;
std::cout << "# is top candidate: " << _is_maybe_top << std::endl;
std::cout << "# mass plane cuts passed: " << _is_masscut_passed << std::endl;
std::cout << "# top candidate mass: " << _top_candidate.m() << std::endl;
std::cout << "# top candidate (pt, eta, phi): ("
<< _top_candidate.perp() << ", "
<< _top_candidate.eta() << ", "
<< _top_candidate.phi_std() << ")" << std::endl;
std::cout << "# top hadrons: " << _top_hadrons.size() << std::endl;
std::cout << "# hard substructures: " << _parts_size << std::endl;
std::cout << "# |m - mtop| : " << _delta_top << std::endl;
std::cout << "# djsum : " << _djsum << std::endl;
std::cout << "# is consistency cut passed: " << _is_ptmincut_passed << std::endl;
std::cout << "#--------------------------------------------------------------------------\n";
return;
}
void HEPTopTagger::get_setting() const
{
std::cout << "#--------------------------------------------------------------------------\n";
std::cout << "# HEPTopTagger Settings" << std::endl;
std::cout << "#" << std::endl;
std::cout << "# mode: " << _mode << " (0 = EARLY_MASSRATIO_SORT_MASS) " << std::endl;
std::cout << "# "
<< " (1 = LATE_MASSRATIO_SORT_MASS) " << std::endl;
std::cout << "# "
<< " (2 = EARLY_MASSRATIO_SORT_MODDJADE) " << std::endl;
std::cout << "# "
<< " (3 = LATE_MASSRATIO_SORT_MODDJADE) " << std::endl;
std::cout << "# "
<< " (4 = TWO_STEP_FILTER) " << std::endl;
std::cout << "# top mass: " << _mtmass << " ";
std::cout << "W mass: " << _mwmass << std::endl;
std::cout << "# top mass window: [" << _mtmin << ", " << _mtmax << "]" << std::endl;
std::cout << "# W mass ratio: [" << _rmin << ", " << _rmax << "] (["
<< _rmin * _mtmass / _mwmass << "%, " << _rmax * _mtmass / _mwmass << "%])" << std::endl;
std::cout << "# mass plane cuts: (m23cut, m13min, m13max) = ("
<< _m23cut << ", " << _m13cutmin << ", " << _m13cutmax << ")" << std::endl;
std::cout << "# mass_drop_threshold: " << _mass_drop_threshold << " ";
std::cout << "max_subjet_mass: " << _max_subjet_mass << std::endl;
std::cout << "# R_filt: " << _Rfilt << " ";
std::cout << "n_filt: " << _nfilt << std::endl;
std::cout << "# minimal subjet pt: " << _minpt_subjet << std::endl;
std::cout << "# minimal reconstructed pt: " << _minpt_tag << std::endl;
std::cout << "# internal jet algorithms (0 = kt, 1 = C/A, 2 = anti-kt): " << std::endl;
std::cout << "# filtering: " << _jet_algorithm_filter << std::endl;
std::cout << "# reclustering: " << _jet_algorithm_recluster << std::endl;
std::cout << "#--------------------------------------------------------------------------\n";
return;
}
// uncluster a fat jet to subjets of given cone size
void HEPTopTagger::UnclusterFatjets(const vector<fastjet::PseudoJet> &big_fatjets,
vector<fastjet::PseudoJet> &small_fatjets,
const ClusterSequence &cseq,
const double small_radius)
{
for (unsigned i = 0; i < big_fatjets.size(); i++)
{
PseudoJet this_jet = big_fatjets[i];
PseudoJet parent1(0, 0, 0, 0), parent2(0, 0, 0, 0);
bool test = cseq.has_parents(this_jet, parent1, parent2);
double dR = 100;
if (test)
dR = sqrt(parent1.squared_distance(parent2));
if (!test || dR < small_radius)
{
small_fatjets.push_back(this_jet);
}
else
{
vector<fastjet::PseudoJet> parents;
parents.push_back(parent1);
parents.push_back(parent2);
UnclusterFatjets(parents, small_fatjets, cseq, small_radius);
}
}
}
HEPTopTagger::HEPTopTagger() : _do_optimalR(1),
_mass_drop_threshold(0.8), _max_subjet_mass(30.),
_mode(Mode(0)), _mtmass(172.9), _mwmass(80.379), _mtmin(150.), _mtmax(200.), _rmin(0.85 * 80.379 / 172.9), _rmax(1.15 * 80.379 / 172.9),
_m23cut(0.35), _m13cutmin(0.2), _m13cutmax(1.3), _minpt_tag(200.),
_nfilt(5), _Rfilt(0.3), _jet_algorithm_filter(fastjet::cambridge_algorithm), _minpt_subjet(0.),
_jet_algorithm_recluster(fastjet::cambridge_algorithm),
_zcut(0.1), _rcut_factor(0.5),
_max_fatjet_R(1.8), _min_fatjet_R(0.5), _step_R(0.1), _optimalR_threshold(0.2),
_R_filt_optimalR_calc(0.2), _N_filt_optimalR_calc(10), _r_min_exp_function(&R_opt_calc_funct),
_optimalR_mmin(150.), _optimalR_mmax(200.), _optimalR_fw(0.175), _R_opt_diff(0.3),
_R_filt_optimalR_pass(0.2), _N_filt_optimalR_pass(5), _R_filt_optimalR_fail(0.3), _N_filt_optimalR_fail(3),
_debug(false)
{
}
HEPTopTagger::HEPTopTagger(double mtmass, double mwmass) : _do_optimalR(1),
_mass_drop_threshold(0.8), _max_subjet_mass(30.),
_mode(Mode(0)), _mtmass(mtmass), _mwmass(mwmass), _mtmin(150.), _mtmax(200.), _rmin(0.85 * 80.379 / 172.9), _rmax(1.15 * 80.379 / 172.9),
_m23cut(0.35), _m13cutmin(0.2), _m13cutmax(1.3), _minpt_tag(200.),
_nfilt(5), _Rfilt(0.3), _jet_algorithm_filter(fastjet::cambridge_algorithm), _minpt_subjet(0.),
_jet_algorithm_recluster(fastjet::cambridge_algorithm),
_zcut(0.1), _rcut_factor(0.5),
_max_fatjet_R(1.8), _min_fatjet_R(0.5), _step_R(0.1), _optimalR_threshold(0.2),
_R_filt_optimalR_calc(0.2), _N_filt_optimalR_calc(10), _r_min_exp_function(&R_opt_calc_funct),
_optimalR_mmin(150.), _optimalR_mmax(200.), _optimalR_fw(0.175), _R_opt_diff(0.3),
_R_filt_optimalR_pass(0.2), _N_filt_optimalR_pass(5), _R_filt_optimalR_fail(0.3), _N_filt_optimalR_fail(3),
_debug(false)
{
}
void HEPTopTagger::run(const fastjet::PseudoJet &jet)
{
_initial_jet = jet;
_jet = jet;
_fat = jet;
// Max Jet radius needs to be equal to the fat jet radius.
_max_fatjet_R = jet.validated_cluster_sequence()->jet_def().R();
int maxR = int(_max_fatjet_R * 10);
int minR = int(_min_fatjet_R * 10);
int stepR = int(_step_R * 10);
if (!_do_optimalR)
{
HEPTopTagger_fixed_R htt(_jet);
htt.set_mass_drop_threshold(_mass_drop_threshold);
htt.set_max_subjet_mass(_max_subjet_mass);
htt.set_filtering_n(_nfilt);
htt.set_filtering_R(_Rfilt);
htt.set_filtering_minpt_subjet(_minpt_subjet);
htt.set_filtering_jetalgorithm(_jet_algorithm_filter);
htt.set_reclustering_jetalgorithm(_jet_algorithm_recluster);
htt.set_mode(_mode);
htt.set_mt(_mtmass);
htt.set_mw(_mwmass);
htt.set_top_mass_range(_mtmin, _mtmax);
htt.set_mass_ratio_range(_rmin, _rmax);
htt.set_mass_ratio_cut(_m23cut, _m13cutmin, _m13cutmax);
htt.set_top_minpt(_minpt_tag);
htt.set_pruning_zcut(_zcut);
htt.set_pruning_rcut_factor(_rcut_factor);
htt.set_debug(_debug);
htt.run();
_HEPTopTagger[maxR] = htt;
_Ropt = maxR;
_HEPTopTagger_opt = _HEPTopTagger[_Ropt];
}
else
{
const ClusterSequence *_seq;
_seq = _initial_jet.validated_cluster_sequence();
// Do optimalR procedure
vector<fastjet::PseudoJet> big_fatjets;
vector<fastjet::PseudoJet> small_fatjets;
big_fatjets.push_back(_jet);
_Ropt = 0;
for (int R = maxR; R >= minR; R -= stepR)
{
UnclusterFatjets(big_fatjets, small_fatjets, *_seq, R / 10.);
if (_debug)
{
cout << "R = " << R << " -> n_small_fatjets = " << small_fatjets.size() << endl;
}
_n_small_fatjets[R] = small_fatjets.size();
// We are sorting by pt - so start with a negative dummy
double dummy = -99999;
for (unsigned i = 0; i < small_fatjets.size(); i++)
{
HEPTopTagger_fixed_R htt(small_fatjets[i]);
htt.set_mass_drop_threshold(_mass_drop_threshold);
htt.set_max_subjet_mass(_max_subjet_mass);
htt.set_filtering_n(_nfilt);
htt.set_filtering_R(_Rfilt);
htt.set_filtering_minpt_subjet(_minpt_subjet);
htt.set_filtering_jetalgorithm(_jet_algorithm_filter);
htt.set_reclustering_jetalgorithm(_jet_algorithm_recluster);
htt.set_mode(_mode);
htt.set_mt(_mtmass);
htt.set_mw(_mwmass);
htt.set_top_mass_range(_mtmin, _mtmax);
htt.set_mass_ratio_range(_rmin, _rmax);
htt.set_mass_ratio_cut(_m23cut, _m13cutmin, _m13cutmax);
htt.set_top_minpt(_minpt_tag);
htt.set_pruning_zcut(_zcut);
htt.set_pruning_rcut_factor(_rcut_factor);
htt.set_debug(_debug);
htt.run();
if (htt.t().perp() > dummy)
{
dummy = htt.t().perp();
_HEPTopTagger[R] = htt;
}
} // End of loop over small_fatjets
// Only check if we have not found Ropt yet
if (_Ropt == 0 && R < maxR)
{
// If the new mass is OUTSIDE the window ..
if (_HEPTopTagger[R].t().m() < (1 - _optimalR_threshold) * _HEPTopTagger[maxR].t().m())
// .. set _Ropt to the previous mass
_Ropt = R + stepR;
}
big_fatjets = small_fatjets;
small_fatjets.clear();
} // End of loop over R
// if we did not find Ropt in the loop, pick the last value
if (_Ropt == 0 && _HEPTopTagger[maxR].t().m() > 0)
_Ropt = minR;
// for the case that there is no tag at all (< 3 hard substructures)
if (_Ropt == 0 && _HEPTopTagger[maxR].t().m() == 0)
_Ropt = maxR;
_HEPTopTagger_opt = _HEPTopTagger[_Ropt];
Filter filter_optimalR_calc(_R_filt_optimalR_calc, SelectorNHardest(_N_filt_optimalR_calc));
_R_opt_calc = _r_min_exp_function(filter_optimalR_calc(_fat).pt());
Filter filter_optimalR_pass(_R_filt_optimalR_pass, SelectorNHardest(_N_filt_optimalR_pass));
Filter filter_optimalR_fail(_R_filt_optimalR_fail, SelectorNHardest(_N_filt_optimalR_fail));
if (optimalR_type() == 1)
{
_filt_fat = filter_optimalR_pass(_fat);
}
else
{
_filt_fat = filter_optimalR_fail(_fat);
}
}
}
// optimal_R type
int HEPTopTagger::optimalR_type()
{
if (_HEPTopTagger_opt.t().m() < _optimalR_mmin || _HEPTopTagger_opt.t().m() > _optimalR_mmax)
{
return 0;
}
if (_HEPTopTagger_opt.f_rec() > _optimalR_fw)
{
return 0;
}
if (_Ropt / 10. - _R_opt_calc > _R_opt_diff)
{
return 0;
}
return 1;
}
double HEPTopTagger::nsub_unfiltered(int order, fastjet::contrib::Njettiness::AxesMode axes, double beta, double R0)
{
fastjet::contrib::Nsubjettiness nsub(order, axes, beta, R0);
return nsub.result(_fat);
}
double HEPTopTagger::nsub_filtered(int order, fastjet::contrib::Njettiness::AxesMode axes, double beta, double R0)
{
fastjet::contrib::Nsubjettiness nsub(order, axes, beta, R0);
return nsub.result(_filt_fat);
}
HEPTopTagger::~HEPTopTagger() {}
}
FASTJET_END_NAMESPACE