00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #include "fastjet/PseudoJet.hh"
00046
00047 #include "fastjet/ClusterSequenceArea.hh"
00048
00049 #include<iostream>
00050 #include<sstream>
00051 #include<vector>
00052
00053 using namespace std;
00054
00055
00056
00057 void print_jets (const fastjet::ClusterSequenceAreaBase &,
00058 const vector<fastjet::PseudoJet> &);
00059
00061 int main (int argc, char ** argv) {
00062
00063
00064
00065 vector<fastjet::PseudoJet> hard_event, full_event;
00066
00067
00068 double etamax = 6.0;
00069
00070
00071
00072
00073
00074 string line;
00075 int nsub = 0;
00076 while (getline(cin, line)) {
00077 istringstream linestream(line);
00078
00079
00080 if (line.substr(0,4) == "#END") {break;}
00081 if (line.substr(0,9) == "#SUBSTART") {
00082
00083 if (nsub == 1) hard_event = full_event;
00084 nsub += 1;
00085 }
00086 if (line.substr(0,1) == "#") {continue;}
00087 valarray<double> fourvec(4);
00088 linestream >> fourvec[0] >> fourvec[1] >> fourvec[2] >> fourvec[3];
00089 fastjet::PseudoJet psjet(fourvec);
00090 psjet.set_user_index(0);
00091
00092 if (abs(psjet.rap()) < etamax) {full_event.push_back(psjet);}
00093 }
00094
00095
00096 if (nsub == 1) hard_event = full_event;
00097
00098
00099 if (nsub == 0) {
00100 cerr << "Error: read empty event\n";
00101 exit(-1);
00102 }
00103
00104
00105
00106
00107 double R = 0.7;
00108 fastjet::Strategy strategy = fastjet::Best;
00109 fastjet::JetDefinition jet_def(fastjet::kt_algorithm, R, strategy);
00110
00111
00112
00113
00114 double ghost_etamax = 6.0;
00115 int active_area_repeats = 1;
00116 double ghost_area = 0.01;
00117 fastjet::ActiveAreaSpec area_spec(ghost_etamax, active_area_repeats,
00118 ghost_area);
00119 fastjet::AreaDefinition area_def(area_spec);
00120
00121
00122
00123 fastjet::ClusterSequenceArea clust_seq(hard_event, jet_def, area_def);
00124
00125
00126
00127
00128 double ptmin = 5.0;
00129 vector<fastjet::PseudoJet> inclusive_jets = clust_seq.inclusive_jets(ptmin);
00130
00131
00132 cout << "" <<endl;
00133 cout << "Hard event only"<<endl;
00134 cout << "Number of input particles: "<<hard_event.size()<<endl;
00135 cout << "Strategy used: "<<clust_seq.strategy_string()<<endl;
00136 cout << "Printing inclusive jets with pt > "<< ptmin<<" GeV\n";
00137 cout << "---------------------------------------\n";
00138 print_jets(clust_seq, inclusive_jets);
00139 cout << endl;
00140
00141
00142
00143
00144
00145
00146 fastjet::ClusterSequenceArea clust_seq_full(full_event, jet_def, area_def);
00147
00148
00149
00150 ptmin = 20.0;
00151 inclusive_jets = clust_seq_full.inclusive_jets(ptmin);
00152
00153
00154 cout << "Full event, with pileup, and its subtraction"<<endl;
00155 cout << "Number of input particles: "<<full_event.size()<<endl;
00156 cout << "Strategy used: "<<clust_seq_full.strategy_string()<<endl;
00157 cout << "Printing inclusive jets with pt > "<< ptmin<<" GeV (before subtraction)\n";
00158 cout << "---------------------------------------\n";
00159 print_jets(clust_seq_full, inclusive_jets);
00160 cout << endl;
00161
00162
00163 }
00164
00165
00166
00170 void print_jets (const fastjet::ClusterSequenceAreaBase & clust_seq,
00171 const vector<fastjet::PseudoJet> & unsorted_jets ) {
00172
00173
00174 vector<fastjet::PseudoJet> jets = sorted_by_pt(unsorted_jets);
00175
00176
00177 vector<fastjet::PseudoJet> corrected_jets(jets.size());
00178
00179
00180
00181
00182 double range = 5.0;
00183 double median_pt_per_area = clust_seq.median_pt_per_unit_area(range);
00184 double median_pt_per_area4vector = clust_seq.median_pt_per_unit_area_4vector(range);
00185
00186 printf(" ijet rap phi Pt area Pt corr (rap corr phi corr Pt corr)ext\n");
00187 for (size_t j = 0; j < jets.size(); j++) {
00188
00189
00190 double area = clust_seq.area(jets[j]);
00191
00192
00193 double pt_corr = jets[j].perp() - area*median_pt_per_area;
00194
00195
00196 fastjet::PseudoJet sub_4vect =
00197 median_pt_per_area4vector*clust_seq.area_4vector(jets[j]);
00198 if (sub_4vect.perp2() >= jets[j].perp2() ||
00199 sub_4vect.E() >= jets[j].E()) {
00200
00201 corrected_jets[j] = 0.0 * jets[j];
00202 } else {
00203
00204 corrected_jets[j] = jets[j] - sub_4vect;
00205 }
00206
00207
00208
00209
00210
00211 printf("%5u %7.3f %7.3f %9.3f %7.3f %9.3f %7.3f %7.3f %9.3f\n",
00212 j,jets[j].rap(),jets[j].phi(),jets[j].perp(), area, pt_corr,
00213 corrected_jets[j].rap(),corrected_jets[j].phi(), corrected_jets[j].perp());
00214 }
00215
00216 cout << endl;
00217 cout << "median pt_over_area = " << median_pt_per_area << endl;
00218 cout << "median pt_over_area4vector = " << median_pt_per_area4vector << endl << endl;
00219
00220
00221 }
00222
00223
00224
00225
00226
00227
00228