Fork me on GitHub

source: git/external/fastjet/plugins/SISCone/siscone.cc@ 93da593

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 93da593 was 273e668, checked in by Pavel Demin <pavel.demin@…>, 10 years ago

upgrade FastJet to version 3.1.0

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