JetDefinition.hh

00001 //STARTHEADER
00002 // $Id: JetDefinition.hh 1850 2011-01-25 19:33:24Z soyez $
00003 //
00004 // Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam
00005 //
00006 //----------------------------------------------------------------------
00007 // This file is part of FastJet.
00008 //
00009 //  FastJet is free software; you can redistribute it and/or modify
00010 //  it under the terms of the GNU General Public License as published by
00011 //  the Free Software Foundation; either version 2 of the License, or
00012 //  (at your option) any later version.
00013 //
00014 //  The algorithms that underlie FastJet have required considerable
00015 //  development and are described in hep-ph/0512210. If you use
00016 //  FastJet as part of work towards a scientific publication, please
00017 //  include a citation to the FastJet paper.
00018 //
00019 //  FastJet is distributed in the hope that it will be useful,
00020 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022 //  GNU General Public License for more details.
00023 //
00024 //  You should have received a copy of the GNU General Public License
00025 //  along with FastJet; if not, write to the Free Software
00026 //  Foundation, Inc.:
00027 //      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 //----------------------------------------------------------------------
00029 //ENDHEADER
00030 
00031 #ifndef __FASTJET_JETDEFINITION_HH__
00032 #define __FASTJET_JETDEFINITION_HH__
00033 
00034 #include<cassert>
00035 #include "fastjet/internal/numconsts.hh"
00036 #include "fastjet/PseudoJet.hh"
00037 #include<string>
00038 #include<memory>
00039 
00040 FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
00041 
00043 //  NB: (implemented in ClusterSequence.cc but defined here because
00044 //  this is a visible location)
00045 std::string fastjet_version_string();
00046 
00047 //======================================================================
00050 enum Strategy {
00052   N2MinHeapTiled   = -4, 
00054   N2Tiled     = -3, 
00056   N2PoorTiled = -2, 
00058   N2Plain     = -1, 
00060   N3Dumb      =  0, 
00062   Best        =  1, 
00065   NlnN        =  2, 
00068   NlnN3pi     =  3, 
00070   NlnN4pi     =  4,
00074   NlnNCam4pi   = 14,
00078   NlnNCam2pi2R = 13,
00082   NlnNCam      = 12, // 2piMultD
00084   plugin_strategy = 999
00085 };
00086 
00087 
00088 //======================================================================
00091 enum JetAlgorithm {
00093   kt_algorithm=0,
00096   cambridge_algorithm=1,
00100   antikt_algorithm=2, 
00105   genkt_algorithm=3, 
00108   cambridge_for_passive_algorithm=11,
00111   genkt_for_passive_algorithm=13, 
00112   //.................................................................
00114   ee_kt_algorithm=50,
00116   ee_genkt_algorithm=53,
00117   //.................................................................
00119   plugin_algorithm = 99
00120 };
00121 
00124 typedef JetAlgorithm JetFinder;
00125 
00127 const JetAlgorithm aachen_algorithm = cambridge_algorithm;
00128 const JetAlgorithm cambridge_aachen_algorithm = cambridge_algorithm;
00129 
00130 //======================================================================
00132 enum RecombinationScheme {
00134   E_scheme=0,
00137   pt_scheme=1,
00140   pt2_scheme=2,
00143   Et_scheme=3,
00146   Et2_scheme=4,
00149   BIpt_scheme=5,
00152   BIpt2_scheme=6,
00154   external_scheme = 99
00155 };
00156 
00157 
00158 
00159 
00160 // forward declaration, needed in order to specify interface for the
00161 // plugin.
00162 class ClusterSequence;
00163 
00164 
00165 
00166 
00167 //======================================================================
00172 class JetDefinition {
00173   
00174 public:
00175 
00178   class Plugin;
00179 
00180   // forward declaration of a class that will provide the
00181   // recombination scheme facilities and/or allow a user to
00182   // extend these facilities
00183   class Recombiner;
00184 
00185   
00186 
00190   JetDefinition(JetAlgorithm jet_algorithm, 
00191                 double R, 
00192                 RecombinationScheme recomb_scheme = E_scheme,
00193                 Strategy strategy = Best) {
00194     *this = JetDefinition(jet_algorithm, R, strategy, recomb_scheme, 1);
00195   }
00196 
00199   JetDefinition(JetAlgorithm jet_algorithm, 
00200                 RecombinationScheme recomb_scheme = E_scheme,
00201                 Strategy strategy = Best) {
00202     double dummyR = 0.0;
00203     *this = JetDefinition(jet_algorithm, dummyR, strategy, recomb_scheme, 0);
00204   }
00205 
00208   JetDefinition(JetAlgorithm jet_algorithm, 
00209                 double R, 
00210                 double xtra_param,
00211                 RecombinationScheme recomb_scheme = E_scheme,
00212                 Strategy strategy = Best) {
00213     *this = JetDefinition(jet_algorithm, R, strategy, recomb_scheme, 2);
00214     set_extra_param(xtra_param);
00215   }
00216 
00217 
00221   JetDefinition(JetAlgorithm jet_algorithm, 
00222                 double R, 
00223                 const Recombiner * recombiner,
00224                 Strategy strategy = Best) {
00225     *this = JetDefinition(jet_algorithm, R, external_scheme, strategy);
00226     _recombiner = recombiner;
00227   }
00228 
00229 
00232   JetDefinition(JetAlgorithm jet_algorithm, 
00233                 const Recombiner * recombiner,
00234                 Strategy strategy = Best) {
00235     *this = JetDefinition(jet_algorithm, external_scheme, strategy);
00236     _recombiner = recombiner;
00237   }
00238 
00241   JetDefinition(JetAlgorithm jet_algorithm, 
00242                 double R, 
00243                 double xtra_param,
00244                 const Recombiner * recombiner,
00245                 Strategy strategy = Best) {
00246     *this = JetDefinition(jet_algorithm, R, external_scheme, strategy);
00247     _recombiner = recombiner;
00248     set_extra_param(xtra_param);
00249   }
00250 
00252   JetDefinition() {
00253     *this = JetDefinition(kt_algorithm, 1.0);
00254   }
00255 
00259   JetDefinition(const Plugin * plugin) {
00260     _plugin = plugin;
00261     _strategy = plugin_strategy;
00262     _Rparam = _plugin->R();
00263     _jet_algorithm = plugin_algorithm;
00264     set_recombination_scheme(E_scheme);
00265   }
00266 
00267 
00273   JetDefinition(JetAlgorithm jet_algorithm, 
00274                 double R, 
00275                 Strategy strategy,
00276                 RecombinationScheme recomb_scheme = E_scheme,
00277                 int nparameters = 1);
00278 // :
00279 //    _jet_algorithm(jet_algorithm), _Rparam(R), _strategy(strategy) {
00280 //    // the largest sensible value for R
00281 //    if (jet_algorithm != ee_kt_algorithm &&
00282 //      jet_algorithm != ee_genkt_algorithm) assert(_Rparam <= 0.5*pi);
00283 //    assert(_jet_algorithm != plugin_algorithm &&
00284 //           _strategy   != plugin_strategy);
00285 //    _plugin = NULL;
00286 //    set_recombination_scheme(recomb_scheme);
00287 //    set_extra_param(0.0); // make sure it's defined
00288 //  }
00289 
00290 
00292   void set_recombination_scheme(RecombinationScheme);
00293 
00295   void set_recombiner(const Recombiner * recomb) {
00296     _recombiner = recomb;
00297     _default_recombiner = DefaultRecombiner(external_scheme);
00298   }
00299 
00301   const Plugin * plugin() const {return _plugin;};
00302 
00304   JetAlgorithm jet_algorithm  () const {return _jet_algorithm  ;}
00306   JetAlgorithm jet_finder     () const {return _jet_algorithm  ;}
00307   double    R           () const {return _Rparam      ;}
00308   // a general purpose extra parameter, whose meaning depends on
00309   // the algorithm, and may often be unused.
00310   double    extra_param () const {return _extra_param ;}
00311   Strategy  strategy    () const {return _strategy    ;}
00312   RecombinationScheme recombination_scheme() const {
00313     return _default_recombiner.scheme();}
00314 
00316   void set_jet_algorithm(JetAlgorithm njf) {_jet_algorithm = njf;}
00318   void set_jet_finder(JetAlgorithm njf)    {_jet_algorithm = njf;}
00320   void set_extra_param(double xtra_param) {_extra_param = xtra_param;}
00321 
00332   const Recombiner * recombiner() const {
00333     return _recombiner == 0 ? & _default_recombiner : _recombiner;}
00334 
00336   std::string description() const;
00337 
00338 
00339 public:
00340   //======================================================================
00345   class Recombiner {
00346   public:
00349     virtual std::string description() const = 0;
00350     
00352     virtual void recombine(const PseudoJet & pa, const PseudoJet & pb, 
00353                            PseudoJet & pab) const = 0;
00354 
00357     virtual void preprocess(PseudoJet & ) const {};
00358     
00360     virtual ~Recombiner() {};
00361 
00364     inline void plus_equal(PseudoJet & pa, const PseudoJet & pb) const {
00365       // put result in a temporary location in case the recombiner
00366       // does something funny (ours doesn't, but who knows about the
00367       // user's)
00368       PseudoJet pres; 
00369       recombine(pa,pb,pres);
00370       pa = pres;
00371     }
00372 
00373   };
00374   
00375   
00376   //======================================================================
00385   class DefaultRecombiner : public Recombiner {
00386   public:
00387     DefaultRecombiner(RecombinationScheme recomb_scheme = E_scheme) : 
00388       _recomb_scheme(recomb_scheme) {}
00389     
00390     virtual std::string description() const;
00391     
00393     virtual void recombine(const PseudoJet & pa, const PseudoJet & pb, 
00394                            PseudoJet & pab) const;
00395 
00396     virtual void preprocess(PseudoJet & p) const;
00397 
00399     RecombinationScheme scheme() const {return _recomb_scheme;}
00400     
00401   private:
00402     RecombinationScheme _recomb_scheme;
00403   };
00404 
00405 
00406   //======================================================================
00414   class Plugin{
00415   public:
00418     virtual std::string description() const = 0;
00419     
00426     virtual void run_clustering(ClusterSequence &) const = 0;
00427     
00428     virtual double R() const = 0;
00429     
00434     virtual bool supports_ghosted_passive_areas() const {return false;}
00435 
00439     virtual void set_ghost_separation_scale(double scale) const;
00440     virtual double ghost_separation_scale() const {return 0.0;}
00441 
00445     virtual bool exclusive_sequence_meaningful() const {return false;}
00446 
00448     virtual ~Plugin() {};
00449   };
00450 
00451 private:
00452 
00453 
00454   JetAlgorithm _jet_algorithm;
00455   double    _Rparam;
00456   double    _extra_param ; 
00457   Strategy  _strategy  ;
00458 
00459   const Plugin * _plugin;
00460 
00461   // when we use our own recombiner it's useful to point to it here
00462   // so that we don't have to worry about deleting it etc...
00463   DefaultRecombiner _default_recombiner;
00464   const Recombiner * _recombiner;
00465 
00466 };
00467 
00468 
00469 
00470 
00471 
00472 
00473 FASTJET_END_NAMESPACE
00474 
00475 #endif // __FASTJET_JETDEFINITION_HH__