FastJet 3.0beta1
|
00001 /// \file 00002 /// \page Examples FastJet examples 00003 /// 00004 /// The FastJet examples have been organised by order of complexity, 00005 /// starting by the simplest case and introducing features one after 00006 /// another. 00007 /// - \subpage Example01 00008 /// - \subpage Example02 00009 /// - \subpage Example03 00010 /// - \subpage Example04 00011 /// - \subpage Example05 00012 /// - \subpage Example06 00013 /// - \subpage Example07 (\subpage Example07old "old version") 00014 /// - \subpage Example08 00015 /// - \subpage Example09 00016 /// - \subpage Example10 00017 /// - \subpage Example11 00018 /// - \subpage Example12 (\subpage Example12old "old version") 00019 /// - \subpage Example13 00020 00021 //STARTHEADER 00022 // $Id: fastjet_example.cc 2409 2011-07-08 15:58:15Z soyez $ 00023 // 00024 // Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam 00025 // 00026 //---------------------------------------------------------------------- 00027 // This file is part of FastJet. 00028 // 00029 // FastJet is free software; you can redistribute it and/or modify 00030 // it under the terms of the GNU General Public License as published by 00031 // the Free Software Foundation; either version 2 of the License, or 00032 // (at your option) any later version. 00033 // 00034 // The algorithms that underlie FastJet have required considerable 00035 // development and are described in hep-ph/0512210. If you use 00036 // FastJet as part of work towards a scientific publication, please 00037 // include a citation to the FastJet paper. 00038 // 00039 // FastJet is distributed in the hope that it will be useful, 00040 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00041 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00042 // GNU General Public License for more details. 00043 // 00044 // You should have received a copy of the GNU General Public License 00045 // along with FastJet; if not, write to the Free Software 00046 // Foundation, Inc.: 00047 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00048 //---------------------------------------------------------------------- 00049 //ENDHEADER 00050 00051 00052 //---------------------------------------------------------------------- 00053 // fastjet example program. 00054 // 00055 // Compile it with: make fastjet_example 00056 // run it with : ./fastjet_example < data/single-event.dat 00057 // 00058 // People who are familiar with the ktjet package are encouraged to 00059 // compare this file to the ktjet_example.cc program which does the 00060 // same thing in the ktjet framework. 00061 //---------------------------------------------------------------------- 00062 #include "fastjet/PseudoJet.hh" 00063 #include "fastjet/ClusterSequence.hh" 00064 #include<iostream> // needed for io 00065 #include<sstream> // needed for internal io 00066 #include<vector> 00067 #include <cstdio> 00068 00069 using namespace std; 00070 00071 // a declaration of a function that pretty prints a list of jets 00072 void print_jets (const vector<fastjet::PseudoJet> &); 00073 00074 /// an example program showing how to use fastjet 00075 int main (int argc, char ** argv) { 00076 00077 vector<fastjet::PseudoJet> input_particles; 00078 00079 // Read in input particles 00080 double px, py , pz, E; 00081 while (cin >> px >> py >> pz >> E) { 00082 // create a fastjet::PseudoJet with these components and put it onto 00083 // back of the input_particles vector 00084 input_particles.push_back(fastjet::PseudoJet(px,py,pz,E)); 00085 } 00086 00087 // create an object that represents your choice of jet algorithm and 00088 // the associated parameters 00089 double Rparam = 1.0; 00090 fastjet::Strategy strategy = fastjet::Best; 00091 fastjet::RecombinationScheme recomb_scheme = fastjet::E_scheme; 00092 fastjet::JetDefinition jet_def(fastjet::kt_algorithm, Rparam, recomb_scheme, strategy); 00093 00094 // run the jet clustering with the above jet definition 00095 fastjet::ClusterSequence clust_seq(input_particles, jet_def); 00096 00097 // tell the user what was done 00098 cout << "Ran " << jet_def.description() << endl; 00099 cout << "Strategy adopted by FastJet was "<< 00100 clust_seq.strategy_string()<<endl<<endl; 00101 00102 // extract the inclusive jets with pt > 5 GeV 00103 double ptmin = 5.0; 00104 vector<fastjet::PseudoJet> inclusive_jets = clust_seq.inclusive_jets(ptmin); 00105 00106 // print them out 00107 cout << "Printing inclusive jets with pt > "<< ptmin<<" GeV\n"; 00108 cout << "---------------------------------------\n"; 00109 print_jets(inclusive_jets); 00110 cout << endl; 00111 00112 // extract the exclusive jets with dcut = 25 GeV^2 00113 double dcut = 25.0; 00114 vector<fastjet::PseudoJet> exclusive_jets = clust_seq.exclusive_jets(dcut); 00115 00116 // print them out 00117 cout << "Printing exclusive jets with dcut = "<< dcut<<" GeV^2\n"; 00118 cout << "--------------------------------------------\n"; 00119 print_jets(exclusive_jets); 00120 00121 00122 } 00123 00124 00125 //---------------------------------------------------------------------- 00126 /// a function that pretty prints a list of jets 00127 void print_jets (const vector<fastjet::PseudoJet> & jets) { 00128 00129 // sort jets into increasing pt 00130 vector<fastjet::PseudoJet> sorted_jets = sorted_by_pt(jets); 00131 00132 // label the columns 00133 printf("%5s %15s %15s %15s %15s\n","jet #", "rapidity", 00134 "phi", "pt", "n constituents"); 00135 00136 // print out the details for each jet 00137 for (unsigned int i = 0; i < sorted_jets.size(); i++) { 00138 // the following is not super efficient since it creates an 00139 // intermediate constituents vector 00140 int n_constituents = sorted_jets[i].constituents().size(); 00141 printf("%5u %15.8f %15.8f %15.8f %8u\n", 00142 i, sorted_jets[i].rap(), sorted_jets[i].phi(), 00143 sorted_jets[i].perp(), n_constituents); 00144 } 00145 00146 }