32#include "fastjet/tools/GridMedianBackgroundEstimator.hh"
35FASTJET_BEGIN_NAMESPACE
44 vector<double> scalar_pt(
n_tiles(), 0.0);
49 _cached_estimate.reset();
50 _cached_estimate.set_has_sigma(
true);
58 vector<double> scalar_dt(
n_tiles(), 0.0);
60 for (
unsigned i = 0; i < particles.size(); i++) {
63 pt = particles[i].pt();
64 dt = particles[i].mt() - pt;
65 if (_rescaling_class == 0){
69 double r = (*_rescaling_class)(particles[i]);
76 sort(scalar_dt.begin(), scalar_dt.end());
81 _cached_estimate.set_has_rho_m(
true);
87 for (
unsigned i = 0; i < particles.size(); i++) {
90 if (_rescaling_class == 0){
91 scalar_pt[j] += particles[i].pt();
93 scalar_pt[j] += particles[i].pt()/(*_rescaling_class)(particles[i]);
107 for (
unsigned i = 0; i < scalar_pt.size(); i++) {
111 std::swap(scalar_pt[i],scalar_pt[newn]);
115 scalar_pt.resize(newn);
121 sort(scalar_pt.begin(), scalar_pt.end());
131 _cache_available =
true;
141 verify_particles_set();
142 return _cached_estimate;
147 verify_particles_set();
148 if (_rescaling_class == 0)
149 return _cached_estimate;
153 return local_estimate;
159 verify_particles_set();
160 return _cached_estimate.rho();
169 verify_particles_set();
170 return _cached_estimate.sigma();
181 double rescaling = (_rescaling_class == 0) ? 1.0 : (*_rescaling_class)(jet);
182 return rescaling*
rho();
191 double rescaling = (_rescaling_class == 0) ? 1.0 : (*_rescaling_class)(jet);
192 return rescaling*
sigma();
198 if (! _enable_rho_m){
199 throw Error(
"GridMediamBackgroundEstimator: rho_m requested but rho_m calculation has been disabled.");
201 verify_particles_set();
202 return _cached_estimate.rho_m();
211 if (! _enable_rho_m){
212 throw Error(
"GridMediamBackgroundEstimator: sigma_m requested but rho_m/sigma_m calculation has been disabled.");
214 verify_particles_set();
215 return _cached_estimate.sigma_m();
223 double rescaling = (_rescaling_class == 0) ? 1.0 : (*_rescaling_class)(jet);
224 return rescaling*
rho_m();
233 double rescaling = (_rescaling_class == 0) ? 1.0 : (*_rescaling_class)(jet);
239void GridMedianBackgroundEstimator::verify_particles_set()
const {
240 if (!_cache_available)
throw Error(
"GridMedianBackgroundEstimator::rho() or sigma() called without particles having been set");
273 if (_cache_available)
274 _warning_rescaling.warn(
"GridMedianBackgroundEstimator::set_rescaling_class(): trying to set the rescaling class when there are already particles that have been set is dangerous: the rescaling will not affect the already existing particles resulting in mis-estimation of rho. You need to call set_particles() again before proceeding with any background estimation.");
/// a class that holds the result of the calculation
void apply_rescaling_factor(double rescaling_factor)
apply a rescaling factor (to rho, rho_m, sigma, sigma_m)
virtual void set_rescaling_class(const FunctionOfPseudoJet< double > *rescaling_class_in)
Set a pointer to a class that calculates the rescaling factor as a function of the jet (position).
double _percentile(const std::vector< double > &sorted_quantity_vector, const double percentile, const double nempty=0.0, const bool do_fj2_calculation=false) const
computes a percentile of a given sorted vector
base class corresponding to errors that can be thrown by FastJet
base class providing interface for a generic function of a PseudoJet
Class to contain pseudojets, including minimal information of use to jet-clustering routines.
virtual double mean_tile_area() const override
returns the mean area of tiles.
virtual int tile_index(const PseudoJet &p) const override
returns the index of the tile in which p is located, or -1 if p is outside the tiling region
virtual bool tile_is_good(int itile) const override
returns whether a given tile is good
virtual int n_tiles() const override
returns the total number of tiles in the tiling; valid tile indices run from 0 ......
virtual std::string description() const override
returns a textual description of the grid
virtual int n_good_tiles() const override
returns the number of tiles that are "good"; i.e.
virtual bool all_tiles_equal_area() const
returns true if all tiles have the same area