siscone is hosted by Hepforge, IPPP Durham

The SISCone Jet Algorithm

Version 3.0.6



SISCone 3.0.6
siscone.cpp
1
2// 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:: $//
26// $Date:: $//
28
29#include <siscone/config.h>
30#include <siscone/ranlux.h>
31#include <siscone/siscone_error.h>
32#include <siscone/defines.h>
33#include "momentum.h"
34#include "siscone.h"
35#include <iostream>
36#include <sstream>
37#include <iomanip>
38
39namespace siscone_spherical{
40using namespace std;
41
42/***************************************************************
43 * CSphsiscone implementation *
44 * final class: gather everything to compute the jet contents. *
45 * *
46 * This is the class user should use. *
47 * It computes the jet contents of a list of particles *
48 * given a cone radius and a threshold for splitting/merging. *
49 ***************************************************************/
50
51// default ctor
52//--------------
54 rerun_allowed = false;
55}
56
57// default dtor
58//--------------
60 rerun_allowed = false;
61}
62
63bool CSphsiscone::init_done=false;
64std::ostream* CSphsiscone::_banner_ostr=&cout;
65
66/*
67 * compute the jets from a given particle set doing multiple passes
68 * such pass N looks for jets among all particles not put into jets
69 * during previous passes.
70 * - _particles list of particles
71 * - _radius cone radius
72 * - _f shared energy threshold for splitting&merging
73 * - _n_pass_max maximum number of runs
74 * - _Emin minimum energy of the protojets
75 * - _split_merge_scale the scale choice for the split-merge procedure
76 * NOTE: using pt leads to IR unsafety for some events with momentum
77 * conservation. So we strongly advise not to change the default
78 * value.
79 * return the number of jets found.
80 **********************************************************************/
81int CSphsiscone::compute_jets(vector<CSphmomentum> &_particles, double _radius, double _f,
82 int _n_pass_max, double _Emin,
83 Esplit_merge_scale _split_merge_scale){
84 // make sure things are initialised
85 _initialise_if_needed();
86
87 // run some general safety tests (NB: f will be checked in split-merge)
88 if (_radius <= 0.0 || _radius >= 0.5*M_PI) {
89 ostringstream message;
90 message << "Illegal value for cone radius, R = " << _radius
91 << " (legal values are 0<R<pi/2)";
92 throw siscone::Csiscone_error(message.str());
93 }
94
95
96
97 ptcomparison.split_merge_scale = _split_merge_scale;
98 partial_clear(); // make sure some things are initialised properly
99
100 // init the split_merge algorithm with the initial list of particles
101 // this initialises particle list p_left of remaining particles to deal with
102 init_particles(_particles);
103
104 bool finished = false;
105
106 rerun_allowed = false;
107 protocones_list.clear();
108
109#ifdef DEBUG_STABLE_CONES
110 nb_hash_cones_total = 0;
111 nb_hash_occupied_total = 0;
112#endif
113
114 do{
115 // initialise stable_cone finder
116 // here we use the list of remaining particles
117 // AFTER COLLINEAR CLUSTERING !!!!!!
119
120 // get stable cones
121 if (get_stable_cones(_radius)){
122 // we have some new protocones.
123 // add them to candidates
124 protocones_list.push_back(protocones);
125 add_protocones(&protocones, R2, _Emin);
126#ifdef DEBUG_STABLE_CONES
127 nb_hash_cones_total += nb_hash_cones;
128 nb_hash_occupied_total += nb_hash_occupied;
129#endif
130 } else {
131 // no new protocone: leave
132 finished=true;
133 }
134
135 _n_pass_max--;
136 } while ((!finished) && (n_left>0) && (_n_pass_max!=0));
137
138 rerun_allowed = true;
139
140 // split & merge
141 return perform(_f, _Emin);
142}
143
144/*
145 * compute the jets from a given particle set doing multiple passes
146 * such pass N looks for jets among all particles not put into jets
147 * during previous passes.
148 * - _particles list of particles
149 * - _radius cone radius
150 * - _n_pass_max maximum number of runs
151 * - _Emin minimum energy of the protojets
152 * - _ordering_scale the ordering scale to decide which stable
153 * cone is removed
154 * return the number of jets found.
155 **********************************************************************/
156int CSphsiscone::compute_jets_progressive_removal(vector<CSphmomentum> &_particles, double _radius,
157 int _n_pass_max, double _Emin,
158 Esplit_merge_scale _ordering_scale){
159 // make sure things are initialised
160 _initialise_if_needed();
161
162 // run some general safety tests (NB: f will be checked in split-merge)
163 if (_radius <= 0.0 || _radius >= 0.5*M_PI) {
164 ostringstream message;
165 message << "Illegal value for cone radius, R = " << _radius
166 << " (legal values are 0<R<pi/2)";
167 throw siscone::Csiscone_error(message.str());
168 }
169
170 ptcomparison.split_merge_scale = _ordering_scale;
171 partial_clear(); // make sure some things are initialised properly
172
173 // init the split_merge algorithm with the initial list of particles
174 // this initialises particle list p_left of remaining particles to deal with
175 //
176 // this stores the "processed" particles in p_uncol_hard
177 init_particles(_particles);
178 jets.clear();
179
180 bool unclustered_left;
181 rerun_allowed = false;
182 protocones_list.clear();
183
184 do{
185 //cout << n_left << " particle left" << endl;
186
187 // initialise stable_cone finder
188 // here we use the list of remaining particles
189 // AFTER COLLINEAR CLUSTERING !!!!!!
191
192 // get stable cones (stored in 'protocones')
193 unclustered_left = get_stable_cones(_radius);
194
195 // add the hardest stable cone to the list of jets
196 if (add_hardest_protocone_to_jets(&protocones, R2, _Emin)) break;
197
198 _n_pass_max--;
199 } while ((unclustered_left) && (n_left>0) && (_n_pass_max!=0));
200
201 // split & merge
202 return jets.size();
203}
204/*
205 * recompute the jets with a different overlap parameter.
206 * we use the same particles and R as in the preceeding call.
207 * - _f shared energy threshold for splitting&merging
208 * - _Emin minimum Energy of the protojets
209 * - _split_merge_scale the scale choice for the split-merge procedure
210 * NOTE: using pt leads to IR unsafety for some events with momentum
211 * conservation. So we strongly advise not to change the default
212 * value.
213 * return the number of jets found, -1 if recomputation not allowed.
214 ********************************************************************/
215int CSphsiscone::recompute_jets(double _f, double _Emin,
216 Esplit_merge_scale _split_merge_scale){
217 if (!rerun_allowed)
218 return -1;
219
220 ptcomparison.split_merge_scale = _split_merge_scale;
221
222 // restore particle list
224 init_pleft();
225
226 // initialise split/merge algorithm
227 unsigned int i;
228 for (i=0;i<protocones_list.size();i++)
229 add_protocones(&(protocones_list[i]), R2, _Emin);
230
231 // split & merge
232 return perform(_f, _Emin);
233}
234
235
236// make sure things are initialised
237void CSphsiscone::_initialise_if_needed(){
238 // initialise random number generator
239 if (init_done) return;
240
241 // initialise random number generator
242 siscone::ranlux_init();
243
244 // do not do this again
245 init_done=true;
246
247 // print the banner
248 if (_banner_ostr != 0){
249 ios::fmtflags flags_to_restore(_banner_ostr->flags());
250
251 (*_banner_ostr) << "#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" << endl;
252 (*_banner_ostr) << "# SISCone version " << setw(28) << left << siscone_version() << "o" << endl;
253 (*_banner_ostr) << "# http://projects.hepforge.org/siscone o" << endl;
254 (*_banner_ostr) << "# o" << endl;
255 (*_banner_ostr) << "# This is SISCone: the Seedless Infrared Safe Cone Jet Algorithm o" << endl;
256 (*_banner_ostr) << "# SISCone was written by Gavin Salam and Gregory Soyez o" << endl;
257 (*_banner_ostr) << "# It is released under the terms of the GNU General Public License o" << endl;
258 (*_banner_ostr) << "# o" << endl;
259 (*_banner_ostr) << "# !!! WARNING !!! o" << endl;
260 (*_banner_ostr) << "# This is the version of SISCone using spherical coordinates o" << endl;
261 (*_banner_ostr) << "# o" << endl;
262 (*_banner_ostr) << "# A description of the algorithm is available in the publication o" << endl;
263 (*_banner_ostr) << "# JHEP 05 (2007) 086 [arXiv:0704.0292 (hep-ph)]. o" << endl;
264 (*_banner_ostr) << "# Please cite it if you use SISCone. o" << endl;
265 (*_banner_ostr) << "#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" << endl;
266 (*_banner_ostr) << endl;
267
268 _banner_ostr->flush();
269 _banner_ostr->flags(flags_to_restore);
270 }
271}
272
273// finally, a bunch of functions to access to
274// basic information (package name, version)
275//---------------------------------------------
276
277/*
278 * return SISCone package name.
279 * This is nothing but "SISCone", it is a replacement to the
280 * SISCONE_PACKAGE_NAME string defined in config.h and which is not
281 * guaranteed to be public.
282 * return the SISCone name as a string
283 */
284string siscone_package_name(){
285 return SISCONE_PACKAGE_NAME;
286}
287
288/*
289 * return SISCone version number.
290 * return a string of the form "X.Y.Z" with possible additional tag
291 * (alpha, beta, devel) to mention stability status
292 */
293string siscone_version(){
294 return SISCONE_VERSION;
295}
296
297}
class corresponding to errors that will be thrown by siscone
Definition: siscone_error.h:38
int compute_jets_progressive_removal(std::vector< CSphmomentum > &_particles, double _radius, int _n_pass_max=0, double _Emin=0.0, Esplit_merge_scale _ordering_scale=SM_Etilde)
compute the jets from a given particle set.
Definition: siscone.cpp:156
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:81
std::vector< std::vector< CSphmomentum > > protocones_list
list of protocones found pass-by-pass
Definition: siscone.h:114
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:215
static bool init_done
check random generator initialisation
Definition: siscone.h:117
Esplit_merge_scale split_merge_scale
the following parameter controls the variable we're using for the split-merge process i....
Definition: split_merge.h:158
int perform(double overlap_tshold, double Emin=0.0)
really do the splitting and merging At the end, the vector jets is filled with the jets found.
int partial_clear()
partial clearance
int add_hardest_protocone_to_jets(std::vector< CSphmomentum > *protocones, double R2, double Emin=0.0)
remove the hardest protocone and declare it a a jet
int init_pleft()
build initial list of left particles
std::vector< CSphmomentum > p_uncol_hard
list of particles remaining with collinear clustering
Definition: split_merge.h:348
int init_particles(std::vector< CSphmomentum > &_particles)
initialisation function for particle list
int n_left
numer of particles that does not belong to any jet
Definition: split_merge.h:346
std::vector< CSphjet > jets
list of jets
Definition: split_merge.h:357
CSphsplit_merge_ptcomparison ptcomparison
member used for detailed comparisons of pt's
Definition: split_merge.h:374
int add_protocones(std::vector< CSphmomentum > *protocones, double R2, double Emin=0.0)
add a list of protocones
void init(std::vector< CSphmomentum > &_particle_list)
initialisation
Definition: protocones.cpp:116
int get_stable_cones(double _radius)
compute stable cones.
Definition: protocones.cpp:143
double R2
cone radius SQUARED
Definition: protocones.h:132
std::vector< CSphmomentum > protocones
list of stable cones
Definition: protocones.h:116

The SISCone project has been developed by Gavin Salam and Gregory Soyez
Documentation generated on Tue Jun 20 2023 18:08:37 for SISCone by  Doxygen 1.9.4