33#include "fastjet/tools/GridMedianBackgroundEstimator.hh"
36FASTJET_BEGIN_NAMESPACE
45 vector<double> scalar_pt(
n_tiles(), 0.0);
50 _cached_estimate.reset();
51 _cached_estimate.set_has_sigma(
true);
59 vector<double> scalar_dt(
n_tiles(), 0.0);
61 for (
unsigned i = 0; i < particles.size(); i++) {
64 pt = particles[i].pt();
65 dt = particles[i].mt() - pt;
66 if (_rescaling_class == 0){
70 double r = (*_rescaling_class)(particles[i]);
77 sort(scalar_dt.begin(), scalar_dt.end());
82 _cached_estimate.set_has_rho_m(
true);
88 for (
unsigned i = 0; i < particles.size(); i++) {
91 if (_rescaling_class == 0){
92 scalar_pt[j] += particles[i].pt();
94 scalar_pt[j] += particles[i].pt()/(*_rescaling_class)(particles[i]);
108 for (
unsigned i = 0; i < scalar_pt.size(); i++) {
112 std::swap(scalar_pt[i],scalar_pt[newn]);
116 scalar_pt.resize(newn);
122 sort(scalar_pt.begin(), scalar_pt.end());
132 _cache_available =
true;
142 verify_particles_set();
143 return _cached_estimate;
148 verify_particles_set();
149 if (_rescaling_class == 0)
150 return _cached_estimate;
154 return local_estimate;
160 verify_particles_set();
161 return _cached_estimate.rho();
170 verify_particles_set();
171 return _cached_estimate.sigma();
182 double rescaling = (_rescaling_class == 0) ? 1.0 : (*_rescaling_class)(jet);
183 return rescaling*
rho();
192 double rescaling = (_rescaling_class == 0) ? 1.0 : (*_rescaling_class)(jet);
193 return rescaling*
sigma();
199 if (! _enable_rho_m){
200 throw Error(
"GridMediamBackgroundEstimator: rho_m requested but rho_m calculation has been disabled.");
202 verify_particles_set();
203 return _cached_estimate.rho_m();
212 if (! _enable_rho_m){
213 throw Error(
"GridMediamBackgroundEstimator: sigma_m requested but rho_m/sigma_m calculation has been disabled.");
215 verify_particles_set();
216 return _cached_estimate.sigma_m();
224 double rescaling = (_rescaling_class == 0) ? 1.0 : (*_rescaling_class)(jet);
225 return rescaling*
rho_m();
234 double rescaling = (_rescaling_class == 0) ? 1.0 : (*_rescaling_class)(jet);
240void GridMedianBackgroundEstimator::verify_particles_set()
const {
241 if (!_cache_available)
throw Error(
"GridMedianBackgroundEstimator::rho() or sigma() called without particles having been set");
274 if (_cache_available)
275 _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