Changes in external/fastjet/ClusterSequence.cc [273e668:d69dfe4] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
external/fastjet/ClusterSequence.cc
r273e668 rd69dfe4 1 // FJSTARTHEADER2 // $Id : ClusterSequence.cc 3685 2014-09-11 20:15:00Z salam$1 //STARTHEADER 2 // $Id$ 3 3 // 4 // Copyright (c) 2005-201 4, Matteo Cacciari, Gavin P. Salam and Gregory Soyez4 // Copyright (c) 2005-2013, Matteo Cacciari, Gavin P. Salam and Gregory Soyez 5 5 // 6 6 //---------------------------------------------------------------------- … … 13 13 // 14 14 // The algorithms that underlie FastJet have required considerable 15 // development. They are described in the original FastJet paper, 16 // hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use 15 // development and are described in hep-ph/0512210. If you use 17 16 // FastJet as part of work towards a scientific publication, please 18 // quote the version you use and include a citation to the manual and 19 // optionally also to hep-ph/0512210. 17 // include a citation to the FastJet paper. 20 18 // 21 19 // FastJet is distributed in the hope that it will be useful, … … 27 25 // along with FastJet. If not, see <http://www.gnu.org/licenses/>. 28 26 //---------------------------------------------------------------------- 29 // FJENDHEADER27 //ENDHEADER 30 28 31 29 #include "fastjet/Error.hh" … … 34 32 #include "fastjet/ClusterSequenceStructure.hh" 35 33 #include "fastjet/version.hh" // stores the current version number 36 #include "fastjet/internal/LazyTiling9Alt.hh"37 #include "fastjet/internal/LazyTiling9.hh"38 #include "fastjet/internal/LazyTiling25.hh"39 #ifndef __FJCORE__40 #include "fastjet/internal/LazyTiling9SeparateGhosts.hh"41 #endif // __FJCORE__42 34 #include<iostream> 43 35 #include<sstream> … … 195 187 //DEP //---------------------------------------------------------------------- 196 188 //DEP void ClusterSequence::_initialise_and_run ( 197 //DEP const double R,189 //DEP const double & R, 198 190 //DEP const Strategy & strategy, 199 191 //DEP const bool & writeout_combinations) { … … 281 273 // ./fastjet_timing_plugins -kt -nhardest 30 -repeat 50000 -strategy -3 -R 0.5 -nev 1 < ../../data/Pythia-PtMin1000-LHC-1000ev.dat 282 274 if (_strategy == Best) { 283 _strategy = _best_strategy();284 #ifdef DROP_CGAL285 // fall back strategy for large N when CGAL is missing286 if (_strategy == NlnN) _strategy = N2MHTLazy25;287 #endif // DROP_CGAL288 } else if (_strategy == BestFJ30) {289 275 int N = _jets.size(); 290 276 //if (N <= 55*max(0.5,min(1.0,_Rparam))) {// old empirical scaling with R … … 338 324 // run the code containing the selected strategy 339 325 // 340 // We order the strategies st arting from the ones used by the Best326 // We order the strategies stqrting from the ones used by the Best 341 327 // strategy in the order of increasing N, then the remaining ones 342 328 // again in the order of increasing N. … … 348 334 } else if (_strategy == N2MinHeapTiled) { 349 335 this->_minheap_faster_tiled_N2_cluster(); 350 } else if (_strategy == N2MHTLazy9Alt) {351 // attempt to use an external tiling routine -- it manipulates352 // the CS history via the plugin mechanism353 _plugin_activated = true;354 LazyTiling9Alt tiling(*this);355 tiling.run();356 _plugin_activated = false;357 358 } else if (_strategy == N2MHTLazy25) {359 // attempt to use an external tiling routine -- it manipulates360 // the CS history via the plugin mechanism361 _plugin_activated = true;362 LazyTiling25 tiling(*this);363 tiling.run();364 _plugin_activated = false;365 366 } else if (_strategy == N2MHTLazy9) {367 // attempt to use an external tiling routine -- it manipulates368 // the CS history via the plugin mechanism369 _plugin_activated = true;370 LazyTiling9 tiling(*this);371 tiling.run();372 _plugin_activated = false;373 374 #ifndef __FJCORE__375 } else if (_strategy == N2MHTLazy9AntiKtSeparateGhosts) {376 // attempt to use an external tiling routine -- it manipulates377 // the CS history via the plugin mechanism378 _plugin_activated = true;379 LazyTiling9SeparateGhosts tiling(*this);380 tiling.run();381 _plugin_activated = false;382 #else383 throw Error("N2MHTLazy9AntiKtSeparateGhosts strategy not supported with FJCORE");384 #endif // __FJCORE__385 386 336 } else if (_strategy == NlnN) { 387 337 this->_delaunay_cluster(); … … 409 359 // these needs to be defined outside the class definition. 410 360 bool ClusterSequence::_first_time = true; 411 LimitedWarning ClusterSequence::_exclusive_warnings;361 int ClusterSequence::_n_exclusive_warnings = 0; 412 362 413 363 … … 523 473 524 474 //---------------------------------------------------------------------- 475 // Return the component corresponding to the specified index. 476 // taken from CLHEP 525 477 string ClusterSequence::strategy_string (Strategy strategy_in) const { 526 478 string strategy; … … 540 492 case N2PoorTiled: 541 493 strategy = "N2PoorTiled"; break; 542 case N2MHTLazy9:543 strategy = "N2MHTLazy9"; break;544 case N2MHTLazy9Alt:545 strategy = "N2MHTLazy9Alt"; break;546 case N2MHTLazy25:547 strategy = "N2MHTLazy25"; break;548 case N2MHTLazy9AntiKtSeparateGhosts:549 strategy = "N2MHTLazy9AntiKtSeparateGhosts"; break;550 494 case N3Dumb: 551 495 strategy = "N3Dumb"; break; … … 584 528 } else {return 1.0;} 585 529 } else {throw Error("Unrecognised jet algorithm");} 586 }587 588 //----------------------------------------------------------------------589 // returns a suggestion for the best strategy to use on event590 // multiplicity, algorithm, R, etc.591 //592 // Some of the work to establish the best strategy is collected in593 // issue-tracker/2014-07-auto-strategy-selection;594 // transition_fit_v2.fit indicates the results of the fits that we're595 // using here. (Automatically generated by transition_fit_v2.gp).596 //597 // The transition to NlnN is always present, and it is the the598 // caller's responsibility to drop back down to N2MHTLazy25 if NlnN599 // isn't available.600 //601 // This routine should be called only if the jet alg is one of kt,602 // antikt, cam or genkt.603 Strategy ClusterSequence::_best_strategy() const {604 int N = _jets.size();605 // define bounded R, always above 0.1, because we don't trust any606 // of our parametrizations below R = 0.1607 double bounded_R = max(_Rparam, 0.1);608 609 // the very first test thing is a quick hard-coded test to decide610 // if we immediately opt for N2Plain611 if (N <= 30 || N <= 39.0/(bounded_R + 0.6)) {612 return N2Plain;613 }614 615 // Define objects that describe our various boundaries. A prefix N_616 // indicates that boundary is for N, while L_ means it's for log(N).617 //618 // Hopefully having them static will ensure minimal overhead619 // in creating them; collecting them in one place should620 // help with updates?621 //622 const static _Parabola N_Tiled_to_MHT_lowR (-45.4947,54.3528,44.6283);623 const static _Parabola L_MHT_to_MHTLazy9_lowR (0.677807,-1.05006,10.6994);624 const static _Parabola L_MHTLazy9_to_MHTLazy25_akt_lowR(0.169967,-0.512589,12.1572);625 const static _Parabola L_MHTLazy9_to_MHTLazy25_kt_lowR (0.16237,-0.484612,12.3373);626 const static _Parabola L_MHTLazy9_to_MHTLazy25_cam_lowR = L_MHTLazy9_to_MHTLazy25_kt_lowR;627 const static _Parabola L_MHTLazy25_to_NlnN_akt_lowR (0.0472051,-0.22043,15.9196);628 const static _Parabola L_MHTLazy25_to_NlnN_kt_lowR (0.118609,-0.326811,14.8287);629 const static _Parabola L_MHTLazy25_to_NlnN_cam_lowR (0.10119,-0.295748,14.3924);630 631 const static _Line L_Tiled_to_MHTLazy9_medR (-1.31304,7.29621);632 const static _Parabola L_MHTLazy9_to_MHTLazy25_akt_medR = L_MHTLazy9_to_MHTLazy25_akt_lowR;633 const static _Parabola L_MHTLazy9_to_MHTLazy25_kt_medR = L_MHTLazy9_to_MHTLazy25_kt_lowR;634 const static _Parabola L_MHTLazy9_to_MHTLazy25_cam_medR = L_MHTLazy9_to_MHTLazy25_cam_lowR;635 const static _Parabola L_MHTLazy25_to_NlnN_akt_medR = L_MHTLazy25_to_NlnN_akt_lowR;636 const static _Parabola L_MHTLazy25_to_NlnN_kt_medR = L_MHTLazy25_to_NlnN_kt_lowR;637 const static _Parabola L_MHTLazy25_to_NlnN_cam_medR = L_MHTLazy25_to_NlnN_cam_lowR;638 639 const static double N_Plain_to_MHTLazy9_largeR = 75;640 const static double N_MHTLazy9_to_MHTLazy25_akt_largeR = 700;641 const static double N_MHTLazy9_to_MHTLazy25_kt_largeR = 1000;642 const static double N_MHTLazy9_to_MHTLazy25_cam_largeR = 1000;643 const static double N_MHTLazy25_to_NlnN_akt_largeR = 100000;644 const static double N_MHTLazy25_to_NlnN_kt_largeR = 40000;645 const static double N_MHTLazy25_to_NlnN_cam_largeR = 15000;646 647 // We have timing studies only for kt, cam and antikt; for other648 // algorithms we set the local jet_algorithm variable to the one of649 // kt,cam,antikt that we think will be closest in behaviour to the650 // other alg.651 JetAlgorithm jet_algorithm;652 if (_jet_algorithm == genkt_algorithm) {653 // for genkt, then we set the local jet_algorithm variable (used654 // only for strategy choice) to be either kt or antikt, depending on655 // the p value.656 double p = jet_def().extra_param();657 if (p < 0.0) jet_algorithm = antikt_algorithm;658 else jet_algorithm = kt_algorithm;659 } else if (_jet_algorithm == cambridge_for_passive_algorithm) {660 // we assume (but haven't tested) that using the kt-alg timing661 // transitions should be adequate for cambridge_for_passive_algorithm662 jet_algorithm = kt_algorithm;663 } else {664 jet_algorithm = _jet_algorithm;665 }666 667 if (bounded_R < 0.65) {668 // low R case669 if (N < N_Tiled_to_MHT_lowR(bounded_R)) return N2Tiled;670 double logN = log(double(N));671 if (logN < L_MHT_to_MHTLazy9_lowR(bounded_R)) return N2MinHeapTiled;672 else {673 if (jet_algorithm == antikt_algorithm){674 if (logN < L_MHTLazy9_to_MHTLazy25_akt_lowR(bounded_R)) return N2MHTLazy9;675 else if (logN < L_MHTLazy25_to_NlnN_akt_lowR(bounded_R)) return N2MHTLazy25;676 else return NlnN;677 } else if (jet_algorithm == kt_algorithm){678 if (logN < L_MHTLazy9_to_MHTLazy25_kt_lowR(bounded_R)) return N2MHTLazy9;679 else if (logN < L_MHTLazy25_to_NlnN_kt_lowR(bounded_R)) return N2MHTLazy25;680 else return NlnN;681 } else if (jet_algorithm == cambridge_algorithm) {682 if (logN < L_MHTLazy9_to_MHTLazy25_cam_lowR(bounded_R)) return N2MHTLazy9;683 else if (logN < L_MHTLazy25_to_NlnN_cam_lowR(bounded_R)) return N2MHTLazy25;684 else return NlnNCam;685 }686 }687 } else if (bounded_R < 0.5*pi) {688 // medium R case689 double logN = log(double(N));690 if (logN < L_Tiled_to_MHTLazy9_medR(bounded_R)) return N2Tiled;691 else {692 if (jet_algorithm == antikt_algorithm){693 if (logN < L_MHTLazy9_to_MHTLazy25_akt_medR(bounded_R)) return N2MHTLazy9;694 else if (logN < L_MHTLazy25_to_NlnN_akt_medR(bounded_R)) return N2MHTLazy25;695 else return NlnN;696 } else if (jet_algorithm == kt_algorithm){697 if (logN < L_MHTLazy9_to_MHTLazy25_kt_medR(bounded_R)) return N2MHTLazy9;698 else if (logN < L_MHTLazy25_to_NlnN_kt_medR(bounded_R)) return N2MHTLazy25;699 else return NlnN;700 } else if (jet_algorithm == cambridge_algorithm) {701 if (logN < L_MHTLazy9_to_MHTLazy25_cam_medR(bounded_R)) return N2MHTLazy9;702 else if (logN < L_MHTLazy25_to_NlnN_cam_medR(bounded_R)) return N2MHTLazy25;703 else return NlnNCam;704 }705 }706 } else {707 // large R case (R > pi/2)708 if (N < N_Plain_to_MHTLazy9_largeR) return N2Plain;709 else {710 if (jet_algorithm == antikt_algorithm){711 if (N < N_MHTLazy9_to_MHTLazy25_akt_largeR) return N2MHTLazy9;712 else if (N < N_MHTLazy25_to_NlnN_akt_largeR) return N2MHTLazy25;713 else return NlnN;714 } else if (jet_algorithm == kt_algorithm){715 if (N < N_MHTLazy9_to_MHTLazy25_kt_largeR) return N2MHTLazy9;716 else if (N < N_MHTLazy25_to_NlnN_kt_largeR) return N2MHTLazy25;717 else return NlnN;718 } else if (jet_algorithm == cambridge_algorithm) {719 if (N < N_MHTLazy9_to_MHTLazy25_cam_largeR) return N2MHTLazy9;720 else if (N < N_MHTLazy25_to_NlnN_cam_largeR) return N2MHTLazy25;721 else return NlnNCam;722 }723 }724 }725 726 bool code_should_never_reach_here = false;727 assert(code_should_never_reach_here);728 return N2MHTLazy9;729 730 530 } 731 531 … … 862 662 //---------------------------------------------------------------------- 863 663 // return all inclusive jets with pt > ptmin 864 vector<PseudoJet> ClusterSequence::inclusive_jets (const double ptmin) const{664 vector<PseudoJet> ClusterSequence::inclusive_jets (const double & ptmin) const{ 865 665 double dcut = ptmin*ptmin; 866 666 int i = _history.size() - 1; // last jet … … 914 714 // return the number of exclusive jets that would have been obtained 915 715 // running the algorithm in exclusive mode with the given dcut 916 int ClusterSequence::n_exclusive_jets (const double dcut) const {716 int ClusterSequence::n_exclusive_jets (const double & dcut) const { 917 717 918 718 // first locate the point where clustering would have stopped (i.e. the … … 933 733 // return all exclusive jets that would have been obtained running 934 734 // the algorithm in exclusive mode with the given dcut 935 vector<PseudoJet> ClusterSequence::exclusive_jets (const double dcut) const {735 vector<PseudoJet> ClusterSequence::exclusive_jets (const double & dcut) const { 936 736 int njets = n_exclusive_jets(dcut); 937 737 return exclusive_jets(njets); … … 942 742 // return the jets obtained by clustering the event to n jets. 943 743 // Throw an error if there are fewer than n particles. 944 vector<PseudoJet> ClusterSequence::exclusive_jets (const int njets) const {744 vector<PseudoJet> ClusterSequence::exclusive_jets (const int & njets) const { 945 745 946 746 // make sure the user does not ask for more than jets than there … … 959 759 // return the jets obtained by clustering the event to n jets. 960 760 // If there are fewer than n particles, simply return all particles 961 vector<PseudoJet> ClusterSequence::exclusive_jets_up_to (const int njets) const {761 vector<PseudoJet> ClusterSequence::exclusive_jets_up_to (const int & njets) const { 962 762 963 763 // provide a warning when extracting exclusive jets for algorithms 964 764 // that does not support it explicitly. 965 // Native algorithm that support it are: kt, ee_kt, Cambridge/Aachen,765 // Native algorithm that support it are: kt, ee_kt, cambridge, 966 766 // genkt and ee_genkt (both with p>=0) 967 767 // For plugins, we check Plugin::exclusive_sequence_meaningful() … … 973 773 (_jet_def.extra_param() <0)) && 974 774 ((_jet_def.jet_algorithm() != plugin_algorithm) || 975 (!_jet_def.plugin()->exclusive_sequence_meaningful()))) { 976 _exclusive_warnings.warn("dcut and exclusive jets for jet-finders other than kt, C/A or genkt with p>=0 should be interpreted with care."); 775 (!_jet_def.plugin()->exclusive_sequence_meaningful())) && 776 (_n_exclusive_warnings < 5)) { 777 _n_exclusive_warnings++; 778 cerr << "FastJet WARNING: dcut and exclusive jets for jet-finders other than kt should be interpreted with care." << endl; 977 779 } 978 780 … … 1027 829 /// return the dmin corresponding to the recombination that went from 1028 830 /// n+1 to n jets 1029 double ClusterSequence::exclusive_dmerge (const int njets) const {831 double ClusterSequence::exclusive_dmerge (const int & njets) const { 1030 832 assert(njets >= 0); 1031 833 if (njets >= _initial_n) {return 0.0;} … … 1039 841 /// exclusive_dmerge, except in cases where the dmin do not increase 1040 842 /// monotonically. 1041 double ClusterSequence::exclusive_dmerge_max (const int njets) const {843 double ClusterSequence::exclusive_dmerge_max (const int & njets) const { 1042 844 assert(njets >= 0); 1043 845 if (njets >= _initial_n) {return 0.0;} … … 1051 853 /// the algorithm with the given dcut. 1052 854 std::vector<PseudoJet> ClusterSequence::exclusive_subjets 1053 (const PseudoJet & jet, const double dcut) const {855 (const PseudoJet & jet, const double & dcut) const { 1054 856 1055 857 set<const history_element*> subhist; … … 1074 876 /// exclusive_subjets.size() 1075 877 int ClusterSequence::n_exclusive_subjets(const PseudoJet & jet, 1076 const double dcut) const {878 const double & dcut) const { 1077 879 set<const history_element*> subhist; 1078 880 // get the set of history elements that correspond to subjets at … … 1379 1181 // //---------------------------------------------------------------------- 1380 1182 // // print out all inclusive jets with pt > ptmin 1381 // void ClusterSequence::print_jets (const double ptmin) const{1183 // void ClusterSequence::print_jets (const double & ptmin) const{ 1382 1184 // vector<PseudoJet> jets = sorted_by_pt(inclusive_jets(ptmin)); 1383 1185 // … … 1455 1257 // initialise the history in a standard way 1456 1258 void ClusterSequence::_add_step_to_history ( 1457 const int step_number, const intparent1,1458 const int parent2, const intjetp_index,1459 const double dij) {1259 const int & step_number, const int & parent1, 1260 const int & parent2, const int & jetp_index, 1261 const double & dij) { 1460 1262 1461 1263 history_element element; … … 1627 1429 /// of the recombined jet, newjet_k. 1628 1430 void ClusterSequence::_do_ij_recombination_step( 1629 const int jet_i, const intjet_j,1630 const double dij,1431 const int & jet_i, const int & jet_j, 1432 const double & dij, 1631 1433 int & newjet_k) { 1632 1434 … … 1664 1466 /// jet_i with the beam 1665 1467 void ClusterSequence::_do_iB_recombination_step( 1666 const int jet_i, const doublediB) {1468 const int & jet_i, const double & diB) { 1667 1469 // get history index 1668 1470 int newstep_k = _history.size();
Note:
See TracChangeset
for help on using the changeset viewer.