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