1#ifndef __FASTJET_BACKGROUND_ESTIMATOR_BASE_HH__
2#define __FASTJET_BACKGROUND_ESTIMATOR_BASE_HH__
34#include "fastjet/ClusterSequenceAreaBase.hh"
35#include "fastjet/FunctionOfPseudoJet.hh"
36#include "fastjet/Selector.hh"
37#include "fastjet/Error.hh"
40FASTJET_BEGIN_NAMESPACE
57 : _rho(0.0), _sigma(0.0), _rho_m(0.0), _sigma_m(0.0),
58 _has_sigma(false), _has_rho_m(false),
66 double rho()
const {
return _rho;}
71 double sigma()
const {
return _sigma;}
78 double rho_m()
const {
return _rho_m;}
104 return _extras.get();
111 return _extras.get() &&
dynamic_cast<const T *
>(_extras.get());
118 template<
typename BackgroundEstimator>
119 const typename BackgroundEstimator::Extras &
extras()
const{
120 return dynamic_cast<const typename BackgroundEstimator::Extras &
>(* _extras.get());
131 _rho = _sigma = _rho_m = _sigma_m = _mean_area = 0.0;
132 _has_sigma = _has_rho_m =
false;
135 void set_rho(
double rho_in) {_rho = rho_in;}
136 void set_sigma(
double sigma_in) {_sigma = sigma_in;}
137 void set_has_sigma(
bool has_sigma_in) {_has_sigma = has_sigma_in;}
138 void set_rho_m(
double rho_m_in) {_rho_m = rho_m_in;}
139 void set_sigma_m(
double sigma_m_in) {_sigma_m = sigma_m_in;}
140 void set_has_rho_m(
bool has_rho_m_in) {_has_rho_m = has_rho_m_in;}
141 void set_mean_area(
double mean_area_in) {_mean_area = mean_area_in;}
145 _rho *= rescaling_factor;
146 _sigma *= rescaling_factor;
147 _rho_m *= rescaling_factor;
148 _sigma_m *= rescaling_factor;
156 _extras.reset(extras_in);
189 _set_cache_unavailable();
192#ifdef FASTJET_HAVE_THREAD_SAFETY
215 set_particles(particles);
234 virtual double rho()
const = 0;
240 throw Error(
"sigma() not supported for this Background Estimator");
253 throw Error(
"sigma(jet) not supported for this Background Estimator");
266 throw Error(
"rho_m() not supported for this Background Estimator");
274 throw Error(
"sigma_m() not supported for this Background Estimator");
279 throw Error(
"rho_m(jet) not supported for this Background Estimator");
284 throw Error(
"sigma_m(jet) not supported for this Background Estimator");
315 return _rescaling_class;
346 void _median_and_stddev(
const std::vector<double> & quantity_vector,
349 double & stand_dev_if_gaussian,
350 bool do_fj2_calculation =
false
361 double _percentile(
const std::vector<double> & sorted_quantity_vector,
362 const double percentile,
363 const double nempty=0.0,
364 const bool do_fj2_calculation =
false)
const;
373 mutable bool _cache_available;
383#ifdef FASTJET_HAVE_THREAD_SAFETY
385 mutable std::atomic<bool> _writing_to_cache;
387 void _set_cache_unavailable(){
388 _cache_available =
false;
389 _writing_to_cache =
false;
395 void _set_cache_unavailable(){
396 _cache_available =
false;
400 void _lock_if_needed()
const;
401 void _unlock_if_needed()
const;
431 double a4=0) : _a0(a0), _a1(a1), _a2(a2), _a3(a3), _a4(a4) {}
434 virtual double result(
const PseudoJet & jet)
const;
436 double _a0, _a1, _a2, _a3, _a4;
/// a class that holds the result of the calculation
void set_extras(Extras *extras_in)
sets the extra info based on the provided pointer
double _mean_area
mean area of the patches used to compute the bkg properties
bool has_rho_m() const
true if this background estimate has a determination of rho_m.
bool has_extras() const
returns true if the background estimate has extra info compatible with the provided template type
double _sigma_m
"mass" background estimated fluctuations
bool _has_rho_m
true if this estimate has a determination of rho_m
double sigma_m() const
fluctuations in the purely longitudinal (particle-mass-induced) component of the background density p...
double _rho_m
"mass" background estimated density per unit area
void apply_rescaling_factor(double rescaling_factor)
apply a rescaling factor (to rho, rho_m, sigma, sigma_m)
double rho() const
background density per unit area
const BackgroundEstimator::Extras & extras() const
returns a reference to the extra information associated with a given BackgroundEstimator.
bool has_sigma()
true if this background estimate has a determination of sigma
double sigma() const
background fluctuations per unit square-root area must be multipled by sqrt(area) to get fluctuations...
bool has_extras() const
returns true if the background estimate has extra info
void reset()
reset to default
double rho_m() const
purely longitudinal (particle-mass-induced) component of the background density per unit area
double _sigma
background estimated fluctuations
double _rho
background estimated density per unit area
BackgroundEstimate()
ctor wo initialisation
double mean_area() const
mean area of the patches used to compute the background properties
bool _has_sigma
true if this estimate has a determination of sigma
Abstract base class that provides the basic interface for classes that estimate levels of background ...
virtual double sigma() const
get sigma, the background fluctuations per unit square-root area; must be multipled by sqrt(area) to ...
virtual std::string description() const =0
returns a textual description of the background estimator
const FunctionOfPseudoJet< double > * rescaling_class() const
return the pointer to the jet density class
virtual double sigma_m() const
returns sigma_m, a measure of the fluctuations in the purely longitudinal, particle-mass-induced comp...
virtual BackgroundEstimate estimate() const =0
get the full set of background properties
virtual double rho() const =0
get rho, the background density per unit area
virtual double sigma_m(const PseudoJet &)
Returns sigma_m locally at the jet position. As for rho(jet), it is non-const.
virtual double sigma(const PseudoJet &)
get sigma, the background fluctuations per unit area, locally at the position of a given jet.
virtual ~BackgroundEstimatorBase()
a default virtual destructor that does nothing
virtual double rho_m() const
returns rho_m, the purely longitudinal, particle-mass-induced component of the background density per...
virtual double rho_m(const PseudoJet &)
Returns rho_m locally at the jet position. As for rho(jet), it is non-const.
virtual bool has_rho_m() const
Returns true if this background estimator has support for determination of rho_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).
BackgroundEstimate _cached_estimate
all the info about what is computed
virtual double rho(const PseudoJet &jet)=0
get rho, the background density per unit area, locally at the position of a given jet.
virtual void set_particles_with_seed(const std::vector< PseudoJet > &particles, const std::vector< int > &)
an alternative call that takes a random number generator seed (typically a vector of length 2) to ens...
virtual BackgroundEstimate estimate(const PseudoJet &jet) const =0
get the full set of background properties for a given reference jet
virtual BackgroundEstimatorBase * copy() const =0
return a pointer to a copy of this BGE; the user is responsible for eventually deleting the resulting...
virtual void set_particles(const std::vector< PseudoJet > &particles)=0
tell the background estimator that it has a new event, composed of the specified particles.
virtual bool has_sigma() const
returns true if this background estimator has support for determination of sigma
A background rescaling that is a simple polynomial in y.
BackgroundRescalingYPolynomial(double a0=1, double a1=0, double a2=0, double a3=0, double a4=0)
construct a background rescaling polynomial of the form a0 + a1*y + a2*y^2 + a3*y^3 + a4*y^4
base class corresponding to errors that can be thrown by FastJet
class to provide facilities for giving warnings up to some maximum number of times and to provide glo...
Class to contain pseudojets, including minimal information of use to jet-clustering routines.
An implementation of shared pointers that is broadly similar to C++11 shared_ptr (https://en....