Fork me on GitHub

source: svn/trunk/external/fastjet/plugins/SISCone/siscone.cc@ 1393

Last change on this file since 1393 was 1332, checked in by Pavel Demin, 11 years ago

upgrade fastjet to 3.0.6

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision Date
File size: 8.8 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:: 1332 $//
24// $Date:: 2013-11-20 20:52:59 +0000 (Wed, 20 Nov 2013) $//
25///////////////////////////////////////////////////////////////////////////////
26
27//#ifdef HAVE_CONFIG_H
28#include "config.h"
29//#else
30//#define PACKAGE_NAME "SISCone"
31//#define VERSION "2.0.6"
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 random number generator
90 if (!init_done){
91 // initialise random number generator
92 ranlux_init();
93
94 // do not do this again
95 init_done=true;
96
97 // print the banner
98 if (_banner_ostr != 0){
99 (*_banner_ostr) << "#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" << endl;
100 (*_banner_ostr) << "# SISCone version " << setw(28) << left << siscone_version() << "o" << endl;
101 (*_banner_ostr) << "# http://projects.hepforge.org/siscone o" << endl;
102 (*_banner_ostr) << "# o" << endl;
103 (*_banner_ostr) << "# This is SISCone: the Seedless Infrared Safe Cone Jet Algorithm o" << endl;
104 (*_banner_ostr) << "# SISCone was written by Gavin Salam and Gregory Soyez o" << endl;
105 (*_banner_ostr) << "# It is released under the terms of the GNU General Public License o" << endl;
106 (*_banner_ostr) << "# o" << endl;
107 (*_banner_ostr) << "# A description of the algorithm is available in the publication o" << endl;
108 (*_banner_ostr) << "# JHEP 05 (2007) 086 [arXiv:0704.0292 (hep-ph)]. o" << endl;
109 (*_banner_ostr) << "# Please cite it if you use SISCone. o" << endl;
110 (*_banner_ostr) << "#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" << endl;
111 (*_banner_ostr) << endl;
112
113 _banner_ostr->flush();
114 }
115 }
116
117 // run some general safety tests (NB: f will be checked in split-merge)
118 if (_radius <= 0.0 || _radius >= 0.5*M_PI) {
119 ostringstream message;
120 message << "Illegal value for cone radius, R = " << _radius
121 << " (legal values are 0<R<pi/2)";
122 throw Csiscone_error(message.str());
123 }
124
125
126
127 ptcomparison.split_merge_scale = _split_merge_scale;
128 partial_clear(); // make sure some things are initialised properly
129
130 // init the split_merge algorithm with the initial list of particles
131 // this initialises particle list p_left of remaining particles to deal with
132 init_particles(_particles);
133
134 bool finished = false;
135
136 rerun_allowed = false;
137 protocones_list.clear();
138
139#ifdef DEBUG_STABLE_CONES
140 nb_hash_cones_total = 0;
141 nb_hash_occupied_total = 0;
142#endif
143
144 do{
145 // initialise stable_cone finder
146 // here we use the list of remaining particles
147 // AFTER COLLINEAR CLUSTERING !!!!!!
148 Cstable_cones::init(p_uncol_hard);
149
150 // get stable cones
151 if (get_stable_cones(_radius)){
152 // we have some new protocones; add them to candidates
153 // Note that add_protocones has to be called first
154 // if we want the 4-vect components to be available
155 // on top of eta and phi.
156 add_protocones(&protocones, R2, _ptmin);
157 protocones_list.push_back(protocones);
158#ifdef DEBUG_STABLE_CONES
159 nb_hash_cones_total += nb_hash_cones;
160 nb_hash_occupied_total += nb_hash_occupied;
161#endif
162 } else {
163 // no new protocone: leave
164 finished=true;
165 }
166
167 _n_pass_max--;
168 } while ((!finished) && (n_left>0) && (_n_pass_max!=0));
169
170 rerun_allowed = true;
171
172 // split & merge
173 return perform(_f, _ptmin);
174}
175
176/*
177 * recompute the jets with a different overlap parameter.
178 * we use the same particles and R as in the preceeding call.
179 * - _f shared energy threshold for splitting&merging
180 * - _ptmin minimum pT of the protojets
181 * - _split_merge_scale the scale choice for the split-merge procedure
182 * NOTE: using pt leads to IR unsafety for some events with momentum
183 * conservation. So we strongly advise not to change the default
184 * value.
185 * return the number of jets found, -1 if recomputation not allowed.
186 ********************************************************************/
187int Csiscone::recompute_jets(double _f, double _ptmin,
188 Esplit_merge_scale _split_merge_scale){
189 if (!rerun_allowed)
190 return -1;
191
192 ptcomparison.split_merge_scale = _split_merge_scale;
193
194 // restore particle list
195 partial_clear();
196 init_pleft();
197
198 // initialise split/merge algorithm
199 unsigned int i;
200 for (i=0;i<protocones_list.size();i++)
201 add_protocones(&(protocones_list[i]), R2, _ptmin);
202
203 // split & merge
204 return perform(_f, _ptmin);
205}
206
207
208// finally, a bunch of functions to access to
209// basic information (package name, version)
210//---------------------------------------------
211
212/*
213 * return SISCone package name.
214 * This is nothing but "SISCone", it is a replacement to the
215 * PACKAGE_NAME string defined in config.h and which is not
216 * public by default.
217 * return the SISCone name as a string
218 */
219string siscone_package_name(){
220 return PACKAGE_NAME;
221}
222
223/*
224 * return SISCone version number.
225 * return a string of the form "X.Y.Z" with possible additional tag
226 * (alpha, beta, devel) to mention stability status
227 */
228string siscone_version(){
229 return VERSION;
230}
231
232}
Note: See TracBrowser for help on using the repository browser.