FastJet 3.4.3
Loading...
Searching...
No Matches
ktjet_example.cc
1//----------------------------------------------------------------------
2// ktjet example program that should do the same thing as the
3// fastjet_example program (as of 3 Feb 2006)
4//
5// NB: the ../Makefile may need to be modified to set proper
6// paths for access to the CLHEP and KtJet libraries.
7//----------------------------------------------------------------------
8#include<iostream> // needed for io
9#include<sstream> // needed for internal io
10#include<vector>
11
12/** Need to include these KtJet Headers */
13#include "KtJet/KtEvent.h"
14#include "KtJet/KtLorentzVector.h"
15
16using namespace std;
17using namespace KtJet;
18
19// a declaration of a function that pretty prints a list of jets
20void print_jets (const vector<KtLorentzVector> &);
21
22/// an example program showing how the fastjet_example program would
23/// be translated for use with ktjet.
24int main (int argc, char ** argv) {
25
26 vector<KtLorentzVector> input_particles;
27
28 // read in input particles
29 double px, py , pz, E;
30 while (cin >> px >> py >> pz >> E) {
31 // create a KtLorentzVector with these components and put it onto
32 // back of the input_particles vector
33 input_particles.push_back(KtLorentzVector(px,py,pz,E));
34 }
35
36 // run the inclusive jet clustering in PP mode using the covariant
37 // E-scheme for recobination (type=4, angle=2, recom=1, rparameter=1.0)
38 double Rparam = 1.0;
39 KtEvent clust_seq(input_particles,4,2,1,Rparam);
40
41 // extract the inclusive jets with pt > 5 GeV, sorted by pt
42 double ptmin = 5.0;
43 vector<KtLorentzVector> temporary_jets = clust_seq.getJetsPt();
44 vector<KtLorentzVector> inclusive_jets;
45 for (unsigned int i = 0; i < temporary_jets.size(); i++) {
46 if (temporary_jets[i].perp() >= ptmin) {
47 inclusive_jets.push_back(temporary_jets[i]);}
48 else {break;}
49 }
50
51 // print them out
52 cout << "Printing inclusive jets with pt > "<< ptmin<<" GeV\n";
53 cout << "---------------------------------------\n";
54 print_jets(inclusive_jets);
55 cout << endl;
56
57 // Extract the exclusive jets with dcut = 25 GeV^2.
58 double dcut = 25.0;
59 // Note that KtJet's definition of dij differs from Ellis&Soper (and
60 // fastjet) in the case where Rparam /= 1.0 (though in this case one
61 // should perhaps not be using the exclusive kt algorithm in any case).
62 clust_seq.findJetsD(dcut * Rparam*Rparam);
63 vector<KtLorentzVector> exclusive_jets = clust_seq.getJetsPt();
64
65 // print them out
66 cout << "Printing exclusive jets with dcut = "<< dcut<<" GeV^2\n";
67 cout << "--------------------------------------------\n";
68 print_jets(exclusive_jets);
69
70
71}
72
73
74//----------------------------------------------------------------------
75// a function that pretty prints a list of jets
76void print_jets (const vector<KtLorentzVector> & jets) {
77
78 // label the columns
79 printf("%5s %15s %15s %15s %15s\n","jet #", "rapidity",
80 "phi", "pt", "n constituents");
81
82 // print out the details for each jet
83 for (unsigned int i = 0; i < jets.size(); i++) {
84 int n_constituents = jets[i].getConstituents().size();
85 double phi = jets[i].phi();
86 if (phi < 0.0) {phi += 6.283185307179586476925286766559005768394;}
87 printf("%5u %15.8f %15.8f %15.8f %8u\n",
88 i, jets[i].rapidity(), phi,
89 jets[i].perp(), n_constituents);
90 }
91
92}
int main()
an example program showing how to use fastjet
Definition 01-basic.cc:52