00001 00002 // File: siscone.cpp // 00003 // Description: source file for the main SISCone class // 00004 // This file is part of the SISCone project. // 00005 // For more details, see http://projects.hepforge.org/siscone // 00006 // // 00007 // Copyright (c) 2006 Gavin Salam and Gregory Soyez // 00008 // // 00009 // This program 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 // This program is distributed in the hope that it will be useful, // 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 00017 // GNU General Public License for more details. // 00018 // // 00019 // You should have received a copy of the GNU General Public License // 00020 // along with this program; if not, write to the Free Software // 00021 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA // 00022 // // 00023 // $Revision:: 219 $// 00024 // $Date:: 2008-04-03 09:21:00 -0400 (Thu, 03 Apr 2008) $// 00026 00027 #include "config.h" 00028 00029 #include "ranlux.h" 00030 #include "momentum.h" 00031 #include "defines.h" 00032 #include "siscone.h" 00033 #include "siscone_error.h" 00034 #include <iostream> 00035 #include <sstream> 00036 #include <iomanip> 00037 00038 namespace siscone{ 00039 using namespace std; 00040 00041 /*************************************************************** 00042 * Csiscone implementation * 00043 * final class: gather everything to compute the jet contents. * 00044 * * 00045 * This is the class user should use. * 00046 * It computes the jet contents of a list of particles * 00047 * given a cone radius and a threshold for splitting/merging. * 00048 ***************************************************************/ 00049 00050 // default ctor 00051 //-------------- 00052 Csiscone::Csiscone(){ 00053 rerun_allowed = false; 00054 } 00055 00056 // default dtor 00057 //-------------- 00058 Csiscone::~Csiscone(){ 00059 rerun_allowed = false; 00060 } 00061 00062 bool Csiscone::init_done=false; 00063 00064 /* 00065 * compute the jets from a given particle set doing multiple passes 00066 * such pass N looks for jets among all particles not put into jets 00067 * during previous passes. 00068 * - _particles list of particles 00069 * - _radius cone radius 00070 * - _f shared energy threshold for splitting&merging 00071 * - _n_pass_max maximum number of runs 00072 * - _ptmin minimum pT of the protojets 00073 * - _split_merge_scale the scale choice for the split-merge procedure 00074 * NOTE: using pt leads to IR unsafety for some events with momentum 00075 * conservation. So we strongly advise not to change the default 00076 * value. 00077 * return the number of jets found. 00078 **********************************************************************/ 00079 int Csiscone::compute_jets(vector<Cmomentum> &_particles, double _radius, double _f, 00080 int _n_pass_max, double _ptmin, 00081 Esplit_merge_scale _split_merge_scale){ 00082 // initialise random number generator 00083 if (!init_done){ 00084 // initialise random number generator 00085 ranlux_init(); 00086 00087 // print the banner 00088 cout << "#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" << endl; 00089 cout << "# SISCone version " << setw(28) << left << siscone_version() << "o" << endl; 00090 cout << "# http://projects.hepforge.org/siscone o" << endl; 00091 cout << "# o" << endl; 00092 cout << "# This is SISCone: the Seedless Infrared Safe Cone Jet Algorithm o" << endl; 00093 cout << "# SISCone was written by Gavin Salam and Gregory Soyez o" << endl; 00094 cout << "# It is released under the terms of the GNU General Public License o" << endl; 00095 cout << "# o" << endl; 00096 cout << "# A description of the algorithm is available in the publication o" << endl; 00097 cout << "# JHEP 05 (2007) 086 [arXiv:0704.0292 (hep-ph)]. o" << endl; 00098 cout << "# Please cite it if you use SISCone. o" << endl; 00099 cout << "#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" << endl; 00100 cout << endl; 00101 // do not do this again 00102 init_done=true; 00103 } 00104 00105 // run some general safety tests (NB: f will be checked in split-merge) 00106 if (_radius <= 0.0 || _radius >= 0.5*M_PI) { 00107 ostringstream message; 00108 message << "Illegal value for cone radius, R = " << _radius 00109 << " (legal values are 0<R<pi/2)"; 00110 throw Csiscone_error(message.str()); 00111 } 00112 00113 00114 00115 ptcomparison.split_merge_scale = _split_merge_scale; 00116 partial_clear(); // make sure some things are initialised properly 00117 00118 // init the split_merge algorithm with the initial list of particles 00119 // this initialises particle list p_left of remaining particles to deal with 00120 init_particles(_particles); 00121 00122 bool finished = false; 00123 00124 rerun_allowed = false; 00125 protocones_list.clear(); 00126 00127 do{ 00128 // initialise stable_cone finder 00129 // here we use the list of remaining particles 00130 // AFTER COLLINEAR CLUSTERING !!!!!! 00131 Cstable_cones::init(p_uncol_hard); 00132 00133 // get stable cones 00134 if (get_stable_cones(_radius)){ 00135 // we have some new protocones. 00136 // add them to candidates 00137 protocones_list.push_back(protocones); 00138 add_protocones(&protocones, R2, _ptmin); 00139 } else { 00140 // no new protocone: leave 00141 finished=true; 00142 } 00143 00144 _n_pass_max--; 00145 } while ((!finished) && (n_left>0) && (_n_pass_max!=0)); 00146 00147 rerun_allowed = true; 00148 00149 // split & merge 00150 return perform(_f, _ptmin); 00151 } 00152 00153 /* 00154 * recompute the jets with a different overlap parameter. 00155 * we use the same particles and R as in the preceeding call. 00156 * - _f shared energy threshold for splitting&merging 00157 * - _ptmin minimum pT of the protojets 00158 * - _split_merge_scale the scale choice for the split-merge procedure 00159 * NOTE: using pt leads to IR unsafety for some events with momentum 00160 * conservation. So we strongly advise not to change the default 00161 * value. 00162 * return the number of jets found, -1 if recomputation not allowed. 00163 ********************************************************************/ 00164 int Csiscone::recompute_jets(double _f, double _ptmin, 00165 Esplit_merge_scale _split_merge_scale){ 00166 if (!rerun_allowed) 00167 return -1; 00168 00169 ptcomparison.split_merge_scale = _split_merge_scale; 00170 00171 // restore particle list 00172 partial_clear(); 00173 init_pleft(); 00174 00175 // initialise split/merge algorithm 00176 unsigned int i; 00177 for (i=0;i<protocones_list.size();i++) 00178 add_protocones(&(protocones_list[i]), R2, _ptmin); 00179 00180 // split & merge 00181 return perform(_f, _ptmin); 00182 } 00183 00184 00185 // finally, a bunch of functions to access to 00186 // basic information (package name, version) 00187 //--------------------------------------------- 00188 00189 /* 00190 * return SISCone package name. 00191 * This is nothing but "SISCone", it is a replacement to the 00192 * PACKAGE_NAME string defined in config.h and which is not 00193 * public by default. 00194 * return the SISCone name as a string 00195 */ 00196 string siscone_package_name(){ 00197 return VERSION; 00198 } 00199 00200 /* 00201 * return SISCone version number. 00202 * return a string of the form "X.Y.Z" with possible additional tag 00203 * (alpha, beta, devel) to mention stability status 00204 */ 00205 string siscone_version(){ 00206 return VERSION; 00207 } 00208 00209 }