Changeset 35cdc46 in git for external/fastjet/tools/Pruner.cc
- Timestamp:
- Sep 3, 2014, 3:18:54 PM (10 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- be2222c
- Parents:
- 5b5a56b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
external/fastjet/tools/Pruner.cc
r5b5a56b r35cdc46 1 // STARTHEADER2 // $Id $3 // 4 // Copyright (c) 2005-201 1, Matteo Cacciari, Gavin P. Salam and Gregory Soyez1 //FJSTARTHEADER 2 // $Id: Pruner.cc 3481 2014-07-29 17:24:12Z soyez $ 3 // 4 // Copyright (c) 2005-2014, 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 and are described in hep-ph/0512210. If you use 15 // development. They are described in the original FastJet paper, 16 // hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use 16 17 // FastJet as part of work towards a scientific publication, please 17 // include a citation to the FastJet paper. 18 // quote the version you use and include a citation to the manual and 19 // optionally also to hep-ph/0512210. 18 20 // 19 21 // FastJet is distributed in the hope that it will be useful, … … 25 27 // along with FastJet. If not, see <http://www.gnu.org/licenses/>. 26 28 //---------------------------------------------------------------------- 27 // ENDHEADER29 //FJENDHEADER 28 30 29 31 #include "fastjet/tools/Pruner.hh" … … 47 49 //---------------------------------------------------------------------- 48 50 // alternative (dynamic) ctor 49 // \param jet_def the jet definition for the internal clustering51 // \param jet_def the jet definition for the internal clustering 50 52 // \param zcut_dyn dynamic pt-fraction cut in the pruning 51 53 // \param Rcut_dyn dynamic angular distance cut in the pruning 52 54 Pruner::Pruner(const JetDefinition &jet_def, 53 FunctionOfPseudoJet<double> *zcut_dyn,54 FunctionOfPseudoJet<double> *Rcut_dyn)55 const FunctionOfPseudoJet<double> *zcut_dyn, 56 const FunctionOfPseudoJet<double> *Rcut_dyn) 55 57 : _jet_def(jet_def), _zcut(0), _Rcut_factor(0), 56 58 _zcut_dyn(zcut_dyn), _Rcut_dyn(Rcut_dyn), _get_recombiner_from_jet(false) { … … 74 76 double zcut = (_zcut_dyn) ? (*_zcut_dyn)(jet) : _zcut; 75 77 PruningPlugin * pruning_plugin; 78 76 79 // for some constructors, we get the recombiner from the 77 // input jet -- some acrobatics are needed (see plans for FJ3.1 78 // for a hopefully better solution). 80 // input jet -- some acrobatics are needed 79 81 if (_get_recombiner_from_jet) { 80 const JetDefinition::Recombiner * common_recombiner = 81 _get_common_recombiner(jet); 82 if (common_recombiner) { 83 JetDefinition jet_def = _jet_def; 84 if (typeid(*common_recombiner) == typeid(JetDefinition::DefaultRecombiner)) { 85 RecombinationScheme scheme = 86 static_cast<const JetDefinition::DefaultRecombiner *>(common_recombiner)->scheme(); 87 jet_def.set_recombination_scheme(scheme); 88 } else { 89 jet_def.set_recombiner(common_recombiner); 90 } 91 pruning_plugin = new PruningPlugin(jet_def, zcut, Rcut); 92 } else { 93 // if there wasn't a common recombiner, we just use the default 94 // recombiner that was in _jet_def 95 pruning_plugin = new PruningPlugin(_jet_def, zcut, Rcut); 96 } 82 JetDefinition jet_def = _jet_def; 83 84 // if all the pieces have a shared recombiner, we'll use that 85 // one. Otherwise, use the one from _jet_def as a fallback. 86 JetDefinition jet_def_for_recombiner; 87 if (_check_common_recombiner(jet, jet_def_for_recombiner)){ 88 jet_def.set_recombiner(jet_def_for_recombiner); 89 } 90 pruning_plugin = new PruningPlugin(jet_def, zcut, Rcut); 97 91 } else { 98 92 pruning_plugin = new PruningPlugin(_jet_def, zcut, Rcut); … … 122 116 PseudoJet result_local = SelectorNHardest(1)(cs->inclusive_jets())[0]; 123 117 PrunerStructure * s = new PrunerStructure(result_local); 118 s->_Rcut = Rcut; 119 s->_zcut = zcut; 124 120 result_local.set_structure_shared_ptr(SharedPtr<PseudoJetStructureBase>(s)); 125 121 … … 155 151 } 156 152 157 // see if there is a common recombiner among the pieces; if there 158 // is return a pointer to it; otherwise, return NULL. 159 // 160 // NB: this way of doing things is not ideal, because quite some work 161 // is needed to get a correct handling of the final recombiner 162 // (e.g. default v. non-default). In future add 163 // set_recombiner(jet_def) to JetDefinition, maybe also add 164 // an invalid_scheme to the default recombiner and then 165 // do all the work below directly with a JetDefinition directly 166 // together with JD::has_same_recombiner(...) 167 const JetDefinition::Recombiner * Pruner::_get_common_recombiner(const PseudoJet &jet) const{ 168 if (jet.has_associated_cluster_sequence()) 169 return jet.validated_cs()->jet_def().recombiner(); 153 // see if there is a common recombiner among the pieces; if there is 154 // return true and set jet_def_for_recombiner so that the recombiner 155 // can be taken from that JetDefinition. Otherwise, return 156 // false. 'assigned' is initially false; when true, each time we meet 157 // a new jet definition, we'll check it shares the same recombiner as 158 // jet_def_for_recombiner. 159 bool Pruner::_check_common_recombiner(const PseudoJet &jet, 160 JetDefinition &jet_def_for_recombiner, 161 bool assigned) const{ 162 if (jet.has_associated_cluster_sequence()){ 163 // if the jet def for recombination has already been assigned, check if we have the same 164 if (assigned) 165 return jet.validated_cs()->jet_def().has_same_recombiner(jet_def_for_recombiner); 166 167 // otherwise, assign it. 168 jet_def_for_recombiner = jet.validated_cs()->jet_def(); 169 assigned = true; 170 return true; 171 } 170 172 171 173 // if the jet has pieces, recurse in the pieces 172 174 if (jet.has_pieces()){ 173 175 vector<PseudoJet> pieces = jet.pieces(); 174 if (pieces.size() == 0) return 0; 175 const JetDefinition::Recombiner * reco = _get_common_recombiner(pieces[0]); 176 for (unsigned int i=1;i<pieces.size(); i++) 177 if (_get_common_recombiner(pieces[i]) != reco) return 0; 176 if (pieces.size() == 0) return false; 177 for (unsigned int i=0;i<pieces.size(); i++) 178 if (!_check_common_recombiner(pieces[i], jet_def_for_recombiner, assigned)) return false; 178 179 // never returned false, so we're OK. 179 return reco;180 return true; 180 181 } 181 182 182 183 // return false for any other (unknown) structure 183 return 0;184 return false; 184 185 } 185 186
Note:
See TracChangeset
for help on using the changeset viewer.