FastJet 3.0beta1
|
00001 //STARTHEADER 00002 // $Id: JetDefinition.hh 2449 2011-07-22 01:08:35Z salam $ 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 00042 /// return a string containing information about the release 00043 // NB: (implemented in ClusterSequence.cc but defined here because 00044 // this is a visible location) 00045 std::string fastjet_version_string(); 00046 00047 //====================================================================== 00048 /// the various options for the algorithmic strategy to adopt in 00049 /// clustering events with kt and cambridge style algorithms. 00050 enum Strategy { 00051 /// fastest form about 500..10^4 00052 N2MinHeapTiled = -4, 00053 /// fastest from about 50..500 00054 N2Tiled = -3, 00055 /// legacy 00056 N2PoorTiled = -2, 00057 /// fastest below 50 00058 N2Plain = -1, 00059 /// worse even than the usual N^3 algorithms 00060 N3Dumb = 0, 00061 /// automatic selection of the best (based on N) 00062 Best = 1, 00063 /// best of the NlnN variants -- best overall for N>10^4. 00064 /// (Does not work for R>=2pi) 00065 NlnN = 2, 00066 /// legacy N ln N using 3pi coverage of cylinder. 00067 /// (Does not work for R>=2pi) 00068 NlnN3pi = 3, 00069 /// legacy N ln N using 4pi coverage of cylinder 00070 NlnN4pi = 4, 00071 /// Chan's closest pair method (in a variant with 4pi coverage), 00072 /// for use exclusively with the Cambridge algorithm. 00073 /// (Does not work for R>=2pi) 00074 NlnNCam4pi = 14, 00075 /// Chan's closest pair method (in a variant with 2pi+2R coverage), 00076 /// for use exclusively with the Cambridge algorithm. 00077 /// (Does not work for R>=2pi) 00078 NlnNCam2pi2R = 13, 00079 /// Chan's closest pair method (in a variant with 2pi+minimal extra 00080 /// variant), for use exclusively with the Cambridge algorithm. 00081 /// (Does not work for R>=2pi) 00082 NlnNCam = 12, // 2piMultD 00083 /// the plugin has been used... 00084 plugin_strategy = 999 00085 }; 00086 00087 00088 //====================================================================== 00089 /// \enum JetAlgorithm 00090 /// the various families of jet-clustering algorithm 00091 enum JetAlgorithm { 00092 /// the longitudinally invariant kt algorithm 00093 kt_algorithm=0, 00094 /// the longitudinally invariant variant of the cambridge algorithm 00095 /// (aka Aachen algoithm). 00096 cambridge_algorithm=1, 00097 /// like the k_t but with distance measures 00098 /// dij = min(1/kti^2,1/ktj^2) Delta R_{ij}^2 / R^2 00099 /// diB = 1/kti^2 00100 antikt_algorithm=2, 00101 /// like the k_t but with distance measures 00102 /// dij = min(kti^{2p},ktj^{2p}) Delta R_{ij}^2 / R^2 00103 /// diB = 1/kti^{2p} 00104 /// where p = extra_param() 00105 genkt_algorithm=3, 00106 /// a version of cambridge with a special distance measure for particles 00107 /// whose pt is < extra_param() 00108 cambridge_for_passive_algorithm=11, 00109 /// a version of genkt with a special distance measure for particles 00110 /// whose pt is < extra_param() [relevant for passive areas when p<=0] 00111 genkt_for_passive_algorithm=13, 00112 //................................................................. 00113 /// the e+e- kt algorithm 00114 ee_kt_algorithm=50, 00115 /// the e+e- genkt algorithm (R > 2 and p=1 gives ee_kt) 00116 ee_genkt_algorithm=53, 00117 //................................................................. 00118 /// any plugin algorithm supplied by the user 00119 plugin_algorithm = 99, 00120 //................................................................. 00121 /// the value for the jet algorithm in a JetDefinition for which 00122 /// no algorithm has yet been defined 00123 undefined_jet_algorithm = 999 00124 }; 00125 00126 /// make standard Les Houches nomenclature JetAlgorithm (algorithm is general 00127 /// recipe without the parameters) backward-compatible with old JetFinder 00128 typedef JetAlgorithm JetFinder; 00129 00130 /// provide other possible names for the Cambridge/Aachen algorithm? 00131 const JetAlgorithm aachen_algorithm = cambridge_algorithm; 00132 const JetAlgorithm cambridge_aachen_algorithm = cambridge_algorithm; 00133 00134 //====================================================================== 00135 /// the various recombination schemes 00136 enum RecombinationScheme { 00137 /// summing the 4-momenta 00138 E_scheme=0, 00139 /// pt weighted recombination of y,phi (and summing of pt's) 00140 /// with preprocessing to make things massless by rescaling E=|\vec p| 00141 pt_scheme=1, 00142 /// pt^2 weighted recombination of y,phi (and summing of pt's) 00143 /// with preprocessing to make things massless by rescaling E=|\vec p| 00144 pt2_scheme=2, 00145 /// pt weighted recombination of y,phi (and summing of pt's) 00146 /// with preprocessing to make things massless by rescaling |\vec p|->=E 00147 Et_scheme=3, 00148 /// pt^2 weighted recombination of y,phi (and summing of pt's) 00149 /// with preprocessing to make things massless by rescaling |\vec p|->=E 00150 Et2_scheme=4, 00151 /// pt weighted recombination of y,phi (and summing of pt's), with 00152 /// no preprocessing 00153 BIpt_scheme=5, 00154 /// pt^2 weighted recombination of y,phi (and summing of pt's) 00155 /// no preprocessing 00156 BIpt2_scheme=6, 00157 /// for the user's external scheme 00158 external_scheme = 99 00159 }; 00160 00161 00162 00163 00164 // forward declaration, needed in order to specify interface for the 00165 // plugin. 00166 class ClusterSequence; 00167 00168 00169 00170 00171 //====================================================================== 00172 /// @ingroup basic_classes 00173 /// \class JetDefinition 00174 /// class that is intended to hold a full definition of the jet 00175 /// clusterer 00176 class JetDefinition { 00177 00178 public: 00179 00180 /// forward declaration of a class that allows the user to introduce 00181 /// their own plugin 00182 class Plugin; 00183 00184 // forward declaration of a class that will provide the 00185 // recombination scheme facilities and/or allow a user to 00186 // extend these facilities 00187 class Recombiner; 00188 00189 00190 /// constructor with alternative ordering or arguments -- note that 00191 /// we have not provided a default jet finder, to avoid ambiguous 00192 /// JetDefinition() constructor. 00193 JetDefinition(JetAlgorithm jet_algorithm, 00194 double R, 00195 RecombinationScheme recomb_scheme = E_scheme, 00196 Strategy strategy = Best) { 00197 *this = JetDefinition(jet_algorithm, R, strategy, recomb_scheme, 1); 00198 } 00199 00200 /// constructor for algorithms that have no free parameters 00201 /// (e.g. ee_kt_algorithm) 00202 JetDefinition(JetAlgorithm jet_algorithm, 00203 RecombinationScheme recomb_scheme = E_scheme, 00204 Strategy strategy = Best) { 00205 double dummyR = 0.0; 00206 *this = JetDefinition(jet_algorithm, dummyR, strategy, recomb_scheme, 0); 00207 } 00208 00209 /// constructor for algorithms that require R + one extra parameter to be set 00210 /// (the gen-kt series for example) 00211 JetDefinition(JetAlgorithm jet_algorithm, 00212 double R, 00213 double xtra_param, 00214 RecombinationScheme recomb_scheme = E_scheme, 00215 Strategy strategy = Best) { 00216 *this = JetDefinition(jet_algorithm, R, strategy, recomb_scheme, 2); 00217 set_extra_param(xtra_param); 00218 } 00219 00220 00221 /// constructor in a form that allows the user to provide a pointer 00222 /// to an external recombiner class (which must remain valid for the 00223 /// life of the JetDefinition object). 00224 JetDefinition(JetAlgorithm jet_algorithm, 00225 double R, 00226 const Recombiner * recombiner, 00227 Strategy strategy = Best) { 00228 *this = JetDefinition(jet_algorithm, R, external_scheme, strategy); 00229 _recombiner = recombiner; 00230 } 00231 00232 00233 /// constructor for case with 0 parameters (ee_kt_algorithm) and 00234 /// and external recombiner 00235 JetDefinition(JetAlgorithm jet_algorithm, 00236 const Recombiner * recombiner, 00237 Strategy strategy = Best) { 00238 *this = JetDefinition(jet_algorithm, external_scheme, strategy); 00239 _recombiner = recombiner; 00240 } 00241 00242 /// constructor allowing the extra parameter to be set and a pointer to 00243 /// a recombiner 00244 JetDefinition(JetAlgorithm jet_algorithm, 00245 double R, 00246 double xtra_param, 00247 const Recombiner * recombiner, 00248 Strategy strategy = Best) { 00249 *this = JetDefinition(jet_algorithm, R, external_scheme, strategy); 00250 _recombiner = recombiner; 00251 set_extra_param(xtra_param); 00252 } 00253 00254 /// a default constructor which creates a jet definition that is in 00255 /// a well-defined internal state, but not actually usable for jet 00256 /// clustering. 00257 JetDefinition() { 00258 *this = JetDefinition(undefined_jet_algorithm, 1.0); 00259 } 00260 00261 00262 // /// a default constructor 00263 // JetDefinition() { 00264 // *this = JetDefinition(kt_algorithm, 1.0); 00265 // } 00266 00267 /// constructor based on a pointer to a user's plugin; the object 00268 /// pointed to must remain valid for the whole duration of existence 00269 /// of the JetDefinition and any related ClusterSequences 00270 JetDefinition(const Plugin * plugin) { 00271 _plugin = plugin; 00272 _strategy = plugin_strategy; 00273 _Rparam = _plugin->R(); 00274 _jet_algorithm = plugin_algorithm; 00275 set_recombination_scheme(E_scheme); 00276 } 00277 00278 00279 /// constructor to fully specify a jet-definition (together with 00280 /// information about how algorithically to run it). 00281 /// 00282 /// the ordering of arguments here is old and deprecated (except 00283 /// as the common constructor for internal use) 00284 JetDefinition(JetAlgorithm jet_algorithm, 00285 double R, 00286 Strategy strategy, 00287 RecombinationScheme recomb_scheme = E_scheme, 00288 int nparameters = 1); 00289 // : 00290 // _jet_algorithm(jet_algorithm), _Rparam(R), _strategy(strategy) { 00291 // // the largest sensible value for R 00292 // if (jet_algorithm != ee_kt_algorithm && 00293 // jet_algorithm != ee_genkt_algorithm) assert(_Rparam <= 0.5*pi); 00294 // assert(_jet_algorithm != plugin_algorithm && 00295 // _strategy != plugin_strategy); 00296 // _plugin = NULL; 00297 // set_recombination_scheme(recomb_scheme); 00298 // set_extra_param(0.0); // make sure it's defined 00299 // } 00300 00301 00302 /// set the recombination scheme to the one provided 00303 void set_recombination_scheme(RecombinationScheme); 00304 00305 /// set the recombiner class to the one provided 00306 void set_recombiner(const Recombiner * recomb) { 00307 if (_recombiner_shared()) _recombiner_shared.reset(recomb); 00308 _recombiner = recomb; 00309 _default_recombiner = DefaultRecombiner(external_scheme); 00310 } 00311 00312 /// calling this tells the JetDefinition to handle the deletion of 00313 /// the recombiner when it is no longer used 00314 void delete_recombiner_when_unused(); 00315 00316 /// return a pointer to the plugin 00317 const Plugin * plugin() const {return _plugin;}; 00318 00319 /// allows to let the JetDefinition handle the deletion of the 00320 /// plugin when it is no longer used 00321 void delete_plugin_when_unused(); 00322 00323 /// return information about the definition... 00324 JetAlgorithm jet_algorithm () const {return _jet_algorithm ;} 00325 /// same as above for backward compatibility 00326 JetAlgorithm jet_finder () const {return _jet_algorithm ;} 00327 double R () const {return _Rparam ;} 00328 // a general purpose extra parameter, whose meaning depends on 00329 // the algorithm, and may often be unused. 00330 double extra_param () const {return _extra_param ;} 00331 Strategy strategy () const {return _strategy ;} 00332 RecombinationScheme recombination_scheme() const { 00333 return _default_recombiner.scheme();} 00334 00335 /// (re)set the jet finder 00336 void set_jet_algorithm(JetAlgorithm njf) {_jet_algorithm = njf;} 00337 /// same as above for backward compatibility 00338 void set_jet_finder(JetAlgorithm njf) {_jet_algorithm = njf;} 00339 /// (re)set the general purpose extra parameter 00340 void set_extra_param(double xtra_param) {_extra_param = xtra_param;} 00341 00342 /// return a pointer to the currently defined recombiner. 00343 /// 00344 /// Warning: the pointer may be to an internal recombiner (for 00345 /// default recombination schemes), in which case if the 00346 /// JetDefinition becomes invalid (e.g. is deleted), the pointer 00347 /// will then point to an object that no longer exists. 00348 /// 00349 /// Note also that if you copy a JetDefinition with a default 00350 /// recombination scheme, then the two copies will have distinct 00351 /// recombiners, and return different recombiner() pointers. 00352 const Recombiner * recombiner() const { 00353 return _recombiner == 0 ? & _default_recombiner : _recombiner;} 00354 00355 /// returns true if the current jet definitions shares the same 00356 /// recombiner as teh one passed as an argument 00357 bool has_same_recombiner(const JetDefinition &other_jd) const; 00358 00359 /// return a textual description of the current jet definition 00360 std::string description() const; 00361 00362 00363 public: 00364 //====================================================================== 00365 /// @ingroup advanced_usage 00366 /// \class Recombiner 00367 /// An abstract base class that will provide the recombination scheme 00368 /// facilities and/or allow a user to extend these facilities 00369 class Recombiner { 00370 public: 00371 /// return a textual description of the recombination scheme 00372 /// implemented here 00373 virtual std::string description() const = 0; 00374 00375 /// recombine pa and pb and put result into pab 00376 virtual void recombine(const PseudoJet & pa, const PseudoJet & pb, 00377 PseudoJet & pab) const = 0; 00378 00379 /// routine called to preprocess each input jet (to make all input 00380 /// jets compatible with the scheme requirements (e.g. massless). 00381 virtual void preprocess(PseudoJet & ) const {}; 00382 00383 /// a destructor to be replaced if necessary in derived classes... 00384 virtual ~Recombiner() {}; 00385 00386 /// pa += pb in the given recombination scheme. Not virtual -- the 00387 /// user should have no reason to want to redefine this! 00388 inline void plus_equal(PseudoJet & pa, const PseudoJet & pb) const { 00389 // put result in a temporary location in case the recombiner 00390 // does something funny (ours doesn't, but who knows about the 00391 // user's) 00392 PseudoJet pres; 00393 recombine(pa,pb,pres); 00394 pa = pres; 00395 } 00396 00397 }; 00398 00399 00400 //====================================================================== 00401 /// @ingroup advanced_usage 00402 /// \class DefaultRecombiner 00403 /// A class that will provide the recombination scheme facilities and/or 00404 /// allow a user to extend these facilities 00405 /// 00406 /// This class is derived from the (abstract) class Recombiner. It 00407 /// simply "sums" PseudoJets using a specified recombination scheme 00408 /// (E-scheme by default) 00409 class DefaultRecombiner : public Recombiner { 00410 public: 00411 DefaultRecombiner(RecombinationScheme recomb_scheme = E_scheme) : 00412 _recomb_scheme(recomb_scheme) {} 00413 00414 virtual std::string description() const; 00415 00416 /// recombine pa and pb and put result into pab 00417 virtual void recombine(const PseudoJet & pa, const PseudoJet & pb, 00418 PseudoJet & pab) const; 00419 00420 virtual void preprocess(PseudoJet & p) const; 00421 00422 /// return the index of the recombination scheme 00423 RecombinationScheme scheme() const {return _recomb_scheme;} 00424 00425 private: 00426 RecombinationScheme _recomb_scheme; 00427 }; 00428 00429 00430 //====================================================================== 00431 /// @ingroup advanced_usage 00432 /// \class Plugin 00433 /// a class that allows a user to introduce their own "plugin" jet 00434 /// finder 00435 /// 00436 /// Note that all the plugins provided with FastJet are derived from 00437 /// this class 00438 class Plugin{ 00439 public: 00440 /// return a textual description of the jet-definition implemented 00441 /// in this plugin 00442 virtual std::string description() const = 0; 00443 00444 /// given a ClusterSequence that has been filled up with initial 00445 /// particles, the following function should fill up the rest of the 00446 /// ClusterSequence, using the following member functions of 00447 /// ClusterSequence: 00448 /// - plugin_do_ij_recombination(...) 00449 /// - plugin_do_iB_recombination(...) 00450 virtual void run_clustering(ClusterSequence &) const = 0; 00451 00452 virtual double R() const = 0; 00453 00454 /// return true if there is specific support for the measurement 00455 /// of passive areas, in the sense that areas determined from all 00456 /// particles below the ghost separation scale will be a passive 00457 /// area. [If you don't understand this, ignore it!] 00458 virtual bool supports_ghosted_passive_areas() const {return false;} 00459 00460 /// set the ghost separation scale for passive area determinations 00461 /// in future runs (strictly speaking that makes the routine 00462 /// a non const, so related internal info must be stored as a mutable) 00463 virtual void set_ghost_separation_scale(double scale) const; 00464 virtual double ghost_separation_scale() const {return 0.0;} 00465 00466 /// if this returns false then a warning will be given 00467 /// whenever the user requests "exclusive" jets from the 00468 /// cluster sequence 00469 virtual bool exclusive_sequence_meaningful() const {return false;} 00470 00471 /// a destructor to be replaced if necessary in derived classes... 00472 virtual ~Plugin() {}; 00473 }; 00474 00475 private: 00476 00477 00478 JetAlgorithm _jet_algorithm; 00479 double _Rparam; 00480 double _extra_param ; ///< parameter whose meaning varies according to context 00481 Strategy _strategy ; 00482 00483 const Plugin * _plugin; 00484 SharedPtr<const Plugin> _plugin_shared; 00485 00486 // when we use our own recombiner it's useful to point to it here 00487 // so that we don't have to worry about deleting it etc... 00488 DefaultRecombiner _default_recombiner; 00489 const Recombiner * _recombiner; 00490 SharedPtr<const Recombiner> _recombiner_shared; 00491 00492 }; 00493 00494 00495 //------------------------------------------------------------------------------- 00496 // helper functions to build a jet made of pieces 00497 // 00498 // These functions include an options recombiner used to compute the 00499 // total composite jet momentum 00500 // ------------------------------------------------------------------------------- 00501 00502 /// build a "CompositeJet" from the vector of its pieces 00503 /// 00504 /// In this case, E-scheme recombination is assumed to compute the 00505 /// total momentum 00506 PseudoJet join(const std::vector<PseudoJet> & pieces, const JetDefinition::Recombiner & recombiner); 00507 00508 /// build a MergedJet from a single PseudoJet 00509 PseudoJet join(const PseudoJet & j1, 00510 const JetDefinition::Recombiner & recombiner); 00511 00512 /// build a MergedJet from 2 PseudoJet 00513 PseudoJet join(const PseudoJet & j1, const PseudoJet & j2, 00514 const JetDefinition::Recombiner & recombiner); 00515 00516 /// build a MergedJet from 3 PseudoJet 00517 PseudoJet join(const PseudoJet & j1, const PseudoJet & j2, const PseudoJet & j3, 00518 const JetDefinition::Recombiner & recombiner); 00519 00520 /// build a MergedJet from 4 PseudoJet 00521 PseudoJet join(const PseudoJet & j1, const PseudoJet & j2, const PseudoJet & j3, const PseudoJet & j4, 00522 const JetDefinition::Recombiner & recombiner); 00523 00524 00525 00526 00527 00528 FASTJET_END_NAMESPACE 00529 00530 #endif // __FASTJET_JETDEFINITION_HH__