Fork me on GitHub

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

Timing
Last change on this file since 6049672 was 1d208a2, checked in by Pavel Demin <pavel.demin@…>, 8 years ago

update FastJet library to 3.2.1 and Nsubjettiness library to 2.2.4

  • Property mode set to 100644
File size: 10.9 KB
RevLine 
[d7d2da3]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// //
[1d208a2]23// $Revision:: 403 $//
24// $Date:: 2016-05-19 16:52:05 +0200 (Thu, 19 May 2016) $//
[d7d2da3]25///////////////////////////////////////////////////////////////////////////////
26
27#include "config.h"
28#include "ranlux.h"
29#include "momentum.h"
30#include "defines.h"
31#include "siscone.h"
32#include "siscone_error.h"
33#include <iostream>
34#include <sstream>
35#include <iomanip>
36
37namespace siscone{
38using namespace std;
39
40/***************************************************************
41 * Csiscone implementation *
42 * final class: gather everything to compute the jet contents. *
43 * *
44 * This is the class user should use. *
45 * It computes the jet contents of a list of particles *
46 * given a cone radius and a threshold for splitting/merging. *
47 ***************************************************************/
48
49// default ctor
50//--------------
51Csiscone::Csiscone(){
52 rerun_allowed = false;
53}
54
55// default dtor
56//--------------
57Csiscone::~Csiscone(){
58 rerun_allowed = false;
59}
60
61bool Csiscone::init_done=false;
62std::ostream* Csiscone::_banner_ostr = &cout;
63
64/*
65 * compute the jets from a given particle set doing multiple passes
66 * such pass N looks for jets among all particles not put into jets
67 * during previous passes.
68 * - _particles list of particles
69 * - _radius cone radius
70 * - _f shared energy threshold for splitting&merging
71 * - _n_pass_max maximum number of runs
72 * - _ptmin minimum pT of the protojets
73 * - _split_merge_scale the scale choice for the split-merge procedure
74 * NOTE: using pt leads to IR unsafety for some events with momentum
75 * conservation. So we strongly advise not to change the default
76 * value.
77 * return the number of jets found.
78 **********************************************************************/
79int Csiscone::compute_jets(vector<Cmomentum> &_particles, double _radius, double _f,
80 int _n_pass_max, double _ptmin,
81 Esplit_merge_scale _split_merge_scale){
[273e668]82 _initialise_if_needed();
[d7d2da3]83
84 // run some general safety tests (NB: f will be checked in split-merge)
85 if (_radius <= 0.0 || _radius >= 0.5*M_PI) {
86 ostringstream message;
87 message << "Illegal value for cone radius, R = " << _radius
88 << " (legal values are 0<R<pi/2)";
89 throw Csiscone_error(message.str());
90 }
91
92
93
94 ptcomparison.split_merge_scale = _split_merge_scale;
95 partial_clear(); // make sure some things are initialised properly
96
97 // init the split_merge algorithm with the initial list of particles
98 // this initialises particle list p_left of remaining particles to deal with
99 init_particles(_particles);
100
101 bool finished = false;
102
103 rerun_allowed = false;
104 protocones_list.clear();
105
106#ifdef DEBUG_STABLE_CONES
107 nb_hash_cones_total = 0;
108 nb_hash_occupied_total = 0;
109#endif
110
111 do{
112 // initialise stable_cone finder
113 // here we use the list of remaining particles
114 // AFTER COLLINEAR CLUSTERING !!!!!!
115 Cstable_cones::init(p_uncol_hard);
116
117 // get stable cones
118 if (get_stable_cones(_radius)){
119 // we have some new protocones; add them to candidates
120 // Note that add_protocones has to be called first
121 // if we want the 4-vect components to be available
122 // on top of eta and phi.
123 add_protocones(&protocones, R2, _ptmin);
124 protocones_list.push_back(protocones);
125#ifdef DEBUG_STABLE_CONES
126 nb_hash_cones_total += nb_hash_cones;
127 nb_hash_occupied_total += nb_hash_occupied;
128#endif
129 } else {
130 // no new protocone: leave
131 finished=true;
132 }
133
134 _n_pass_max--;
135 } while ((!finished) && (n_left>0) && (_n_pass_max!=0));
136
137 rerun_allowed = true;
138
139 // split & merge
140 return perform(_f, _ptmin);
141}
142
[273e668]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 * - _ptmin minimum pT 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 Csiscone::compute_jets_progressive_removal(vector<Cmomentum> &_particles, double _radius,
157 int _n_pass_max, double _ptmin,
158 Esplit_merge_scale _ordering_scale){
159 _initialise_if_needed();
160
161 // run some general safety tests (NB: f will be checked in split-merge)
162 if (_radius <= 0.0 || _radius >= 0.5*M_PI) {
163 ostringstream message;
164 message << "Illegal value for cone radius, R = " << _radius
165 << " (legal values are 0<R<pi/2)";
166 throw Csiscone_error(message.str());
167 }
168
169 ptcomparison.split_merge_scale = _ordering_scale;
170 partial_clear(); // make sure some things are initialised properly
171
172 // init the split_merge algorithm with the initial list of particles
173 // this initialises particle list p_left of remaining particles to deal with
174 //
175 // this stores the "processed" particles in p_uncol_hard
176 init_particles(_particles);
177 jets.clear();
178
179 bool unclustered_left;
180 rerun_allowed = false;
181 protocones_list.clear();
182
183 do{
184 //cout << n_left << " particle left" << endl;
185
186 // initialise stable_cone finder
187 // here we use the list of remaining particles
188 // AFTER COLLINEAR CLUSTERING !!!!!!
189 Cstable_cones::init(p_uncol_hard);
190
191 // get stable cones (stored in 'protocones')
192 unclustered_left = get_stable_cones(_radius);
193
194 // add the hardest stable cone to the list of jets
195 if (add_hardest_protocone_to_jets(&protocones, R2, _ptmin)) break;
196
197 _n_pass_max--;
198 } while ((unclustered_left) && (n_left>0) && (_n_pass_max!=0));
199
200 // split & merge
201 return jets.size();
202}
203
204
[d7d2da3]205/*
206 * recompute the jets with a different overlap parameter.
207 * we use the same particles and R as in the preceeding call.
208 * - _f shared energy threshold for splitting&merging
209 * - _ptmin minimum pT of the protojets
210 * - _split_merge_scale the scale choice for the split-merge procedure
211 * NOTE: using pt leads to IR unsafety for some events with momentum
212 * conservation. So we strongly advise not to change the default
213 * value.
214 * return the number of jets found, -1 if recomputation not allowed.
215 ********************************************************************/
216int Csiscone::recompute_jets(double _f, double _ptmin,
217 Esplit_merge_scale _split_merge_scale){
218 if (!rerun_allowed)
219 return -1;
220
221 ptcomparison.split_merge_scale = _split_merge_scale;
222
223 // restore particle list
224 partial_clear();
225 init_pleft();
226
227 // initialise split/merge algorithm
228 unsigned int i;
229 for (i=0;i<protocones_list.size();i++)
230 add_protocones(&(protocones_list[i]), R2, _ptmin);
231
232 // split & merge
233 return perform(_f, _ptmin);
234}
235
[273e668]236// ensure things are initialised
237void Csiscone::_initialise_if_needed(){
238 // initialise random number generator
239 if (init_done) return;
240
241 // initialise random number generator
242 ranlux_init();
243
244 // do not do this again
245 init_done=true;
246
247 // print the banner
248 if (_banner_ostr != 0){
[1d208a2]249 ios::fmtflags flags_to_restore(_banner_ostr->flags());
250
[273e668]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) << "# A description of the algorithm is available in the publication o" << endl;
260 (*_banner_ostr) << "# JHEP 05 (2007) 086 [arXiv:0704.0292 (hep-ph)]. o" << endl;
261 (*_banner_ostr) << "# Please cite it if you use SISCone. o" << endl;
262 (*_banner_ostr) << "#ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" << endl;
263 (*_banner_ostr) << endl;
264
265 _banner_ostr->flush();
[1d208a2]266 _banner_ostr->flags(flags_to_restore);
[273e668]267 }
268}
[d7d2da3]269
270// finally, a bunch of functions to access to
271// basic information (package name, version)
272//---------------------------------------------
273
274/*
275 * return SISCone package name.
276 * This is nothing but "SISCone", it is a replacement to the
[1d208a2]277 * SISCONE_PACKAGE_NAME string defined in config.h and which is not
278 * guaranteed to be public.
[d7d2da3]279 * return the SISCone name as a string
280 */
281string siscone_package_name(){
[1d208a2]282 return SISCONE_PACKAGE_NAME;
[d7d2da3]283}
284
285/*
286 * return SISCone version number.
287 * return a string of the form "X.Y.Z" with possible additional tag
288 * (alpha, beta, devel) to mention stability status
289 */
290string siscone_version(){
[1d208a2]291 return SISCONE_VERSION;
[d7d2da3]292}
293
294}
Note: See TracBrowser for help on using the repository browser.