FastJet 3.0beta1
|
00001 //---------------------------------------------------------------------- 00002 /// \file 00003 /// \page Example03 03 - using plugins 00004 /// 00005 /// fastjet plugins example program: 00006 /// we illustrate the plugin usage 00007 /// here, we use the SISCone plugin though different choices are possible 00008 /// see the output of 'fastjet-config --list-plugins' for more details 00009 /// 00010 /// Note that when using plugins, the code needs to be linked against 00011 /// the libfastjetplugins library (with the default monolithic 00012 /// build. For non-monolithic build, individual libraries have to be 00013 /// used for each plugin). 00014 /// This is ensured in practice by calling 00015 /// fastjet-config --libs --plugins 00016 /// 00017 /// run it with : ./03-plugin < data/single-event.dat 00018 /// 00019 /// Source code: 03-plugin.cc 00020 //---------------------------------------------------------------------- 00021 00022 //STARTHEADER 00023 // $Id: 03-plugin.cc 1911 2011-01-28 18:18:24Z soyez $ 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 if enabled 00057 #include "fastjet/config.h" 00058 #ifdef FASTJET_ENABLE_PLUGIN_SISCONE 00059 #include "fastjet/SISConePlugin.hh" 00060 #else 00061 #warning "SISCone plugin not enabled. Skipping the example" 00062 #endif // FASTJET_ENABLE_PLUGIN_SISCONE 00063 00064 00065 using namespace std; 00066 00067 int main (int argc, char ** argv) { 00068 00069 #ifdef FASTJET_ENABLE_PLUGIN_SISCONE 00070 00071 // read in input particles 00072 //---------------------------------------------------------- 00073 vector<fastjet::PseudoJet> input_particles; 00074 00075 double px, py , pz, E; 00076 while (cin >> px >> py >> pz >> E) { 00077 // create a fastjet::PseudoJet with these components and put it onto 00078 // back of the input_particles vector 00079 input_particles.push_back(fastjet::PseudoJet(px,py,pz,E)); 00080 } 00081 00082 00083 // create a jet definition fron a plugin. 00084 // It basically requires declaring a JetDefinition from a pointer to 00085 // the plugin 00086 // 00087 // we will use the SISCone plugin here. Its (mandatory) parameters 00088 // are a cone radius and an overlap threshold, plus other optional 00089 // parameters 00090 // 00091 // for other plugin, see individual documentations for a description 00092 // of their parameters 00093 // 00094 // the list of available plugins for a given build of FastJet can be 00095 // obtained using 00096 // fastjet-config --list-plugins 00097 // from the command line. 00098 //---------------------------------------------------------- 00099 double cone_radius = 0.7; 00100 double overlap_threshold = 0.75; 00101 fastjet::SISConePlugin siscone(cone_radius, overlap_threshold); 00102 fastjet::JetDefinition jet_def(& siscone); 00103 00104 00105 // run the jet clustering with the above jet definition 00106 //---------------------------------------------------------- 00107 fastjet::ClusterSequence clust_seq(input_particles, jet_def); 00108 00109 00110 // get the resulting jets ordered in pt 00111 //---------------------------------------------------------- 00112 double ptmin = 5.0; 00113 vector<fastjet::PseudoJet> inclusive_jets = sorted_by_pt(clust_seq.inclusive_jets(ptmin)); 00114 00115 00116 // tell the user what was done 00117 // - the description of the algorithm used 00118 // - extract the inclusive jets with pt > 5 GeV 00119 // show the output as 00120 // {index, rap, phi, pt} 00121 //---------------------------------------------------------- 00122 cout << "Ran " << jet_def.description() << endl; 00123 00124 // label the columns 00125 printf("%5s %15s %15s %15s\n","jet #", "rapidity", "phi", "pt"); 00126 00127 // print out the details for each jet 00128 for (unsigned int i = 0; i < inclusive_jets.size(); i++) { 00129 printf("%5u %15.8f %15.8f %15.8f\n", 00130 i, inclusive_jets[i].rap(), inclusive_jets[i].phi(), 00131 inclusive_jets[i].perp()); 00132 } 00133 00134 #endif 00135 00136 return 0; 00137 00138 }