Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:18

0001 #ifndef __FASTJET_JETDEFINITION_HH__
0002 #define __FASTJET_JETDEFINITION_HH__
0003 
0004 //FJSTARTHEADER
0005 // $Id$
0006 //
0007 // Copyright (c) 2005-2021, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
0008 //
0009 //----------------------------------------------------------------------
0010 // This file is part of FastJet.
0011 //
0012 //  FastJet is free software; you can redistribute it and/or modify
0013 //  it under the terms of the GNU General Public License as published by
0014 //  the Free Software Foundation; either version 2 of the License, or
0015 //  (at your option) any later version.
0016 //
0017 //  The algorithms that underlie FastJet have required considerable
0018 //  development. They are described in the original FastJet paper,
0019 //  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
0020 //  FastJet as part of work towards a scientific publication, please
0021 //  quote the version you use and include a citation to the manual and
0022 //  optionally also to hep-ph/0512210.
0023 //
0024 //  FastJet is distributed in the hope that it will be useful,
0025 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
0026 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0027 //  GNU General Public License for more details.
0028 //
0029 //  You should have received a copy of the GNU General Public License
0030 //  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
0031 //----------------------------------------------------------------------
0032 //FJENDHEADER
0033 
0034 #include<cassert>
0035 #include "fastjet/internal/numconsts.hh"
0036 #include "fastjet/PseudoJet.hh"
0037 #include "fastjet/internal/deprecated.hh"
0038 #include<string>
0039 #include<memory>
0040 
0041 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
0042 
0043 /// return a string containing information about the release
0044 //  NB: (implemented in ClusterSequence.cc but defined here because
0045 //  this is a visible location)
0046 std::string fastjet_version_string();
0047 
0048 //======================================================================
0049 /// the various options for the algorithmic strategy to adopt in
0050 /// clustering events with kt and cambridge style algorithms.
0051 enum Strategy {
0052   /// Like N2MHTLazy9 in a number of respects, but does not calculate
0053   /// ghost-ghost distances and so does not carry out ghost-ghost
0054   /// recombination. 
0055   ///
0056   /// If you want active ghosted areas, then this is only suitable for
0057   /// use with the anti-kt algorithm (or genkt with negative p), and
0058   /// does not produce any pure ghost jets. If used with active areas
0059   /// with Kt or Cam algorithms it will actually produce a passive
0060   /// area.
0061   /// 
0062   /// Particles are deemed to be ghosts if their pt is below a
0063   /// threshold (currently 1e-50, hard coded as ghost_limit in
0064   /// LazyTiling9SeparateGhosts).
0065   ///
0066   /// Currently for events with a couple of thousand normal particles
0067   /// and O(10k) ghosts, this can be quicker than N2MHTLazy9, which
0068   /// would otherwise be the best strategy. 
0069   ///
0070   /// New in FJ3.1
0071   N2MHTLazy9AntiKtSeparateGhosts   = -10, 
0072   /// only looks into a neighbouring tile for a particle's nearest
0073   /// neighbour (NN) if that particle's in-tile NN is further than the
0074   /// distance to the edge of the neighbouring tile. Uses tiles of
0075   /// size R and a 3x3 tile grid around the particle.
0076   /// New in FJ3.1
0077   N2MHTLazy9   = -7, 
0078   /// Similar to N2MHTLazy9, but uses tiles of size R/2 and a 5x5 tile
0079   /// grid around the particle.
0080   /// New in FJ3.1
0081   N2MHTLazy25   = -6, 
0082   /// Like to N2MHTLazy9 but uses slightly different optimizations,
0083   /// e.g. for calculations of distance to nearest tile; as of
0084   /// 2014-07-18 it is slightly slower and not recommended for
0085   /// production use. To considered deprecated.
0086   /// New in FJ3.1
0087   N2MHTLazy9Alt   = -5, 
0088   /// faster that N2Tiled above about 500 particles; differs from it
0089   /// by retainig the di(closest j) distances in a MinHeap (sort of
0090   /// priority queue) rather than a simple vector. 
0091   N2MinHeapTiled   = -4, 
0092   /// fastest from about 50..500
0093   N2Tiled     = -3, 
0094   /// legacy
0095   N2PoorTiled = -2, 
0096   /// fastest below 50
0097   N2Plain     = -1, 
0098   /// worse even than the usual N^3 algorithms
0099   N3Dumb      =  0, 
0100   /// automatic selection of the best (based on N), including 
0101   /// the LazyTiled strategies that are new to FJ3.1
0102   Best        =  1, 
0103   /// best of the NlnN variants -- best overall for N>10^4.
0104   /// (Does not work for R>=2pi)
0105   NlnN        =  2, 
0106   /// legacy N ln N using 3pi coverage of cylinder.
0107   /// (Does not work for R>=2pi)
0108   NlnN3pi     =  3, 
0109   /// legacy N ln N using 4pi coverage of cylinder
0110   NlnN4pi     =  4,
0111   /// Chan's closest pair method (in a variant with 4pi coverage),
0112   /// for use exclusively with the Cambridge algorithm.
0113   /// (Does not work for R>=2pi)
0114   NlnNCam4pi   = 14,
0115   /// Chan's closest pair method (in a variant with 2pi+2R coverage),
0116   /// for use exclusively with the Cambridge algorithm.
0117   /// (Does not work for R>=2pi)
0118   NlnNCam2pi2R = 13,
0119   /// Chan's closest pair method (in a variant with 2pi+minimal extra
0120   /// variant), for use exclusively with the Cambridge algorithm. 
0121   /// (Does not work for R>=2pi)
0122   NlnNCam      = 12, // 2piMultD
0123   /// the automatic strategy choice that was being made in FJ 3.0
0124   /// (restricted to strategies that were present in FJ 3.0)
0125   BestFJ30     =  21, 
0126   /// the plugin has been used...
0127   plugin_strategy = 999
0128 };
0129 
0130 
0131 //======================================================================
0132 /// \enum JetAlgorithm
0133 /// the various families of jet-clustering algorithm
0134 //
0135 // [Remember to update the "is_spherical()" routine if any further
0136 // spherical algorithms are added to the list below]
0137 enum JetAlgorithm {
0138   /// the longitudinally invariant kt algorithm
0139   kt_algorithm=0,
0140   /// the longitudinally invariant variant of the cambridge algorithm
0141   /// (aka Aachen algoithm).
0142   cambridge_algorithm=1,
0143   /// like the k_t but with distance measures 
0144   ///       dij = min(1/kti^2,1/ktj^2) Delta R_{ij}^2 / R^2
0145   ///       diB = 1/kti^2
0146   antikt_algorithm=2, 
0147   /// like the k_t but with distance measures 
0148   ///       dij = min(kti^{2p},ktj^{2p}) Delta R_{ij}^2 / R^2
0149   ///       diB = 1/kti^{2p}
0150   /// where p = extra_param()
0151   genkt_algorithm=3, 
0152   /// a version of cambridge with a special distance measure for
0153   /// particles whose pt is < extra_param(); this is not usually
0154   /// intended for end users, but is instead automatically selected
0155   /// when requesting a passive Cambridge area.
0156   cambridge_for_passive_algorithm=11,
0157   /// a version of genkt with a special distance measure for particles
0158   /// whose pt is < extra_param() [relevant for passive areas when p<=0]
0159   /// ***** NB: THERE IS CURRENTLY NO IMPLEMENTATION FOR THIS ALG *******
0160   genkt_for_passive_algorithm=13, 
0161   //.................................................................
0162   /// the e+e- kt algorithm
0163   ee_kt_algorithm=50,
0164   /// the e+e- genkt algorithm  (R > 2 and p=1 gives ee_kt)
0165   ee_genkt_algorithm=53,
0166   //.................................................................
0167   /// any plugin algorithm supplied by the user
0168   plugin_algorithm = 99,
0169   //.................................................................
0170   /// the value for the jet algorithm in a JetDefinition for which
0171   /// no algorithm has yet been defined
0172   undefined_jet_algorithm = 999
0173 };
0174 
0175 /// make standard Les Houches nomenclature JetAlgorithm (algorithm is general
0176 /// recipe without the parameters) backward-compatible with old JetFinder
0177 typedef JetAlgorithm JetFinder;
0178 
0179 /// provide other possible names for the Cambridge/Aachen algorithm
0180 const JetAlgorithm aachen_algorithm = cambridge_algorithm;
0181 const JetAlgorithm cambridge_aachen_algorithm = cambridge_algorithm;
0182 
0183 //======================================================================
0184 /// The various recombination schemes
0185 ///
0186 /// Note that the schemes that recombine with non-linear weighting of
0187 /// the directions (e.g. pt2, winner-takes-all) are collinear safe
0188 /// only for algorithms with a suitable ordering of the
0189 /// recombinations: orderings in which, for particles of comparable
0190 /// energies, small-angle clusterings take place before large-angle
0191 /// clusterings. This property is satisfied by all gen-kt algorithms.
0192 /// 
0193 enum RecombinationScheme {
0194   /// summing the 4-momenta
0195   E_scheme=0,
0196   /// pt weighted recombination of y,phi (and summing of pt's)
0197   /// with preprocessing to make things massless by rescaling E=|\vec p|
0198   pt_scheme=1,
0199   /// pt^2 weighted recombination of y,phi (and summing of pt's)
0200   /// with preprocessing to make things massless by rescaling E=|\vec p|
0201   pt2_scheme=2,
0202   /// pt weighted recombination of y,phi (and summing of pt's)
0203   /// with preprocessing to make things massless by rescaling |\vec p|->=E
0204   Et_scheme=3,
0205   /// pt^2 weighted recombination of y,phi (and summing of pt's)
0206   /// with preprocessing to make things massless by rescaling |\vec p|->=E
0207   Et2_scheme=4,
0208   /// pt weighted recombination of y,phi (and summing of pt's), with 
0209   /// no preprocessing
0210   BIpt_scheme=5,
0211   /// pt^2 weighted recombination of y,phi (and summing of pt's)
0212   /// no preprocessing
0213   BIpt2_scheme=6,
0214   /// pt-based Winner-Takes-All (WTA) recombination: the
0215   /// result of the recombination has the rapidity, azimuth and mass
0216   /// of the PseudoJet with the larger pt, and a pt equal to the
0217   /// sum of the two pt's
0218   WTA_pt_scheme=7,
0219   /// mod-p-based Winner-Takes-All (WTA) recombination: the result of
0220   /// the recombination gets the 3-vector direction and mass of the
0221   /// PseudoJet with the larger |3-momentum| (modp), and a
0222   /// |3-momentum| equal to the scalar sum of the two |3-momenta|.
0223   WTA_modp_scheme=8,
0224   // Energy-ordering can lead to dangerous situations with particles at
0225   // rest. We instead implement the WTA_modp_scheme
0226   //
0227   // // energy-based Winner-Takes-All (WTA) recombination: the result of
0228   // // the recombination gets the 3-vector direction and mass of the
0229   // // PseudoJet with the larger energy, and an energy equal to the
0230   // // to the sum of the two energies
0231   // WTA_E_scheme=8,
0232   /// for the user's external scheme
0233   external_scheme = 99
0234 };
0235 
0236 
0237 
0238 // forward declaration, needed in order to specify interface for the
0239 // plugin.
0240 class ClusterSequence;
0241 
0242 
0243 
0244 
0245 //======================================================================
0246 /// @ingroup basic_classes
0247 /// \class JetDefinition
0248 /// class that is intended to hold a full definition of the jet
0249 /// clusterer
0250 class JetDefinition {
0251   
0252 public:
0253 
0254   /// forward declaration of a class that allows the user to introduce
0255   /// their own plugin 
0256   class Plugin;
0257 
0258   // forward declaration of a class that will provide the
0259   // recombination scheme facilities and/or allow a user to
0260   // extend these facilities
0261   class Recombiner;
0262 
0263 
0264   /// constructor with alternative ordering or arguments -- note that
0265   /// we have not provided a default jet finder, to avoid ambiguous
0266   /// JetDefinition() constructor.
0267   JetDefinition(JetAlgorithm jet_algorithm_in, 
0268                 double R_in, 
0269                 RecombinationScheme recomb_scheme_in = E_scheme,
0270                 Strategy strategy_in = Best) {
0271     *this = JetDefinition(jet_algorithm_in, R_in, recomb_scheme_in, strategy_in, 1);
0272   }
0273 
0274   /// constructor for algorithms that have no free parameters
0275   /// (e.g. ee_kt_algorithm)
0276   JetDefinition(JetAlgorithm jet_algorithm_in, 
0277                 RecombinationScheme recomb_scheme_in = E_scheme,
0278                 Strategy strategy_in = Best) {
0279     double dummyR = 0.0;
0280     *this = JetDefinition(jet_algorithm_in, dummyR, recomb_scheme_in, strategy_in, 0);
0281   }
0282 
0283   /// constructor for algorithms that require R + one extra parameter to be set 
0284   /// (the gen-kt series for example)
0285   JetDefinition(JetAlgorithm jet_algorithm_in, 
0286                 double R_in, 
0287                 double xtra_param_in,
0288                 RecombinationScheme recomb_scheme_in = E_scheme,
0289                 Strategy strategy_in = Best) {
0290     *this = JetDefinition(jet_algorithm_in, R_in, recomb_scheme_in, strategy_in, 2);
0291     set_extra_param(xtra_param_in);
0292   }
0293 
0294 
0295   /// constructor in a form that allows the user to provide a pointer
0296   /// to an external recombiner class (which must remain valid for the
0297   /// life of the JetDefinition object).
0298   JetDefinition(JetAlgorithm jet_algorithm_in, 
0299                 double R_in, 
0300                 const Recombiner * recombiner_in,
0301                 Strategy strategy_in = Best) {
0302     *this = JetDefinition(jet_algorithm_in, R_in, external_scheme, strategy_in);
0303     _recombiner = recombiner_in;
0304   }
0305 
0306 
0307   /// constructor for case with 0 parameters (ee_kt_algorithm) and
0308   /// and external recombiner
0309   JetDefinition(JetAlgorithm jet_algorithm_in, 
0310                 const Recombiner * recombiner_in,
0311                 Strategy strategy_in = Best) {
0312     *this = JetDefinition(jet_algorithm_in, external_scheme, strategy_in);
0313     _recombiner = recombiner_in;
0314   }
0315 
0316   /// constructor allowing the extra parameter to be set and a pointer to
0317   /// a recombiner
0318   JetDefinition(JetAlgorithm jet_algorithm_in, 
0319                 double R_in, 
0320                 double xtra_param_in,
0321                 const Recombiner * recombiner_in,
0322                 Strategy strategy_in = Best) {
0323     *this = JetDefinition(jet_algorithm_in, R_in, xtra_param_in, external_scheme, strategy_in);
0324     _recombiner = recombiner_in;
0325   }
0326 
0327   /// a default constructor which creates a jet definition that is in
0328   /// a well-defined internal state, but not actually usable for jet
0329   /// clustering.
0330   JetDefinition()  {
0331     *this = JetDefinition(undefined_jet_algorithm, 1.0);
0332   }
0333   
0334 
0335   // /// a default constructor
0336   // JetDefinition() {
0337   //   *this = JetDefinition(kt_algorithm, 1.0);
0338   // }
0339 
0340   /// constructor based on a pointer to a user's plugin; the object
0341   /// pointed to must remain valid for the whole duration of existence
0342   /// of the JetDefinition and any related ClusterSequences
0343   JetDefinition(const Plugin * plugin_in) {
0344     _plugin = plugin_in;
0345     _strategy = plugin_strategy;
0346     _Rparam = _plugin->R();
0347     _extra_param = 0.0; // a dummy value to keep static code checkers happy
0348     _jet_algorithm = plugin_algorithm;
0349     set_recombination_scheme(E_scheme);
0350   }
0351 
0352   /// constructor to fully specify a jet-definition (together with
0353   /// information about how algorithically to run it).
0354   JetDefinition(JetAlgorithm jet_algorithm_in, 
0355                 double R_in, 
0356                 RecombinationScheme recomb_scheme_in,
0357                 Strategy strategy_in,
0358                 int nparameters_in);
0359 
0360   /// constructor to fully specify a jet-definition (together with
0361   /// information about how algorithically to run it).
0362   ///
0363   /// the ordering of arguments here is old and deprecated (except
0364   /// as the common constructor for internal use)
0365   FASTJET_DEPRECATED_MSG("This argument ordering is deprecated. Use JetDefinition(alg, R, strategy, scheme[, n_parameters]) instead",
0366   JetDefinition(JetAlgorithm jet_algorithm_in, 
0367                 double R_in, 
0368                 Strategy strategy_in,
0369                 RecombinationScheme recomb_scheme_in = E_scheme,
0370                 int nparameters_in = 1)){
0371     (*this) = JetDefinition(jet_algorithm_in,R_in,recomb_scheme_in,strategy_in,nparameters_in);
0372   }
0373 
0374 
0375   /// cluster the supplied particles and returns a vector of resulting
0376   /// jets, sorted by pt (or energy in the case of spherical,
0377   /// i.e. e+e-, algorithms). This routine currently only makes
0378   /// sense for "inclusive" type algorithms.
0379   template <class L> 
0380   std::vector<PseudoJet> operator()(const std::vector<L> & particles) const;
0381   
0382   /// R values larger than max_allowable_R are not allowed.
0383   ///
0384   /// We use a value of 1000, substantially smaller than
0385   /// numeric_limits<double>::max(), to leave room for the convention
0386   /// within PseudoJet of setting unphysical (infinite) rapidities to
0387   /// +-(MaxRap + abs(pz())), where MaxRap is 10^5.
0388   static const double max_allowable_R; //= 1000.0;
0389 
0390   /// set the recombination scheme to the one provided
0391   void set_recombination_scheme(RecombinationScheme);
0392 
0393   /// set the recombiner class to the one provided
0394   ///
0395   /// Note that in order to associate to a jet definition a recombiner
0396   /// from another jet definition, it is strongly recommended to use
0397   /// the set_recombiner(const JetDefinition &) method below. The
0398   /// latter correctly handles the situations where the jet definition
0399   /// owns the recombiner (i.e. where delete_recombiner_when_unused
0400   /// has been called). In such cases, using set_recombiner(const
0401   /// Recombiner *) may lead to memory corruption.
0402   void set_recombiner(const Recombiner * recomb) {
0403     if (_shared_recombiner) _shared_recombiner.reset(recomb);
0404     _recombiner = recomb;
0405     _default_recombiner = DefaultRecombiner(external_scheme);
0406   }
0407 
0408   /// set the recombiner to be the same as the one of 'other_jet_def'
0409   ///
0410   /// Note that this is the recommended method to associate to a jet
0411   /// definition the recombiner from another jet definition. Compared
0412   /// to the set_recombiner(const Recombiner *) above, it correctly
0413   /// handles the case where the jet definition owns the recombiner
0414   /// (i.e. where delete_recombiner_when_unused has been called)
0415   void set_recombiner(const JetDefinition &other_jet_def);
0416 
0417   /// calling this tells the JetDefinition to handle the deletion of
0418   /// the recombiner when it is no longer used. (Should not be called
0419   /// if the recombiner was initialised from a JetDef whose recombiner
0420   /// was already scheduled to delete itself - memory handling will
0421   /// already be automatic across both JetDef's in that case).
0422   void delete_recombiner_when_unused();
0423 
0424   /// return a pointer to the plugin 
0425   const Plugin * plugin() const {return _plugin;};
0426 
0427   /// calling this causes the JetDefinition to handle the deletion of the
0428   /// plugin when it is no longer used
0429   void delete_plugin_when_unused();
0430 
0431   /// return information about the definition...
0432   JetAlgorithm jet_algorithm  () const {return _jet_algorithm  ;}
0433   /// same as above for backward compatibility
0434   JetAlgorithm jet_finder     () const {return _jet_algorithm  ;}
0435   double    R           () const {return _Rparam      ;}
0436   // a general purpose extra parameter, whose meaning depends on
0437   // the algorithm, and may often be unused.
0438   double    extra_param () const {return _extra_param ;}
0439   Strategy  strategy    () const {return _strategy    ;}
0440   RecombinationScheme recombination_scheme() const {
0441     return _default_recombiner.scheme();}
0442 
0443   /// (re)set the jet finder
0444   void set_jet_algorithm(JetAlgorithm njf) {_jet_algorithm = njf;}
0445   /// same as above for backward compatibility
0446   void set_jet_finder(JetAlgorithm njf)    {_jet_algorithm = njf;}
0447   /// (re)set the general purpose extra parameter
0448   void set_extra_param(double xtra_param) {_extra_param = xtra_param;}
0449 
0450   /// returns a pointer to the currently defined recombiner. 
0451   ///
0452   /// Warning: the pointer may be to an internal recombiner (for
0453   /// default recombination schemes), in which case if the
0454   /// JetDefinition becomes invalid (e.g. is deleted), the pointer
0455   /// will then point to an object that no longer exists.
0456   /// 
0457   /// Note also that if you copy a JetDefinition with a default
0458   /// recombination scheme, then the two copies will have distinct
0459   /// recombiners, and return different recombiner() pointers.
0460   const Recombiner * recombiner() const {
0461     return _recombiner == 0 ? & _default_recombiner : _recombiner;}
0462 
0463   /// returns true if the current jet definitions shares the same
0464   /// recombiner as the one passed as an argument
0465   bool has_same_recombiner(const JetDefinition &other_jd) const;
0466 
0467   /// returns true if the jet definition involves an algorithm
0468   /// intended for use on a spherical geometry (e.g. e+e- algorithms,
0469   /// as opposed to most pp algorithms, which use a cylindrical,
0470   /// rapidity-phi geometry).
0471   bool is_spherical() const;
0472 
0473   /// return a textual description of the current jet definition 
0474   std::string description() const;
0475 
0476   /// returns a description not including the recombiner information
0477   std::string description_no_recombiner() const;
0478 
0479   /// a short textual description of the algorithm jet_alg
0480   static std::string algorithm_description(const JetAlgorithm jet_alg);
0481 
0482   /// the number of parameters associated to a given jet algorithm
0483   static unsigned int n_parameters_for_algorithm(const JetAlgorithm jet_alg);
0484 
0485 public:
0486   //======================================================================
0487   /// @ingroup advanced_usage
0488   /// \class Recombiner
0489   /// An abstract base class that will provide the recombination scheme
0490   /// facilities and/or allow a user to extend these facilities
0491   class Recombiner {
0492   public:
0493     /// return a textual description of the recombination scheme
0494     /// implemented here
0495     virtual std::string description() const = 0;
0496     
0497     /// recombine pa and pb and put result into pab
0498     virtual void recombine(const PseudoJet & pa, const PseudoJet & pb, 
0499                            PseudoJet & pab) const = 0;
0500 
0501     /// routine called to preprocess each input jet (to make all input
0502     /// jets compatible with the scheme requirements (e.g. massless).
0503     virtual void preprocess(PseudoJet & ) const {};
0504     
0505     /// a destructor to be replaced if necessary in derived classes...
0506     virtual ~Recombiner() {};
0507 
0508     /// pa += pb in the given recombination scheme. Not virtual -- the
0509     /// user should have no reason to want to redefine this!
0510     inline void plus_equal(PseudoJet & pa, const PseudoJet & pb) const {
0511       // put result in a temporary location in case the recombiner
0512       // does something funny (ours doesn't, but who knows about the
0513       // user's)
0514       PseudoJet pres; 
0515       recombine(pa,pb,pres);
0516       pa = pres;
0517     }
0518 
0519   };
0520   
0521   
0522   //======================================================================
0523   /// @ingroup advanced_usage
0524   /// \class DefaultRecombiner
0525   /// A class that will provide the recombination scheme facilities and/or
0526   /// allow a user to extend these facilities
0527   ///
0528   /// This class is derived from the (abstract) class Recombiner. It
0529   /// simply "sums" PseudoJets using a specified recombination scheme
0530   /// (E-scheme by default)
0531   class DefaultRecombiner : public Recombiner {
0532   public:
0533     DefaultRecombiner(RecombinationScheme recomb_scheme = E_scheme) : 
0534       _recomb_scheme(recomb_scheme) {}
0535     
0536     virtual std::string description() const FASTJET_OVERRIDE;
0537     
0538     /// recombine pa and pb and put result into pab
0539     virtual void recombine(const PseudoJet & pa, const PseudoJet & pb, 
0540                            PseudoJet & pab) const FASTJET_OVERRIDE;
0541 
0542     virtual void preprocess(PseudoJet & p) const FASTJET_OVERRIDE;
0543 
0544     /// return the index of the recombination scheme
0545     RecombinationScheme scheme() const {return _recomb_scheme;}
0546     
0547   private:
0548     RecombinationScheme _recomb_scheme;
0549   };
0550 
0551 
0552   //======================================================================
0553   /// @ingroup advanced_usage
0554   /// \class Plugin
0555   /// a class that allows a user to introduce their own "plugin" jet
0556   /// finder
0557   ///
0558   /// Note that all the plugins provided with FastJet are derived from
0559   /// this class
0560   class Plugin{
0561   public:
0562     /// return a textual description of the jet-definition implemented
0563     /// in this plugin
0564     virtual std::string description() const = 0;
0565     
0566     /// given a ClusterSequence that has been filled up with initial
0567     /// particles, the following function should fill up the rest of the
0568     /// ClusterSequence, using the following member functions of
0569     /// ClusterSequence:
0570     ///   - plugin_do_ij_recombination(...)
0571     ///   - plugin_do_iB_recombination(...)
0572     virtual void run_clustering(ClusterSequence &) const = 0;
0573     
0574     virtual double R() const = 0;
0575     
0576     /// return true if there is specific support for the measurement
0577     /// of passive areas, in the sense that areas determined from all
0578     /// particles below the ghost separation scale will be a passive
0579     /// area. [If you don't understand this, ignore it!]
0580     virtual bool supports_ghosted_passive_areas() const {return false;}
0581 
0582     /// set the ghost separation scale for passive area determinations
0583     /// in future runs (strictly speaking that makes the routine
0584     /// a non const, so related internal info must be stored as a mutable)
0585     virtual void set_ghost_separation_scale(double scale) const;
0586     virtual double ghost_separation_scale() const {return 0.0;}
0587 
0588     /// if this returns false then a warning will be given
0589     /// whenever the user requests "exclusive" jets from the
0590     /// cluster sequence
0591     virtual bool exclusive_sequence_meaningful() const {return false;}
0592 
0593     /// returns true if the plugin implements an algorithm intended
0594     /// for use on a spherical geometry (e.g. e+e- algorithms, as
0595     /// opposed to most pp algorithms, which use a cylindrical,
0596     /// rapidity-phi geometry).
0597     virtual bool is_spherical() const {return false;}
0598 
0599     /// a destructor to be replaced if necessary in derived classes...
0600     virtual ~Plugin() {};
0601   };
0602 
0603 private:
0604 
0605 
0606   JetAlgorithm _jet_algorithm;
0607   double    _Rparam;
0608   double    _extra_param ; ///< parameter whose meaning varies according to context
0609   Strategy  _strategy  ;
0610 
0611   const Plugin * _plugin;
0612   SharedPtr<const Plugin> _plugin_shared;
0613 
0614   // when we use our own recombiner it's useful to point to it here
0615   // so that we don't have to worry about deleting it etc...
0616   DefaultRecombiner _default_recombiner;
0617   const Recombiner * _recombiner;
0618   SharedPtr<const Recombiner> _shared_recombiner;
0619 
0620 };
0621 
0622 
0623 //-------------------------------------------------------------------------------
0624 // helper functions to build a jet made of pieces
0625 //
0626 // These functions include an options recombiner used to compute the
0627 // total composite jet momentum
0628 // -------------------------------------------------------------------------------
0629 
0630 /// build a "CompositeJet" from the vector of its pieces
0631 ///
0632 /// In this case, E-scheme recombination is assumed to compute the
0633 /// total momentum
0634 PseudoJet join(const std::vector<PseudoJet> & pieces, const JetDefinition::Recombiner & recombiner);
0635 
0636 /// build a MergedJet from a single PseudoJet
0637 PseudoJet join(const PseudoJet & j1, 
0638            const JetDefinition::Recombiner & recombiner);
0639 
0640 /// build a MergedJet from 2 PseudoJet
0641 PseudoJet join(const PseudoJet & j1, const PseudoJet & j2, 
0642            const JetDefinition::Recombiner & recombiner);
0643 
0644 /// build a MergedJet from 3 PseudoJet
0645 PseudoJet join(const PseudoJet & j1, const PseudoJet & j2, const PseudoJet & j3, 
0646            const JetDefinition::Recombiner & recombiner);
0647 
0648 /// build a MergedJet from 4 PseudoJet
0649 PseudoJet join(const PseudoJet & j1, const PseudoJet & j2, const PseudoJet & j3, const PseudoJet & j4, 
0650            const JetDefinition::Recombiner & recombiner);
0651 
0652 
0653 FASTJET_END_NAMESPACE
0654 
0655 // include ClusterSequence which includes the implementation of the 
0656 // templated JetDefinition::operator()(...) member
0657 #include "fastjet/ClusterSequence.hh"
0658 
0659 
0660 #endif // __FASTJET_JETDEFINITION_HH__