1 | //STARTHEADER
|
---|
2 | // $Id: JetDefinition.hh,v 1.1 2008-11-06 14:32:08 ovyn Exp $
|
---|
3 | //
|
---|
4 | // Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam
|
---|
5 | //
|
---|
6 | //----------------------------------------------------------------------
|
---|
7 | // This file is part of FastJet.
|
---|
8 | //
|
---|
9 | // FastJet 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 | // The algorithms that underlie FastJet have required considerable
|
---|
15 | // development and are described in hep-ph/0512210. If you use
|
---|
16 | // FastJet as part of work towards a scientific publication, please
|
---|
17 | // include a citation to the FastJet paper.
|
---|
18 | //
|
---|
19 | // FastJet is distributed in the hope that it will be useful,
|
---|
20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
22 | // GNU General Public License for more details.
|
---|
23 | //
|
---|
24 | // You should have received a copy of the GNU General Public License
|
---|
25 | // along with FastJet; if not, write to the Free Software
|
---|
26 | // Foundation, Inc.:
|
---|
27 | // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
28 | //----------------------------------------------------------------------
|
---|
29 | //ENDHEADER
|
---|
30 |
|
---|
31 | #ifndef __FASTJET_JETDEFINITION_HH__
|
---|
32 | #define __FASTJET_JETDEFINITION_HH__
|
---|
33 |
|
---|
34 | #include<cassert>
|
---|
35 | #include "Utilities/Fastjet/include/fastjet/internal/numconsts.hh"
|
---|
36 | #include "Utilities/Fastjet/include/fastjet/PseudoJet.hh"
|
---|
37 | #include<string>
|
---|
38 | #include<memory>
|
---|
39 |
|
---|
40 | FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
|
---|
41 |
|
---|
42 | /// return a string containing information about the release
|
---|
43 | // NB: (implemented in ClusterSequence.cc but defined here because
|
---|
44 | // this is a visible location)
|
---|
45 | std::string fastjet_version_string();
|
---|
46 |
|
---|
47 | //======================================================================
|
---|
48 | /// the various options for the algorithmic strategy to adopt in
|
---|
49 | /// clustering events with kt and cambridge style algorithms.
|
---|
50 | enum Strategy {
|
---|
51 | /// fastest form about 500..10^4
|
---|
52 | N2MinHeapTiled = -4,
|
---|
53 | /// fastest from about 50..500
|
---|
54 | N2Tiled = -3,
|
---|
55 | /// legacy
|
---|
56 | N2PoorTiled = -2,
|
---|
57 | /// fastest below 50
|
---|
58 | N2Plain = -1,
|
---|
59 | /// worse even than the usual N^3 algorithms
|
---|
60 | N3Dumb = 0,
|
---|
61 | /// automatic selection of the best (based on N)
|
---|
62 | Best = 1,
|
---|
63 | /// best of the NlnN variants -- best overall for N>10^4
|
---|
64 | NlnN = 2,
|
---|
65 | /// legacy N ln N using 3pi coverage of cylinder
|
---|
66 | NlnN3pi = 3,
|
---|
67 | /// legacy N ln N using 4pi coverage of cylinder
|
---|
68 | NlnN4pi = 4,
|
---|
69 | /// Chan's closest pair method (in a variant with 4pi coverage),
|
---|
70 | /// for use exclusively with the Cambridge algorithm
|
---|
71 | NlnNCam4pi = 14,
|
---|
72 | NlnNCam2pi2R = 13,
|
---|
73 | NlnNCam = 12, // 2piMultD
|
---|
74 | /// the plugin has been used...
|
---|
75 | plugin_strategy = 999
|
---|
76 | };
|
---|
77 |
|
---|
78 |
|
---|
79 | //======================================================================
|
---|
80 | /// the various families of jet-clustering algorithm
|
---|
81 | enum JetAlgorithm {
|
---|
82 | /// the longitudinally invariant kt algorithm
|
---|
83 | kt_algorithm=0,
|
---|
84 | /// the longitudinally invariant variant of the cambridge algorithm
|
---|
85 | /// (aka Aachen algoithm).
|
---|
86 | cambridge_algorithm=1,
|
---|
87 | /// like the k_t but with distance measures
|
---|
88 | /// dij = min(1/kti^2,1/ktj^2) Delta R_{ij}^2 / R^2
|
---|
89 | /// diB = 1/kti^2
|
---|
90 | antikt_algorithm=2,
|
---|
91 | /// like the k_t but with distance measures
|
---|
92 | /// dij = min(kti^{2p},ktj^{2p}) Delta R_{ij}^2 / R^2
|
---|
93 | /// diB = 1/kti^{2p}
|
---|
94 | genkt_algorithm=3,
|
---|
95 | /// a version of cambridge with a special distance measure for particles
|
---|
96 | /// whose pt is < extra_param()
|
---|
97 | cambridge_for_passive_algorithm=11,
|
---|
98 | /// a version of genkt with a special distance measure for particles
|
---|
99 | /// whose pt is < extra_param() [relevant for passive areas when p<=0]
|
---|
100 | genkt_for_passive_algorithm=13,
|
---|
101 | /// any plugin algorithm supplied by the user
|
---|
102 | plugin_algorithm = 99
|
---|
103 | };
|
---|
104 |
|
---|
105 | /// make standard Les Houches nomenclature JetAlgorithm (algorithm is general
|
---|
106 | /// recipe without the parameters) backward-compatible with old JetFinder
|
---|
107 | typedef JetAlgorithm JetFinder;
|
---|
108 |
|
---|
109 | /// provide other possible names for the Cambridge/Aachen algorithm?
|
---|
110 | const JetAlgorithm aachen_algorithm = cambridge_algorithm;
|
---|
111 | const JetAlgorithm cambridge_aachen_algorithm = cambridge_algorithm;
|
---|
112 |
|
---|
113 | //======================================================================
|
---|
114 | /// the various recombination schemes
|
---|
115 | enum RecombinationScheme {
|
---|
116 | /// summing the 4-momenta
|
---|
117 | E_scheme=0,
|
---|
118 | /// pt weighted recombination of y,phi (and summing of pt's)
|
---|
119 | /// with preprocessing to make things massless by rescaling E=|\vec p|
|
---|
120 | pt_scheme=1,
|
---|
121 | /// pt^2 weighted recombination of y,phi (and summing of pt's)
|
---|
122 | /// with preprocessing to make things massless by rescaling E=|\vec p|
|
---|
123 | pt2_scheme=2,
|
---|
124 | /// pt weighted recombination of y,phi (and summing of pt's)
|
---|
125 | /// with preprocessing to make things massless by rescaling |\vec p|->=E
|
---|
126 | Et_scheme=3,
|
---|
127 | /// pt^2 weighted recombination of y,phi (and summing of pt's)
|
---|
128 | /// with preprocessing to make things massless by rescaling |\vec p|->=E
|
---|
129 | Et2_scheme=4,
|
---|
130 | /// pt weighted recombination of y,phi (and summing of pt's), with
|
---|
131 | /// no preprocessing
|
---|
132 | BIpt_scheme=5,
|
---|
133 | /// pt^2 weighted recombination of y,phi (and summing of pt's)
|
---|
134 | /// no preprocessing
|
---|
135 | BIpt2_scheme=6,
|
---|
136 | /// for the user's external scheme
|
---|
137 | external_scheme = 99
|
---|
138 | };
|
---|
139 |
|
---|
140 |
|
---|
141 |
|
---|
142 |
|
---|
143 | // forward declaration, needed in order to specify interface for the
|
---|
144 | // plugin.
|
---|
145 | class ClusterSequence;
|
---|
146 |
|
---|
147 |
|
---|
148 |
|
---|
149 |
|
---|
150 | //======================================================================
|
---|
151 | /// class that is intended to hold a full definition of the jet
|
---|
152 | /// clusterer
|
---|
153 | class JetDefinition {
|
---|
154 |
|
---|
155 | public:
|
---|
156 |
|
---|
157 | /// forward declaration of a class that allows the user to introduce
|
---|
158 | /// their own plugin
|
---|
159 | class Plugin;
|
---|
160 |
|
---|
161 | // forward declaration of a class that will provide the
|
---|
162 | // recombination scheme facilities and/or allow a user to
|
---|
163 | // extend these facilities
|
---|
164 | class Recombiner;
|
---|
165 |
|
---|
166 | /// constructor to fully specify a jet-definition (together
|
---|
167 | /// with information about how algorithically to run it).
|
---|
168 | ///
|
---|
169 | JetDefinition(JetAlgorithm jet_algorithm,
|
---|
170 | double R,
|
---|
171 | Strategy strategy,
|
---|
172 | RecombinationScheme recomb_scheme = E_scheme) :
|
---|
173 | _jet_algorithm(jet_algorithm), _Rparam(R), _strategy(strategy) {
|
---|
174 | // the largest sensible value for R
|
---|
175 | assert(_Rparam <= 0.5*pi);
|
---|
176 | assert(_jet_algorithm != plugin_algorithm &&
|
---|
177 | _strategy != plugin_strategy);
|
---|
178 | _plugin = NULL;
|
---|
179 | set_recombination_scheme(recomb_scheme);
|
---|
180 | }
|
---|
181 |
|
---|
182 |
|
---|
183 | /// constructor with alternative ordering or arguments -- note that
|
---|
184 | /// we have not provided a default jet finder, to avoid ambiguous
|
---|
185 | /// JetDefinition() constructor.
|
---|
186 | JetDefinition(JetAlgorithm jet_algorithm = kt_algorithm,
|
---|
187 | double R = 1.0,
|
---|
188 | RecombinationScheme recomb_scheme = E_scheme,
|
---|
189 | Strategy strategy = Best) {
|
---|
190 | *this = JetDefinition(jet_algorithm, R, strategy, recomb_scheme);
|
---|
191 | }
|
---|
192 |
|
---|
193 |
|
---|
194 | /// constructor in a form that allows the user to provide a pointer
|
---|
195 | /// to an external recombiner class (which must remain valid for the
|
---|
196 | /// life of the JetDefinition object).
|
---|
197 | JetDefinition(JetAlgorithm jet_algorithm,
|
---|
198 | double R,
|
---|
199 | const Recombiner * recombiner,
|
---|
200 | Strategy strategy = Best) {
|
---|
201 | *this = JetDefinition(jet_algorithm, R, strategy, external_scheme);
|
---|
202 | _recombiner = recombiner;
|
---|
203 | }
|
---|
204 |
|
---|
205 | /// constructor based on a pointer to a user's plugin; the object
|
---|
206 | /// pointed to must remain valid for the whole duration of existence
|
---|
207 | /// of the JetDefinition and any related ClusterSequences
|
---|
208 | JetDefinition(const Plugin * plugin) {
|
---|
209 | _plugin = plugin;
|
---|
210 | _strategy = plugin_strategy;
|
---|
211 | _Rparam = _plugin->R();
|
---|
212 | _jet_algorithm = plugin_algorithm;
|
---|
213 | set_recombination_scheme(E_scheme);
|
---|
214 | }
|
---|
215 |
|
---|
216 | /// set the recombination scheme to the one provided
|
---|
217 | void set_recombination_scheme(RecombinationScheme);
|
---|
218 |
|
---|
219 | /// set the recombiner class to the one provided
|
---|
220 | void set_recombiner(const Recombiner * recomb) {
|
---|
221 | _recombiner = recomb;
|
---|
222 | _default_recombiner = DefaultRecombiner(external_scheme);
|
---|
223 | }
|
---|
224 |
|
---|
225 | /// return a pointer to the plugin
|
---|
226 | const Plugin * plugin() const {return _plugin;};
|
---|
227 |
|
---|
228 | /// return information about the definition...
|
---|
229 | JetAlgorithm jet_algorithm () const {return _jet_algorithm ;}
|
---|
230 | /// same as above for backward compatibility
|
---|
231 | JetAlgorithm jet_finder () const {return _jet_algorithm ;}
|
---|
232 | double R () const {return _Rparam ;}
|
---|
233 | // a general purpose extra parameter, whose meaning depends on
|
---|
234 | // the algorithm, and may often be unused.
|
---|
235 | double extra_param () const {return _extra_param ;}
|
---|
236 | Strategy strategy () const {return _strategy ;}
|
---|
237 | RecombinationScheme recombination_scheme() const {
|
---|
238 | return _default_recombiner.scheme();}
|
---|
239 |
|
---|
240 | /// (re)set the jet finder
|
---|
241 | void set_jet_algorithm(JetAlgorithm njf) {_jet_algorithm = njf;}
|
---|
242 | /// same as above for backward compatibility
|
---|
243 | void set_jet_finder(JetAlgorithm njf) {_jet_algorithm = njf;}
|
---|
244 | /// (re)set the general purpose extra parameter
|
---|
245 | void set_extra_param(double xtra_param) {_extra_param = xtra_param;}
|
---|
246 |
|
---|
247 | /// return a pointer to the currently defined recombiner (it may
|
---|
248 | /// be the internal one)
|
---|
249 | const Recombiner * recombiner() const {
|
---|
250 | return _recombiner == 0 ? & _default_recombiner : _recombiner;}
|
---|
251 |
|
---|
252 | /// return a textual description of the current jet definition
|
---|
253 | std::string description() const;
|
---|
254 |
|
---|
255 |
|
---|
256 | public:
|
---|
257 | //======================================================================
|
---|
258 | /// An abstract base class that will provide the recombination scheme
|
---|
259 | /// facilities and/or allow a user to extend these facilities
|
---|
260 | class Recombiner {
|
---|
261 | public:
|
---|
262 | /// return a textual description of the recombination scheme
|
---|
263 | /// implemented here
|
---|
264 | virtual std::string description() const = 0;
|
---|
265 |
|
---|
266 | /// recombine pa and pb and put result into pab
|
---|
267 | virtual void recombine(const PseudoJet & pa, const PseudoJet & pb,
|
---|
268 | PseudoJet & pab) const = 0;
|
---|
269 |
|
---|
270 | /// routine called to preprocess each input jet (to make all input
|
---|
271 | /// jets compatible with the scheme requirements (e.g. massless).
|
---|
272 | virtual void preprocess(PseudoJet & p) const {};
|
---|
273 |
|
---|
274 | /// a destructor to be replaced if necessary in derived classes...
|
---|
275 | virtual ~Recombiner() {};
|
---|
276 |
|
---|
277 | /// pa += pb in the given recombination scheme. Not virtual -- the
|
---|
278 | /// user should have no reason to want to redefine this!
|
---|
279 | inline void plus_equal(PseudoJet & pa, const PseudoJet & pb) const {
|
---|
280 | // put result in a temporary location in case the recombiner
|
---|
281 | // does something funny (ours doesn't, but who knows about the
|
---|
282 | // user's)
|
---|
283 | PseudoJet pres;
|
---|
284 | recombine(pa,pb,pres);
|
---|
285 | pa = pres;
|
---|
286 | }
|
---|
287 |
|
---|
288 | };
|
---|
289 |
|
---|
290 |
|
---|
291 | //======================================================================
|
---|
292 | /// A class that will provide the recombination scheme facilities and/or
|
---|
293 | /// allow a user to extend these facilities
|
---|
294 | class DefaultRecombiner : public Recombiner {
|
---|
295 | public:
|
---|
296 | DefaultRecombiner(RecombinationScheme recomb_scheme = E_scheme) :
|
---|
297 | _recomb_scheme(recomb_scheme) {}
|
---|
298 |
|
---|
299 | virtual std::string description() const;
|
---|
300 |
|
---|
301 | /// recombine pa and pb and put result into pab
|
---|
302 | virtual void recombine(const PseudoJet & pa, const PseudoJet & pb,
|
---|
303 | PseudoJet & pab) const;
|
---|
304 |
|
---|
305 | virtual void preprocess(PseudoJet & p) const;
|
---|
306 |
|
---|
307 | /// return the index of the recombination scheme
|
---|
308 | RecombinationScheme scheme() const {return _recomb_scheme;}
|
---|
309 |
|
---|
310 | private:
|
---|
311 | RecombinationScheme _recomb_scheme;
|
---|
312 | };
|
---|
313 |
|
---|
314 |
|
---|
315 | //======================================================================
|
---|
316 | /// a class that allows a user to introduce their own "plugin" jet
|
---|
317 | /// finder
|
---|
318 | class Plugin{
|
---|
319 | public:
|
---|
320 | /// return a textual description of the jet-definition implemented
|
---|
321 | /// in this plugin
|
---|
322 | virtual std::string description() const = 0;
|
---|
323 |
|
---|
324 | /// given a ClusterSequence that has been filled up with initial
|
---|
325 | /// particles, the following function should fill up the rest of the
|
---|
326 | /// ClusterSequence, using the following member functions of
|
---|
327 | /// ClusterSequence:
|
---|
328 | /// - plugin_do_ij_recombination(...)
|
---|
329 | /// - plugin_do_iB_recombination(...)
|
---|
330 | virtual void run_clustering(ClusterSequence &) const = 0;
|
---|
331 |
|
---|
332 | virtual double R() const = 0;
|
---|
333 |
|
---|
334 | /// return true if there is specific support for the measurement
|
---|
335 | /// of passive areas, in the sense that areas determined from all
|
---|
336 | /// particles below the ghost separation scale will be a passive
|
---|
337 | /// area. [If you don't understand this, ignore it!]
|
---|
338 | virtual bool supports_ghosted_passive_areas() const {return false;}
|
---|
339 |
|
---|
340 | /// set the ghost separation scale for passive area determinations
|
---|
341 | /// in future runs (strictly speaking that makes the routine
|
---|
342 | /// a non const, so related internal info must be stored as a mutable)
|
---|
343 | virtual void set_ghost_separation_scale(double scale) const;
|
---|
344 | virtual double ghost_separation_scale() const {return 0.0;}
|
---|
345 |
|
---|
346 | /// a destructor to be replaced if necessary in derived classes...
|
---|
347 | virtual ~Plugin() {};
|
---|
348 | };
|
---|
349 |
|
---|
350 | private:
|
---|
351 |
|
---|
352 |
|
---|
353 | JetAlgorithm _jet_algorithm;
|
---|
354 | double _Rparam;
|
---|
355 | double _extra_param ; ///< parameter whose meaning varies according to context
|
---|
356 | Strategy _strategy ;
|
---|
357 |
|
---|
358 | const Plugin * _plugin;
|
---|
359 |
|
---|
360 | // when we use our own recombiner it's useful to point to it here
|
---|
361 | // so that we don't have to worry about deleting it etc...
|
---|
362 | DefaultRecombiner _default_recombiner;
|
---|
363 | const Recombiner * _recombiner;
|
---|
364 |
|
---|
365 | };
|
---|
366 |
|
---|
367 |
|
---|
368 |
|
---|
369 |
|
---|
370 |
|
---|
371 |
|
---|
372 | FASTJET_END_NAMESPACE
|
---|
373 |
|
---|
374 | #endif // __FASTJET_JETDEFINITION_HH__
|
---|