-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfastjetfatjet.cc
139 lines (114 loc) · 3.78 KB
/
fastjetfatjet.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
#include "fastjet/ClusterSequence.hh"
#include <iostream>
#include "fastjet/tools/Filter.hh"
#include "fastjet/tools/MassDropTagger.hh"
namespace fj = fastjet;
using namespace fastjet;
using namespace std;
extern "C" {
void fastjetfatjet_(const double * p, const int & npart,
const double & R, const double & palg, const double & ptmin,
double * f77jets, int & njets, int * f77jetvec, int & itagjet, double * f77mwjet,
bool & passcuts) {
// transfer p[4*ipart+0..3] -> input_particles[i]
vector<fj::PseudoJet> input_particles;
for (int i=0; i<npart; i++) {
valarray<double> mom(4); // mom[0..3]
for (int j=0;j<=3; j++) {
mom[j] = *(p++);
}
fj::PseudoJet psjet(mom);
input_particles.push_back(psjet);
// label input_particles entries
input_particles[i].set_user_index(i+1);
}
// prepare jet def and run fastjet
fj::JetDefinition jet_def;
if (palg == 1.0) {
jet_def = fj::JetDefinition(fj::kt_algorithm, R);
} else if (palg == 0.0) {
jet_def = fj::JetDefinition(fj::cambridge_algorithm, R);
} else if (palg == -1.0) {
jet_def = fj::JetDefinition(fj::antikt_algorithm, R);
} else {
jet_def = fj::JetDefinition(fj::genkt_algorithm, R, palg);
}
// perform clustering
fj::ClusterSequence cs(input_particles, jet_def);
// extract jets (pt-ordered)
vector<fj::PseudoJet> jets = sorted_by_pt(cs.inclusive_jets(ptmin));
njets = jets.size();
// initialize to 0
itagjet = -1;
passcuts = true ;
// find particles inside i-th jet
vector<fj::PseudoJet> *constit;
constit=new vector<fj::PseudoJet>[njets];
for(int i=0; i<njets; i++) {
constit[i] = cs.constituents(jets[i]);
for(int j=0; j<constit[i].size(); j++) {
*(f77jetvec + constit[i][j].user_index()-1) = i+1;
}
}
// GZ -- NEW STUFF AFTER HERE
double mw = 80.419;
double mmin = 1000000000;
PseudoJet fatjet;
double masswindow = 10;
double ptcut2 = 300*300;
double ptmin2 = 0;
// declare the tagger
double mcut = 0.67;
double ycut = 0.09;
MassDropTagger mdtagger(mcut, ycut);
vector<fj::PseudoJet> tagged_jets = mdtagger(jets);
// PseudoJet filtered_tagged_jet;
for(int i=0; i<njets; i++) {
if (tagged_jets[i] != 0){
// output filtered jet
vector<PseudoJet> pieces = tagged_jets[i].pieces();
double Rfilt = min(0.3, 0.5 * pieces[0].delta_R(pieces[1]));
PseudoJet filtered_tagged_jet = Filter(Rfilt, SelectorNHardest(3))(tagged_jets[i]);
// if (abs(filtered_tagged_jet.m2()-mw2) < mmin && filtered_tagged_jet.perp2() > ptcut2 ){
// mmin = abs(filtered_tagged_jet.m2()-mw2);
// fatjet = filtered_tagged_jet;
// itagjet = i;
// }
if (abs(sqrt(filtered_tagged_jet.m2())-mw) < masswindow
&& filtered_tagged_jet.perp2() > ptmin2
&& filtered_tagged_jet.perp2() > ptcut2){
ptmin2 = filtered_tagged_jet.perp2();
fatjet = filtered_tagged_jet;
itagjet = i;
}
}
}
if (itagjet == -1){
passcuts = false ;
}
// // now require jet to be in the 10 GeV mass window
// if( abs(fatjet.m2()-mw2) > masswindow2) {
// passcuts = false ;
// }
if (passcuts) {
// transfer jets -> f77jets[4*ijet+0..3]
for (int i=0; i<njets; i++) {
for (int j=0;j<=3; j++) {
*f77jets = jets[i][j];
f77jets++;
}
}
for (int j=0;j<=3; j++) {
*f77mwjet = fatjet[j];
//cout << "filt" << filtered_tagged_jet[j] << endl;
*f77mwjet++;
}
// to fortran convention (1...n) rather than (0...n-1)
itagjet=itagjet+1;
} // if passcuts
// cout << "passcuts" << passcuts << endl;
// END OF NEW STUFF
// clean up
delete [] constit;
}
}