|
SISCone
2.0.5
|
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:: 325 $// 00024 // $Date:: 2011-11-25 12:41:17 +0100 (Fri, 25 Nov 2011) $// 00026 00027 //#ifdef HAVE_CONFIG_H 00028 #include "config.h" 00029 //#else 00030 //#define PACKAGE_NAME "SISCone" 00031 //#define VERSION "1.4.0-devel" 00032 //#warning "No config.h file available, using preset values" 00033 //#endif 00034 00035 #include "ranlux.h" 00036 #include "momentum.h" 00037 #include "defines.h" 00038 #include "siscone.h" 00039 #include "siscone_error.h" 00040 #include <iostream> 00041 #include <sstream> 00042 #include <iomanip> 00043 00044 namespace siscone{ 00045 using namespace std; 00046 00047 /*************************************************************** 00048 * Csiscone implementation * 00049 * final class: gather everything to compute the jet contents. * 00050 * * 00051 * This is the class user should use. * 00052 * It computes the jet contents of a list of particles * 00053 * given a cone radius and a threshold for splitting/merging. * 00054 ***************************************************************/ 00055 00056 // default ctor 00057 //-------------- 00058 Csiscone::Csiscone(){ 00059 rerun_allowed = false; 00060 } 00061 00062 // default dtor 00063 //-------------- 00064 Csiscone::~Csiscone(){ 00065 rerun_allowed = false; 00066 } 00067 00068 bool Csiscone::init_done=false; 00069 std::ostream* Csiscone::_banner_ostr = &cout; 00070 00071 /* 00072 * compute the jets from a given particle set doing multiple passes 00073 * such pass N looks for jets among all particles not put into jets 00074 * during previous passes. 00075 * - _particles list of particles 00076 * - _radius cone radius 00077 * - _f shared energy threshold for splitting&merging 00078 * - _n_pass_max maximum number of runs 00079 * - _ptmin minimum pT of the protojets 00080 * - _split_merge_scale the scale choice for the split-merge procedure 00081 * NOTE: using pt leads to IR unsafety for some events with momentum 00082 * conservation. So we strongly advise not to change the default 00083 * value. 00084 * return the number of jets found. 00085 **********************************************************************/ 00086 int Csiscone::compute_jets(vector<Cmomentum> &_particles, double _radius, double _f, 00087 int _n_pass_max, double _ptmin, 00088 Esplit_merge_scale _split_merge_scale){ 00089 // initialise random number generator 00090 if (!init_done){ 00091 // initialise random number generator 00092 ranlux_init(); 00093 00094 // do not do this again 00095 init_done=true; 00096 00097 // print the banner 00098 if (_banner_ostr != 0){ 00099 (*_banner_ostr) << "#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" << endl; 00100 (*_banner_ostr) << "# SISCone version " << setw(28) << left << siscone_version() << "o" << endl; 00101 (*_banner_ostr) << "# http://projects.hepforge.org/siscone o" << endl; 00102 (*_banner_ostr) << "# o" << endl; 00103 (*_banner_ostr) << "# This is SISCone: the Seedless Infrared Safe Cone Jet Algorithm o" << endl; 00104 (*_banner_ostr) << "# SISCone was written by Gavin Salam and Gregory Soyez o" << endl; 00105 (*_banner_ostr) << "# It is released under the terms of the GNU General Public License o" << endl; 00106 (*_banner_ostr) << "# o" << endl; 00107 (*_banner_ostr) << "# A description of the algorithm is available in the publication o" << endl; 00108 (*_banner_ostr) << "# JHEP 05 (2007) 086 [arXiv:0704.0292 (hep-ph)]. o" << endl; 00109 (*_banner_ostr) << "# Please cite it if you use SISCone. o" << endl; 00110 (*_banner_ostr) << "#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" << endl; 00111 (*_banner_ostr) << endl; 00112 00113 _banner_ostr->flush(); 00114 } 00115 } 00116 00117 // run some general safety tests (NB: f will be checked in split-merge) 00118 if (_radius <= 0.0 || _radius >= 0.5*M_PI) { 00119 ostringstream message; 00120 message << "Illegal value for cone radius, R = " << _radius 00121 << " (legal values are 0<R<pi/2)"; 00122 throw Csiscone_error(message.str()); 00123 } 00124 00125 00126 00127 ptcomparison.split_merge_scale = _split_merge_scale; 00128 partial_clear(); // make sure some things are initialised properly 00129 00130 // init the split_merge algorithm with the initial list of particles 00131 // this initialises particle list p_left of remaining particles to deal with 00132 init_particles(_particles); 00133 00134 bool finished = false; 00135 00136 rerun_allowed = false; 00137 protocones_list.clear(); 00138 00139 #ifdef DEBUG_STABLE_CONES 00140 nb_hash_cones_total = 0; 00141 nb_hash_occupied_total = 0; 00142 #endif 00143 00144 do{ 00145 // initialise stable_cone finder 00146 // here we use the list of remaining particles 00147 // AFTER COLLINEAR CLUSTERING !!!!!! 00148 Cstable_cones::init(p_uncol_hard); 00149 00150 // get stable cones 00151 if (get_stable_cones(_radius)){ 00152 // we have some new protocones; add them to candidates 00153 // Note that add_protocones has to be called first 00154 // if we want the 4-vect components to be available 00155 // on top of eta and phi. 00156 add_protocones(&protocones, R2, _ptmin); 00157 protocones_list.push_back(protocones); 00158 #ifdef DEBUG_STABLE_CONES 00159 nb_hash_cones_total += nb_hash_cones; 00160 nb_hash_occupied_total += nb_hash_occupied; 00161 #endif 00162 } else { 00163 // no new protocone: leave 00164 finished=true; 00165 } 00166 00167 _n_pass_max--; 00168 } while ((!finished) && (n_left>0) && (_n_pass_max!=0)); 00169 00170 rerun_allowed = true; 00171 00172 // split & merge 00173 return perform(_f, _ptmin); 00174 } 00175 00176 /* 00177 * recompute the jets with a different overlap parameter. 00178 * we use the same particles and R as in the preceeding call. 00179 * - _f shared energy threshold for splitting&merging 00180 * - _ptmin minimum pT of the protojets 00181 * - _split_merge_scale the scale choice for the split-merge procedure 00182 * NOTE: using pt leads to IR unsafety for some events with momentum 00183 * conservation. So we strongly advise not to change the default 00184 * value. 00185 * return the number of jets found, -1 if recomputation not allowed. 00186 ********************************************************************/ 00187 int Csiscone::recompute_jets(double _f, double _ptmin, 00188 Esplit_merge_scale _split_merge_scale){ 00189 if (!rerun_allowed) 00190 return -1; 00191 00192 ptcomparison.split_merge_scale = _split_merge_scale; 00193 00194 // restore particle list 00195 partial_clear(); 00196 init_pleft(); 00197 00198 // initialise split/merge algorithm 00199 unsigned int i; 00200 for (i=0;i<protocones_list.size();i++) 00201 add_protocones(&(protocones_list[i]), R2, _ptmin); 00202 00203 // split & merge 00204 return perform(_f, _ptmin); 00205 } 00206 00207 00208 // finally, a bunch of functions to access to 00209 // basic information (package name, version) 00210 //--------------------------------------------- 00211 00212 /* 00213 * return SISCone package name. 00214 * This is nothing but "SISCone", it is a replacement to the 00215 * PACKAGE_NAME string defined in config.h and which is not 00216 * public by default. 00217 * return the SISCone name as a string 00218 */ 00219 string siscone_package_name(){ 00220 return PACKAGE_NAME; 00221 } 00222 00223 /* 00224 * return SISCone version number. 00225 * return a string of the form "X.Y.Z" with possible additional tag 00226 * (alpha, beta, devel) to mention stability status 00227 */ 00228 string siscone_version(){ 00229 return VERSION; 00230 } 00231 00232 }