Fork me on GitHub

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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • external/fastjet/tools/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
Note: See TracChangeset for help on using the changeset viewer.