79#include "fastjet/PseudoJet.hh"
80#include "fastjet/ClusterSequence.hh"
96inline double pow2(
const double x) {
return x*x;}
99int main (
int argc,
char ** argv) {
106 cmdline.int_val(
"-clever",
fj::Best)));
107 int repeat = cmdline.int_val(
"-repeat",1);
108 int combine = cmdline.int_val(
"-combine",1);
109 bool write = cmdline.present(
"-write");
110 bool unique_write = cmdline.present(
"-unique_write");
111 bool hydjet = cmdline.present(
"-hydjet");
112 double ktR = cmdline.double_val(
"-r",1.0);
113 double inclkt = cmdline.double_val(
"-incl",-1.0);
114 int excln = cmdline.int_val (
"-excln",-1);
115 double excld = cmdline.double_val(
"-excld",-1.0);
116 double etamax = cmdline.double_val(
"-etamax",1.0e305);
117 bool show_constituents = cmdline.present(
"-const");
118 bool massless = cmdline.present(
"-massless");
119 int nev = cmdline.int_val(
"-nev",1);
120 bool add_dense_coverage = cmdline.present(
"-dense");
126 if (cmdline.present(
"-cam")) {
132 if (!cmdline.all_options_used()) {cerr <<
133 "Error: some options were not recognized"<<endl;
137 for (
int iev = 0; iev < nev; iev++) {
138 vector<fj::PseudoJet> jets;
141 while (getline(cin, line)) {
143 istringstream linestream(line);
144 if (line ==
"#END") {
146 if (ndone == combine) {
break;}
148 if (line.substr(0,1) ==
"#") {
continue;}
149 valarray<double> fourvec(4);
154 int ii, istat,id,m1,m2,d1,d2;
156 linestream >> ii>> istat >>
id >> m1 >> m2 >> d1 >> d2
157 >> fourvec[0] >> fourvec[1] >> fourvec[2] >> mass;
160 fourvec[3] = sqrt(+pow2(fourvec[0])+pow2(fourvec[1])
161 +pow2(fourvec[2])+pow2(mass));
165 linestream >> fourvec[0] >> fourvec[1] >> fourvec[2];
166 fourvec[3] = sqrt(pow2(fourvec[0])+pow2(fourvec[1])+pow2(fourvec[2]));}
168 linestream >> fourvec[0] >> fourvec[1] >> fourvec[2] >> fourvec[3];
172 if (abs(psjet.rap()) < etamax) {jets.push_back(psjet);}
178 if (add_dense_coverage) {
183 for (
int iphi = 0; iphi<nphi; iphi++) {
184 for (
int ieta = -neta; ieta<neta+1; ieta++) {
185 double phi = (iphi+0.5) * (fj::twopi/nphi) + rand()*0.001/RAND_MAX;
186 double eta = ieta * (10.0/neta) + rand()*0.001/RAND_MAX;
187 kt = 0.0000001*(1+rand()*0.1/RAND_MAX);
188 double pminus = kt*exp(-eta);
189 double pplus = kt*exp(+eta);
190 double px = kt*sin(phi);
191 double py = kt*cos(phi);
193 fj::PseudoJet mom(px,py,0.5*(pplus-pminus),0.5*(pplus+pminus));
201 for (
int irepeat = 0; irepeat < repeat ; irepeat++) {
203 if (irepeat != 0) {
continue;}
204 cout <<
"iev "<<iev<<
": number of particles = "<< jets.size() << endl;
205 cout <<
"strategy used = "<< clust_seq.strategy_string()<< endl;
209 vector<fj::PseudoJet> jets =
sorted_by_pt(clust_seq.inclusive_jets(inclkt));
210 for (
size_t j = 0; j < jets.size(); j++) {
211 printf(
"%5u %15.8f %15.8f %15.8f\n",j,jets[j].rap(),jets[j].phi(),sqrt(jets[j].kt2()));
212 if (show_constituents) {
213 vector<fj::PseudoJet> const_jets = jets[j].constituents();
214 for (
size_t k = 0; k < const_jets.size(); k++) {
215 printf(
" jet%03u %15.8f %15.8f %15.8f\n",j,const_jets[k].rap(),
216 const_jets[k].phi(),sqrt(const_jets[k].kt2()));
224 vector<fj::PseudoJet> jets =
sorted_by_E(clust_seq.exclusive_jets(excln));
226 cout <<
"Printing "<<excln<<
" exclusive jets\n";
227 for (
size_t j = 0; j < jets.size(); j++) {
228 printf(
"%5u %15.8f %15.8f %15.8f\n",
230 j,jets[j].rap(),jets[j].phi(),jets[j].kt2());
235 vector<fj::PseudoJet> jets =
sorted_by_pt(clust_seq.exclusive_jets(excld));
236 cout <<
"Printing exclusive jets for d = "<<excld<<
"\n";
237 for (
size_t j = 0; j < jets.size(); j++) {
238 printf(
"%5u %15.8f %15.8f %15.8f\n",
239 j,jets[j].rap(),jets[j].phi(),sqrt(jets[j].kt2()));
245 vector<int> unique_history = clust_seq.unique_history_order();
247 vector<int> inv_unique_history(clust_seq.history().size());
248 for (
unsigned int i = 0; i < unique_history.size(); i++) {
249 inv_unique_history[unique_history[i]] = i;}
251 for (
unsigned int i = 0; i < unique_history.size(); i++) {
252 fj::ClusterSequence::history_element el =
253 clust_seq.history()[unique_history[i]];
254 int uhp1 = el.parent1>=0 ? inv_unique_history[el.parent1] : el.parent1;
255 int uhp2 = el.parent2>=0 ? inv_unique_history[el.parent2] : el.parent2;
256 printf(
"%7d u %15.8e %7d u %7d u\n",i,el.dij,uhp1, uhp2);
int main()
an example program showing how to use fastjet
class that is intended to hold a full definition of the jet clusterer
Class to contain pseudojets, including minimal information of use to jet-clustering routines.
Strategy
the various options for the algorithmic strategy to adopt in clustering events with kt and cambridge ...
@ Best
automatic selection of the best (based on N), including the LazyTiled strategies that are new to FJ3....
vector< PseudoJet > sorted_by_E(const vector< PseudoJet > &jets)
return a vector of jets sorted into decreasing energy
JetAlgorithm
the various families of jet-clustering algorithm
@ cambridge_algorithm
the longitudinally invariant variant of the cambridge algorithm (aka Aachen algoithm).
@ kt_algorithm
the longitudinally invariant kt algorithm
vector< PseudoJet > sorted_by_pt(const vector< PseudoJet > &jets)
return a vector of jets sorted into decreasing kt2