77 #include "fastjet/PseudoJet.hh"
78 #include "fastjet/ClusterSequence.hh"
94 inline double pow2(
const double x) {
return x*x;}
97 int main (
int argc,
char ** argv) {
99 CmdLine cmdline(argc,argv);
104 cmdline.int_val(
"-clever", fj::Best)));
105 int repeat = cmdline.int_val(
"-repeat",1);
106 int combine = cmdline.int_val(
"-combine",1);
107 bool write = cmdline.present(
"-write");
108 bool unique_write = cmdline.present(
"-unique_write");
109 bool hydjet = cmdline.present(
"-hydjet");
110 double ktR = cmdline.double_val(
"-r",1.0);
111 double inclkt = cmdline.double_val(
"-incl",-1.0);
112 int excln = cmdline.int_val (
"-excln",-1);
113 double excld = cmdline.double_val(
"-excld",-1.0);
114 double etamax = cmdline.double_val(
"-etamax",1.0e305);
115 bool show_constituents = cmdline.present(
"-const");
116 bool massless = cmdline.present(
"-massless");
117 int nev = cmdline.int_val(
"-nev",1);
118 bool add_dense_coverage = cmdline.present(
"-dense");
124 if (cmdline.present(
"-cam")) {
130 if (!cmdline.all_options_used()) {cerr <<
131 "Error: some options were not recognized"<<endl;
135 for (
int iev = 0; iev < nev; iev++) {
136 vector<fj::PseudoJet> jets;
139 while (getline(cin, line)) {
141 istringstream linestream(line);
142 if (line ==
"#END") {
144 if (ndone == combine) {
break;}
146 if (line.substr(0,1) ==
"#") {
continue;}
147 valarray<double> fourvec(4);
152 int ii, istat,id,m1,m2,d1,d2;
154 linestream >> ii>> istat >>
id >> m1 >> m2 >> d1 >> d2
155 >> fourvec[0] >> fourvec[1] >> fourvec[2] >> mass;
158 fourvec[3] = sqrt(+pow2(fourvec[0])+pow2(fourvec[1])
159 +pow2(fourvec[2])+pow2(mass));
163 linestream >> fourvec[0] >> fourvec[1] >> fourvec[2];
164 fourvec[3] = sqrt(pow2(fourvec[0])+pow2(fourvec[1])+pow2(fourvec[2]));}
166 linestream >> fourvec[0] >> fourvec[1] >> fourvec[2] >> fourvec[3];
170 if (abs(psjet.rap()) < etamax) {jets.push_back(psjet);}
176 if (add_dense_coverage) {
181 for (
int iphi = 0; iphi<nphi; iphi++) {
182 for (
int ieta = -neta; ieta<neta+1; ieta++) {
183 double phi = (iphi+0.5) * (fj::twopi/nphi) + rand()*0.001/RAND_MAX;
184 double eta = ieta * (10.0/neta) + rand()*0.001/RAND_MAX;
185 kt = 0.0000001*(1+rand()*0.1/RAND_MAX);
186 double pminus = kt*exp(-eta);
187 double pplus = kt*exp(+eta);
188 double px = kt*sin(phi);
189 double py = kt*cos(phi);
191 fj::PseudoJet mom(px,py,0.5*(pplus-pminus),0.5*(pplus+pminus));
199 for (
int irepeat = 0; irepeat < repeat ; irepeat++) {
201 if (irepeat != 0) {
continue;}
202 cout <<
"iev "<<iev<<
": number of particles = "<< jets.size() << endl;
203 cout <<
"strategy used = "<< clust_seq.strategy_string()<< endl;
207 vector<fj::PseudoJet> jets =
sorted_by_pt(clust_seq.inclusive_jets(inclkt));
208 for (
size_t j = 0; j < jets.size(); j++) {
209 printf(
"%5u %15.8f %15.8f %15.8f\n",j,jets[j].rap(),jets[j].phi(),sqrt(jets[j].kt2()));
210 if (show_constituents) {
211 vector<fj::PseudoJet> const_jets = jets[j].constituents();
212 for (
size_t k = 0; k < const_jets.size(); k++) {
213 printf(
" jet%03u %15.8f %15.8f %15.8f\n",j,const_jets[k].rap(),
214 const_jets[k].phi(),sqrt(const_jets[k].kt2()));
222 vector<fj::PseudoJet> jets =
sorted_by_E(clust_seq.exclusive_jets(excln));
224 cout <<
"Printing "<<excln<<
" exclusive jets\n";
225 for (
size_t j = 0; j < jets.size(); j++) {
226 printf(
"%5u %15.8f %15.8f %15.8f\n",
228 j,jets[j].rap(),jets[j].phi(),jets[j].kt2());
233 vector<fj::PseudoJet> jets =
sorted_by_pt(clust_seq.exclusive_jets(excld));
234 cout <<
"Printing exclusive jets for d = "<<excld<<
"\n";
235 for (
size_t j = 0; j < jets.size(); j++) {
236 printf(
"%5u %15.8f %15.8f %15.8f\n",
237 j,jets[j].rap(),jets[j].phi(),sqrt(jets[j].kt2()));
243 vector<int> unique_history = clust_seq.unique_history_order();
245 vector<int> inv_unique_history(clust_seq.history().size());
246 for (
unsigned int i = 0; i < unique_history.size(); i++) {
247 inv_unique_history[unique_history[i]] = i;}
249 for (
unsigned int i = 0; i < unique_history.size(); i++) {
250 fj::ClusterSequence::history_element el =
251 clust_seq.history()[unique_history[i]];
252 int uhp1 = el.parent1>=0 ? inv_unique_history[el.parent1] : el.parent1;
253 int uhp2 = el.parent2>=0 ? inv_unique_history[el.parent2] : el.parent2;
254 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 ...
vector< PseudoJet > sorted_by_pt(const vector< PseudoJet > &jets)
return a vector of jets sorted into decreasing kt2
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_E(const vector< PseudoJet > &jets)
return a vector of jets sorted into decreasing energy