fastjet_subjets.cc

Go to the documentation of this file.
00001 //STARTHEADER
00002 // $Id: fastjet_subjets.cc 1292 2008-10-09 17:27:36Z salam $
00003 //
00004 // Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam
00005 //
00006 //----------------------------------------------------------------------
00007 // This file is part of FastJet.
00008 //
00009 //  FastJet is free software; you can redistribute it and/or modify
00010 //  it under the terms of the GNU General Public License as published by
00011 //  the Free Software Foundation; either version 2 of the License, or
00012 //  (at your option) any later version.
00013 //
00014 //  The algorithms that underlie FastJet have required considerable
00015 //  development and are described in hep-ph/0512210. If you use
00016 //  FastJet as part of work towards a scientific publication, please
00017 //  include a citation to the FastJet paper.
00018 //
00019 //  FastJet is distributed in the hope that it will be useful,
00020 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022 //  GNU General Public License for more details.
00023 //
00024 //  You should have received a copy of the GNU General Public License
00025 //  along with FastJet; if not, write to the Free Software
00026 //  Foundation, Inc.:
00027 //      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 //----------------------------------------------------------------------
00029 //ENDHEADER
00030 
00031 
00032 //----------------------------------------------------------------------
00033 // fastjet example program to show how to access subjets;
00034 // 
00035 // See also fastjet_higgs_decomp.cc to see the use of subjets for
00036 // identifying boosted higgs (and other objects)
00037 //
00038 // Compile it with: make fastjet_subjets
00039 // run it with    : ./fastjet_subjets < data/single-event.dat
00040 //
00041 //----------------------------------------------------------------------
00042 #include "fastjet/PseudoJet.hh"
00043 #include "fastjet/ClusterSequence.hh"
00044 #include<iostream> // needed for io
00045 #include<sstream>  // needed for internal io
00046 #include<vector> 
00047 
00048 using namespace std;
00049 
00050 // to avoid excessive typing, define an abbreviation for the
00051 // fastjet namespace
00052 namespace fj = fastjet;
00053 
00054 
00055 // a declaration of a function that pretty prints a list of jets
00056 void print_jets (const fj::ClusterSequence &, 
00057                  const vector<fj::PseudoJet> &);
00058 
00059 // and this pretty prinst a single jet
00060 void print_jet (const fj::ClusterSequence & clust_seq, 
00061                 const fj::PseudoJet & jet);
00062 
00063 // pretty print the jets and their subjets
00064 void print_jets_and_sub (const fj::ClusterSequence & clust_seq, 
00065                          const vector<fj::PseudoJet> & jets,
00066                          double dcut);
00067 
00069 int main (int argc, char ** argv) {
00070   
00071   vector<fj::PseudoJet> input_particles;
00072   
00073   // read in input particles
00074   double px, py , pz, E;
00075   while (cin >> px >> py >> pz >> E) {
00076     // create a fj::PseudoJet with these components and put it onto
00077     // back of the input_particles vector
00078     input_particles.push_back(fj::PseudoJet(px,py,pz,E)); 
00079   }
00080   
00081   // We'll do two subjet analyses, physically rather different
00082   double R = 1.0;
00083   //fj::JetDefinition kt_def(fj::kt_algorithm, R);
00084   fj::JetDefinition cam_def(fj::cambridge_algorithm, R);
00085 
00086   // run the jet clustering with the above jet definition
00087   //fj::ClusterSequence kt_seq(input_particles, kt_def);
00088   fj::ClusterSequence cam_seq(input_particles, cam_def);
00089 
00090   // tell the user what was done
00091   cout << "Ran " << cam_def.description() << endl;
00092   cout << "Strategy adopted by FastJet was "<<
00093        cam_seq.strategy_string()<<endl<<endl;
00094 
00095   // extract the inclusive jets with pt > 5 GeV
00096   double ptmin = 5.0;
00097   vector<fj::PseudoJet> inclusive_jets = cam_seq.inclusive_jets(ptmin);
00098 
00099   // for the subjets  
00100   double smallR = 0.4;
00101   double dcut_cam = pow(smallR/R,2);
00102 
00103   // print them out
00104   cout << "Printing inclusive jets (R = "<<R<<") with pt > "<< ptmin<<" GeV\n";
00105   cout << "and their subjets with smallR = " << smallR << "\n";
00106   cout << "---------------------------------------\n";
00107   print_jets_and_sub(cam_seq, inclusive_jets, dcut_cam);
00108   cout << endl;
00109 
00110 
00111   // print them out
00112   vector<fj::PseudoJet> exclusive_jets = cam_seq.exclusive_jets(dcut_cam);
00113   cout << "Printing exclusive jets with dcut = "<< dcut_cam<<" \n";
00114   cout << "--------------------------------------------\n";
00115   print_jets(cam_seq, exclusive_jets);
00116 
00117 
00118 }
00119 
00120 
00121 //----------------------------------------------------------------------
00123 void print_jets (const fj::ClusterSequence & clust_seq, 
00124                  const vector<fj::PseudoJet> & jets) {
00125 
00126   // sort jets into increasing pt
00127   vector<fj::PseudoJet> sorted_jets = sorted_by_pt(jets);  
00128 
00129   // label the columns
00130   printf("%5s %15s %15s %15s %15s\n","jet #", "rapidity", 
00131          "phi", "pt", "n constituents");
00132   
00133   // print out the details for each jet
00134   for (unsigned int i = 0; i < sorted_jets.size(); i++) {
00135     printf("%5u ",i);
00136     print_jet(clust_seq, sorted_jets[i]);
00137   }
00138 
00139 }
00140 
00141 
00142 //----------------------------------------------------------------------
00144 void print_jets_and_sub (const fj::ClusterSequence & clust_seq, 
00145                          const vector<fj::PseudoJet> & jets,
00146                          double dcut) {
00147 
00148   // sort jets into increasing pt
00149   vector<fj::PseudoJet> sorted_jets = sorted_by_pt(jets);  
00150 
00151   // label the columns
00152   printf("%5s %15s %15s %15s %15s\n","jet #", "rapidity", 
00153          "phi", "pt", "n constituents");
00154   
00155   // print out the details for each jet
00156   for (unsigned int i = 0; i < sorted_jets.size(); i++) {
00157     printf("%5u       ",i);
00158     print_jet(clust_seq, sorted_jets[i]);
00159     vector<fj::PseudoJet> subjets = 
00160       sorted_by_pt(clust_seq.exclusive_subjets(sorted_jets[i], dcut));
00161     for (unsigned int j = 0; j < subjets.size(); j++) {
00162       printf("    -sub-%02u ",j);
00163       print_jet(clust_seq, subjets[j]);
00164     }
00165   }
00166 
00167 }
00168 
00169 
00170 //----------------------------------------------------------------------
00172 void print_jet (const fj::ClusterSequence & clust_seq, 
00173                 const fj::PseudoJet & jet) {
00174   int n_constituents = clust_seq.constituents(jet).size();
00175   printf("%15.8f %15.8f %15.8f %8u\n",
00176          jet.rap(), jet.phi(), jet.perp(), n_constituents);
00177 }

Generated on Fri Apr 17 16:15:09 2009 for fastjet by  doxygen 1.5.7.1