03-plugin.cc

Go to the documentation of this file.
00001 //----------------------------------------------------------------------
00020 //----------------------------------------------------------------------
00021 
00022 //STARTHEADER
00023 // $Id: 03-plugin.cc 1884 2011-01-27 14:48:39Z salam $
00024 //
00025 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin Salam and Gregory Soyez
00026 //
00027 //----------------------------------------------------------------------
00028 // This file is part of FastJet.
00029 //
00030 //  FastJet is free software; you can redistribute it and/or modify
00031 //  it under the terms of the GNU General Public License as published by
00032 //  the Free Software Foundation; either version 2 of the License, or
00033 //  (at your option) any later version.
00034 //
00035 //  The algorithms that underlie FastJet have required considerable
00036 //  development and are described in hep-ph/0512210. If you use
00037 //  FastJet as part of work towards a scientific publication, please
00038 //  include a citation to the FastJet paper.
00039 //
00040 //  FastJet is distributed in the hope that it will be useful,
00041 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00042 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00043 //  GNU General Public License for more details.
00044 //
00045 //  You should have received a copy of the GNU General Public License
00046 //  along with FastJet; if not, write to the Free Software
00047 //  Foundation, Inc.:
00048 //      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00049 //----------------------------------------------------------------------
00050 //ENDHEADER
00051 
00052 #include "fastjet/ClusterSequence.hh"
00053 #include <iostream> // needed for io
00054 #include <cstdio>   // needed for io
00055 
00056 // include the SISCone plugin header
00057 #include "fastjet/SISConePlugin.hh"
00058 
00059 
00060 using namespace std;
00061 
00062 int main (int argc, char ** argv) {
00063 
00064   // read in input particles
00065   //----------------------------------------------------------
00066   vector<fastjet::PseudoJet> input_particles;
00067   
00068   double px, py , pz, E;
00069   while (cin >> px >> py >> pz >> E) {
00070     // create a fastjet::PseudoJet with these components and put it onto
00071     // back of the input_particles vector
00072     input_particles.push_back(fastjet::PseudoJet(px,py,pz,E)); 
00073   }
00074   
00075 
00076   // create a jet definition fron a plugin.
00077   // It basically requires declaring a JetDefinition from a pointer to
00078   // the plugin
00079   //
00080   // we will use the SISCone plugin here. Its (mandatory) parameters
00081   // are a cone radius and an overlap threshold, plus other optional
00082   // parameters
00083   //
00084   // for other plugin, see individual documentations for a description
00085   // of their parameters
00086   //
00087   // the list of available plugins for a given build of FastJet can be
00088   // obtained using
00089   //   fastjet-config --list-plugins 
00090   // from the command line.
00091   //----------------------------------------------------------
00092   double cone_radius = 0.7;
00093   double overlap_threshold = 0.75;
00094   fastjet::SISConePlugin siscone(cone_radius, overlap_threshold);
00095   fastjet::JetDefinition jet_def(& siscone);
00096 
00097 
00098   // run the jet clustering with the above jet definition
00099   //----------------------------------------------------------
00100   fastjet::ClusterSequence clust_seq(input_particles, jet_def);
00101 
00102 
00103   // get the resulting jets ordered in pt
00104   //----------------------------------------------------------
00105   double ptmin = 5.0;
00106   vector<fastjet::PseudoJet> inclusive_jets = sorted_by_pt(clust_seq.inclusive_jets(ptmin));
00107 
00108 
00109   // tell the user what was done
00110   //  - the description of the algorithm used
00111   //  - extract the inclusive jets with pt > 5 GeV
00112   //    show the output as 
00113   //      {index, rap, phi, pt}
00114   //----------------------------------------------------------
00115   cout << "Ran " << jet_def.description() << endl;
00116 
00117   // label the columns
00118   printf("%5s %15s %15s %15s\n","jet #", "rapidity", "phi", "pt");
00119  
00120   // print out the details for each jet
00121   for (unsigned int i = 0; i < inclusive_jets.size(); i++) {
00122     printf("%5u %15.8f %15.8f %15.8f\n",
00123            i, inclusive_jets[i].rap(), inclusive_jets[i].phi(),
00124            inclusive_jets[i].perp());
00125   }
00126 
00127   return 0;
00128 
00129 }