31 #include "fastjet/tools/Subtractor.hh"
37 FASTJET_BEGIN_NAMESPACE
39 const double Subtractor::_invalid_rho = -numeric_limits<double>::infinity();
44 Subtractor::Subtractor(
double rho) : _bge(0), _rho(rho) {
45 if (
_rho<0.0)
throw Error(
"Subtractor(rho) was passed a negative rho value; rho should be >= 0");
52 if (
_rho<0.0)
throw Error(
"Subtractor(rho, rho_m) was passed a negative rho value; rho should be >= 0");
53 if (rho_m<0.0)
throw Error(
"Subtractor(rho, rho_m) was passed a negative rho_m value; rho_m should be >= 0");
73 throw Error(
"Subtractor::result(...): Trying to subtract a jet without area support");
83 vector<PseudoJet> constits_unknown, constits_known;
87 vector<PseudoJet> constits_known_lv, constits_known_pu;
95 known_lv = (constits_known_lv.size()!=0)
96 ? SelectorIdentity().
sum(constits_known_lv) : 0.0*jet;
97 known_pu = (constits_known_pu.size()!=0)
98 ? SelectorIdentity().
sum(constits_known_pu) : 0.0*jet;
99 if (constits_unknown.size()==0){
103 return subtracted_jet;
119 if (to_subtract.
pt2() < jet.
pt2() ) {
122 subtracted_jet -= to_subtract;
127 return subtracted_jet;
132 if (subtracted_jet.
pt2() < known_lv.
pt2()){
134 return subtracted_jet;
145 subtracted_jet.
phi(),
149 return subtracted_jet;
155 string desc =
"Subtractor that uses the following background estimator to determine rho: "+
_bge->
description();
156 if (
use_rho_m()) desc +=
"; including the rho_m correction";
157 if (
safe_mass()) desc +=
"; including mass safety tests";
164 ostr <<
"Subtractor that uses a fixed value of rho = " <<
_rho;
165 if (
use_rho_m()) ostr <<
" and rho_m = " << _rho_m;
168 return "Uninitialised subtractor";
183 throw Error(
"Subtractor::_amount_to_subtract(...): default Subtractor does not have any information about the background, needed to perform the subtraction");
189 double const rho_m_warning_threshold = 1e-5;
196 if (!
_bge->
has_rho_m())
throw Error(
"Subtractor::_amount_to_subtract(...): requested subtraction with rho_m from a background estimator, but the estimator does not have rho_m support");
201 throw Error(
"Subtractor::_amount_to_subtract(...): default Subtractor does not have any information about the background rho_m, needed to perform the rho_m subtraction");
203 to_subtract += rho_m *
PseudoJet(0.0, 0.0, area.pz(), area.E());
206 _bge->
rho_m(jet) > rho_m_warning_threshold * rho) {
207 _unused_rho_m_warning.
warn(
"Subtractor::_amount_to_subtract(...): 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");
214 FASTJET_END_NAMESPACE
PseudoJet PtYPhiM(double pt, double y, double phi, double m)
return a pseudojet with the given pt, y, phi and mass
double rap() const
returns the rapidity or some large value when the rapidity is infinite
void set_defaults()
reset all parameters to default values
Selector _sel_known_vertex
selects the particles with a known vertex origin
void sift(const std::vector< PseudoJet > &jets, std::vector< PseudoJet > &jets_that_pass, std::vector< PseudoJet > &jets_that_fail) const
sift the input jets into two vectors – those that pass the selector and those that do not ...
virtual PseudoJet result(const PseudoJet &jet) const
returns a jet that's subtracted
double _rho
the fixed value of rho and/or rho_m to use if the user has selected that option
virtual bool has_rho_m() const
Returns true if this background estimator has support for determination of rho_m. ...
Subtractor()
default constructor
virtual std::string description() const =0
returns a textual description of the background estimator
virtual std::string description() const
class description
double m2() const
returns the squared invariant mass // like CLHEP
void warn(const char *warning)
outputs a warning to standard error (or the user's default warning stream if set) ...
bool safe_mass() const
returns whether or not safety tests on the mass are included
base class corresponding to errors that can be thrown by FastJet
void set_use_rho_m(bool use_rho_m_in=true)
when 'use_rho_m' is true, include in the subtraction the correction from rho_m, the purely longitudin...
std::string description() const
returns a textual description of the selector
bool _use_rho_m
include the rho_m correction
const SharedPtr< SelectorWorker > & worker() const
returns a (reference to) the underlying worker's shared pointer
virtual double rho_m() const
returns rho_m, the purely longitudinal, particle-mass-induced component of the background density per...
Selector _sel_leading_vertex
amongst the particles with a known vertex origin, select those coming from the leading vertex ...
Class that encodes information about cuts and other selection criteria that can be applied to PseudoJ...
bool use_rho_m() const
returns whether or not the rho_m component is used
double phi() const
returns phi (in the range 0..2pi)
BackgroundEstimatorBase * _bge
the tool used to estimate the background if has to be mutable in case its underlying selector takes a...
static const double _invalid_rho
a value of rho that is used as a default to label that the stored rho is not valid for subtraction...
PseudoJet sum(const std::vector< PseudoJet > &jets) const
Return the 4-vector sum of the objects that pass the selection.
virtual bool has_area() const
check if it has a defined area
double m() const
returns the invariant mass (If m2() is negative then -sqrt(-m2()) is returned, as in CLHEP) ...
double pt() const
returns the scalar transverse momentum
virtual std::vector< PseudoJet > constituents() const
retrieve the constituents.
Class to contain pseudojets, including minimal information of use to jet-clustering routines...
void reset_momentum(double px, double py, double pz, double E)
reset the 4-momentum according to the supplied components but leave all other information (indices...
PseudoJet _amount_to_subtract(const PseudoJet &jet) const
compute the 4-vector that should be subtracted from the given jet
double pt2() const
returns the squared transverse momentum
bool _safe_mass
ensures that the subtracted mass is +ve
virtual PseudoJet area_4vector() const
return the jet 4-vector area.
virtual double rho() const =0
get rho, the background density per unit area