run_jet_finder.cc
Go to the documentation of this file.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 #include "fastjet/PseudoJet.hh"
00032 #include "fastjet/ClusterSequence.hh"
00033 #include<iostream>
00034 #include<sstream>
00035 #include<vector>
00036 #include <cstdio>
00037
00038 using namespace std;
00039
00040
00041 void print_jets (const fastjet::ClusterSequence &,
00042 const vector<fastjet::PseudoJet> &);
00043
00044
00045
00048 void run_jet_finder (const vector<fastjet::PseudoJet> & input_particles,
00049 const fastjet::JetDefinition & jet_def) {
00050
00051
00052 fastjet::ClusterSequence clust_seq(input_particles, jet_def);
00053
00054
00055 cout << "Ran " << jet_def.description() << endl;
00056
00057
00058 double ptmin = 5.0;
00059 vector<fastjet::PseudoJet> inclusive_jets = clust_seq.inclusive_jets(ptmin);
00060
00061
00062 cout << "Printing inclusive jets with pt > "<< ptmin<<" GeV\n";
00063 cout << "---------------------------------------\n";
00064 print_jets(clust_seq, inclusive_jets);
00065 cout << endl;
00066
00067
00068 cout << clust_seq.unclustered_particles().size() << " particles unclustered" << endl << endl;
00069 }
00070
00071
00072
00074 void read_input_particles(istream & input,
00075 vector<fastjet::PseudoJet> & input_particles){
00076
00077
00078 double px, py , pz, E;
00079 string line;
00080 while (getline(input, line)) {
00081 if (line.substr(0,1) == "#") {continue;}
00082 istringstream linestream(line);
00083 linestream >> px >> py >> pz >> E;
00084
00085
00086 input_particles.push_back(fastjet::PseudoJet(px,py,pz,E));
00087 }
00088
00089 }
00090
00091
00093 void print_jets (const fastjet::ClusterSequence & clust_seq,
00094 const vector<fastjet::PseudoJet> & jets) {
00095
00096
00097 vector<fastjet::PseudoJet> sorted_jets = sorted_by_pt(jets);
00098
00099
00100 printf("%5s %15s %15s %15s %15s\n","jet #", "rapidity",
00101 "phi", "pt", "n constituents");
00102
00103
00104 for (unsigned int i = 0; i < sorted_jets.size(); i++) {
00105 int n_constituents = clust_seq.constituents(sorted_jets[i]).size();
00106 printf("%5u %15.8f %15.8f %15.8f %8u\n",
00107 i, sorted_jets[i].rap(), sorted_jets[i].phi(),
00108 sorted_jets[i].perp(), n_constituents);
00109 }
00110
00111 }