2 // $Id: JetDefinition.hh 1402 2009-01-21 18:03:54Z salam $
4 // Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam
6 //----------------------------------------------------------------------
7 // This file is part of FastJet.
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.
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.
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.
24 // You should have received a copy of the GNU General Public License
25 // along with FastJet; if not, write to the Free Software
27 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 //----------------------------------------------------------------------
31 #ifndef __FASTJET_JETDEFINITION_HH__
32 #define __FASTJET_JETDEFINITION_HH__
35 #include "fastjet/internal/numconsts.hh"
36 #include "fastjet/PseudoJet.hh"
40 namespace fastjet { // defined in fastjet/internal/base.hh
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();
47 //======================================================================
48 /// the various options for the algorithmic strategy to adopt in
49 /// clustering events with kt and cambridge style algorithms.
51 /// fastest form about 500..10^4
53 /// fastest from about 50..500
59 /// worse even than the usual N^3 algorithms
61 /// automatic selection of the best (based on N)
63 /// best of the NlnN variants -- best overall for N>10^4
65 /// legacy N ln N using 3pi coverage of cylinder
67 /// legacy N ln N using 4pi coverage of cylinder
69 /// Chan's closest pair method (in a variant with 4pi coverage),
70 /// for use exclusively with the Cambridge algorithm
73 NlnNCam = 12, // 2piMultD
74 /// the plugin has been used...
79 //======================================================================
80 /// the various families of jet-clustering algorithm
82 /// the longitudinally invariant kt algorithm
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
91 /// like the k_t but with distance measures
92 /// dij = min(kti^{2p},ktj^{2p}) Delta R_{ij}^2 / R^2
94 /// where p = extra_param()
96 /// a version of cambridge with a special distance measure for particles
97 /// whose pt is < extra_param()
98 cambridge_for_passive_algorithm=11,
99 /// a version of genkt with a special distance measure for particles
100 /// whose pt is < extra_param() [relevant for passive areas when p<=0]
101 genkt_for_passive_algorithm=13,
102 //.................................................................
103 /// the e+e- kt algorithm
105 /// the e+e- genkt algorithm (R > 2 and p=1 gives ee_kt)
106 ee_genkt_algorithm=53,
107 //.................................................................
108 /// any plugin algorithm supplied by the user
109 plugin_algorithm = 99
112 /// make standard Les Houches nomenclature JetAlgorithm (algorithm is general
113 /// recipe without the parameters) backward-compatible with old JetFinder
114 typedef JetAlgorithm JetFinder;
116 /// provide other possible names for the Cambridge/Aachen algorithm?
117 const JetAlgorithm aachen_algorithm = cambridge_algorithm;
118 const JetAlgorithm cambridge_aachen_algorithm = cambridge_algorithm;
120 //======================================================================
121 /// the various recombination schemes
122 enum RecombinationScheme {
123 /// summing the 4-momenta
125 /// pt weighted recombination of y,phi (and summing of pt's)
126 /// with preprocessing to make things massless by rescaling E=|\vec p|
128 /// pt^2 weighted recombination of y,phi (and summing of pt's)
129 /// with preprocessing to make things massless by rescaling E=|\vec p|
131 /// pt weighted recombination of y,phi (and summing of pt's)
132 /// with preprocessing to make things massless by rescaling |\vec p|->=E
134 /// pt^2 weighted recombination of y,phi (and summing of pt's)
135 /// with preprocessing to make things massless by rescaling |\vec p|->=E
137 /// pt weighted recombination of y,phi (and summing of pt's), with
140 /// pt^2 weighted recombination of y,phi (and summing of pt's)
143 /// for the user's external scheme
150 // forward declaration, needed in order to specify interface for the
152 class ClusterSequence;
157 //======================================================================
158 /// class that is intended to hold a full definition of the jet
160 class JetDefinition {
164 /// forward declaration of a class that allows the user to introduce
168 // forward declaration of a class that will provide the
169 // recombination scheme facilities and/or allow a user to
170 // extend these facilities
175 /// constructor with alternative ordering or arguments -- note that
176 /// we have not provided a default jet finder, to avoid ambiguous
177 /// JetDefinition() constructor.
178 JetDefinition(JetAlgorithm jet_algorithm,
180 RecombinationScheme recomb_scheme = E_scheme,
181 Strategy strategy = Best) {
182 *this = JetDefinition(jet_algorithm, R, strategy, recomb_scheme, 1);
185 /// constructor for algorithms that have no free parameters
186 /// (e.g. ee_kt_algorithm)
187 JetDefinition(JetAlgorithm jet_algorithm,
188 RecombinationScheme recomb_scheme = E_scheme,
189 Strategy strategy = Best) {
191 *this = JetDefinition(jet_algorithm, dummyR, strategy, recomb_scheme, 0);
194 /// constructor for algorithms that require R + one extra parameter to be set
195 /// (the gen-kt series for example)
196 JetDefinition(JetAlgorithm jet_algorithm,
199 RecombinationScheme recomb_scheme = E_scheme,
200 Strategy strategy = Best) {
201 *this = JetDefinition(jet_algorithm, R, strategy, recomb_scheme, 2);
202 set_extra_param(xtra_param);
206 /// constructor in a form that allows the user to provide a pointer
207 /// to an external recombiner class (which must remain valid for the
208 /// life of the JetDefinition object).
209 JetDefinition(JetAlgorithm jet_algorithm,
211 const Recombiner * recombiner,
212 Strategy strategy = Best) {
213 *this = JetDefinition(jet_algorithm, R, external_scheme, strategy);
214 _recombiner = recombiner;
218 /// constructor for case with 0 parameters (ee_kt_algorithm) and
219 /// and external recombiner
220 JetDefinition(JetAlgorithm jet_algorithm,
221 const Recombiner * recombiner,
222 Strategy strategy = Best) {
223 *this = JetDefinition(jet_algorithm, external_scheme, strategy);
224 _recombiner = recombiner;
227 /// constructor allowing the extra parameter to be set and a pointer to
229 JetDefinition(JetAlgorithm jet_algorithm,
232 const Recombiner * recombiner,
233 Strategy strategy = Best) {
234 *this = JetDefinition(jet_algorithm, R, external_scheme, strategy);
235 _recombiner = recombiner;
236 set_extra_param(xtra_param);
239 /// a default constructor
241 *this = JetDefinition(kt_algorithm, 1.0);
244 /// constructor based on a pointer to a user's plugin; the object
245 /// pointed to must remain valid for the whole duration of existence
246 /// of the JetDefinition and any related ClusterSequences
247 JetDefinition(const Plugin * plugin) {
249 _strategy = plugin_strategy;
250 _Rparam = _plugin->R();
251 _jet_algorithm = plugin_algorithm;
252 set_recombination_scheme(E_scheme);
256 /// constructor to fully specify a jet-definition (together with
257 /// information about how algorithically to run it).
259 /// the ordering of arguments here is old and deprecated (except
260 /// as the common constructor for internal use)
261 JetDefinition(JetAlgorithm jet_algorithm,
264 RecombinationScheme recomb_scheme = E_scheme,
265 int nparameters = 1);
267 // _jet_algorithm(jet_algorithm), _Rparam(R), _strategy(strategy) {
268 // // the largest sensible value for R
269 // if (jet_algorithm != ee_kt_algorithm &&
270 // jet_algorithm != ee_genkt_algorithm) assert(_Rparam <= 0.5*pi);
271 // assert(_jet_algorithm != plugin_algorithm &&
272 // _strategy != plugin_strategy);
274 // set_recombination_scheme(recomb_scheme);
275 // set_extra_param(0.0); // make sure it's defined
279 /// set the recombination scheme to the one provided
280 void set_recombination_scheme(RecombinationScheme);
282 /// set the recombiner class to the one provided
283 void set_recombiner(const Recombiner * recomb) {
284 _recombiner = recomb;
285 _default_recombiner = DefaultRecombiner(external_scheme);
288 /// return a pointer to the plugin
289 const Plugin * plugin() const {return _plugin;};
291 /// return information about the definition...
292 JetAlgorithm jet_algorithm () const {return _jet_algorithm ;}
293 /// same as above for backward compatibility
294 JetAlgorithm jet_finder () const {return _jet_algorithm ;}
295 double R () const {return _Rparam ;}
296 // a general purpose extra parameter, whose meaning depends on
297 // the algorithm, and may often be unused.
298 double extra_param () const {return _extra_param ;}
299 Strategy strategy () const {return _strategy ;}
300 RecombinationScheme recombination_scheme() const {
301 return _default_recombiner.scheme();}
303 /// (re)set the jet finder
304 void set_jet_algorithm(JetAlgorithm njf) {_jet_algorithm = njf;}
305 /// same as above for backward compatibility
306 void set_jet_finder(JetAlgorithm njf) {_jet_algorithm = njf;}
307 /// (re)set the general purpose extra parameter
308 void set_extra_param(double xtra_param) {_extra_param = xtra_param;}
310 /// return a pointer to the currently defined recombiner (it may
311 /// be the internal one)
312 const Recombiner * recombiner() const {
313 return _recombiner == 0 ? & _default_recombiner : _recombiner;}
315 /// return a textual description of the current jet definition
316 std::string description() const;
320 //======================================================================
321 /// An abstract base class that will provide the recombination scheme
322 /// facilities and/or allow a user to extend these facilities
325 /// return a textual description of the recombination scheme
327 virtual std::string description() const = 0;
329 /// recombine pa and pb and put result into pab
330 virtual void recombine(const PseudoJet & pa, const PseudoJet & pb,
331 PseudoJet & pab) const = 0;
333 /// routine called to preprocess each input jet (to make all input
334 /// jets compatible with the scheme requirements (e.g. massless).
335 virtual void preprocess(PseudoJet & p) const {};
337 /// a destructor to be replaced if necessary in derived classes...
338 virtual ~Recombiner() {};
340 /// pa += pb in the given recombination scheme. Not virtual -- the
341 /// user should have no reason to want to redefine this!
342 inline void plus_equal(PseudoJet & pa, const PseudoJet & pb) const {
343 // put result in a temporary location in case the recombiner
344 // does something funny (ours doesn't, but who knows about the
347 recombine(pa,pb,pres);
354 //======================================================================
355 /// A class that will provide the recombination scheme facilities and/or
356 /// allow a user to extend these facilities
357 class DefaultRecombiner : public Recombiner {
359 DefaultRecombiner(RecombinationScheme recomb_scheme = E_scheme) :
360 _recomb_scheme(recomb_scheme) {}
362 virtual std::string description() const;
364 /// recombine pa and pb and put result into pab
365 virtual void recombine(const PseudoJet & pa, const PseudoJet & pb,
366 PseudoJet & pab) const;
368 virtual void preprocess(PseudoJet & p) const;
370 /// return the index of the recombination scheme
371 RecombinationScheme scheme() const {return _recomb_scheme;}
374 RecombinationScheme _recomb_scheme;
378 //======================================================================
379 /// a class that allows a user to introduce their own "plugin" jet
383 /// return a textual description of the jet-definition implemented
385 virtual std::string description() const = 0;
387 /// given a ClusterSequence that has been filled up with initial
388 /// particles, the following function should fill up the rest of the
389 /// ClusterSequence, using the following member functions of
391 /// - plugin_do_ij_recombination(...)
392 /// - plugin_do_iB_recombination(...)
393 virtual void run_clustering(ClusterSequence &) const = 0;
395 virtual double R() const = 0;
397 /// return true if there is specific support for the measurement
398 /// of passive areas, in the sense that areas determined from all
399 /// particles below the ghost separation scale will be a passive
400 /// area. [If you don't understand this, ignore it!]
401 virtual bool supports_ghosted_passive_areas() const {return false;}
403 /// set the ghost separation scale for passive area determinations
404 /// in future runs (strictly speaking that makes the routine
405 /// a non const, so related internal info must be stored as a mutable)
406 virtual void set_ghost_separation_scale(double scale) const;
407 virtual double ghost_separation_scale() const {return 0.0;}
409 /// a destructor to be replaced if necessary in derived classes...
410 virtual ~Plugin() {};
416 JetAlgorithm _jet_algorithm;
418 double _extra_param ; ///< parameter whose meaning varies according to context
421 const Plugin * _plugin;
423 // when we use our own recombiner it's useful to point to it here
424 // so that we don't have to worry about deleting it etc...
425 DefaultRecombiner _default_recombiner;
426 const Recombiner * _recombiner;
435 } // fastjet namespace
437 #endif // __FASTJET_JETDEFINITION_HH__