1 #ifndef __FASTJET_SELECTOR_HH__
2 #define __FASTJET_SELECTOR_HH__
34 #include "fastjet/PseudoJet.hh"
36 #include "fastjet/RangeDefinition.hh"
41 FASTJET_BEGIN_NAMESPACE
84 virtual void terminator(std::vector<const PseudoJet *> & jets)
const {
85 for (
unsigned i = 0; i < jets.size(); i++) {
86 if (jets[i] && !pass(*jets[i])) jets[i] = NULL;
94 virtual std::string
description()
const {
return "missing description";}
107 throw Error(
"set_reference(...) cannot be used for a selector worker that does not take a reference");
115 throw Error(
"this SelectorWorker has nothing to copy");
124 rapmax = std::numeric_limits<double>::infinity();
133 virtual bool has_finite_area()
const;
140 throw Error(
"this selector has no computable area");
179 if (!validated_worker()->applies_jet_by_jet()) {
180 throw Error(
"Cannot apply this selector to an individual jet");
182 return _worker->pass(jet);
194 unsigned int count(
const std::vector<PseudoJet> & jets)
const;
200 PseudoJet sum(
const std::vector<PseudoJet> & jets)
const;
206 double scalar_pt_sum(
const std::vector<PseudoJet> & jets)
const;
210 void sift(
const std::vector<PseudoJet> & jets,
211 std::vector<PseudoJet> & jets_that_pass,
212 std::vector<PseudoJet> & jets_that_fail)
const;
216 return validated_worker()->applies_jet_by_jet();
220 std::vector<PseudoJet> operator()(
const std::vector<PseudoJet> & jets)
const;
228 validated_worker()->terminator(jets);
233 return validated_worker()->get_rapidity_extent(rapmin, rapmax);
238 return validated_worker()->description();
244 return validated_worker()->is_geometric();
251 return validated_worker()->has_finite_area();
273 double area(
double ghost_area)
const;
288 return validated_worker()->takes_reference();
295 if (! validated_worker()->takes_reference()){
301 _copy_worker_if_needed();
303 _worker->set_reference(reference);
318 InvalidArea() :
Error(
"Attempt to obtain area from Selector for which this is not meaningful") {}
341 if (_worker.unique())
return;
345 _worker.reset(_worker->copy());
365 Selector SelectorIdentity();
378 Selector
operator ||(
const Selector & s1,
const Selector & s2);
388 Selector
operator&&(
const Selector & s1,
const Selector & s2);
398 Selector
operator*(
const Selector & s1,
const Selector & s2);
467 Selector
SelectorRectangle(
const double half_rap_width,
const double half_phi_width);
490 FASTJET_END_NAMESPACE
base class corresponding to errors that can be thrown by FastJet
Class to contain pseudojets, including minimal information of use to jet-clustering routines.
class for holding a range definition specification, given by limits on rapidity and azimuth.
default selector worker is an abstract virtual base class
virtual void set_reference(const PseudoJet &)
sets the reference jet for the selector NB: "reference" is commented to avoid unused-variable compile...
virtual bool has_known_area() const
check if it has an analytically computable area
virtual void terminator(std::vector< const PseudoJet * > &jets) const
For each jet that does not pass the cuts, this routine sets the pointer to 0.
virtual bool takes_reference() const
returns true if the worker is defined with respect to a reference jet
virtual ~SelectorWorker()
default dtor
virtual void get_rapidity_extent(double &rapmin, double &rapmax) const
returns the rapidity range for which it may return "true"
virtual bool applies_jet_by_jet() const
returns true if this can be applied jet by jet
virtual SelectorWorker * copy()
return a copy of the current object.
virtual double known_area() const
if it has a computable area, return it
virtual std::string description() const
returns a description of the worker
virtual bool is_geometric() const
check if it is a geometric selector (i.e.
virtual bool pass(const PseudoJet &jet) const =0
returns true if a given object passes the selection criterion, and is the main function that needs to...
class that gets thrown when the area is requested from a Selector for which the area is not meaningfu...
class that gets thrown when a Selector is applied despite it not having a valid underlying worker.
Class that encodes information about cuts and other selection criteria that can be applied to PseudoJ...
void _copy_worker_if_needed()
Helper for copying selector workers if needed.
bool has_finite_area() const
returns true if it has a meaningful and finite area (i.e.
bool pass(const PseudoJet &jet) const
return true if the jet passes the selection
bool applies_jet_by_jet() const
returns true if this can be applied jet by jet
virtual ~Selector()
dummy virtual dtor
Selector(SelectorWorker *worker_in)
constructor that causes the Selector to use the supplied worker
bool operator()(const PseudoJet &jet) const
an operator way of knowing whether a given jet passes the selection or not
const SharedPtr< SelectorWorker > & worker() const
returns a (reference to) the underlying worker's shared pointer
std::string description() const
returns a textual description of the selector
const Selector & set_reference(const PseudoJet &reference)
set the reference jet for this Selector
bool takes_reference() const
returns true if this can be applied jet by jet
bool is_geometric() const
returns true if it is a geometric selector (i.e.
virtual void nullify_non_selected(std::vector< const PseudoJet * > &jets) const
For each jet that does not pass the cuts, this routine sets the pointer to 0.
const SelectorWorker * validated_worker() const
returns a worker if there is a valid one, otherwise throws an InvalidWorker error
Selector()
default constructor produces a Selector whose action is undefined (any attempt to use it will lead to...
void get_rapidity_extent(double &rapmin, double &rapmax) const
returns the rapidity range for which it may return "true"
An implementation of shared pointers that is broadly similar to C++11 shared_ptr (https://en....
Selector SelectorCircle(const double radius)
select objets within a distance 'radius' from the location of the reference jet, set by Selector::set...
Selector SelectorRectangle(const double half_rap_width, const double half_phi_width)
select objets within rapidity distance 'half_rap_width' from the reference jet and azimuthal-angle di...
Selector SelectorPtRange(double ptmin, double ptmax)
select objects with ptmin <= pt <= ptmax
Selector SelectorEtMax(double Etmax)
select objects with Et <= Etmax
Selector SelectorIsPureGhost()
select objects that are (or are only made of) ghosts.
Selector SelectorIsZero()
select PseudoJet with 0 momentum
Selector SelectorNHardest(unsigned int n)
select the n hardest objects
Selector operator&&(const Selector &s1, const Selector &s2)
logical and between two selectors
Selector SelectorEtaRange(double etamin, double etamax)
select objects with etamin <= eta <= etamax
Selector SelectorMassMin(double mmin)
select objects with Mass >= Mmin
Selector SelectorMassMax(double mmax)
select objects with Mass <= Mmax
Selector SelectorRapPhiRange(double rapmin, double rapmax, double phimin, double phimax)
select objects with rapmin <= rap <= rapmax && phimin <= phi <= phimax
Selector operator||(const Selector &s1, const Selector &s2)
logical or between two selectors
Selector SelectorAbsEtaMin(double absetamin)
select objects with |eta| >= absetamin
Selector SelectorPtMax(double ptmax)
select objects with pt <= ptmax
Selector operator*(const Selector &s1, const Selector &s2)
successive application of 2 selectors
Selector SelectorAbsEtaRange(double absetamin, double absetamax)
select objects with absetamin <= |eta| <= absetamax
Selector SelectorEtaMin(double etamin)
select objects with eta >= etamin
Selector SelectorRapRange(double rapmin, double rapmax)
select objects with rapmin <= rap <= rapmax
Selector SelectorDoughnut(const double radius_in, const double radius_out)
select objets with distance from the reference jet is between 'radius_in' and 'radius_out'; the refer...
Selector SelectorStrip(const double half_width)
select objets within a rapidity distance 'half_width' from the location of the reference jet,...
Selector SelectorRapMin(double rapmin)
select objects with rap >= rapmin
Selector SelectorAbsRapMax(double absrapmax)
select objects with |rap| <= absrapmax
Selector SelectorEtMin(double Etmin)
select objects with Et >= Etmin
Selector SelectorAbsRapMin(double absrapmin)
select objects with |rap| >= absrapmin
Selector SelectorEMin(double Emin)
select objects with E >= Emin
Selector SelectorERange(double Emin, double Emax)
select objects with Emin <= E <= Emax
Selector SelectorPtFractionMin(double fraction)
select objects that carry at least a fraction "fraction" of the reference jet.
Selector SelectorAbsEtaMax(double absetamax)
select objects with |eta| <= absetamax
Selector SelectorRapMax(double rapmax)
select objects with rap <= rapmax
Selector operator!(const Selector &s)
logical not applied on a selector
Selector SelectorEtRange(double Etmin, double Etmax)
select objects with Etmin <= Et <= Etmax
Selector SelectorPhiRange(double phimin, double phimax)
select objects with phimin <= phi <= phimax
Selector SelectorPtMin(double ptmin)
select objects with pt >= ptmin
Selector SelectorEtaMax(double etamax)
select objects with eta <= etamax
Selector SelectorEMax(double Emax)
select objects with E <= Emax
Selector SelectorMassRange(double mmin, double mmax)
select objects with Mmin <= Mass <= Mmax
Selector SelectorAbsRapRange(double rapmin, double rapmax)
select objects with absrapmin <= |rap| <= absrapmax