SISCone  2.0.6
siscone.cpp
1 // File: siscone.cpp //
3 // Description: source file for the main SISCone class //
4 // This file is part of the SISCone project. //
5 // WARNING: this is not the main SISCone trunk but //
6 // an adaptation to spherical coordinates //
7 // For more details, see http://projects.hepforge.org/siscone //
8 // //
9 // Copyright (c) 2006-2008 Gavin Salam and Gregory Soyez //
10 // //
11 // This program is free software; you can redistribute it and/or modify //
12 // it under the terms of the GNU General Public License as published by //
13 // the Free Software Foundation; either version 2 of the License, or //
14 // (at your option) any later version. //
15 // //
16 // This program is distributed in the hope that it will be useful, //
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
19 // GNU General Public License for more details. //
20 // //
21 // You should have received a copy of the GNU General Public License //
22 // along with this program; if not, write to the Free Software //
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
24 // //
25 // $Revision:: 341 $//
26 // $Date:: 2013-04-08 12:21:06 +0200 (Mon, 08 Apr 2013) $//
28 
29 //#ifdef HAVE_CONFIG_H
30 #include <siscone/config.h>
31 //#else
32 //#define PACKAGE_NAME "SISCone"
33 //#define VERSION "2.0.6"
34 //#warning "No config.h file available, using preset values"
35 //#endif
36 
37 #include <siscone/ranlux.h>
38 #include <siscone/siscone_error.h>
39 #include <siscone/defines.h>
40 #include "momentum.h"
41 #include "siscone.h"
42 #include <iostream>
43 #include <sstream>
44 #include <iomanip>
45 
46 namespace siscone_spherical{
47 using namespace std;
48 
49 /***************************************************************
50  * CSphsiscone implementation *
51  * final class: gather everything to compute the jet contents. *
52  * *
53  * This is the class user should use. *
54  * It computes the jet contents of a list of particles *
55  * given a cone radius and a threshold for splitting/merging. *
56  ***************************************************************/
57 
58 // default ctor
59 //--------------
61  rerun_allowed = false;
62 }
63 
64 // default dtor
65 //--------------
67  rerun_allowed = false;
68 }
69 
70 bool CSphsiscone::init_done=false;
71 std::ostream* CSphsiscone::_banner_ostr=&cout;
72 
73 /*
74  * compute the jets from a given particle set doing multiple passes
75  * such pass N looks for jets among all particles not put into jets
76  * during previous passes.
77  * - _particles list of particles
78  * - _radius cone radius
79  * - _f shared energy threshold for splitting&merging
80  * - _n_pass_max maximum number of runs
81  * - _Emin minimum energy of the protojets
82  * - _split_merge_scale the scale choice for the split-merge procedure
83  * NOTE: using pt leads to IR unsafety for some events with momentum
84  * conservation. So we strongly advise not to change the default
85  * value.
86  * return the number of jets found.
87  **********************************************************************/
88 int CSphsiscone::compute_jets(vector<CSphmomentum> &_particles, double _radius, double _f,
89  int _n_pass_max, double _Emin,
90  Esplit_merge_scale _split_merge_scale){
91  // initialise random number generator
92  if (!init_done){
93  // initialise random number generator
94  siscone::ranlux_init();
95 
96  // do not do this again
97  init_done=true;
98 
99  // print the banner
100  if (_banner_ostr != 0){
101  (*_banner_ostr) << "#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" << endl;
102  (*_banner_ostr) << "# SISCone version " << setw(28) << left << siscone_version() << "o" << endl;
103  (*_banner_ostr) << "# http://projects.hepforge.org/siscone o" << endl;
104  (*_banner_ostr) << "# o" << endl;
105  (*_banner_ostr) << "# This is SISCone: the Seedless Infrared Safe Cone Jet Algorithm o" << endl;
106  (*_banner_ostr) << "# SISCone was written by Gavin Salam and Gregory Soyez o" << endl;
107  (*_banner_ostr) << "# It is released under the terms of the GNU General Public License o" << endl;
108  (*_banner_ostr) << "# o" << endl;
109  (*_banner_ostr) << "# !!! WARNING !!! o" << endl;
110  (*_banner_ostr) << "# This is the version of SISCone using spherical coordinates o" << endl;
111  (*_banner_ostr) << "# o" << endl;
112  (*_banner_ostr) << "# A description of the algorithm is available in the publication o" << endl;
113  (*_banner_ostr) << "# JHEP 05 (2007) 086 [arXiv:0704.0292 (hep-ph)]. o" << endl;
114  (*_banner_ostr) << "# Please cite it if you use SISCone. o" << endl;
115  (*_banner_ostr) << "#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" << endl;
116  (*_banner_ostr) << endl;
117  _banner_ostr->flush();
118  }
119  }
120 
121  // run some general safety tests (NB: f will be checked in split-merge)
122  if (_radius <= 0.0 || _radius >= 0.5*M_PI) {
123  ostringstream message;
124  message << "Illegal value for cone radius, R = " << _radius
125  << " (legal values are 0<R<pi/2)";
126  throw siscone::Csiscone_error(message.str());
127  }
128 
129 
130 
131  ptcomparison.split_merge_scale = _split_merge_scale;
132  partial_clear(); // make sure some things are initialised properly
133 
134  // init the split_merge algorithm with the initial list of particles
135  // this initialises particle list p_left of remaining particles to deal with
136  init_particles(_particles);
137 
138  bool finished = false;
139 
140  rerun_allowed = false;
141  protocones_list.clear();
142 
143 #ifdef DEBUG_STABLE_CONES
144  nb_hash_cones_total = 0;
145  nb_hash_occupied_total = 0;
146 #endif
147 
148  do{
149  // initialise stable_cone finder
150  // here we use the list of remaining particles
151  // AFTER COLLINEAR CLUSTERING !!!!!!
152  CSphstable_cones::init(p_uncol_hard);
153 
154  // get stable cones
155  if (get_stable_cones(_radius)){
156  // we have some new protocones.
157  // add them to candidates
158  protocones_list.push_back(protocones);
159  add_protocones(&protocones, R2, _Emin);
160 #ifdef DEBUG_STABLE_CONES
161  nb_hash_cones_total += nb_hash_cones;
162  nb_hash_occupied_total += nb_hash_occupied;
163 #endif
164  } else {
165  // no new protocone: leave
166  finished=true;
167  }
168 
169  _n_pass_max--;
170  } while ((!finished) && (n_left>0) && (_n_pass_max!=0));
171 
172  rerun_allowed = true;
173 
174  // split & merge
175  return perform(_f, _Emin);
176 }
177 
178 /*
179  * recompute the jets with a different overlap parameter.
180  * we use the same particles and R as in the preceeding call.
181  * - _f shared energy threshold for splitting&merging
182  * - _Emin minimum Energy of the protojets
183  * - _split_merge_scale the scale choice for the split-merge procedure
184  * NOTE: using pt leads to IR unsafety for some events with momentum
185  * conservation. So we strongly advise not to change the default
186  * value.
187  * return the number of jets found, -1 if recomputation not allowed.
188  ********************************************************************/
189 int CSphsiscone::recompute_jets(double _f, double _Emin,
190  Esplit_merge_scale _split_merge_scale){
191  if (!rerun_allowed)
192  return -1;
193 
194  ptcomparison.split_merge_scale = _split_merge_scale;
195 
196  // restore particle list
197  partial_clear();
198  init_pleft();
199 
200  // initialise split/merge algorithm
201  unsigned int i;
202  for (i=0;i<protocones_list.size();i++)
203  add_protocones(&(protocones_list[i]), R2, _Emin);
204 
205  // split & merge
206  return perform(_f, _Emin);
207 }
208 
209 
210 // finally, a bunch of functions to access to
211 // basic information (package name, version)
212 //---------------------------------------------
213 
214 /*
215  * return SISCone package name.
216  * This is nothing but "SISCone", it is a replacement to the
217  * PACKAGE_NAME string defined in config.h and which is not
218  * public by default.
219  * return the SISCone name as a string
220  */
221 string siscone_package_name(){
222  return PACKAGE_NAME;
223 }
224 
225 /*
226  * return SISCone version number.
227  * return a string of the form "X.Y.Z" with possible additional tag
228  * (alpha, beta, devel) to mention stability status
229  */
230 string siscone_version(){
231  return VERSION;
232 }
233 
234 }
class corresponding to errors that will be thrown by siscone
Definition: siscone_error.h:38
static bool init_done
check random generator initialisation
Definition: siscone.h:99
int compute_jets(std::vector< CSphmomentum > &_particles, double _radius, double _f, int _n_pass_max=0, double _Emin=0.0, Esplit_merge_scale _split_merge_scale=SM_Etilde)
compute the jets from a given particle set.
Definition: siscone.cpp:88
void init(std::vector< CSphmomentum > &_particle_list)
initialisation
Definition: protocones.cpp:116
int recompute_jets(double _f, double _Emin=0.0, Esplit_merge_scale _split_merge_scale=SM_Etilde)
recompute the jets with a different overlap parameter.
Definition: siscone.cpp:189
~CSphsiscone()
default dtor
Definition: siscone.cpp:66
CSphsiscone()
default ctor
Definition: siscone.cpp:60
The SISCone project has been developed by Gavin Salam and Gregory Soyez
Documentation generated for SISCone by  Doxygen 1.8.13