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/JetDefinition.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: JetDefinition.cc 3492 2014-07-30 16:58:20Z 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/JetDefinition.hh"
     
    6870  // cross-check the number of parameters that were declared in setting up the
    6971  // algorithm (passed internally from the public constructors)
    70   switch (jet_algorithm_in) {
    71   case ee_kt_algorithm:
    72     if (nparameters != 0) {
    73       ostringstream oss;
    74       oss << "ee_kt_algorithm should be constructed with 0 parameters but was called with "
    75           << nparameters << " parameter(s)\n";
    76       throw Error(oss.str());
    77     }
    78     break;
    79   case genkt_algorithm:
    80   case ee_genkt_algorithm:
    81     if (nparameters != 2) {
    82       ostringstream oss;
    83       oss << "(ee_)genkt_algorithm should be constructed with 2 parameters but was called with "
    84           << nparameters << " parameter(s)\n";
    85       throw Error(oss.str());
    86     }
    87     break;
    88   default:
    89     if (nparameters != 1) {
    90       ostringstream oss;
    91       oss << "The jet algorithm you requested ("
    92           << jet_algorithm_in << ") should be constructed with 1 parameter but was called with "
    93           << nparameters << " parameter(s)\n";
    94       throw Error(oss.str());
    95     }
     72  unsigned int nparameters_expected = n_parameters_for_algorithm(jet_algorithm_in);
     73  if (nparameters != (int) nparameters_expected){
     74    ostringstream oss;
     75    oss << "The jet algorithm you requested ("
     76        << jet_algorithm_in << ") should be constructed with " << nparameters_expected
     77        << " parameter(s) but was called with " << nparameters << " parameter(s)\n";
     78    throw Error(oss.str());
    9679  }
    9780
     
    10689
    10790//----------------------------------------------------------------------
     91// returns true if the jet definition involves an algorithm
     92// intended for use on a spherical geometry (e.g. e+e- algorithms,
     93// as opposed to most pp algorithms, which use a cylindrical,
     94// rapidity-phi geometry).
     95bool JetDefinition::is_spherical() const {
     96  if (jet_algorithm() == plugin_algorithm) {
     97    return plugin()->is_spherical();
     98  } else {
     99    return (jet_algorithm() == ee_kt_algorithm ||  // as of 2013-02-14, the two
     100            jet_algorithm() == ee_genkt_algorithm  // native spherical algorithms
     101            );
     102  }
     103}
     104
     105//----------------------------------------------------------------------
    108106string JetDefinition::description() const {
     107  ostringstream name;
     108 
     109  name << description_no_recombiner();
     110
     111  if ((jet_algorithm() == plugin_algorithm) || (jet_algorithm() == undefined_jet_algorithm)){
     112    return name.str();
     113  }
     114
     115  if (n_parameters_for_algorithm(jet_algorithm()) == 0)
     116    name << " with ";
     117  else
     118    name << " and ";
     119  name << recombiner()->description();
     120
     121  return name.str();
     122}
     123
     124//----------------------------------------------------------------------
     125string JetDefinition::description_no_recombiner() const {
     126 
    109127  ostringstream name;
    110128  if (jet_algorithm() == plugin_algorithm) {
    111129    return plugin()->description();
    112   } else if (jet_algorithm() == kt_algorithm) {
    113     name << "Longitudinally invariant kt algorithm with R = " << R();
    114     name << " and " << recombiner()->description();
    115   } else if (jet_algorithm() == cambridge_algorithm) {
    116     name << "Longitudinally invariant Cambridge/Aachen algorithm with R = "
    117          << R() ;
    118     name << " and " << recombiner()->description();
    119   } else if (jet_algorithm() == antikt_algorithm) {
    120     name << "Longitudinally invariant anti-kt algorithm with R = "
    121          << R() ;
    122     name << " and " << recombiner()->description();
    123   } else if (jet_algorithm() == genkt_algorithm) {
    124     name << "Longitudinally invariant generalised kt algorithm with R = "
    125          << R() << ", p = " << extra_param();
    126     name << " and " << recombiner()->description();
    127   } else if (jet_algorithm() == cambridge_for_passive_algorithm) {
    128     name << "Longitudinally invariant Cambridge/Aachen algorithm with R = "
    129          << R() << "and a special hack whereby particles with kt < "
    130          << extra_param() << "are treated as passive ghosts";
    131   } else if (jet_algorithm() == ee_kt_algorithm) {
    132     name << "e+e- kt (Durham) algorithm (NB: no R)";
    133     name << " with " << recombiner()->description();
    134   } else if (jet_algorithm() == ee_genkt_algorithm) {
    135     name << "e+e- generalised kt algorithm with R = "
    136          << R() << ", p = " << extra_param();
    137     name << " and " << recombiner()->description();
    138130  } else if (jet_algorithm() == undefined_jet_algorithm) {
    139     name << "uninitialised JetDefinition (jet_algorithm=undefined_jet_algorithm)" ;
    140   } else {
    141     throw Error("JetDefinition::description(): unrecognized jet_algorithm");
    142   }
     131    return "uninitialised JetDefinition (jet_algorithm=undefined_jet_algorithm)" ;
     132  }
     133
     134  name << algorithm_description(jet_algorithm());
     135  switch (n_parameters_for_algorithm(jet_algorithm())){
     136  case 0: name << " (NB: no R)"; break;
     137  case 1: name << " with R = " << R(); break; // the parameter is always R
     138  case 2:
     139    // the 1st parameter is always R
     140    name << " with R = " << R();
     141    // the 2nd depends on the algorithm
     142    if (jet_algorithm() == cambridge_for_passive_algorithm){
     143      name << "and a special hack whereby particles with kt < "
     144           << extra_param() << "are treated as passive ghosts";
     145    } else {
     146      name << ", p = " << extra_param();
     147    }
     148  };
     149
    143150  return name.str();
    144151}
    145152
    146 
     153//----------------------------------------------------------------------
     154string JetDefinition::algorithm_description(const JetAlgorithm jet_alg){
     155  ostringstream name;
     156  switch (jet_alg){
     157  case plugin_algorithm:                return "plugin algorithm";
     158  case kt_algorithm:                    return "Longitudinally invariant kt algorithm";
     159  case cambridge_algorithm:             return "Longitudinally invariant Cambridge/Aachen algorithm";
     160  case antikt_algorithm:                return "Longitudinally invariant anti-kt algorithm";
     161  case genkt_algorithm:                 return "Longitudinally invariant generalised kt algorithm";
     162  case cambridge_for_passive_algorithm: return "Longitudinally invariant Cambridge/Aachen algorithm";
     163  case ee_kt_algorithm:                 return "e+e- kt (Durham) algorithm (NB: no R)";
     164  case ee_genkt_algorithm:              return "e+e- generalised kt algorithm";
     165  case undefined_jet_algorithm:         return "undefined jet algorithm";
     166  default:
     167    throw Error("JetDefinition::algorithm_description(): unrecognized jet_algorithm");
     168  };
     169}
     170
     171//----------------------------------------------------------------------
     172unsigned int JetDefinition::n_parameters_for_algorithm(const JetAlgorithm jet_alg){
     173  switch (jet_alg) {
     174  case ee_kt_algorithm:    return 0;
     175  case genkt_algorithm:
     176  case ee_genkt_algorithm: return 2;
     177  default:                 return 1;
     178  };
     179}
     180
     181//----------------------------------------------------------------------
    147182void JetDefinition::set_recombination_scheme(
    148183                               RecombinationScheme recomb_scheme) {
     
    150185
    151186  // do not forget to delete the existing recombiner if needed
    152   if (_recombiner_shared()) _recombiner_shared.reset();
     187  if (_shared_recombiner()) _shared_recombiner.reset();
    153188
    154189  _recombiner = 0;
     190}
     191
     192void JetDefinition::set_recombiner(const JetDefinition &other_jet_def){
     193  // make sure the "invariants" of the other jet def are sensible
     194  assert(other_jet_def._recombiner ||
     195         other_jet_def.recombination_scheme() != external_scheme);
     196
     197  // first treat the situation where we're using the default recombiner
     198  if (other_jet_def._recombiner == 0){
     199    set_recombination_scheme(other_jet_def.recombination_scheme());
     200    return;
     201  }
     202
     203  // in other cases, copy the pointer to the recombiner
     204  _recombiner = other_jet_def._recombiner;
     205  // set the default recombiner appropriately
     206  _default_recombiner = DefaultRecombiner(external_scheme);
     207  // and set the _shared_recombiner to the same state
     208  // as in the other_jet_def, whatever that was
     209  _shared_recombiner.reset(other_jet_def._shared_recombiner);
     210
     211  // NB: it is tempting to go via set_recombiner and then to sort
     212  // out the shared part, but this would be dangerous in the
     213  // specific (rare?) case where other_jet_def is the same as this
     214  // it deletes_recombiner_when_unused. In that case the shared
     215  // pointer reset would delete the recombiner.
    155216}
    156217
     
    163224  if (other_jd.recombination_scheme() != scheme) return false;
    164225
    165   // if the scheme is "external", also check that they ahve the same
     226  // if the scheme is "external", also check that they have the same
    166227  // recombiner
    167228  return (scheme != external_scheme)
     
    169230}
    170231
    171 /// allows to let the JetDefinition handle the deletion of the
     232/// causes the JetDefinition to handle the deletion of the
    172233/// recombiner when it is no longer used
    173234void JetDefinition::delete_recombiner_when_unused(){
    174235  if (_recombiner == 0){
    175236    throw Error("tried to call JetDefinition::delete_recombiner_when_unused() for a JetDefinition without a user-defined recombination scheme");
    176   }
    177 
    178   _recombiner_shared.reset(_recombiner);
     237  } else if (_shared_recombiner.get()) {
     238    throw Error("Error in JetDefinition::delete_recombiner_when_unused: the recombiner is already scheduled for deletion when unused (or was already set as shared)");
     239  }
     240
     241  _shared_recombiner.reset(_recombiner);
    179242}
    180243
Note: See TracChangeset for help on using the changeset viewer.