Fork me on GitHub

Changeset 35cdc46 in git for external/fastjet/tools


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

Location:
external/fastjet/tools
Files:
2 added
24 edited

Legend:

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

    r5b5a56b r35cdc46  
    1 //STARTHEADER
    2 // $Id$
     1//FJSTARTHEADER
     2// $Id: BackgroundEstimatorBase.cc 3433 2014-07-23 08:17:03Z salam $
    33//
    4 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     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
  • external/fastjet/tools/BackgroundEstimatorBase.hh

    r5b5a56b r35cdc46  
    22#define __FASTJET_BACKGROUND_ESTIMATOR_BASE_HH__
    33
    4 //STARTHEADER
    5 // $Id: BackgroundEstimatorBase.hh 2689 2011-11-14 14:51:06Z soyez $
    6 //
    7 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     4//FJSTARTHEADER
     5// $Id: BackgroundEstimatorBase.hh 3516 2014-08-01 14:07:58Z salam $
     6//
     7// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
    88//
    99//----------------------------------------------------------------------
     
    1616//
    1717//  The algorithms that underlie FastJet have required considerable
    18 //  development and are described in hep-ph/0512210. If you use
     18//  development. They are described in the original FastJet paper,
     19//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
    1920//  FastJet as part of work towards a scientific publication, please
    20 //  include a citation to the FastJet paper.
     21//  quote the version you use and include a citation to the manual and
     22//  optionally also to hep-ph/0512210.
    2123//
    2224//  FastJet is distributed in the hope that it will be useful,
     
    2830//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
    2931//----------------------------------------------------------------------
    30 //ENDHEADER
     32//FJENDHEADER
    3133
    3234#include <fastjet/ClusterSequenceAreaBase.hh>
     
    4345///
    4446/// Abstract base class that provides the basic interface for classes
    45 /// that estimate levels of background radiation in hadrion and
     47/// that estimate levels of background radiation in hadron and
    4648/// heavy-ion collider events.
    47 ///
    4849///
    4950class BackgroundEstimatorBase {
     
    99100  /// determination of sigma
    100101  virtual bool has_sigma() {return false;}
    101   //\}
    102  
     102
     103  //----------------------------------------------------------------
     104  // now do the same thing for rho_m and sigma_m
     105
     106  /// returns rho_m, the purely longitudinal, particle-mass-induced
     107  /// component of the background density per unit area
     108  virtual double rho_m() const{
     109    throw Error("rho_m() not supported for this Background Estimator");
     110  }
     111
     112  /// returns sigma_m, a measure of the fluctuations in the purely
     113  /// longitudinal, particle-mass-induced component of the background
     114  /// density per unit area; must be multipled by sqrt(area) to get
     115  /// fluctuations for a region of a given area.
     116  virtual double sigma_m() const {
     117    throw Error("sigma_m() not supported for this Background Estimator");
     118  }
     119
     120  /// Returns rho_m locally at the jet position. As for rho(jet), it is non-const.
     121  virtual double rho_m(const PseudoJet & /*jet*/){
     122    throw Error("rho_m(jet) not supported for this Background Estimator");
     123  }
     124
     125  /// Returns sigma_m locally at the jet position. As for rho(jet), it is non-const.
     126  virtual double sigma_m(const PseudoJet & /*jet*/) {
     127    throw Error("sigma_m(jet) not supported for this Background Estimator");
     128  }
     129
     130  /// Returns true if this background estimator has support for
     131  /// determination of rho_m.
     132  ///
     133  /// Note that support for sigma_m is automatic is one has sigma and
     134  /// rho_m support.
     135  virtual bool has_rho_m() const {return false;}
     136  //\}
     137
    103138
    104139  /// @name configuring the behaviour
     
    114149  /// The BackgroundRescalingYPolynomial class can be used to get a
    115150  /// rescaling that depends just on rapidity.
     151  ///
     152  /// There is currently no support for different rescaling classes
     153  /// for rho and rho_m determinations.
    116154  virtual void set_rescaling_class(const FunctionOfPseudoJet<double> * rescaling_class_in) { _rescaling_class = rescaling_class_in; }
    117155
  • external/fastjet/tools/Boost.hh

    r5b5a56b r35cdc46  
    1 //STARTHEADER
    2 // $Id: Boost.hh 2689 2011-11-14 14:51:06Z soyez $
     1//FJSTARTHEADER
     2// $Id: Boost.hh 3433 2014-07-23 08:17:03Z salam $
    33//
    4 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     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#ifndef __FASTJET_TOOL_BOOST_HH__
  • external/fastjet/tools/CASubJetTagger.cc

    r5b5a56b r35cdc46  
    1 //STARTHEADER
    2 // $Id$
     1//FJSTARTHEADER
     2// $Id: CASubJetTagger.cc 3433 2014-07-23 08:17:03Z salam $
    33//
    4 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     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/CASubJetTagger.hh>
  • external/fastjet/tools/CASubJetTagger.hh

    r5b5a56b r35cdc46  
    1 //STARTHEADER
    2 // $Id: CASubJetTagger.hh 2616 2011-09-30 18:03:40Z salam $
    3 //
    4 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     1//FJSTARTHEADER
     2// $Id: CASubJetTagger.hh 3433 2014-07-23 08:17:03Z salam $
     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#ifndef __CASUBJET_TAGGER_HH__
  • external/fastjet/tools/Filter.cc

    r5b5a56b r35cdc46  
    1 //STARTHEADER
    2 // $Id$
     1//FJSTARTHEADER
     2// $Id: Filter.cc 3633 2014-08-15 13:23:52Z soyez $
    33//
    4 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     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/Filter.hh"
     32#include "fastjet/tools/Recluster.hh"
    3033#include <fastjet/ClusterSequenceActiveAreaExplicitGhosts.hh>
    3134#include <cassert>
     
    4548// class description
    4649string Filter::description() const {
     50  if (!_initialised){
     51    return "uninitialised Filter";
     52  }
     53
    4754  ostringstream ostr;
    4855  ostr << "Filter with subjet_def = ";
     
    7380// by the filtering
    7481PseudoJet Filter::result(const PseudoJet &jet) const {
     82  if (!_initialised){
     83    //Q: do we throw or do we return an empty PJ?
     84    throw Error("uninitialised Filter");
     85  }
     86
    7587  // start by getting the list of subjets (including a list of sanity
    7688  // checks)
     
    7890  //     _set_filtered_elements_cafilt)
    7991  vector<PseudoJet> subjets;
    80   JetDefinition subjet_def;
    81   bool discard_area;
    82   // NB: on return, subjet_def is set to the jet definition actually
    83   //     used (so that we can make use of its recombination scheme
    84   //     when joining the jets to be kept).
    85   _set_filtered_elements(jet, subjets, subjet_def, discard_area);
     92  //JetDefinition subjet_def;
     93  bool ca_optimised = _set_filtered_elements(jet, subjets);
     94
     95  // apply subtraction if needed:
     96  if (_subtractor){
     97    subjets = (*_subtractor)(subjets);
     98  } else if (_rho!=0){
     99    if (subjets.size()>0){
     100      const ClusterSequenceAreaBase *csab = subjets[0].validated_csab();
     101      for (unsigned int i=0;i<subjets.size();i++){
     102        subjets[i]=csab->subtracted_jet(subjets[i], _rho);
     103      }
     104    }
     105  }
    86106
    87107  // now build the vector of kept and rejected subjets
     
    94114
    95115  // gather the info under the form of a PseudoJet
    96   return _finalise(jet, kept, rejected, subjet_def, discard_area);
     116  return _finalise(jet, kept, rejected, ca_optimised);
    97117}
    98118
    99119
    100120// sets filtered_elements to be all the subjets on which filtering will work
    101 void Filter::_set_filtered_elements(const PseudoJet & jet,
    102                                     vector<PseudoJet> & filtered_elements,
    103                                     JetDefinition & subjet_def,
    104                                     bool & discard_area) const {
    105   // sanity checks
    106   //-------------------------------------------------------------------
    107   // make sure that the jet has constituents
    108   if (! jet.has_constituents())
    109     throw Error("Filter can only be applied on jets having constituents");
     121//
     122// return true when the subjets have been optained using teh optimised
     123// method for C/A
     124bool Filter::_set_filtered_elements(const PseudoJet & jet,
     125                                    vector<PseudoJet> & filtered_elements) const {
     126  // create the recluster instance
     127  Recluster recluster;
     128  if ((_Rfilt>=0) || (_Rfiltfunc))
     129    recluster = Recluster(cambridge_algorithm, (_Rfiltfunc) ? (*_Rfiltfunc)(jet) : _Rfilt, Recluster::keep_all);
     130  else
     131    recluster = Recluster(_subjet_def, false, Recluster::keep_all);
    110132
    111   // for a whole variety of checks, we shall need the "recursive"
    112   // pieces of the jet (the jet itself or recursing down to its most
    113   // fundamental pieces).
    114   // So we do compute these once and for all
    115   vector<PseudoJet> all_pieces; //.clear();
    116   if ((!_get_all_pieces(jet, all_pieces)) || (all_pieces.size()==0))
    117     throw Error("Attempt to filter a jet that has no associated ClusterSequence or is not a superposition of jets associated with a ClusterSequence");
    118  
    119   // if the filter uses subtraction, make sure we have a CS that supports area and has
    120   // explicit ghosts
    121   if (_uses_subtraction()) {
    122     if (!jet.has_area())   
    123       throw Error("Attempt to filter and subtract (non-zero rho or subtractor) without area info for the original jet");
    124 
    125     if (!_check_explicit_ghosts(all_pieces))
    126       throw Error("Attempt to filter and subtract (non-zero rho or subtractor) without explicit ghosts");
    127   }
    128 
    129   // if we're dealing with a dynamic determination of the filtering
    130   // radius, do it now
    131   if ((_Rfilt>=0) || (_Rfiltfunc)){
    132     double Rfilt = (_Rfiltfunc) ? (*_Rfiltfunc)(jet) : _Rfilt;
    133     const JetDefinition::Recombiner * common_recombiner = _get_common_recombiner(all_pieces);
    134     if (common_recombiner) {
    135       if (typeid(*common_recombiner) == typeid(JetDefinition::DefaultRecombiner)) {
    136         RecombinationScheme scheme =
    137           static_cast<const JetDefinition::DefaultRecombiner *>(common_recombiner)->scheme();
    138         subjet_def = JetDefinition(cambridge_algorithm, Rfilt, scheme);
    139       } else {
    140         subjet_def = JetDefinition(cambridge_algorithm, Rfilt, common_recombiner);
    141       }
    142     } else {
    143       subjet_def = JetDefinition(cambridge_algorithm, Rfilt);
    144     }
    145   } else {
    146     subjet_def = _subjet_def;
    147   }
    148 
    149   // get the jet definition to be use and whether we can apply our
    150   // simplified C/A+C/A filter
    151   //
    152   // we apply C/A clustering iff
    153   //  - the request subjet_def is C/A
    154   //  - the jet is either directly coming from C/A or if it is a
    155   //    superposition of C/A jets
    156   //  - the pieces agree with the recombination scheme of subjet_def
    157   //------------------------------------------------------------------
    158   bool simple_cafilt = _check_ca(all_pieces);
    159 
    160   // extract the subjets
    161   //-------------------------------------------------------------------
    162   discard_area = false;
    163   if (simple_cafilt){
    164     // first make sure that 'filtered_elements' is empty
    165     filtered_elements.clear();
    166     _set_filtered_elements_cafilt(jet, filtered_elements, subjet_def.R());
    167     // in the following case, areas can be erroneous and will be discarded
    168     discard_area = (!_uses_subtraction()) && (jet.has_area()) && (!_check_explicit_ghosts(all_pieces));
    169   } else {
    170     // here we'll simply recluster the jets.
    171     //
    172     // To include an area support we need
    173     //  - the jet to have an area
    174     //  - subtraction requested or explicit ghosts
    175     bool do_areas = (jet.has_area()) && ((_uses_subtraction()) || (_check_explicit_ghosts(all_pieces)));
    176     _set_filtered_elements_generic(jet, filtered_elements, subjet_def, do_areas);
    177   }
    178 
    179   // order the filtered elements in pt
    180   filtered_elements = sorted_by_pt(filtered_elements);
     133  // get the subjets
     134  //JetDefinition subjet_def;
     135  return recluster.get_new_jets_and_def(jet, filtered_elements);
    181136}
    182 
    183 // set the filtered elements in the simple case of C/A+C/A
    184 //
    185 // WATCH OUT: this could be recursively called, so filtered elements
    186 //            of 'jet' are APPENDED to 'filtered_elements'
    187 void Filter::_set_filtered_elements_cafilt(const PseudoJet & jet,
    188                                            vector<PseudoJet> & filtered_elements,
    189                                            double Rfilt) const{
    190   // we know that the jet is either a C/A jet or a superposition of
    191   // such pieces
    192   if (jet.has_associated_cluster_sequence()){
    193     // just extract the exclusive subjets of 'jet'
    194     const ClusterSequence *cs = jet.associated_cluster_sequence();
    195     vector<PseudoJet> local_fe;
    196 
    197     double dcut = Rfilt / cs->jet_def().R();
    198     if (dcut>=1.0){
    199       local_fe.push_back(jet);
    200     } else {
    201       dcut *= dcut;
    202       local_fe = jet.exclusive_subjets(dcut);
    203     }
    204 
    205     // subtract the jets if needed
    206     // Note that this one would work on pieces!!
    207     //-----------------------------------------------------------------
    208     if (_uses_subtraction()){
    209       const ClusterSequenceAreaBase * csab = jet.validated_csab();
    210       for (unsigned int i=0;i<local_fe.size();i++) {
    211         if (_subtractor) {
    212           local_fe[i] = (*_subtractor)(local_fe[i]);
    213         } else {
    214           local_fe[i] = csab->subtracted_jet(local_fe[i], _rho);
    215         }
    216       }
    217     }
    218 
    219     copy(local_fe.begin(), local_fe.end(), back_inserter(filtered_elements));
    220     return;
    221   }
    222 
    223   // just recurse into the pieces
    224   const vector<PseudoJet> & pieces = jet.pieces();
    225   for (vector<PseudoJet>::const_iterator it = pieces.begin();
    226        it!=pieces.end(); it++)
    227     _set_filtered_elements_cafilt(*it, filtered_elements, Rfilt);
    228 }
    229 
    230 
    231 // set the filtered elements in the generic re-clustering case (wo
    232 // subtraction)
    233 void Filter::_set_filtered_elements_generic(const PseudoJet & jet,
    234                                             vector<PseudoJet> & filtered_elements,
    235                                             const JetDefinition & subjet_def,
    236                                             bool do_areas) const{
    237   // create a new, internal, ClusterSequence from the jet constituents
    238   // get the subjets directly from there
    239   //
    240   // If the jet has area support then we separate the ghosts from the
    241   // "regular" particles so the subjets will also have area
    242   // support. Note that we do this regardless of whether rho is zero
    243   // or not.
    244   //
    245   // Note that to be able to separate the ghosts, one needs explicit
    246   // ghosts!!
    247   // ---------------------------------------------------------------
    248   if (do_areas){
    249     vector<PseudoJet> all_constituents = jet.constituents();
    250     vector<PseudoJet> regular_constituents, ghosts; 
    251 
    252     for (vector<PseudoJet>::iterator it = all_constituents.begin();
    253          it != all_constituents.end(); it++){
    254       if (it->is_pure_ghost())
    255         ghosts.push_back(*it);
    256       else
    257         regular_constituents.push_back(*it);
    258     }
    259 
    260     // figure out the ghost area from the 1st ghost (if none, any value
    261     // would probably do as the area will be 0 and subtraction will have
    262     // no effect!)
    263     double ghost_area = (ghosts.size()) ? ghosts[0].area() : 0.01;
    264     ClusterSequenceActiveAreaExplicitGhosts * csa
    265       = new ClusterSequenceActiveAreaExplicitGhosts(regular_constituents,
    266                                                     subjet_def,
    267                                                     ghosts, ghost_area);
    268 
    269     // get the subjets: we use the subtracted or unsubtracted ones
    270     // depending on rho or _subtractor being non-zero
    271     if (_uses_subtraction()) {
    272       if (_subtractor) {
    273         filtered_elements = (*_subtractor)(csa->inclusive_jets());
    274       } else {
    275         filtered_elements = csa->subtracted_jets(_rho);
    276       }
    277     } else {
    278       filtered_elements = csa->inclusive_jets();
    279     }
    280 
    281     // allow the cs to be deleted when it's no longer used
    282     csa->delete_self_when_unused();
    283   } else {
    284     ClusterSequence * cs = new ClusterSequence(jet.constituents(), subjet_def);
    285     filtered_elements = cs->inclusive_jets();
    286     // allow the cs to be deleted when it's no longer used
    287     cs->delete_self_when_unused();
    288   }
    289 }
    290 
    291137
    292138// gather the information about what is kept and rejected under the
     
    295141                            vector<PseudoJet> & kept,
    296142                            vector<PseudoJet> & rejected,
    297                             const JetDefinition & subjet_def,
    298                             const bool discard_area) const {
    299   // figure out which recombiner to use
    300   const JetDefinition::Recombiner &rec = *(subjet_def.recombiner());
     143                            bool ca_optimisation_used) const {
     144  PseudoJet filtered_jet;
    301145
    302   // create an appropriate structure and transfer the info to it
    303   PseudoJet filtered_jet = join<StructureType>(kept, rec);
     146  if (kept.size()+rejected.size()>0){
     147    // figure out which recombiner to use
     148    const JetDefinition::Recombiner &rec = (kept.size()>0)
     149      ? *(kept[0].associated_cs()->jet_def().recombiner())
     150      : *(rejected[0].associated_cs()->jet_def().recombiner());
     151
     152    // create an appropriate structure and transfer the info to it
     153    filtered_jet = join<StructureType>(kept, rec);
     154  } else {
     155    filtered_jet = join<StructureType>(kept);
     156  }
    304157  StructureType *fs = (StructureType*) filtered_jet.structure_non_const_ptr();
    305 //  fs->_original_jet = jet;
    306158  fs->_rejected = rejected;
     159 
     160  // if we've used C/A optimisation, we need to get rid of the area
     161  // information if it comes from a non-explicit-ghost clustering.
     162  // (because in that case it can be erroneous due the lack of
     163  // information about empty areas)
     164  if ((ca_optimisation_used) && (kept.size()+rejected.size()>0)){
     165    bool has_non_explicit_ghost_area = (kept.size()>0)
     166      ? (kept[0].has_area()     && kept[0].validated_csab()->has_explicit_ghosts())
     167      : (rejected[0].has_area() && rejected[0].validated_csab()->has_explicit_ghosts());
     168    if (has_non_explicit_ghost_area)
     169      fs->discard_area();
     170  }
    307171
    308   if (discard_area){
    309     // safety check: make sure there is an area to discard!!!
    310     assert(fs->_area_4vector_ptr);
    311     delete fs->_area_4vector_ptr;
    312     fs->_area_4vector_ptr=0;
    313   }
    314  
    315172  return filtered_jet;
    316173}
    317174
    318 // various checks
    319 //----------------------------------------------------------------------
    320 
    321 // get the pieces down to the fundamental pieces
    322 //
    323 // Note that this just checks that there is an associated CS to the
    324 // fundamental pieces, not that it is still valid
    325 bool Filter::_get_all_pieces(const PseudoJet &jet, vector<PseudoJet> &all_pieces) const{
    326   if (jet.has_associated_cluster_sequence()){
    327     all_pieces.push_back(jet);
    328     return true;
    329   }
    330 
    331   if (jet.has_pieces()){
    332     const vector<PseudoJet> pieces = jet.pieces();
    333     for (vector<PseudoJet>::const_iterator it=pieces.begin(); it!=pieces.end(); it++)
    334       if (!_get_all_pieces(*it, all_pieces)) return false;
    335     return true;
    336   }
    337 
    338   return false;
    339 }
    340 
    341 // get the common recombiner to all pieces (NULL if none)
    342 //
    343 // Note that if the jet has an associated cluster sequence that is no
    344 // longer valid, an error will be thrown (needed since it could be the
    345 // 1st check called after the enumeration of the pieces)
    346 const JetDefinition::Recombiner* Filter::_get_common_recombiner(const vector<PseudoJet> &all_pieces) const{
    347   const JetDefinition & jd_ref = all_pieces[0].validated_cs()->jet_def();
    348   for (unsigned int i=1; i<all_pieces.size(); i++)
    349     if (!all_pieces[i].validated_cs()->jet_def().has_same_recombiner(jd_ref)) return NULL;
    350 
    351   return jd_ref.recombiner();
    352 }
    353 
    354 // check if the jet (or all its pieces) have explicit ghosts
    355 // (assuming the jet has area support
    356 //
    357 // Note that if the jet has an associated cluster sequence that is no
    358 // longer valid, an error will be thrown (needed since it could be the
    359 // 1st check called after the enumeration of the pieces)
    360 bool Filter::_check_explicit_ghosts(const vector<PseudoJet> &all_pieces) const{
    361   for (vector<PseudoJet>::const_iterator it=all_pieces.begin(); it!=all_pieces.end(); it++)
    362     if (! it->validated_csab()->has_explicit_ghosts()) return false;
    363   return true;
    364 }
    365 
    366 // check if one can apply the simplification for C/A subjets
    367 //
    368 // This includes:
    369 //  - the subjet definition asks for C/A subjets
    370 //  - all the pieces share the same CS
    371 //  - that CS is C/A with the same recombiner as the subjet def
    372 //  - the filtering radius is not larger than any of the pairwise
    373 //    distance between the pieces
    374 //
    375 // Note that if the jet has an associated cluster sequence that is no
    376 // longer valid, an error will be thrown (needed since it could be the
    377 // 1st check called after the enumeration of the pieces)
    378 bool Filter::_check_ca(const vector<PseudoJet> &all_pieces) const{
    379   if (_subjet_def.jet_algorithm() != cambridge_algorithm) return false;
    380 
    381   // check that the 1st of all the pieces (we're sure there is at
    382   // least one) is coming from a C/A clustering. Then check that all
    383   // the following pieces share the same ClusterSequence
    384   const ClusterSequence * cs_ref = all_pieces[0].validated_cs();
    385   if (cs_ref->jet_def().jet_algorithm() != cambridge_algorithm) return false;
    386   for (unsigned int i=1; i<all_pieces.size(); i++)
    387     if (all_pieces[i].validated_cs() != cs_ref) return false;
    388 
    389   // check that the 1st peice has the same recombiner as the one used
    390   // for the subjet clustering
    391   // Note that since they share the same CS, checking the 2st one is enough
    392   if (!cs_ref->jet_def().has_same_recombiner(_subjet_def)) return false;
    393 
    394   // we also have to make sure that the filtering radius is not larger
    395   // than any of the inter-pieces distance
    396   double Rfilt2 = _subjet_def.R();
    397   Rfilt2 *= Rfilt2;
    398   for (unsigned int i=0; i<all_pieces.size()-1; i++){
    399     for (unsigned int j=i+1; j<all_pieces.size(); j++){
    400       if (all_pieces[i].squared_distance(all_pieces[j]) <  Rfilt2) return false;
    401     }
    402   }
    403 
    404   return true;
    405 }
    406 
    407 //----------------------------------------------------------------------
    408 // FilterInterface implementation
    409 //----------------------------------------------------------------------
    410 
    411175
    412176FASTJET_END_NAMESPACE      // defined in fastjet/internal/base.hh
  • external/fastjet/tools/Filter.hh

    r5b5a56b r35cdc46  
    22#define __FASTJET_TOOLS_FILTER_HH__
    33
    4 //STARTHEADER
    5 // $Id: Filter.hh 2694 2011-11-14 22:27:51Z salam $
    6 //
    7 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     4//FJSTARTHEADER
     5// $Id: Filter.hh 3494 2014-07-30 20:38:48Z soyez $
     6//
     7// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
    88//
    99//----------------------------------------------------------------------
     
    1616//
    1717//  The algorithms that underlie FastJet have required considerable
    18 //  development and are described in hep-ph/0512210. If you use
     18//  development. They are described in the original FastJet paper,
     19//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
    1920//  FastJet as part of work towards a scientific publication, please
    20 //  include a citation to the FastJet paper.
     21//  quote the version you use and include a citation to the manual and
     22//  optionally also to hep-ph/0512210.
    2123//
    2224//  FastJet is distributed in the hope that it will be useful,
     
    2830//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
    2931//----------------------------------------------------------------------
    30 //ENDHEADER
     32//FJENDHEADER
    3133
    3234#include <fastjet/ClusterSequence.hh>
     
    98100  /// Note: this is just for derived classes
    99101  ///       a Filter initialised through this constructor will not work!
    100   Filter() : _Rfiltfunc(0){};
     102  Filter() : _Rfiltfunc(0), _initialised(false){};
    101103
    102104  /// define a filter that decomposes a jet into subjets using a
     
    113115  /// ghosts
    114116  Filter(JetDefinition subjet_def, Selector selector, double rho = 0.0) :
    115     _subjet_def(subjet_def), _Rfiltfunc(0), _Rfilt(-1), _selector(selector), _rho(rho), _subtractor(0) {}
     117    _subjet_def(subjet_def), _Rfiltfunc(0), _Rfilt(-1), _selector(selector), _rho(rho), _subtractor(0), _initialised(true) {}
    116118
    117119  /// Same as the full constructor (see above) but just specifying the radius
     
    121123  ///  \param Rfilt   the filtering radius
    122124  Filter(double Rfilt, Selector selector, double rho = 0.0) :
    123     _Rfiltfunc(0), _Rfilt(Rfilt), _selector(selector), _rho(rho), _subtractor(0) {
     125    _Rfiltfunc(0), _Rfilt(Rfilt), _selector(selector), _rho(rho), _subtractor(0), _initialised(true) {
    124126    if (_Rfilt<0)
    125127      throw Error("Attempt to create a Filter with a negative filtering radius");
     
    133135  ///  \param Rfilt_func   the filtering radius function of a PseudoJet
    134136  Filter(FunctionOfPseudoJet<double> *Rfilt_func, Selector selector, double rho = 0.0) :
    135     _Rfiltfunc(Rfilt_func), _Rfilt(-1), _selector(selector), _rho(rho), _subtractor(0) {}
     137    _Rfiltfunc(Rfilt_func), _Rfilt(-1), _selector(selector), _rho(rho), _subtractor(0), _initialised(true) {}
    136138
    137139  /// default dtor
     
    140142  /// Set a subtractor that is applied to all individual subjets before
    141143  /// deciding which ones to keep. It takes precedence over a non-zero rho.
    142   void set_subtractor(const Transformer * subtractor) {_subtractor = subtractor;}
     144  void set_subtractor(const FunctionOfPseudoJet<PseudoJet> * subtractor) {_subtractor = subtractor;}
    143145
    144146  /// runs the filtering and sets kept and rejected to be the jets of interest
     
    159161  /// It also sets the subjet_def to be used in joining things (the bit of
    160162  /// subjet def that is of interest for later is the recombiner).
    161   void _set_filtered_elements(const PseudoJet & jet,
    162                               std::vector<PseudoJet> & filtered_elements,
    163                               JetDefinition & subjet_def,
    164                               bool & discard_area) const;
     163  ///
     164  /// this returns true if teh optimisation trick for C/A reclustering has been used
     165  bool _set_filtered_elements(const PseudoJet & jet,
     166                              std::vector<PseudoJet> & filtered_elements) const;
    165167 
    166   /// set the filtered elements in the simple case of C/A+C/A
    167   void _set_filtered_elements_cafilt(const PseudoJet & jet,
    168                                      std::vector<PseudoJet> & filtered_elements,
    169                                      double Rfilt) const;
    170 
    171   /// set the filtered elements in the generic re-clustering case
    172   void _set_filtered_elements_generic(const PseudoJet & jet,
    173                                       std::vector<PseudoJet> & filtered_elements,
    174                                       const JetDefinition & subjet_def,
    175                                       bool do_areas) const;
    176 
    177168  /// gather the information about what is kept and rejected under the
    178169  /// form of a PseudoJet with a special ClusterSequenceInfo
     170  ///
     171  /// The last argument (ca_optimisation_used) should be true if the
     172  /// optimisation trick for C/A reclustering has been used (in which
     173  /// case some extra tests have to be run for non-explicit-ghost
     174  /// areas)
    179175  PseudoJet _finalise(const PseudoJet & jet,
    180176                      std::vector<PseudoJet> & kept,
    181177                      std::vector<PseudoJet> & rejected,
    182                       const JetDefinition & subjet_def,
    183                       const bool discard_area) const;
    184 
    185   // a series of checks
    186   //--------------------------------------------------------------------
    187   /// get the pieces down to the fundamental pieces
    188   bool _get_all_pieces(const PseudoJet &jet, std::vector<PseudoJet> &all_pieces) const;
    189 
    190   /// get the common recombiner to all pieces (NULL if none)
    191   const JetDefinition::Recombiner* _get_common_recombiner(const std::vector<PseudoJet> &all_pieces) const;
    192 
    193   /// check if one can apply the simplified trick for C/A subjets
    194   bool _check_ca(const std::vector<PseudoJet> &all_pieces) const;
    195 
    196   /// check if the jet (or all its pieces) have explicit ghosts
    197   /// (assuming the jet has area support
    198   ///
    199   /// Note that if the jet has an associated cluster sequence that is no
    200   /// longer valid, an error will be thrown
    201   bool _check_explicit_ghosts(const std::vector<PseudoJet> &all_pieces) const;
     178                      bool ca_optimisation_used) const;
    202179
    203180  bool _uses_subtraction() const {return (_subtractor || _rho != 0);}
     
    209186  Selector _selector;  ///< the subjet selection criterium
    210187  double _rho;                 ///< the background density (used for subtraction when possible)
    211   const Transformer * _subtractor; ///< for subtracting bkgd density from subjets
     188  const FunctionOfPseudoJet<PseudoJet> * _subtractor; ///< for subtracting bkgd density from subjets
     189
     190  bool _initialised;    ///< true when the Filter has been properly intialised
    212191};
    213192
  • external/fastjet/tools/GridMedianBackgroundEstimator.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: GridMedianBackgroundEstimator.cc 3555 2014-08-11 09:56:35Z salam $
     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
     
    3234
    3335FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
     36
    3437
    3538//----------------------------------------------------------------------
     
    3942// of the specified particles.
    4043void GridMedianBackgroundEstimator::set_particles(const vector<PseudoJet> & particles) {
    41   fill(_scalar_pt.begin(), _scalar_pt.end(), 0.0);
    42   for (unsigned i = 0; i < particles.size(); i++) {
    43     int j = igrid(particles[i]);
    44     if (j >= 0){
    45       if (_rescaling_class == 0)
    46         _scalar_pt[j] += particles[i].perp();
    47       else
    48         _scalar_pt[j] += particles[i].perp()/(*_rescaling_class)(particles[i]);
     44  vector<double> scalar_pt(n_tiles(), 0.0);
     45
     46#ifdef FASTJET_GMBGE_USEFJGRID
     47  assert(all_tiles_equal_area());
     48  //assert(n_good_tiles() == n_tiles()); // not needed now that we have an implementation
     49#endif
     50
     51  // check if we need to compute only rho or both rho and rho_m
     52  if (_enable_rho_m){
     53    // both rho and rho_m
     54    //
     55    // this requires a few other variables
     56    vector<double> scalar_dt(n_tiles(), 0.0);
     57    double pt, dt;
     58    for (unsigned i = 0; i < particles.size(); i++) {
     59      int j = tile_index(particles[i]);
     60      if (j >= 0){
     61        pt = particles[i].pt();
     62        dt = particles[i].mt() - pt;
     63        if (_rescaling_class == 0){
     64          scalar_pt[j] += pt;
     65          scalar_dt[j] += dt;
     66        } else {
     67          double r = (*_rescaling_class)(particles[i]);
     68          scalar_pt[j] += pt/r;
     69          scalar_dt[j] += dt/r;
     70        }
     71      }
     72    }
     73    // sort things for _percentile
     74    sort(scalar_dt.begin(), scalar_dt.end());
     75
     76    // compute rho_m and sigma_m (see comment below for the
     77    // normaliosation of sigma)
     78    double p50 = _percentile(scalar_dt, 0.5);
     79    _rho_m   = p50 / mean_tile_area();
     80    _sigma_m = (p50-_percentile(scalar_dt, (1.0-0.6827)/2.0))/sqrt(mean_tile_area());
     81  } else {
     82    // only rho
     83    //fill(_scalar_pt.begin(), _scalar_pt.end(), 0.0);
     84    for (unsigned i = 0; i < particles.size(); i++) {
     85      int j = tile_index(particles[i]);
     86      if (j >= 0){
     87        if (_rescaling_class == 0){
     88          scalar_pt[j] += particles[i].pt();
     89        } else {
     90          scalar_pt[j] += particles[i].pt()/(*_rescaling_class)(particles[i]);
     91        }
     92      }
    4993    }
    5094  }
    51   sort(_scalar_pt.begin(), _scalar_pt.end());
     95
     96  // if there are some "bad" tiles, then we need to exclude them from
     97  // the calculation of the median. We'll do this by condensing the
     98  // scalar_pt vector down to just the values for the tiles that are
     99  // good.
     100  //
     101  // tested answers look right in "issue" 2014-08-08-testing-rect-grid
     102  if (n_good_tiles() != n_tiles()) {
     103    int newn = 0;
     104    for (unsigned i = 0; i < scalar_pt.size(); i++) {
     105      if (tile_is_good(i)) {
     106        // clang gets confused with the SharedPtr swap if we don't
     107        // have std:: here
     108        std::swap(scalar_pt[i],scalar_pt[newn]);
     109        newn++;
     110      }
     111    }
     112    scalar_pt.resize(newn);
     113  }
     114
     115  // in all cases, carry on with the computation of rho
     116  //
     117  // first sort
     118  sort(scalar_pt.begin(), scalar_pt.end());
     119
     120  // then compute rho
     121  //
     122  // watch out: by definition, our sigma is the standard deviation of
     123  // the pt density multiplied by the square root of the cell area
     124  double p50 = _percentile(scalar_pt, 0.5);
     125  _rho   = p50 / mean_tile_area();
     126  _sigma = (p50-_percentile(scalar_pt, (1.0-0.6827)/2.0))/sqrt(mean_tile_area());
    52127
    53128  _has_particles = true;
     
    61136double GridMedianBackgroundEstimator::rho() const {
    62137  verify_particles_set();
    63   return _percentile(_scalar_pt, 0.5) / _cell_area;
     138  return _rho;
    64139}
    65140
     
    71146double GridMedianBackgroundEstimator::sigma() const{
    72147  verify_particles_set();
    73   // watch out: by definition, our sigma is the standard deviation of
    74   // the pt density multiplied by the square root of the cell area
    75   return (_percentile(_scalar_pt, 0.5) -
    76           _percentile(_scalar_pt, (1.0-0.6827)/2.0)
    77           )/sqrt(_cell_area);
     148  return _sigma;
    78149}
    79150
     
    85156// determination.
    86157double GridMedianBackgroundEstimator::rho(const PseudoJet & jet)  {
    87   verify_particles_set();
     158  //verify_particles_set();
    88159  double rescaling = (_rescaling_class == 0) ? 1.0 : (*_rescaling_class)(jet);
    89160  return rescaling*rho();
     
    95166// the position of a given jet. As for rho(jet), it is non-const.
    96167double GridMedianBackgroundEstimator::sigma(const PseudoJet & jet){
    97   verify_particles_set();
     168  //verify_particles_set();
    98169  double rescaling = (_rescaling_class == 0) ? 1.0 : (*_rescaling_class)(jet);
    99170  return rescaling*sigma();
     171}
     172
     173//----------------------------------------------------------------------
     174// returns rho_m (particle-masses contribution to the 4-vector density)
     175double GridMedianBackgroundEstimator::rho_m() const {
     176  if (! _enable_rho_m){
     177    throw Error("GridMediamBackgroundEstimator: rho_m requested but rho_m calculation has been disabled.");
     178  }
     179  verify_particles_set();
     180  return _rho_m;
     181}
     182
     183
     184//----------------------------------------------------------------------
     185// returns sigma_m (particle-masses contribution to the 4-vector
     186// density); must be multipled by sqrt(area) to get fluctuations
     187// for a region of a given area.
     188double GridMedianBackgroundEstimator::sigma_m() const{
     189  if (! _enable_rho_m){
     190    throw Error("GridMediamBackgroundEstimator: sigma_m requested but rho_m/sigma_m calculation has been disabled.");
     191  }
     192  verify_particles_set();
     193  return _sigma_m;
     194}
     195
     196//----------------------------------------------------------------------
     197// returns rho_m locally at the position of a given jet. As for
     198// rho(jet), it is non-const.
     199double GridMedianBackgroundEstimator::rho_m(const PseudoJet & jet)  {
     200  //verify_particles_set();
     201  double rescaling = (_rescaling_class == 0) ? 1.0 : (*_rescaling_class)(jet);
     202  return rescaling*rho_m();
     203}
     204
     205
     206//----------------------------------------------------------------------
     207// returns sigma_m locally at the position of a given jet. As for
     208// rho(jet), it is non-const.
     209double GridMedianBackgroundEstimator::sigma_m(const PseudoJet & jet){
     210  //verify_particles_set();
     211  double rescaling = (_rescaling_class == 0) ? 1.0 : (*_rescaling_class)(jet);
     212  return rescaling*sigma_m();
    100213}
    101214
     
    112225string GridMedianBackgroundEstimator::description() const {
    113226  ostringstream desc;
     227#ifdef FASTJET_GMBGE_USEFJGRID
     228  desc << "GridMedianBackgroundEstimator, with " << RectangularGrid::description();
     229#else
    114230  desc << "GridMedianBackgroundEstimator, with grid extension |y| < " << _ymax
    115        << " and requested grid spacing = " << _requested_grid_spacing;
     231       << ", and grid cells of size dy x dphi = " << _dy << " x " << _dphi
     232       << " (requested size = " << _requested_grid_spacing << ")";
     233#endif
    116234  return desc.str();
    117235}       
     
    144262
    145263
     264#ifndef FASTJET_GMBGE_USEFJGRID
    146265//----------------------------------------------------------------------
    147266// protected material
     
    168287
    169288  _ntotal = _nphi * _ny;
    170   _scalar_pt.resize(_ntotal);
    171   _cell_area = _dy * _dphi;
    172 }
    173 
    174 
    175 //----------------------------------------------------------------------
    176 // retrieve the grid cell index for a given PseudoJet
    177 int GridMedianBackgroundEstimator::igrid(const PseudoJet & p) const {
     289  //_scalar_pt.resize(_ntotal);
     290  _tile_area = _dy * _dphi;
     291}
     292
     293
     294//----------------------------------------------------------------------
     295// retrieve the grid tile index for a given PseudoJet
     296int GridMedianBackgroundEstimator::tile_index(const PseudoJet & p) const {
    178297  // directly taking int does not work for values between -1 and 0
    179298  // so use floor instead
     
    193312  if (iphi == _nphi) iphi = 0; // just in case of rounding errors
    194313
    195   int igrid_res = iy*_nphi + iphi;
    196   assert (igrid_res >= 0 && igrid_res < _ny*_nphi);
    197   return igrid_res;
    198 }
     314  int index_res = iy*_nphi + iphi;
     315  assert (index_res >= 0 && index_res < _ny*_nphi);
     316  return index_res;
     317}
     318#endif // FASTJET_GMBGE_USEFJGRID
     319
    199320
    200321
  • external/fastjet/tools/GridMedianBackgroundEstimator.hh

    r5b5a56b r35cdc46  
    22#define __GRID_MEDIAN_BACKGROUND_ESTIMATOR_HH__
    33
    4 //STARTHEADER
    5 // $Id: GridMedianBackgroundEstimator.hh 2580 2011-09-13 17:25:43Z salam $
    6 //
    7 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     4//FJSTARTHEADER
     5// $Id: GridMedianBackgroundEstimator.hh 3610 2014-08-13 09:49:28Z salam $
     6//
     7// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
    88//
    99//----------------------------------------------------------------------
     
    1616//
    1717//  The algorithms that underlie FastJet have required considerable
    18 //  development and are described in hep-ph/0512210. If you use
     18//  development. They are described in the original FastJet paper,
     19//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
    1920//  FastJet as part of work towards a scientific publication, please
    20 //  include a citation to the FastJet paper.
     21//  quote the version you use and include a citation to the manual and
     22//  optionally also to hep-ph/0512210.
    2123//
    2224//  FastJet is distributed in the hope that it will be useful,
     
    2830//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
    2931//----------------------------------------------------------------------
    30 //ENDHEADER
     32//FJENDHEADER
    3133
    3234
    3335#include "fastjet/tools/BackgroundEstimatorBase.hh"
     36
     37// if defined then we'll use the RectangularGrid class
     38//
     39// (For FastJet 3.2, maybe remove the symbol and simply clean up the
     40// code below to use exclusively the RectangularGrid)
     41#define FASTJET_GMBGE_USEFJGRID
     42
     43#ifdef FASTJET_GMBGE_USEFJGRID
     44#include "fastjet/RectangularGrid.hh"
     45#endif
     46
     47
    3448
    3549FASTJET_BEGIN_NAMESPACE      // defined in fastjet/internal/base.hh
     
    6175///   rho() [Without rescaling, they are identical]
    6276///
    63 class GridMedianBackgroundEstimator : public BackgroundEstimatorBase {
     77class GridMedianBackgroundEstimator : public BackgroundEstimatorBase
     78#ifdef FASTJET_GMBGE_USEFJGRID
     79                                                                    , RectangularGrid
     80#endif
     81{
     82
    6483public:
    6584  /// @name  constructors and destructors
    6685  //\{
     86#ifdef FASTJET_GMBGE_USEFJGRID
    6787  //----------------------------------------------------------------
    6888  ///   \param ymax   maximal absolute rapidity extent of the grid
     
    7191  ///             periodicity in azimuthal angle (size, not area)
    7292  GridMedianBackgroundEstimator(double ymax, double requested_grid_spacing) :
     93    RectangularGrid(ymax, requested_grid_spacing),
     94    _has_particles(false), _enable_rho_m(true) {}
     95
     96  //----------------------------------------------------------------
     97  /// Constructor based on a user's fully specified RectangularGrid
     98  GridMedianBackgroundEstimator(const RectangularGrid & grid) :
     99    RectangularGrid(grid),
     100    _has_particles(false), _enable_rho_m(true) {
     101    if (!RectangularGrid::is_initialised())
     102      throw Error("attempt to construct GridMedianBackgroundEstimator with uninitialised RectangularGrid");
     103  }   
     104
     105#else  // alternative in old framework where we didn't have the rectangular grid
     106  GridMedianBackgroundEstimator(double ymax, double requested_grid_spacing) :
    73107    _ymin(-ymax), _ymax(ymax),
    74108    _requested_grid_spacing(requested_grid_spacing),
    75     _has_particles(false){setup_grid();}
     109    _has_particles(false), _enable_rho_m(true)
     110  {
     111     setup_grid();
     112  }
     113#endif // FASTJET_GMBGE_USEFJGRID
     114
    76115  //\}
    77116
     
    84123  /// of the specified particles.
    85124  void set_particles(const std::vector<PseudoJet> & particles);
     125
     126  /// determine whether the automatic calculation of rho_m and sigma_m
     127  /// is enabled (by default true)
     128  void set_compute_rho_m(bool enable){ _enable_rho_m = enable;}
    86129
    87130  //\}
     
    114157  bool has_sigma() {return true;}
    115158
     159  //-----------------------------------------------------------------
     160  /// Returns rho_m, the purely longitudinal, particle-mass-induced
     161  /// component of the background density per unit area
     162  double rho_m() const;
     163
     164  /// returns sigma_m, a measure of the fluctuations in the purely
     165  /// longitudinal, particle-mass-induced component of the background
     166  /// density per unit area; must be multipled by sqrt(area) to get
     167  /// fluctuations for a region of a given area.
     168  double sigma_m() const;
     169
     170  /// Returns rho_m locally at the jet position. As for rho(jet), it is non-const.
     171  double rho_m(const PseudoJet & jet);
     172
     173  /// Returns sigma_m locally at the jet position. As for rho(jet), it is non-const.
     174  double sigma_m(const PseudoJet & jet);
     175
     176  /// Returns true if this background estimator has support for
     177  /// determination of rho_m.
     178  ///
     179  /// Note that support for sigma_m is automatic is one has sigma and
     180  /// rho_m support.
     181  bool has_rho_m() const {return _enable_rho_m;}
     182
     183
    116184  /// returns the area of the grid cells (all identical, but
    117185  /// referred to as "mean" area for uniformity with JetMedianBGE).
    118   double mean_area() const {return _cell_area;}
     186  double mean_area() const {return mean_tile_area();}
    119187  //\}
    120188
     
    134202  /// Note that this has to be called BEFORE any attempt to do an
    135203  /// actual computation
     204  ///
     205  /// The same profile will be used for both pt and mt (this is
     206  /// probabaly a good approximation since the particle density
     207  /// changes is what dominates the rapidity profile)
    136208  virtual void set_rescaling_class(const FunctionOfPseudoJet<double> * rescaling_class);
    137209
     
    149221
    150222private:
     223
     224#ifndef FASTJET_GMBGE_USEFJGRID
     225
    151226  /// configure the grid
    152227  void setup_grid();
    153228
    154229  /// retrieve the grid cell index for a given PseudoJet
    155   int igrid(const PseudoJet & p) const;
     230  int tile_index(const PseudoJet & p) const;
     231
     232  // information about the grid
     233  double _ymin, _ymax, _dy, _dphi, _requested_grid_spacing, _tile_area;
     234  int _ny, _nphi, _ntotal;
     235
     236  int n_tiles() const {return _ntotal;}
     237  int n_good_tiles() const {return n_tiles();}
     238  int tile_is_good(int /* itile */) const {return true;}
     239
     240  double mean_tile_area() const {return _tile_area;}
     241#endif // FASTJET_GMBGE_USEFJGRID
     242
    156243
    157244  /// verify that particles have been set and throw an error if not
    158245  void verify_particles_set() const;
    159246
    160   // information about the grid
    161   double _ymin, _ymax, _dy, _dphi, _requested_grid_spacing, _cell_area;
    162   int _ny, _nphi, _ntotal;
    163 
    164247  // information abotu the event
    165   std::vector<double> _scalar_pt;
     248  //std::vector<double> _scalar_pt;
     249  double _rho, _sigma, _rho_m, _sigma_m;
    166250  bool _has_particles;
    167 
    168   // various warnings to let people aware of potential dangers
     251  bool _enable_rho_m;
     252
     253  // various warnings to inform people of potential dangers
    169254  LimitedWarning _warning_rho_of_jet;
    170255  LimitedWarning _warning_rescaling;
  • external/fastjet/tools/JHTopTagger.cc

    r5b5a56b r35cdc46  
    1 //STARTHEADER
    2 // $Id$
     1//FJSTARTHEADER
     2// $Id: JHTopTagger.cc 3433 2014-07-23 08:17:03Z salam $
    33//
    4 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     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/JHTopTagger.hh>
  • external/fastjet/tools/JHTopTagger.hh

    r5b5a56b r35cdc46  
    22#define __FASTJET_JH_TOP_TAGGER_HH__
    33
    4 //STARTHEADER
    5 // $Id: JHTopTagger.hh 2689 2011-11-14 14:51:06Z soyez $
    6 //
    7 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     4//FJSTARTHEADER
     5// $Id: JHTopTagger.hh 3433 2014-07-23 08:17:03Z salam $
     6//
     7// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
    88//
    99//----------------------------------------------------------------------
     
    1616//
    1717//  The algorithms that underlie FastJet have required considerable
    18 //  development and are described in hep-ph/0512210. If you use
     18//  development. They are described in the original FastJet paper,
     19//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
    1920//  FastJet as part of work towards a scientific publication, please
    20 //  include a citation to the FastJet paper.
     21//  quote the version you use and include a citation to the manual and
     22//  optionally also to hep-ph/0512210.
    2123//
    2224//  FastJet is distributed in the hope that it will be useful,
     
    2830//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
    2931//----------------------------------------------------------------------
    30 //ENDHEADER
     32//FJENDHEADER
    3133
    3234
  • external/fastjet/tools/JetMedianBackgroundEstimator.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: JetMedianBackgroundEstimator.cc 3517 2014-08-01 14:23:13Z 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/JetMedianBackgroundEstimator.hh"
     
    3133#include <fastjet/ClusterSequenceStructure.hh>
    3234#include <iostream>
     35#include <sstream>
    3336
    3437FASTJET_BEGIN_NAMESPACE     // defined in fastjet/internal/base.hh
     
    3740
    3841double BackgroundJetScalarPtDensity::result(const PseudoJet & jet) const {
    39   std::vector<PseudoJet> constituents = jet.constituents();
     42  // do not include the ghosts in the list of constituents to have a
     43  // correct behaviour when _pt_power is <= 0
     44  std::vector<PseudoJet> constituents = (!SelectorIsPureGhost())(jet.constituents());
    4045  double scalar_pt = 0;
    4146  for (unsigned i = 0; i < constituents.size(); i++) {
     
    4348  }
    4449  return scalar_pt / jet.area();
     50}
     51
     52
     53std::string BackgroundJetScalarPtDensity::description() const {
     54  ostringstream oss;
     55  oss << "BackgroundScalarJetPtDensity";
     56  if (_pt_power != 1.0) oss << " with pt_power = " << _pt_power;
     57  return oss.str();
    4558}
    4659
     
    7285                                         const JetDefinition &jet_def,
    7386                                         const AreaDefinition &area_def)
    74   : _rho_range(rho_range), _jet_def(jet_def), _area_def(area_def) {
     87  : _rho_range(rho_range), _jet_def(jet_def), _area_def(area_def){
    7588
    7689  // initialise things decently
     
    261274
    262275//----------------------------------------------------------------------
     276// returns rho_m (particle-masses contribution to the 4-vector density)
     277double JetMedianBackgroundEstimator::rho_m() const {
     278  if (! has_rho_m()){
     279    throw Error("JetMediamBackgroundEstimator: rho_m requested but rho_m calculation is disabled (either eplicitly or due to the presence of a jet density class).");
     280  }
     281  if (_rho_range.takes_reference())
     282    throw Error("The background estimation is obtained from a selector that takes a reference jet. rho(PseudoJet) should be used in that case");
     283  _recompute_if_needed();
     284  return _rho_m;
     285}
     286
     287
     288//----------------------------------------------------------------------
     289// returns sigma_m (particle-masses contribution to the 4-vector
     290// density); must be multipled by sqrt(area) to get fluctuations
     291// for a region of a given area.
     292double JetMedianBackgroundEstimator::sigma_m() const{
     293  if (! has_rho_m()){
     294    throw Error("JetMediamBackgroundEstimator: sigma_m requested but rho_m/sigma_m calculation is disabled (either explicitly or due to the presence of a jet density class).");
     295  }
     296  if (_rho_range.takes_reference())
     297    throw Error("The background estimation is obtained from a selector that takes a reference jet. rho(PseudoJet) should be used in that case");
     298  _recompute_if_needed();
     299  return _sigma_m;
     300}
     301
     302//----------------------------------------------------------------------
     303// returns rho_m locally at the position of a given jet. As for
     304// rho(jet), it is non-const.
     305double JetMedianBackgroundEstimator::rho_m(const PseudoJet & jet)  {
     306  _recompute_if_needed(jet);
     307  double our_rho = _rho_m;
     308  if (_rescaling_class != 0) {
     309    our_rho *= (*_rescaling_class)(jet);
     310  }
     311  return our_rho;
     312}
     313
     314
     315//----------------------------------------------------------------------
     316// returns sigma_m locally at the position of a given jet. As for
     317// rho(jet), it is non-const.
     318double JetMedianBackgroundEstimator::sigma_m(const PseudoJet & jet){
     319  _recompute_if_needed(jet);
     320  double our_sigma = _sigma_m;
     321  if (_rescaling_class != 0) {
     322    our_sigma *= (*_rescaling_class)(jet);
     323  }
     324  return our_sigma;
     325}
     326
     327//----------------------------------------------------------------------
    263328// configuring behaviour
    264329//----------------------------------------------------------------------
     
    271336  set_provide_fj2_sigma(false);
    272337
     338  _enable_rho_m = true;
     339
    273340  // reset the computed values
    274341  _rho = _sigma = 0.0;
     342  _rho_m = _sigma_m = 0.0;
    275343  _n_jets_used = _n_empty_jets = 0;
    276344  _empty_area = _mean_area = 0.0;
     
    289357// is used (as occurs also if this function is not called).
    290358void JetMedianBackgroundEstimator::set_jet_density_class(const FunctionOfPseudoJet<double> * jet_density_class_in) {
    291   _warnings_preliminary.warn("JetMedianBackgroundEstimator::set_jet_density_class: density classes are still preliminary in FastJet 3.0. Their interface may differ in future releases (without guaranteeing backward compatibility).");
     359  _warnings_preliminary.warn("JetMedianBackgroundEstimator::set_jet_density_class: density classes are still preliminary in FastJet 3.1. Their interface may differ in future releases (without guaranteeing backward compatibility). Note that since FastJet 3.1, rho_m and sigma_m are accessible direclty in JetMedianBackgroundEstimator and GridMedianBackgroundEstimator(with no need for a density class).");
    292360  _jet_density_class = jet_density_class_in;
    293361  _uptodate = false;
     
    338406  // fill the vector of pt/area (or the quantity from the jet density class)
    339407  //  - in the range
    340   vector<double> vector_for_median;
     408  vector<double> vector_for_median_pt;
     409  vector<double> vector_for_median_dt;
    341410  double total_area  = 0.0;
    342411  _n_jets_used = 0;
     
    346415
    347416  // compute the pt/area for the selected jets
     417  double median_input_pt, median_input_dt=0.0;
     418  BackgroundJetPtMDensity m_density;
     419  bool do_rho_m = has_rho_m();
    348420  for (unsigned i = 0; i < selected_jets.size(); i++) {
    349421    const PseudoJet & current_jet = selected_jets[i];
    350422
    351423    double this_area = (_use_area_4vector) ? current_jet.area_4vector().perp() : current_jet.area();
    352 
    353424    if (this_area>0){
    354       double median_input;
     425      // for the pt component, we either use pt or the user-provided
     426      // density class
    355427      if (_jet_density_class == 0) {
    356         median_input = current_jet.perp()/this_area;
     428        median_input_pt = current_jet.perp()/this_area;
    357429      } else {
    358         median_input = (*_jet_density_class)(current_jet);
     430        median_input_pt = (*_jet_density_class)(current_jet);
    359431      }
     432
     433      // handle the rho_m part if requested
     434      // note that we're using the scalar area as a normalisation inside the
     435      // density class!
     436      if (do_rho_m)
     437        median_input_dt = m_density(current_jet);
     438   
     439      // perform rescaling if needed
    360440      if (_rescaling_class != 0) {
    361         median_input /= (*_rescaling_class)(current_jet);
     441        double resc = (*_rescaling_class)(current_jet);;
     442        median_input_pt /= resc;
     443        median_input_dt /= resc;
    362444      }
    363       vector_for_median.push_back(median_input);
     445     
     446      // store the result for future computation of the median
     447      vector_for_median_pt.push_back(median_input_pt);
     448      if (do_rho_m)
     449        vector_for_median_dt.push_back(median_input_dt);
     450
    364451      total_area  += this_area;
    365452      _n_jets_used++;
     
    367454      _warnings_zero_area.warn("JetMedianBackgroundEstimator::_compute(...): discarded jet with zero area. Zero-area jets may be due to (i) too large a ghost area (ii) a jet being outside the ghost range (iii) the computation not being done using an appropriate algorithm (kt;C/A).");
    368455    }
    369      
    370456  }
    371457 
    372458  // there is nothing inside our region, so answer will always be zero
    373   if (vector_for_median.size() == 0) {
     459  if (vector_for_median_pt.size() == 0) {
    374460    _rho        = 0.0;
    375461    _sigma      = 0.0;
     462    _rho_m      = 0.0;
     463    _sigma_m    = 0.0;
    376464    _mean_area  = 0.0;
    377465    return;
     
    392480
    393481  double stand_dev;
    394   _median_and_stddev(vector_for_median, _n_empty_jets, _rho, stand_dev,
     482  _median_and_stddev(vector_for_median_pt, _n_empty_jets, _rho, stand_dev,
    395483                     _provide_fj2_sigma);
    396484
     
    398486  _mean_area  = total_area / total_njets;
    399487  _sigma      = stand_dev * sqrt(_mean_area);
     488
     489  // compute the rho_m part now
     490  if (do_rho_m){
     491    _median_and_stddev(vector_for_median_dt, _n_empty_jets, _rho_m, stand_dev,
     492                       _provide_fj2_sigma);
     493    _sigma_m = stand_dev * sqrt(_mean_area);
     494  }
    400495
    401496  // record that the computation has been performed 
     
    439534
    440535
    441 
    442536FASTJET_END_NAMESPACE
    443537
  • external/fastjet/tools/JetMedianBackgroundEstimator.hh

    r5b5a56b r35cdc46  
    22#define __FASTJET_BACKGROUND_ESTIMATOR_HH__
    33
    4 //STARTHEADER
    5 // $Id: JetMedianBackgroundEstimator.hh 2689 2011-11-14 14:51:06Z soyez $
     4//FJSTARTHEADER
     5// $Id: JetMedianBackgroundEstimator.hh 3517 2014-08-01 14:23:13Z soyez $
    66//
    7 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     7// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
    88//
    99//----------------------------------------------------------------------
     
    1616//
    1717//  The algorithms that underlie FastJet have required considerable
    18 //  development and are described in hep-ph/0512210. If you use
     18//  development. They are described in the original FastJet paper,
     19//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
    1920//  FastJet as part of work towards a scientific publication, please
    20 //  include a citation to the FastJet paper.
     21//  quote the version you use and include a citation to the manual and
     22//  optionally also to hep-ph/0512210.
    2123//
    2224//  FastJet is distributed in the hope that it will be useful,
     
    2830//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
    2931//----------------------------------------------------------------------
    30 //ENDHEADER
     32//FJENDHEADER
    3133
    3234#include <fastjet/ClusterSequenceAreaBase.hh>
     
    121123  ///
    122124  JetMedianBackgroundEstimator(const Selector &rho_range = SelectorIdentity())
    123     : _rho_range(rho_range), _jet_def(JetDefinition()) { reset(); }
     125    : _rho_range(rho_range), _jet_def(JetDefinition()),
     126      _enable_rho_m(true){ reset(); }
    124127 
    125128
     
    168171  }
    169172
     173  /// determine whether the automatic calculation of rho_m and sigma_m
     174  /// is enabled (by default true)
     175  void set_compute_rho_m(bool enable){ _enable_rho_m = enable;}
     176
    170177  //\}
    171178
     
    201208  virtual bool has_sigma() {return true;}
    202209
     210  //----------------------------------------------------------------
     211  // now do the same thing for rho_m and sigma_m
     212
     213  /// returns rho_m, the purely longitudinal, particle-mass-induced
     214  /// component of the background density per unit area
     215  virtual double rho_m() const;
     216
     217  /// returns sigma_m, a measure of the fluctuations in the purely
     218  /// longitudinal, particle-mass-induced component of the background
     219  /// density per unit area; must be multipled by sqrt(area) to get
     220  /// fluctuations for a region of a given area.
     221  virtual double sigma_m() const;
     222
     223  /// Returns rho_m locally at the jet position. As for rho(jet), it is non-const.
     224  virtual double rho_m(const PseudoJet & /*jet*/);
     225
     226  /// Returns sigma_m locally at the jet position. As for rho(jet), it is non-const.
     227  virtual double sigma_m(const PseudoJet & /*jet*/);
     228
     229  /// Returns true if this background estimator has support for
     230  /// determination of rho_m.
     231  ///
     232  /// In te presence of a density class, support for rho_m is
     233  /// automatically disabled
     234  ///
     235  /// Note that support for sigma_m is automatic is one has sigma and
     236  /// rho_m support.
     237  virtual bool has_rho_m() const {return _enable_rho_m && (_jet_density_class == 0);}
    203238  //\}
    204239 
     
    208243  /// Returns the mean area of the jets used to actually compute the
    209244  /// background properties in the last call of rho() or sigma()
     245  /// If the configuration has changed in the meantime, throw an error.
    210246  double mean_area() const{
    211     _recompute_if_needed();
     247    if (!_uptodate)
     248      throw Error("JetMedianBackgroundEstimator::mean_area(): one may not retrieve information about the last call to rho() or sigma() when the configuration has changed in the meantime.");
     249    //_recompute_if_needed();
    212250    return _mean_area;
    213251  }
     
    215253  /// returns the number of jets used to actually compute the
    216254  /// background properties in the last call of rho() or sigma()
     255  /// If the configuration has changed in the meantime, throw an error.
    217256  unsigned int n_jets_used() const{
    218     _recompute_if_needed();
     257    if (!_uptodate)
     258      throw Error("JetMedianBackgroundEstimator::n_jets_used(): one may not retrieve information about the last call to rho() or sigma() when the configuration has changed in the meantime.");
     259    //_recompute_if_needed();
    219260    return _n_jets_used;
     261  }
     262
     263  /// returns the jets used to actually compute the background
     264  /// properties
     265  std::vector<PseudoJet> jets_used() const{
     266    if (!_uptodate) throw Error("JetMedianBackgroundEstimator::n_jets_used(): one may not retrieve information about the last call to rho() or sigma() when the configuration has changed in the meantime.");
     267    _check_csa_alive();
     268    std::vector<PseudoJet> tmp_jets = _rho_range(_included_jets);
     269    std::vector<PseudoJet> used_jets;
     270    for (unsigned int i=0; i<tmp_jets.size(); i++){
     271      if (tmp_jets[i].area()>0) used_jets.push_back(tmp_jets[i]);
     272    }
     273    return used_jets;
    220274  }
    221275
     
    223277  /// the selector) that is not occupied by jets. The value is that
    224278  /// for the last call of rho() or sigma()
     279  /// If the configuration has changed in the meantime, throw an error.
    225280  ///
    226281  /// The answer is defined to be zero if the area calculation
     
    234289  /// call to the ClusterSequenceAreaBase function.
    235290  double empty_area() const{
    236     _recompute_if_needed();
     291    if (!_uptodate)
     292      throw Error("JetMedianBackgroundEstimator::empty_area(): one may not retrieve information about the last call to rho() or sigma() when the configuration has changed in the meantime.");
     293    //_recompute_if_needed();
    237294    return _empty_area;
    238295  }
     
    241298  /// background properties. The value is that for the last call of
    242299  /// rho() or sigma().
     300  /// If the configuration has changed in the meantime, throw an error.
    243301  ///
    244302  /// If the area has explicit ghosts the result is zero; for active
     
    250308  /// call to the ClusterSequenceAreaBase function.
    251309  double n_empty_jets() const{
    252     _recompute_if_needed();
     310    if (!_uptodate)
     311      throw Error("JetMedianBackgroundEstimator::n_empty_jets(): one may not retrieve information about the last call to rho() or sigma() when the configuration has changed in the meantime.");
     312    //_recompute_if_needed();
    253313    return _n_empty_jets;
    254314  }
     
    361421  /// Issue a warning otherwise
    362422  void _check_jet_alg_good_for_median() const;
    363  
     423
    364424  // the basic parameters of this class (passed through the variou ctors)
    365425  Selector _rho_range;                   ///< range to compute the background in
     
    368428  std::vector<PseudoJet> _included_jets; ///< jets to be used
    369429 
    370   // the tunable aprameters of the class
     430  // the tunable parameters of the class
    371431  bool _use_area_4vector;
    372432  bool _provide_fj2_sigma;
    373433  const FunctionOfPseudoJet<double> * _jet_density_class;
    374434  //SharedPtr<BackgroundRescalingBase> _rescaling_class_sharedptr;
     435  bool _enable_rho_m;
    375436 
    376437  // the actual results of the computation
    377438  mutable double _rho;               ///< background estimated density per unit area
    378439  mutable double _sigma;             ///< background estimated fluctuations
     440  mutable double _rho_m;             ///< "mass" background estimated density per unit area
     441  mutable double _sigma_m;           ///< "mass" background estimated fluctuations
    379442  mutable double _mean_area;         ///< mean area of the jets used to estimate the background
    380443  mutable unsigned int _n_jets_used; ///< number of jets used to estimate the background
     
    429492  virtual double result(const PseudoJet & jet) const;
    430493
    431   virtual std::string description() const {return "BackgroundScalarJetPtDensity";}
     494  virtual std::string description() const;
    432495
    433496private:
  • external/fastjet/tools/MassDropTagger.cc

    r5b5a56b r35cdc46  
    1 //STARTHEADER
    2 // $Id$
     1//FJSTARTHEADER
     2// $Id: MassDropTagger.cc 3433 2014-07-23 08:17:03Z salam $
    33//
    4 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     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/MassDropTagger.hh>
  • external/fastjet/tools/MassDropTagger.hh

    r5b5a56b r35cdc46  
    1 //STARTHEADER
    2 // $Id: MassDropTagger.hh 2731 2011-11-21 12:15:21Z soyez $
     1//FJSTARTHEADER
     2// $Id: MassDropTagger.hh 3433 2014-07-23 08:17:03Z salam $
    33//
    4 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     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#ifndef __FASTJET_MASS_DROP_TAGGER_HH__
  • 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
  • external/fastjet/tools/Pruner.hh

    r5b5a56b r35cdc46  
    22#define __FASTJET_TOOLS_PRUNER_HH__
    33
    4 //STARTHEADER
    5 // $Id: Pruner.hh 2616 2011-09-30 18:03:40Z salam $
    6 //
    7 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     4//FJSTARTHEADER
     5// $Id: Pruner.hh 3481 2014-07-29 17:24:12Z soyez $
     6//
     7// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
    88//
    99//----------------------------------------------------------------------
     
    1616//
    1717//  The algorithms that underlie FastJet have required considerable
    18 //  development and are described in hep-ph/0512210. If you use
     18//  development. They are described in the original FastJet paper,
     19//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
    1920//  FastJet as part of work towards a scientific publication, please
    20 //  include a citation to the FastJet paper.
     21//  quote the version you use and include a citation to the manual and
     22//  optionally also to hep-ph/0512210.
    2123//
    2224//  FastJet is distributed in the hope that it will be useful,
     
    2830//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
    2931//----------------------------------------------------------------------
    30 //ENDHEADER
     32//FJENDHEADER
    3133
    3234#include "fastjet/ClusterSequence.hh"
     
    4345class PruningRecombiner;
    4446class PruningPlugin;
     47
     48// This tells third-party code that the pruner structure
     49// stores Rcut info; the alternative is for the user to
     50// get the information from the version number
     51#define FASTJET_PRUNER_STRUCTURE_STORES_RCUT
    4552
    4653//----------------------------------------------------------------------
     
    135142  ///  \param Rcut_dyn    dynamic angular distance cut in the pruning
    136143  Pruner(const JetDefinition &jet_def,
    137          FunctionOfPseudoJet<double> *zcut_dyn,
    138          FunctionOfPseudoJet<double> *Rcut_dyn);
     144         const FunctionOfPseudoJet<double> *zcut_dyn,
     145         const FunctionOfPseudoJet<double> *Rcut_dyn);
    139146
    140147  /// action on a single jet
     
    152159  bool _check_explicit_ghosts(const PseudoJet &jet) const;
    153160
    154   /// return a pointer to a "common" recombiner if there is one,
    155   /// alternatively a null pointer.
    156   const JetDefinition::Recombiner * _get_common_recombiner(const PseudoJet &jet) const;
     161  /// see if there is a common recombiner among the pieces; if there
     162  /// is return true and set jet_def_for_recombiner so that the
     163  /// recombiner can be taken from that JetDefinition. Otherwise,
     164  /// return false. 'assigned' is initially false; when true, each
     165  /// time we meet a new jet definition, we'll check it shares the
     166  /// same recombiner as jet_def_for_recombiner.
     167  bool _check_common_recombiner(const PseudoJet &jet,
     168                                JetDefinition &jet_def_for_recombiner,
     169                                bool assigned=false) const;
    157170
    158171  JetDefinition _jet_def; ///< the internal jet definition
    159172  double _zcut;           ///< the pt-fraction cut
    160173  double _Rcut_factor;    ///< the angular separation cut factor
    161   FunctionOfPseudoJet<double> *_zcut_dyn; ///< dynamic zcut
    162   FunctionOfPseudoJet<double> *_Rcut_dyn; ///< dynamic Rcut
     174  const FunctionOfPseudoJet<double> *_zcut_dyn; ///< dynamic zcut
     175  const FunctionOfPseudoJet<double> *_Rcut_dyn; ///< dynamic Rcut
    163176  bool   _get_recombiner_from_jet; ///< true for minimal constructor,
    164177                                   ///< causes recombiner to be set equal
     
    194207  std::vector<PseudoJet> extra_jets() const;
    195208
     209  /// return the value of Rcut that was used for this specific pruning.
     210  double Rcut() const {return _Rcut;}
     211
     212  /// return the value of Rcut that was used for this specific pruning.
     213  double zcut() const {return _zcut;}
     214
    196215protected:
    197216  friend class Pruner; ///< to allow setting the internal information
     217
     218private:
     219  double _Rcut, _zcut;
    198220};
    199221
  • external/fastjet/tools/RestFrameNSubjettinessTagger.cc

    r5b5a56b r35cdc46  
    1 //STARTHEADER
    2 // $Id$
     1//FJSTARTHEADER
     2// $Id: RestFrameNSubjettinessTagger.cc 3433 2014-07-23 08:17:03Z salam $
    33//
    4 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     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/RestFrameNSubjettinessTagger.hh>
  • external/fastjet/tools/RestFrameNSubjettinessTagger.hh

    r5b5a56b r35cdc46  
    22#define __FASTJET_RESTFRAMENSUBJETTINESS_TAGGER_HH__
    33
    4 //STARTHEADER
    5 // $Id: RestFrameNSubjettinessTagger.hh 2689 2011-11-14 14:51:06Z soyez $
     4//FJSTARTHEADER
     5// $Id: RestFrameNSubjettinessTagger.hh 3433 2014-07-23 08:17:03Z salam $
    66//
    7 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     7// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
    88//
    99//----------------------------------------------------------------------
     
    1616//
    1717//  The algorithms that underlie FastJet have required considerable
    18 //  development and are described in hep-ph/0512210. If you use
     18//  development. They are described in the original FastJet paper,
     19//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
    1920//  FastJet as part of work towards a scientific publication, please
    20 //  include a citation to the FastJet paper.
     21//  quote the version you use and include a citation to the manual and
     22//  optionally also to hep-ph/0512210.
    2123//
    2224//  FastJet is distributed in the hope that it will be useful,
     
    2830//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
    2931//----------------------------------------------------------------------
    30 //ENDHEADER
     32//FJENDHEADER
    3133
    3234#include <fastjet/PseudoJet.hh>
  • external/fastjet/tools/Subtractor.cc

    r5b5a56b r35cdc46  
    1 //STARTHEADER
    2 // $Id$
     1//FJSTARTHEADER
     2// $Id: Subtractor.cc 3594 2014-08-12 15:25:11Z soyez $
    33//
    4 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     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/Subtractor.hh"
     
    3840
    3941
     42//----------------------------------------------------------------------
     43// ctor
    4044Subtractor::Subtractor(double rho) : _bge(0), _rho(rho) {
    4145  assert(_rho>0.0);
     46  set_defaults();
    4247}
    4348
     49//----------------------------------------------------------------------
     50void Subtractor::set_defaults(){
     51  _use_rho_m = false; // likely to change in future releases!!
     52  _safe_mass = false; // likely to change in future releases!!
     53
     54  _sel_known_vertex = Selector();
     55  _sel_leading_vertex = Selector();
     56}
     57
     58//----------------------------------------------------------------------
     59// perform the subtraction of a given jet
    4460PseudoJet Subtractor::result(const PseudoJet & jet) const {
    4561  if (!jet.has_area()){
    4662    throw Error("Trying to subtract a jet without area support");
    4763  }
    48  
     64
     65  PseudoJet known_lv, known_pu;
     66  PseudoJet unknown = jet;
     67  if (_sel_known_vertex.worker()){
     68    // separate the jet constituents in 3 groups:
     69    //   unknown vertex
     70    //   known vertex, leading vertex
     71    //   known vertex, non-leading vertex (PU)
     72    vector<PseudoJet> constits_unknown, constits_known;
     73    _sel_known_vertex.sift(jet.constituents(),
     74                           constits_known,
     75                           constits_unknown);
     76    vector<PseudoJet> constits_known_lv, constits_known_pu;
     77    _sel_leading_vertex.sift(constits_known,
     78                             constits_known_lv,
     79                             constits_known_pu);
     80
     81    // For the parts related to the known vertices (LV or PU), we just
     82    // sum the 4-momenta. For the unknown part, we assign it the full
     83    // jet area.
     84    known_lv = (constits_known_lv.size()!=0)
     85      ? SelectorIdentity().sum(constits_known_lv) : 0.0*jet;
     86    known_pu = (constits_known_pu.size()!=0)
     87      ? SelectorIdentity().sum(constits_known_pu) : 0.0*jet;
     88    if (constits_unknown.size()==0){
     89      // no need for any form of subtraction!
     90      PseudoJet subtracted_jet = jet;
     91      subtracted_jet.reset_momentum(known_lv);
     92      return subtracted_jet;
     93    }
     94    unknown = jet; // that keeps all info including area
     95    unknown.reset_momentum(SelectorIdentity().sum(constits_unknown));
     96  } else {
     97    known_lv = jet; // ensures correct rap-phi!
     98    known_lv *= 0.0;
     99    known_pu = known_lv;
     100  }
     101
     102  // prepare for the subtraction and compute the 4-vector to be
     103  // subtracted
     104  PseudoJet subtracted_jet = jet;
     105  PseudoJet to_subtract = known_pu + _amount_to_subtract(unknown);
     106
     107  // sanity check for the transverse momentum
     108  if (to_subtract.pt2() < jet.pt2() ) {
     109    // this subtraction should retain the jet's structural
     110    // information
     111    subtracted_jet -= to_subtract;
     112  } else {
     113    // this sets the jet's momentum while maintaining all of the jet's
     114    // structural information
     115    subtracted_jet.reset_momentum(known_lv);
     116    return subtracted_jet;
     117  }
     118
     119  // make sure that in the end the pt is at least the one known to
     120  // come from the leading vertex
     121  if (subtracted_jet.pt2() < known_lv.pt2()){
     122    subtracted_jet.reset_momentum(known_lv);
     123    return subtracted_jet;
     124  }
     125
     126  // sanity check for the mass (if needed)
     127  if ((_safe_mass) && (subtracted_jet.m2() < known_lv.m2())){
     128    // in this case, we keep pt and phi as obtained from the
     129    // subtraction above and take rap and m from the part that comes
     130    // from the leading vertex (or the original jet if nothing comes
     131    // from the leading vertex)
     132    subtracted_jet.reset_momentum(PtYPhiM(subtracted_jet.pt(),
     133                                          known_lv.rap(),
     134                                          subtracted_jet.phi(),
     135                                          known_lv.m()));
     136  }
     137
     138  return subtracted_jet;
     139}
     140
     141//----------------------------------------------------------------------
     142std::string Subtractor::description() const{
     143  if (_bge != 0) {
     144    string desc = "Subtractor that uses the following background estimator to determine rho: "+_bge->description();
     145    if (use_rho_m()) desc += "; including the rho_m correction";
     146    if (safe_mass()) desc += "; including mass safety tests";
     147    if (_sel_known_vertex.worker()){
     148      desc += "; using known vertex selection: "+_sel_known_vertex.description()+" and leading vertex selection: "+_sel_leading_vertex.description();
     149    }
     150    return desc;
     151  } else if (_rho != _invalid_rho) {
     152    ostringstream ostr;
     153    ostr << "Subtractor that uses a fixed value of rho = " << _rho;
     154    return ostr.str();
     155  } else {
     156    return "Uninitialised subtractor";
     157  }
     158}
     159
     160//----------------------------------------------------------------------
     161// compute the 4-vector that should be subtracted from the given
     162// jet
     163PseudoJet Subtractor::_amount_to_subtract(const PseudoJet &jet) const{
     164  // the "transverse momentum" part
    49165  double rho;
    50166  if (_bge != 0) {
     
    56172  }
    57173
    58   PseudoJet subtracted_jet = jet;
    59   PseudoJet area4vect = jet.area_4vector();
    60   // sanity check
    61   if (rho*area4vect.perp() < jet.perp() ) {
    62     // this subtraction should retain the jet's structural
    63     // information
    64     subtracted_jet -= rho*area4vect;
    65   } else {
    66     // this sets the jet's momentum to zero while
    67     // maintaining all of the jet's structural information
    68     subtracted_jet *= 0;
     174  PseudoJet area = jet.area_4vector();
     175  PseudoJet to_subtract = rho*area;
     176
     177  double const rho_m_warning_threshold = 1e-5;
     178
     179  // add an optional contribution from the unknown particles masses
     180  if (_use_rho_m){
     181    assert(_bge != 0); // test done in "set_use_rho_m()"
     182    to_subtract += _bge->rho_m(jet) * PseudoJet(0.0, 0.0, area.pz(), area.E());
     183  } else if (_bge &&
     184             _bge->has_rho_m() &&
     185             _bge->rho_m(jet) > rho_m_warning_threshold * rho) {
     186    _unused_rho_m_warning.warn("Background estimator indicates non-zero rho_m, but use_rho_m()==false in subtractor; consider calling set_use_rho_m(true) to include the rho_m information");
    69187  }
    70   return subtracted_jet;
     188
     189  return to_subtract;
    71190}
    72191
    73 //----------------------------------------------------------------------
    74 std::string Subtractor::description() const{
    75   if (_bge != 0) {
    76     return "Subtractor that uses the following background estimator to determine rho: "+_bge->description();
    77   } else if (_rho != _invalid_rho) {
    78     ostringstream ostr;
    79     ostr << "Subtractor that uses a fixed value of rho = " << _rho;
    80     return ostr.str();
    81   } else {
    82     return "Uninitialised subtractor";
    83   }
    84 }
    85192
    86193FASTJET_END_NAMESPACE
  • external/fastjet/tools/Subtractor.hh

    r5b5a56b r35cdc46  
    1 //STARTHEADER
    2 // $Id: Subtractor.hh 2577 2011-09-13 15:11:38Z salam $
    3 //
    4 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     1//FJSTARTHEADER
     2// $Id: Subtractor.hh 3584 2014-08-12 12:40:10Z 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#ifndef __FASTJET_TOOLS_SUBTRACTOR_HH__
     
    6163  /// define a subtractor based on a BackgroundEstimator
    6264  Subtractor(BackgroundEstimatorBase * bge) :
    63     _bge(bge), _rho(-1.0) {}
     65    _bge(bge), _rho(-1.0) { set_defaults(); }
    6466
    6567  /// define a subtractor that uses a fixed value of rho, the background
     
    6870
    6971  /// default constructor
    70   Subtractor() : _bge(0), _rho(_invalid_rho) {}
     72  Subtractor() : _bge(0), _rho(_invalid_rho) { set_defaults(); }
    7173
    7274  /// default dtor
    7375  virtual ~Subtractor(){};
     76
     77  /// @name configuring the behaviour
     78  //\{
     79  //----------------------------------------------------------------
     80
     81  /// reset all parameters to default values
     82  ///
     83  /// Note: by default, the rho_m term is not included and the safety
     84  /// test for the mass is not done. This is mostly for backwards
     85  /// compatibility with FastJet 3.0 and is highly likely to change in
     86  /// a future release of FastJet
     87  void set_defaults();
     88
     89  /// when 'use_rho_m' is true, include in the subtraction the
     90  /// correction from rho_m, the purely longitudinal,
     91  /// particle-mass-induced component of the background density per
     92  /// unit area
     93  ///
     94  /// Note: this will be switched off by default (for backwards
     95  /// compatibility with FastJet 3.0) but is highly likely to change
     96  /// in a future release of FastJet
     97  void set_use_rho_m(bool use_rho_m_in = true){
     98    if (_bge == 0) {
     99      throw Error("Subtractor: rho_m support works only for Subtractors constructed with background estimator");
     100    }
     101    _use_rho_m=use_rho_m_in;
     102  }
     103 
     104  /// returns whether or not the rho_m component is used
     105  bool use_rho_m() const{ return _use_rho_m;}
     106
     107  /// when 'safe_mass' is true, ensure that the mass of the subtracted
     108  /// 4-vector remain positive
     109  ///
     110  /// when true, if the subtracted mass is negative, we return a
     111  /// 4-vector with 0 mass, pt and phi from the subtracted 4-vector
     112  /// and the rapidity of the original, unsubtracted jet.
     113  ///
     114  /// Note: this will be switched off by default (for backwards
     115  /// compatibility with FastJet 3.0) but is highly likely to change
     116  /// in a future release of FastJet
     117  void set_safe_mass(bool safe_mass_in=true){ _safe_mass=safe_mass_in;}
     118
     119  /// returns whether or not safety tests on the mass are included
     120  bool safe_mass() const{ return _safe_mass;}
     121
     122  /// This is mostly intended for cherge-hadron-subtracted type of
     123  /// events where we wich to use vertex information to improve the
     124  /// subtraction.
     125  ///
     126  /// Given the following parameters:
     127  ///   \param sel_known_vertex    selects the particles with a
     128  ///                              known vertex origin
     129  ///   \param sel_leading_vertex  amongst the particles with a
     130  ///                              known vertex origin, select those
     131  ///                              coming from the leading vertex
     132  /// Momentum identified as coming from the leading vertex will be
     133  /// kept, momentum identified as coming from a non-leading vertex
     134  /// will be eliminated and a regular area-median subtraction will be
     135  /// applied on the 4-vector sum of the particles with unknown vertex
     136  /// origin.
     137  ///
     138  /// When this is set, we shall ensure that the pt of the subtracted
     139  /// 4-vector is at least the pt of the particles that are known to
     140  /// come from the leading vertex (if it fails, subtraction returns
     141  /// the component that is known to come from the leading vertex ---
     142  /// or, the original unsubtracted jet if it contains no particles
     143  /// from the leading vertex).  Furthermore, when safe_mass() is on, we
     144  /// also impose a similar constraint on the mass of the subtracted
     145  /// 4-vector (if the test fails, the longitudinal part of the
     146  /// subtracted 4-vector is taken from the component that is known to
     147  /// come from the leading vertex).
     148  void set_known_selectors(const Selector &sel_known_vertex,
     149                           const Selector &sel_leading_vertex){
     150    _sel_known_vertex   = sel_known_vertex;
     151    _sel_leading_vertex = sel_leading_vertex;
     152  }
     153
     154  //\}
     155
     156  /// @name description and action
     157  //\{
     158  //----------------------------------------------------------------
    74159
    75160  /// returns a jet that's subtracted
     
    82167  virtual std::string description() const;
    83168
     169  //\}
    84170protected:
     171  /// compute the 4-vector that should be subtracted from the given
     172  /// jet
     173  PseudoJet _amount_to_subtract(const PseudoJet &jet) const;
    85174
    86175  /// the tool used to estimate the background
     
    89178  /// the fixed value of rho to use if the user has selected that option
    90179  double _rho;
     180
     181  // configuration parameters/flags
     182  bool _use_rho_m;   ///< include the rho_m correction
     183  bool _safe_mass;   ///< ensures that the subtracted mass is +ve
     184
     185  Selector _sel_known_vertex;   ///< selects the particles with a
     186                                ///< known vertex origin
     187  Selector _sel_leading_vertex; ///< amongst the particles with a
     188                                ///< known vertex origin, select those
     189                                ///< coming from the leading vertex
    91190
    92191  /// a value of rho that is used as a default to label that the stored
     
    98197  // that's not allowed in an include file.
    99198  static const double _invalid_rho;
     199
     200  mutable LimitedWarning _unused_rho_m_warning;
    100201};
    101202
  • external/fastjet/tools/TopTaggerBase.cc

    r5b5a56b r35cdc46  
    1 //STARTHEADER
    2 // $Id$
     1//FJSTARTHEADER
     2// $Id: TopTaggerBase.cc 3433 2014-07-23 08:17:03Z salam $
    33//
    4 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     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/TopTaggerBase.hh>
  • external/fastjet/tools/TopTaggerBase.hh

    r5b5a56b r35cdc46  
    22#define __FASTJET_TOP_TAGGER_BASE_HH__
    33
    4 //STARTHEADER
    5 // $Id: TopTaggerBase.hh 2689 2011-11-14 14:51:06Z soyez $
     4//FJSTARTHEADER
     5// $Id: TopTaggerBase.hh 3433 2014-07-23 08:17:03Z salam $
    66//
    7 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     7// Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
    88//
    99//----------------------------------------------------------------------
     
    1616//
    1717//  The algorithms that underlie FastJet have required considerable
    18 //  development and are described in hep-ph/0512210. If you use
     18//  development. They are described in the original FastJet paper,
     19//  hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
    1920//  FastJet as part of work towards a scientific publication, please
    20 //  include a citation to the FastJet paper.
     21//  quote the version you use and include a citation to the manual and
     22//  optionally also to hep-ph/0512210.
    2123//
    2224//  FastJet is distributed in the hope that it will be useful,
     
    2830//  along with FastJet. If not, see <http://www.gnu.org/licenses/>.
    2931//----------------------------------------------------------------------
    30 //ENDHEADER
     32//FJENDHEADER
    3133
    3234#include <fastjet/internal/base.hh>
  • external/fastjet/tools/Transformer.hh

    r5b5a56b r35cdc46  
    1 //STARTHEADER
    2 // $Id: Transformer.hh 2577 2011-09-13 15:11:38Z salam $
     1//FJSTARTHEADER
     2// $Id: Transformer.hh 3433 2014-07-23 08:17:03Z salam $
    33//
    4 // Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
     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#ifndef __FASTJET_TRANSFORMER_HH__
Note: See TracChangeset for help on using the changeset viewer.