Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-30 10:10:52

0001 #ifndef __FASTJET_JETDEFINITION_HH__
0002 #define __FASTJET_JETDEFINITION_HH__
0003 
0004 //FJSTARTHEADER
0005 // $Id$
0006 //
0007 // Copyright (c) 2005-2025, 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   /// a variant of N2Plain strategy for native \f$e^+e^-\f$ algorithms
0127   /// (eekt, ee_genkt) that uses a more accurate calculation of the
0128   /// distance measure when angles between PseudoJets are smaller than
0129   /// \f$\epsilon^{1/4}\f$, where \f$\epsilon\f$ is the machine
0130   /// precision. It shifts the breakdown point from \f$\theta\sim
0131   /// \sqrt{\epsilon}\f$ to \f$\theta \sim \epsilon\f$.
0132   N2PlainEEAccurate =  31,
0133   /// the plugin has been used...
0134   plugin_strategy = 999
0135 };
0136 
0137 
0138 //======================================================================
0139 /// \enum JetAlgorithm
0140 /// the various families of jet-clustering algorithm
0141 //
0142 // [Remember to update the "is_spherical()" routine if any further
0143 // spherical algorithms are added to the list below]
0144 enum JetAlgorithm {
0145   /// the longitudinally invariant kt algorithm
0146   kt_algorithm=0,
0147   /// the longitudinally invariant variant of the cambridge algorithm
0148   /// (aka Aachen algoithm).
0149   cambridge_algorithm=1,
0150   /// like the k_t but with distance measures 
0151   ///       dij = min(1/kti^2,1/ktj^2) Delta R_{ij}^2 / R^2
0152   ///       diB = 1/kti^2
0153   antikt_algorithm=2, 
0154   /// like the k_t but with distance measures 
0155   ///       dij = min(kti^{2p},ktj^{2p}) Delta R_{ij}^2 / R^2
0156   ///       diB = 1/kti^{2p}
0157   /// where p = extra_param()
0158   genkt_algorithm=3, 
0159   /// a version of cambridge with a special distance measure for
0160   /// particles whose pt is < extra_param(); this is not usually
0161   /// intended for end users, but is instead automatically selected
0162   /// when requesting a passive Cambridge area.
0163   cambridge_for_passive_algorithm=11,
0164   /// a version of genkt with a special distance measure for particles
0165   /// whose pt is < extra_param() [relevant for passive areas when p<=0]
0166   /// ***** NB: THERE IS CURRENTLY NO IMPLEMENTATION FOR THIS ALG *******
0167   genkt_for_passive_algorithm=13, 
0168   //.................................................................
0169   /// the e+e- kt algorithm
0170   ee_kt_algorithm=50,
0171   /// the e+e- genkt algorithm  (R > 2 and p=1 gives ee_kt)
0172   ee_genkt_algorithm=53,
0173   //.................................................................
0174   /// any plugin algorithm supplied by the user
0175   plugin_algorithm = 99,
0176   //.................................................................
0177   /// the value for the jet algorithm in a JetDefinition for which
0178   /// no algorithm has yet been defined
0179   undefined_jet_algorithm = 999
0180 };
0181 
0182 /// make standard Les Houches nomenclature JetAlgorithm (algorithm is general
0183 /// recipe without the parameters) backward-compatible with old JetFinder
0184 typedef JetAlgorithm JetFinder;
0185 
0186 /// provide other possible names for the Cambridge/Aachen algorithm
0187 const JetAlgorithm aachen_algorithm = cambridge_algorithm;
0188 const JetAlgorithm cambridge_aachen_algorithm = cambridge_algorithm;
0189 
0190 //======================================================================
0191 /// The various recombination schemes
0192 ///
0193 /// Note that the schemes that recombine with non-linear weighting of
0194 /// the directions (e.g. pt2, winner-takes-all) are collinear safe
0195 /// only for algorithms with a suitable ordering of the
0196 /// recombinations: orderings in which, for particles of comparable
0197 /// energies, small-angle clusterings take place before large-angle
0198 /// clusterings. This property is satisfied by all gen-kt algorithms.
0199 /// 
0200 enum RecombinationScheme {
0201   /// summing the 4-momenta
0202   E_scheme=0,
0203   /// pt weighted recombination of y,phi (and summing of pt's)
0204   /// with preprocessing to make things massless by rescaling E=|\vec p|
0205   pt_scheme=1,
0206   /// pt^2 weighted recombination of y,phi (and summing of pt's)
0207   /// with preprocessing to make things massless by rescaling E=|\vec p|
0208   pt2_scheme=2,
0209   /// pt weighted recombination of y,phi (and summing of pt's)
0210   /// with preprocessing to make things massless by rescaling |\vec p|->=E
0211   Et_scheme=3,
0212   /// pt^2 weighted recombination of y,phi (and summing of pt's)
0213   /// with preprocessing to make things massless by rescaling |\vec p|->=E
0214   Et2_scheme=4,
0215   /// pt weighted recombination of y,phi (and summing of pt's), with 
0216   /// no preprocessing
0217   BIpt_scheme=5,
0218   /// pt^2 weighted recombination of y,phi (and summing of pt's)
0219   /// no preprocessing
0220   BIpt2_scheme=6,
0221   /// pt-based Winner-Takes-All (WTA) recombination: the
0222   /// result of the recombination has the rapidity, azimuth and mass
0223   /// of the PseudoJet with the larger pt, and a pt equal to the
0224   /// sum of the two pt's
0225   WTA_pt_scheme=7,
0226   /// mod-p-based Winner-Takes-All (WTA) recombination: the result of
0227   /// the recombination gets the 3-vector direction and mass of the
0228   /// PseudoJet with the larger |3-momentum| (modp), and a
0229   /// |3-momentum| equal to the scalar sum of the two |3-momenta|.
0230   WTA_modp_scheme=8,
0231   // Energy-ordering can lead to dangerous situations with particles at
0232   // rest. We instead implement the WTA_modp_scheme
0233   //
0234   // // energy-based Winner-Takes-All (WTA) recombination: the result of
0235   // // the recombination gets the 3-vector direction and mass of the
0236   // // PseudoJet with the larger energy, and an energy equal to the
0237   // // to the sum of the two energies
0238   // WTA_E_scheme=8,
0239   /// for the user's external scheme
0240   external_scheme = 99
0241 };
0242 
0243 
0244 
0245 // forward declaration, needed in order to specify interface for the
0246 // plugin.
0247 class ClusterSequence;
0248 
0249 
0250 
0251 
0252 //======================================================================
0253 /// @ingroup basic_classes
0254 /// \class JetDefinition
0255 /// class that is intended to hold a full definition of the jet
0256 /// clusterer
0257 class JetDefinition {
0258   
0259 public:
0260 
0261   /// forward declaration of a class that allows the user to introduce
0262   /// their own plugin 
0263   class Plugin;
0264 
0265   // forward declaration of a class that will provide the
0266   // recombination scheme facilities and/or allow a user to
0267   // extend these facilities
0268   class Recombiner;
0269 
0270 
0271   /// constructor with alternative ordering or arguments -- note that
0272   /// we have not provided a default jet finder, to avoid ambiguous
0273   /// JetDefinition() constructor.
0274   JetDefinition(JetAlgorithm jet_algorithm_in, 
0275                 double R_in, 
0276                 RecombinationScheme recomb_scheme_in = E_scheme,
0277                 Strategy strategy_in = Best) {
0278     *this = JetDefinition(jet_algorithm_in, R_in, recomb_scheme_in, strategy_in, 1);
0279   }
0280 
0281   /// constructor for algorithms that have no free parameters
0282   /// (e.g. ee_kt_algorithm)
0283   JetDefinition(JetAlgorithm jet_algorithm_in, 
0284                 RecombinationScheme recomb_scheme_in = E_scheme,
0285                 Strategy strategy_in = Best) {
0286     double dummyR = 0.0;
0287     *this = JetDefinition(jet_algorithm_in, dummyR, recomb_scheme_in, strategy_in, 0);
0288   }
0289 
0290   /// constructor for algorithms that require R + one extra parameter to be set 
0291   /// (the gen-kt series for example)
0292   JetDefinition(JetAlgorithm jet_algorithm_in, 
0293                 double R_in, 
0294                 double xtra_param_in,
0295                 RecombinationScheme recomb_scheme_in = E_scheme,
0296                 Strategy strategy_in = Best) {
0297     *this = JetDefinition(jet_algorithm_in, R_in, recomb_scheme_in, strategy_in, 2);
0298     set_extra_param(xtra_param_in);
0299   }
0300 
0301 
0302   /// constructor in a form that allows the user to provide a pointer
0303   /// to an external recombiner class (which must remain valid for the
0304   /// life of the JetDefinition object).
0305   JetDefinition(JetAlgorithm jet_algorithm_in, 
0306                 double R_in, 
0307                 const Recombiner * recombiner_in,
0308                 Strategy strategy_in = Best) {
0309     *this = JetDefinition(jet_algorithm_in, R_in, external_scheme, strategy_in);
0310     _recombiner = recombiner_in;
0311   }
0312 
0313 
0314   /// constructor for case with 0 parameters (ee_kt_algorithm) and
0315   /// and external recombiner
0316   JetDefinition(JetAlgorithm jet_algorithm_in, 
0317                 const Recombiner * recombiner_in,
0318                 Strategy strategy_in = Best) {
0319     *this = JetDefinition(jet_algorithm_in, external_scheme, strategy_in);
0320     _recombiner = recombiner_in;
0321   }
0322 
0323   /// constructor allowing the extra parameter to be set and a pointer to
0324   /// a recombiner
0325   JetDefinition(JetAlgorithm jet_algorithm_in, 
0326                 double R_in, 
0327                 double xtra_param_in,
0328                 const Recombiner * recombiner_in,
0329                 Strategy strategy_in = Best) {
0330     *this = JetDefinition(jet_algorithm_in, R_in, xtra_param_in, external_scheme, strategy_in);
0331     _recombiner = recombiner_in;
0332   }
0333 
0334   /// a default constructor which creates a jet definition that is in
0335   /// a well-defined internal state, but not actually usable for jet
0336   /// clustering.
0337   JetDefinition()  {
0338     *this = JetDefinition(undefined_jet_algorithm, 1.0);
0339   }
0340   
0341 
0342   // /// a default constructor
0343   // JetDefinition() {
0344   //   *this = JetDefinition(kt_algorithm, 1.0);
0345   // }
0346 
0347   /// constructor based on a pointer to a user's plugin; the object
0348   /// pointed to must remain valid for the whole duration of existence
0349   /// of the JetDefinition and any related ClusterSequences
0350   JetDefinition(const Plugin * plugin_in) {
0351     _plugin = plugin_in;
0352     _strategy = plugin_strategy;
0353     _Rparam = _plugin->R();
0354     _extra_param = 0.0; // a dummy value to keep static code checkers happy
0355     _jet_algorithm = plugin_algorithm;
0356     set_recombination_scheme(E_scheme);
0357   }
0358 
0359   /// constructor to fully specify a jet-definition (together with
0360   /// information about how algorithically to run it).
0361   JetDefinition(JetAlgorithm jet_algorithm_in, 
0362                 double R_in, 
0363                 RecombinationScheme recomb_scheme_in,
0364                 Strategy strategy_in,
0365                 int nparameters_in);
0366 
0367   /// constructor to fully specify a jet-definition (together with
0368   /// information about how algorithically to run it).
0369   ///
0370   /// the ordering of arguments here is old and deprecated (except
0371   /// as the common constructor for internal use)
0372   FASTJET_DEPRECATED_MSG("This argument ordering is deprecated. Use JetDefinition(alg, R, strategy, scheme[, n_parameters]) instead",
0373   JetDefinition(JetAlgorithm jet_algorithm_in, 
0374                 double R_in, 
0375                 Strategy strategy_in,
0376                 RecombinationScheme recomb_scheme_in = E_scheme,
0377                 int nparameters_in = 1)){
0378     (*this) = JetDefinition(jet_algorithm_in,R_in,recomb_scheme_in,strategy_in,nparameters_in);
0379   }
0380 
0381 
0382   /// cluster the supplied particles and returns a vector of resulting
0383   /// jets, sorted by pt (or energy in the case of spherical,
0384   /// i.e. e+e-, algorithms). This routine currently only makes
0385   /// sense for "inclusive" type algorithms.
0386   template <class L> 
0387   std::vector<PseudoJet> operator()(const std::vector<L> & particles) const;
0388   
0389   /// R values larger than max_allowable_R are not allowed.
0390   ///
0391   /// We use a value of 1000, substantially smaller than
0392   /// numeric_limits<double>::max(), to leave room for the convention
0393   /// within PseudoJet of setting unphysical (infinite) rapidities to
0394   /// +-(MaxRap + abs(pz())), where MaxRap is 10^5.
0395   static const double max_allowable_R; //= 1000.0;
0396 
0397   /// set the recombination scheme to the one provided
0398   void set_recombination_scheme(RecombinationScheme);
0399 
0400   /// set the recombiner class to the one provided
0401   ///
0402   /// Note that in order to associate to a jet definition a recombiner
0403   /// from another jet definition, it is strongly recommended to use
0404   /// the set_recombiner(const JetDefinition &) method below. The
0405   /// latter correctly handles the situations where the jet definition
0406   /// owns the recombiner (i.e. where delete_recombiner_when_unused
0407   /// has been called). In such cases, using set_recombiner(const
0408   /// Recombiner *) may lead to memory corruption.
0409   void set_recombiner(const Recombiner * recomb) {
0410     if (_shared_recombiner) _shared_recombiner.reset(recomb);
0411     _recombiner = recomb;
0412     _default_recombiner = DefaultRecombiner(external_scheme);
0413   }
0414 
0415   /// set the recombiner to be the same as the one of 'other_jet_def'
0416   ///
0417   /// Note that this is the recommended method to associate to a jet
0418   /// definition the recombiner from another jet definition. Compared
0419   /// to the set_recombiner(const Recombiner *) above, it correctly
0420   /// handles the case where the jet definition owns the recombiner
0421   /// (i.e. where delete_recombiner_when_unused has been called)
0422   void set_recombiner(const JetDefinition &other_jet_def);
0423 
0424   /// calling this tells the JetDefinition to handle the deletion of
0425   /// the recombiner when it is no longer used. (Should not be called
0426   /// if the recombiner was initialised from a JetDef whose recombiner
0427   /// was already scheduled to delete itself - memory handling will
0428   /// already be automatic across both JetDef's in that case).
0429   void delete_recombiner_when_unused();
0430 
0431   /// return a pointer to the plugin 
0432   const Plugin * plugin() const {return _plugin;};
0433 
0434   /// calling this causes the JetDefinition to handle the deletion of the
0435   /// plugin when it is no longer used
0436   void delete_plugin_when_unused();
0437 
0438   /// return information about the definition...
0439   JetAlgorithm jet_algorithm  () const {return _jet_algorithm  ;}
0440   /// same as above for backward compatibility
0441   JetAlgorithm jet_finder     () const {return _jet_algorithm  ;}
0442   double    R           () const {return _Rparam      ;}
0443   // a general purpose extra parameter, whose meaning depends on
0444   // the algorithm, and may often be unused.
0445   double    extra_param () const {return _extra_param ;}
0446   Strategy  strategy    () const {return _strategy    ;}
0447   RecombinationScheme recombination_scheme() const {
0448     return _default_recombiner.scheme();}
0449 
0450   /// (re)set the jet finder
0451   void set_jet_algorithm(JetAlgorithm njf) {_jet_algorithm = njf;}
0452   /// same as above for backward compatibility
0453   void set_jet_finder(JetAlgorithm njf)    {_jet_algorithm = njf;}
0454   /// (re)set the general purpose extra parameter
0455   void set_extra_param(double xtra_param) {_extra_param = xtra_param;}
0456 
0457   /// returns a pointer to the currently defined recombiner. 
0458   ///
0459   /// Warning: the pointer may be to an internal recombiner (for
0460   /// default recombination schemes), in which case if the
0461   /// JetDefinition becomes invalid (e.g. is deleted), the pointer
0462   /// will then point to an object that no longer exists.
0463   /// 
0464   /// Note also that if you copy a JetDefinition with a default
0465   /// recombination scheme, then the two copies will have distinct
0466   /// recombiners, and return different recombiner() pointers.
0467   const Recombiner * recombiner() const {
0468     return _recombiner == 0 ? & _default_recombiner : _recombiner;}
0469 
0470   /// returns true if the current jet definitions shares the same
0471   /// recombiner as the one passed as an argument
0472   bool has_same_recombiner(const JetDefinition &other_jd) const;
0473 
0474   /// returns true if the jet definition involves an algorithm
0475   /// intended for use on a spherical geometry (e.g. e+e- algorithms,
0476   /// as opposed to most pp algorithms, which use a cylindrical,
0477   /// rapidity-phi geometry).
0478   bool is_spherical() const;
0479 
0480   /// return a textual description of the current jet definition 
0481   std::string description() const;
0482 
0483   /// returns a description not including the recombiner information
0484   std::string description_no_recombiner() const;
0485 
0486   /// a short textual description of the algorithm jet_alg
0487   static std::string algorithm_description(const JetAlgorithm jet_alg);
0488 
0489   /// the number of parameters associated to a given jet algorithm
0490   static unsigned int n_parameters_for_algorithm(const JetAlgorithm jet_alg);
0491 
0492 public:
0493   //======================================================================
0494   /// @ingroup advanced_usage
0495   /// \class Recombiner
0496   /// An abstract base class that will provide the recombination scheme
0497   /// facilities and/or allow a user to extend these facilities
0498   class Recombiner {
0499   public:
0500     /// return a textual description of the recombination scheme
0501     /// implemented here
0502     virtual std::string description() const = 0;
0503     
0504     /// recombine pa and pb and put result into pab
0505     virtual void recombine(const PseudoJet & pa, const PseudoJet & pb, 
0506                            PseudoJet & pab) const = 0;
0507 
0508     /// routine called to preprocess each input jet (to make all input
0509     /// jets compatible with the scheme requirements (e.g. massless).
0510     virtual void preprocess(PseudoJet & ) const {};
0511     
0512     /// a destructor to be replaced if necessary in derived classes...
0513     virtual ~Recombiner() {};
0514 
0515     /// pa += pb in the given recombination scheme. Not virtual -- the
0516     /// user should have no reason to want to redefine this!
0517     inline void plus_equal(PseudoJet & pa, const PseudoJet & pb) const {
0518       // put result in a temporary location in case the recombiner
0519       // does something funny (ours doesn't, but who knows about the
0520       // user's)
0521       PseudoJet pres; 
0522       recombine(pa,pb,pres);
0523       pa = pres;
0524     }
0525 
0526   };
0527   
0528   
0529   //======================================================================
0530   /// @ingroup advanced_usage
0531   /// \class DefaultRecombiner
0532   /// A class that will provide the recombination scheme facilities and/or
0533   /// allow a user to extend these facilities
0534   ///
0535   /// This class is derived from the (abstract) class Recombiner. It
0536   /// simply "sums" PseudoJets using a specified recombination scheme
0537   /// (E-scheme by default)
0538   class DefaultRecombiner : public Recombiner {
0539   public:
0540     DefaultRecombiner(RecombinationScheme recomb_scheme = E_scheme) : 
0541       _recomb_scheme(recomb_scheme) {}
0542     
0543     virtual std::string description() const FASTJET_OVERRIDE;
0544     
0545     /// recombine pa and pb and put result into pab
0546     virtual void recombine(const PseudoJet & pa, const PseudoJet & pb, 
0547                            PseudoJet & pab) const FASTJET_OVERRIDE;
0548 
0549     virtual void preprocess(PseudoJet & p) const FASTJET_OVERRIDE;
0550 
0551     /// return the index of the recombination scheme
0552     RecombinationScheme scheme() const {return _recomb_scheme;}
0553     
0554   private:
0555     RecombinationScheme _recomb_scheme;
0556   };
0557 
0558 
0559   //======================================================================
0560   /// @ingroup advanced_usage
0561   /// \class Plugin
0562   /// a class that allows a user to introduce their own "plugin" jet
0563   /// finder
0564   ///
0565   /// Note that all the plugins provided with FastJet are derived from
0566   /// this class
0567   class Plugin{
0568   public:
0569     /// return a textual description of the jet-definition implemented
0570     /// in this plugin
0571     virtual std::string description() const = 0;
0572     
0573     /// given a ClusterSequence that has been filled up with initial
0574     /// particles, the following function should fill up the rest of the
0575     /// ClusterSequence, using the following member functions of
0576     /// ClusterSequence:
0577     ///   - plugin_do_ij_recombination(...)
0578     ///   - plugin_do_iB_recombination(...)
0579     virtual void run_clustering(ClusterSequence &) const = 0;
0580     
0581     virtual double R() const = 0;
0582     
0583     /// return true if there is specific support for the measurement
0584     /// of passive areas, in the sense that areas determined from all
0585     /// particles below the ghost separation scale will be a passive
0586     /// area. [If you don't understand this, ignore it!]
0587     virtual bool supports_ghosted_passive_areas() const {return false;}
0588 
0589     /// set the ghost separation scale for passive area determinations
0590     /// in future runs (strictly speaking that makes the routine
0591     /// a non const, so related internal info must be stored as a mutable)
0592     virtual void set_ghost_separation_scale(double scale) const;
0593     virtual double ghost_separation_scale() const {return 0.0;}
0594 
0595     /// if this returns false then a warning will be given
0596     /// whenever the user requests "exclusive" jets from the
0597     /// cluster sequence
0598     virtual bool exclusive_sequence_meaningful() const {return false;}
0599 
0600     /// returns true if the plugin implements an algorithm intended
0601     /// for use on a spherical geometry (e.g. e+e- algorithms, as
0602     /// opposed to most pp algorithms, which use a cylindrical,
0603     /// rapidity-phi geometry).
0604     virtual bool is_spherical() const {return false;}
0605 
0606     /// a destructor to be replaced if necessary in derived classes...
0607     virtual ~Plugin() {};
0608   };
0609 
0610 private:
0611 
0612 
0613   JetAlgorithm _jet_algorithm;
0614   double    _Rparam;
0615   double    _extra_param ; ///< parameter whose meaning varies according to context
0616   Strategy  _strategy  ;
0617 
0618   const Plugin * _plugin;
0619   SharedPtr<const Plugin> _plugin_shared;
0620 
0621   // when we use our own recombiner it's useful to point to it here
0622   // so that we don't have to worry about deleting it etc...
0623   DefaultRecombiner _default_recombiner;
0624   const Recombiner * _recombiner;
0625   SharedPtr<const Recombiner> _shared_recombiner;
0626 
0627 };
0628 
0629 
0630 //-------------------------------------------------------------------------------
0631 // helper functions to build a jet made of pieces
0632 //
0633 // These functions include an options recombiner used to compute the
0634 // total composite jet momentum
0635 // -------------------------------------------------------------------------------
0636 
0637 /// build a "CompositeJet" from the vector of its pieces
0638 ///
0639 /// In this case, E-scheme recombination is assumed to compute the
0640 /// total momentum
0641 PseudoJet join(const std::vector<PseudoJet> & pieces, const JetDefinition::Recombiner & recombiner);
0642 
0643 /// build a MergedJet from a single PseudoJet
0644 PseudoJet join(const PseudoJet & j1, 
0645            const JetDefinition::Recombiner & recombiner);
0646 
0647 /// build a MergedJet from 2 PseudoJet
0648 PseudoJet join(const PseudoJet & j1, const PseudoJet & j2, 
0649            const JetDefinition::Recombiner & recombiner);
0650 
0651 /// build a MergedJet from 3 PseudoJet
0652 PseudoJet join(const PseudoJet & j1, const PseudoJet & j2, const PseudoJet & j3, 
0653            const JetDefinition::Recombiner & recombiner);
0654 
0655 /// build a MergedJet from 4 PseudoJet
0656 PseudoJet join(const PseudoJet & j1, const PseudoJet & j2, const PseudoJet & j3, const PseudoJet & j4, 
0657            const JetDefinition::Recombiner & recombiner);
0658 
0659 
0660 FASTJET_END_NAMESPACE
0661 
0662 // include ClusterSequence which includes the implementation of the 
0663 // templated JetDefinition::operator()(...) member
0664 #include "fastjet/ClusterSequence.hh"
0665 
0666 
0667 #endif // __FASTJET_JETDEFINITION_HH__