Fork me on GitHub

source: svn/trunk/Utilities/Fastjet/plugins/SISCone/interface/split_merge.h@ 568

Last change on this file since 568 was 11, checked in by severine ovyn, 16 years ago

Fastjet added; CDFCones directory has been changed

File size: 13.2 KB
Line 
1// -*- C++ -*-
2///////////////////////////////////////////////////////////////////////////////
3// File: split_merge.h //
4// Description: header file for splitting/merging (contains the CJet class) //
5// This file is part of the SISCone project. //
6// For more details, see http://projects.hepforge.org/siscone //
7// //
8// Copyright (c) 2006 Gavin Salam and Gregory Soyez //
9// //
10// This program is free software; you can redistribute it and/or modify //
11// it under the terms of the GNU General Public License as published by //
12// the Free Software Foundation; either version 2 of the License, or //
13// (at your option) any later version. //
14// //
15// This program is distributed in the hope that it will be useful, //
16// but WITHOUT ANY WARRANTY; without even the implied warranty of //
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
18// GNU General Public License for more details. //
19// //
20// You should have received a copy of the GNU General Public License //
21// along with this program; if not, write to the Free Software //
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
23// //
24// $Revision: 1.1 $//
25// $Date: 2008-11-06 14:32:12 $//
26///////////////////////////////////////////////////////////////////////////////
27
28#ifndef __SPLIT_MERGE_H__
29#define __SPLIT_MERGE_H__
30
31#include "../interface/defines.h"
32#include "../interface/geom_2d.h"
33#include "../interface/momentum.h"
34#include <stdio.h>
35#include <vector>
36#include <set>
37#include <memory>
38#include <string>
39
40namespace siscone{
41
42/**
43 * \class Cjet
44 * real Jet information.
45 *
46 * This class contains information for one single jet.
47 * That is, first, its momentum carrying information
48 * about its centre and pT, and second, its particle
49 * contents
50 */
51class Cjet{
52 public:
53 /// default ctor
54 Cjet();
55
56 /// default dtor
57 ~Cjet();
58
59 Cmomentum v; ///< jet momentum
60 double pt_tilde; ///< p-scheme pt
61 int n; ///< number of particles inside
62 std::vector<int> contents; ///< particle contents (list of indices)
63
64 /// ordering variable used for ordering and overlap in the
65 /// split--merge. This variable is automatically set either to
66 /// pt_tilde, or to mt or to pt, depending on the siscone
67 /// parameter. Note that the default behaviour is pt_tilde and that
68 /// other chices may lead to infrared unsafe situations.
69 /// Note: we use the square of the varible rather than the variable itself
70 double sm_var2;
71
72 /// covered range in eta-phi
73 Ceta_phi_range range;
74
75 /// pass at which the jet has been found
76 /// It starts at 0 (first pass), -1 means infinite rapidity
77 int pass;
78};
79
80/// ordering of jets in pt (e.g. used in final jets ordering)
81bool jets_pt_less(const Cjet &j1, const Cjet &j2);
82
83
84/// the choices of scale variable that can be used in the split-merge
85/// step, both for ordering the protojets and for measuing their
86/// overlap; pt, Et and mt=sqrt(pt^2+m^2) are all defined in E-scheme
87/// (4-momentum) recombination; pttilde = \sum_{i\in jet} |p_{t,i}|
88///
89/// NB: if one changes the order here, one _MUST_ also change the order
90/// in the SISCone plugin
91enum Esplit_merge_scale {
92 SM_pt, ///< transverse momentum (E-scheme), IR unsafe
93 SM_Et, ///< transverse energy (E-scheme), not long. boost inv.
94 ///< original run-II choice [may not be implemented]
95 SM_mt, ///< transverse mass (E-scheme), IR safe except
96 ///< in decays of two identical narrow heavy particles
97 SM_pttilde ///< pt-scheme pt = \sum_{i in jet} |p_{ti}|, should
98 ///< be IR safe in all cases
99};
100
101/// return the name of the split-merge scale choice
102std::string split_merge_scale_name(Esplit_merge_scale sms);
103
104/**
105 * \class Csplit_merge_comparison
106 * a class that allows us to carry out comparisons of pt of jets, using
107 * information from exact particle contents where necessary.
108 *
109 */
110class Csplit_merge_ptcomparison{
111public:
112 Csplit_merge_ptcomparison() :
113 particles(0), split_merge_scale(SM_pttilde){};
114
115 // return the name corresponding to the SM scale variable
116 std::string SM_scale_name() const {
117 return split_merge_scale_name(split_merge_scale);}
118
119 std::vector<Cmomentum> * particles;
120 std::vector<double> * pt;
121 bool operator()(const Cjet &jet1, const Cjet &jet2) const;
122
123 /**
124 * get the difference between 2 jets, calculated such that rounding
125 * errors will not affect the result even if the two jets have
126 * almost the same content (so that the difference is below the
127 * rounding errors)
128 *
129 * \param j1 first jet
130 * \param j2 second jet
131 * \param v jet1-jet2
132 * \param pt_tilde jet1-jet2 pt_tilde
133 */
134 void get_difference(const Cjet &j1, const Cjet &j2, Cmomentum *v, double *pt_tilde) const;
135
136 /// the following parameter controls the variable we're using for
137 /// the split-merge process i.e. the variable we use for
138 /// 1. ordering jet candidates;
139 /// 2. computing te overlap fraction of two candidates.
140 /// The default value uses pttile (p-scheme pt). Other alternatives are
141 /// pt, mt=sqrt(pt^2+m^2)=sqrt(E^2-pz^2) or Et.
142 /// NOTE: Modifying the default choice can have nasty effects:
143 /// - using pt leads to some IR unsafety when we have two jets,
144 /// e.g. back-to-back, with the same pt. In that case, their ordering
145 /// in pt is random and can be affected by the addition of a
146 /// soft particle. Hence, we highly recommand to keep this to
147 /// the default value i.e. to use pt only for the purpose of
148 /// investigating the IR issue
149 /// - using Et is safe but do not respect boost invariance
150 /// - using mt solves the IR unsafety issues with the pt variable
151 /// for QCD jets but the IR unsafety remains for nack-to-back
152 /// jets of unstable narrow-width particles (e.g. Higgs).
153 /// Therefore, keeping the default value is strongly advised.
154 Esplit_merge_scale split_merge_scale;
155};
156
157
158// iterator types
159/// iterator definition for the jet candidates structure
160typedef std::multiset<siscone::Cjet,Csplit_merge_ptcomparison>::iterator cjet_iterator;
161
162/// iterator definition for the jet structure
163typedef std::vector<siscone::Cjet>::iterator jet_iterator;
164
165
166
167/**
168 * \class Csplit_merge
169 * Class used to split and merge jets.
170 */
171class Csplit_merge{
172 public:
173 /// default ctor
174 Csplit_merge();
175
176 /// default dtor
177 ~Csplit_merge();
178
179
180 //////////////////////////////
181 // initialisation functions //
182 //////////////////////////////
183
184 /**
185 * initialisation function
186 * \param _particles list of particles
187 * \param protocones list of protocones (initial jet candidates)
188 * \param R2 cone radius (squared)
189 * \param ptmin minimal pT allowed for jets
190 * \return 0 on success, 1 on error
191 */
192 int init(std::vector<Cmomentum> &_particles, std::vector<Cmomentum> *protocones, double R2, double ptmin=0.0);
193
194 /**
195 * initialisation function for particle list
196 * \param _particles list of particles
197 * \return 0 on success, 1 on error
198 */
199 int init_particles(std::vector<Cmomentum> &_particles);
200
201 /**
202 * build initial list of left particles
203 */
204 int init_pleft();
205
206
207 ////////////////////////
208 // cleaning functions //
209 ////////////////////////
210
211 /// partial clearance
212 int partial_clear();
213
214 /// full clearance
215 int full_clear();
216
217
218 /////////////////////////////////
219 // main parts of the algorithm //
220 /////////////////////////////////
221
222 /**
223 * build the list 'p_uncol_hard' from p_remain by clustering
224 * collinear particles and removing particles softer than
225 * stable_cone_soft_pt2_cutoff
226 * note that thins in only used for stable-cone detection
227 * so the parent_index field is unnecessary
228 */
229 int merge_collinear_and_remove_soft();
230
231 /**
232 * add a list of protocones
233 * \param protocones list of protocones (initial jet candidates)
234 * \param R2 cone radius (squared)
235 * \param ptmin minimal pT allowed for jets
236 * \return 0 on success, 1 on error
237 */
238 int add_protocones(std::vector<Cmomentum> *protocones, double R2, double ptmin=0.0);
239
240 /**
241 * really do the splitting and merging
242 * At the end, the vector jets is filled with the jets found.
243 * the 'contents' field of each jets contains the indices
244 * of the particles included in that jet.
245 * \param overlap_tshold threshold for splitting/merging transition
246 * \param ptmin minimal pT allowed for jets
247 * \return the number of jets is returned
248 */
249 int perform(double overlap_tshold, double ptmin=0.0);
250
251
252 //////////////////////////////
253 // save and debug functions //
254 //////////////////////////////
255
256 /// save final jets
257 /// \param flux stream to save the jet contentss
258 int save_contents(FILE *flux);
259
260 /// show jets/candidates status
261 int show();
262
263 // particle information
264 int n; ///< number of particles
265 std::vector<Cmomentum> particles; ///< list of particles
266 std::vector<double> pt; ///< list of particles' pt
267 int n_left; ///< numer of particles that does not belong to any jet
268 std::vector<Cmomentum> p_remain; ///< list of particles remaining to deal with
269 std::vector<Cmomentum> p_uncol_hard; ///< list of particles remaining with collinear clustering
270 int n_pass; ///< index of the run
271
272 /// minimal difference in squared distance between a particle and
273 /// two overlapping protojets when doing a split (useful when
274 /// testing approx. collinear safety)
275 double most_ambiguous_split;
276
277 // jets information
278 std::vector<Cjet> jets; ///< list of jets
279
280 // working entries
281 int *indices; ///< maximal size array for indices works
282 int idx_size; ///< number of elements in indices1
283
284 /// The following flag indicates that identical protocones
285 /// are to be merged automatically each time around the split-merge
286 /// loop and before anything else happens.
287 ///
288 /// This flag is only effective if ALLOW_MERGE_IDENTICAL_PROTOCONES
289 /// is set in 'defines.h'
290 /// Note that this lead to infrared-unsafety so it is disabled
291 /// by default
292 bool merge_identical_protocones;
293
294 /// member used for detailed comparisons of pt's
295 Csplit_merge_ptcomparison ptcomparison;
296
297 /// stop split--merge when the SM_var of the hardest protojet
298 /// is below this cut-off.
299 /// This is not collinear-safe so you should not use this
300 /// variable unless you really know what you are doing
301 /// Note that the cut-off is set on the variable squared.
302 double SM_var2_hardest_cut_off;
303
304 /// pt cutoff for the particles to put in p_uncol_hard
305 /// this is meant to allow removing soft particles in the
306 /// stable-cone search.
307 double stable_cone_soft_pt2_cutoff;
308
309 private:
310 /**
311 * get the overlap between 2 jets
312 * \param j1 first jet
313 * \param j2 second jet
314 * \param v returned overlap^2 (determined by the choice of SM variable)
315 * \return true if overlapping, false if disjoint
316 */
317 bool get_overlap(const Cjet &j1, const Cjet &j2, double *v);
318
319
320 /**
321 * split the two given jets.
322 * during this procedure, the jets j1 & j2 are replaced
323 * by 2 new jets. Common particles are associted to the
324 * closest initial jet.
325 * \param it_j1 iterator of the first jet in 'candidates'
326 * \param it_j2 iterator of the second jet in 'candidates'
327 * \param j1 first jet (Cjet instance)
328 * \param j2 second jet (Cjet instance)
329 * \return true on success, false on error
330 */
331 bool split(cjet_iterator &it_j1, cjet_iterator &it_j2);
332
333 /**
334 * merge the two given jet.
335 * during this procedure, the jets j1 & j2 are replaced
336 * by 1 single jets containing both of them.
337 * \param it_j1 iterator of the first jet in 'candidates'
338 * \param it_j2 iterator of the second jet in 'candidates'
339 * \return true on success, false on error
340 */
341 bool merge(cjet_iterator &it_j1, cjet_iterator &it_j2);
342
343 /**
344 * Check whether or not a jet has to be inserted in the
345 * list of protojets. If it has, set its sm_variable and
346 * insert it to the list of protojets.
347 * \param jet jet to insert
348 */
349 bool insert(Cjet &jet);
350
351 /**
352 * given a 4-momentum and its associated pT, return the
353 * variable tht has to be used for SM
354 * \param v 4 momentum of the protojet
355 * \param pt_tilde pt_tilde of the protojet
356 */
357 double get_sm_var2(Cmomentum &v, double &pt_tilde);
358
359 // jet information
360 /// list of jet candidates
361 std::auto_ptr<std::multiset<Cjet,Csplit_merge_ptcomparison> > candidates;
362
363 /// minimal pt2
364 double pt_min2;
365
366#ifdef ALLOW_MERGE_IDENTICAL_PROTOCONES
367 /// checkxor for the candidates (to avoid having twice the same contents)
368 std::set<Creference> cand_refs;
369#endif
370};
371
372}
373
374
375#endif
Note: See TracBrowser for help on using the repository browser.