29 #include "fastjet/GhostedAreaSpec.hh" 30 #include "fastjet/Error.hh" 36 FASTJET_BEGIN_NAMESPACE
38 BasicRandom<double> GhostedAreaSpec::_random_generator;
39 LimitedWarning GhostedAreaSpec::_warn_fj2_placement_deprecated;
42 GhostedAreaSpec::GhostedAreaSpec(
45 double ghost_area_in ,
46 double grid_scatter_in ,
47 double pt_scatter_in ,
48 double mean_ghost_pt_in
51 _ghost_area(ghost_area_in),
52 _grid_scatter(grid_scatter_in),
53 _pt_scatter(pt_scatter_in),
54 _mean_ghost_pt(mean_ghost_pt_in),
55 _fj2_placement(false),
57 _actual_ghost_area(-1.0)
62 if (!_selector.
has_finite_area())
throw Error(
"To construct a GhostedAreaSpec with a Selector, the selector must have a finite area");
63 if (!_selector.
applies_jet_by_jet())
throw Error(
"To construct a GhostedAreaSpec with a Selector, the selector must apply jet-by-jet");
65 double ghost_maxrap_local, ghost_minrap_local;
67 _ghost_maxrap = 0.5*(ghost_maxrap_local - ghost_minrap_local);
68 _ghost_rap_offset = 0.5*(ghost_maxrap_local + ghost_minrap_local);
78 if (val) _warn_fj2_placement_deprecated.
warn(
"FJ2 placement of ghosts can lead to systematic edge effects in area evaluation and is deprecated. Prefer new (default) FJ3 placement.");
87 _drap = sqrt(_ghost_area);
90 _nphi = int(ceil(twopi/_dphi)); _dphi = twopi/_nphi;
91 _nrap = int(ceil(_ghost_maxrap/_drap)); _drap = _ghost_maxrap / _nrap;
92 _actual_ghost_area = _dphi * _drap;
93 _n_ghosts = (2*_nrap+1)*_nphi;
100 _nphi = int(twopi/_dphi + 0.5); _dphi = twopi/_nphi;
101 _nrap = int(_ghost_maxrap/_drap + 0.5); _drap = _ghost_maxrap / _nrap;
102 _actual_ghost_area = _dphi * _drap;
103 _n_ghosts = (2*_nrap)*_nphi;
116 if (_fj2_placement) {
121 nrap_upper = _nrap-1;
125 for (
int irap = -_nrap; irap <= nrap_upper; irap++) {
126 for (
int iphi = 0; iphi < _nphi; iphi++) {
133 double phi_fj2 = (iphi+0.5) * _dphi + _dphi*(_our_rand()-0.5)*_grid_scatter;
135 if (_fj2_placement) phi = 0.5*pi - phi_fj2;
137 double rap = (irap+rap_offset) * _drap + _drap*(_our_rand()-0.5)*_grid_scatter
138 + _ghost_rap_offset ;
139 double pt = _mean_ghost_pt*(1+(_our_rand()-0.5)*_pt_scatter);
141 double exprap = exp(+rap);
142 double pminus = pt/exprap;
143 double pplus = pt*exprap;
144 double px = pt*cos(phi);
145 double py = pt*sin(phi);
146 PseudoJet mom(px,py,0.5*(pplus-pminus),0.5*(pplus+pminus));
155 if (_selector.
worker().get() && !_selector.
pass(mom))
continue;
156 event.push_back(mom);
164 ostr <<
"ghosts of area " << actual_ghost_area()
165 <<
" (had requested " << ghost_area() <<
")";
166 if (_selector.
worker().get())
167 ostr <<
", placed according to selector (" << _selector.
description() <<
")";
169 ostr <<
", placed up to y = " << ghost_maxrap() ;
170 ostr <<
", scattered wrt to perfect grid by (rel) " << grid_scatter()
171 <<
", mean_ghost_pt = " << mean_ghost_pt()
172 <<
", rel pt_scatter = " << pt_scatter()
173 <<
", n repetitions of ghost distributions = " << repeat();
177 FASTJET_END_NAMESPACE
void set_cached_rap_phi(double rap, double phi)
in some cases when setting a 4-momentum, the user/program knows what rapidity and azimuth are associa...
void add_ghosts(std::vector< PseudoJet > &) const
push a set of ghost 4-momenta onto the back of the vector of PseudoJets
void warn(const std::string &warning)
outputs a warning to standard error (or the user's default warning stream if set) ...
const SharedPtr< SelectorWorker > & worker() const
returns a (reference to) the underlying worker's shared pointer
void _initialize()
does the initialization of actual ghost parameters
bool has_finite_area() const
returns true if it has a meaningful and finite area (i.e.
void get_rapidity_extent(double &rapmin, double &rapmax) const
returns the rapidity range for which it may return "true"
bool applies_jet_by_jet() const
returns true if this can be applied jet by jet
bool pass(const PseudoJet &jet) const
return true if the jet passes the selection
base class corresponding to errors that can be thrown by FastJet
Class that encodes information about cuts and other selection criteria that can be applied to PseudoJ...
std::string description() const
returns a textual description of the selector
void set_fj2_placement(bool val)
if val is true, set ghost placement as it was in FastJet 2.X.
std::string description() const
for a summary
Class to contain pseudojets, including minimal information of use to jet-clustering routines...