Fork me on GitHub

Ignore:
Timestamp:
Sep 3, 2014, 3:18:54 PM (10 years ago)
Author:
Pavel Demin <demin@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
be2222c
Parents:
5b5a56b
Message:

upgrade FastJet to version 3.1.0-beta.1, upgrade Nsubjettiness to version 2.1.0, add SoftKiller version 1.0.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • external/fastjet/tools/Pruner.cc

    r5b5a56b r35cdc46  
    1 //STARTHEADER
    2 // $Id$
    3 //
    4 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     1//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
    55//
    66//----------------------------------------------------------------------
     
    1313//
    1414//  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
    1617//  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.
    1820//
    1921//  FastJet is distributed in the hope that it will be useful,
     
    2527//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
    2628//----------------------------------------------------------------------
    27 //ENDHEADER
     29//FJENDHEADER
    2830
    2931#include "fastjet/tools/Pruner.hh"
     
    4749//----------------------------------------------------------------------
    4850// alternative (dynamic) ctor
    49 //  \param jet_def the jet definition for the internal clustering
     51//  \param jet_def     the jet definition for the internal clustering
    5052//  \param zcut_dyn    dynamic pt-fraction cut in the pruning
    5153//  \param Rcut_dyn    dynamic angular distance cut in the pruning
    5254Pruner::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)
    5557  : _jet_def(jet_def), _zcut(0), _Rcut_factor(0),
    5658    _zcut_dyn(zcut_dyn), _Rcut_dyn(Rcut_dyn), _get_recombiner_from_jet(false)  {
     
    7476  double zcut = (_zcut_dyn) ? (*_zcut_dyn)(jet) : _zcut;
    7577  PruningPlugin * pruning_plugin;
     78
    7679  // 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
    7981  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);
    9791  } else {
    9892    pruning_plugin = new PruningPlugin(_jet_def, zcut, Rcut);
     
    122116  PseudoJet result_local = SelectorNHardest(1)(cs->inclusive_jets())[0];
    123117  PrunerStructure * s = new PrunerStructure(result_local);
     118  s->_Rcut = Rcut;
     119  s->_zcut = zcut;
    124120  result_local.set_structure_shared_ptr(SharedPtr<PseudoJetStructureBase>(s));
    125121 
     
    155151}
    156152
    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.
     159bool 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  }
    170172
    171173  // if the jet has pieces, recurse in the pieces
    172174  if (jet.has_pieces()){
    173175    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;
    178179    // never returned false, so we're OK.
    179     return reco;
     180    return true;
    180181  }
    181182
    182183  // return false for any other (unknown) structure
    183   return 0;
     184  return false;
    184185}
    185186
Note: See TracChangeset for help on using the changeset viewer.