30 #include "fastjet/ClusterSequence.hh"
31 #include "fastjet/GridJetPlugin.hh"
37 FASTJET_BEGIN_NAMESPACE
42 GridJetPlugin::GridJetPlugin (
double ymax,
43 double requested_grid_spacing,
45 _ymin(-ymax), _ymax(ymax),
46 _requested_grid_spacing(requested_grid_spacing) ,
47 _post_jet_def(post_jet_def)
52 void GridJetPlugin::setup_grid() {
56 assert(_ymax>0 && _ymax - _ymin >= _requested_grid_spacing);
58 double ny_double = (_ymax-_ymin) / _requested_grid_spacing;
59 _ny = int(ny_double+0.49999);
60 _dy = (_ymax-_ymin) / _ny;
62 _nphi = int (twopi / _requested_grid_spacing + 0.5);
63 _dphi = twopi / _nphi;
66 assert(_ny >= 1 && _nphi >= 1);
68 _ntotal = _nphi * _ny;
75 desc <<
"GridJetPlugin plugin with ymax = " << _ymax <<
", dy = " << _dy <<
", dphi = " << _dphi <<
" (requested grid spacing was " << _requested_grid_spacing <<
")";
77 desc <<
", followed by " << _post_jet_def.
description();
88 int GridJetPlugin::igrid(
const PseudoJet & p)
const {
99 int iy = int(floor( (p.
rap() - _ymin) / _dy ));
100 if (iy < 0 || iy >= _ny)
return -1;
102 int iphi = int( p.
phi()/_dphi );
103 assert(iphi >= 0 && iphi <= _nphi);
104 if (iphi == _nphi) iphi = 0;
106 int igrid_res = iy*_nphi + iphi;
107 assert (igrid_res >= 0 && igrid_res < _ny*_nphi);
119 vector<int> grid(_ntotal, -1);
121 int nparticles = cs.
jets().size();
122 double dij_or_diB = 1.0;
124 int ngrid_active = 0;
127 for (
int i = 0; i < nparticles; i++) {
128 int igrd = igrid(cs.
jets()[i]);
131 if (igrd < 0)
continue;
132 assert(igrd <= _ntotal);
133 if (grid[igrd] == -1) {
146 for (
unsigned igrd = 0; igrd < grid.size(); igrd++) {
152 vector<PseudoJet> inputs;
153 vector<int> cs_indices;
154 inputs.reserve(ngrid_active);
155 cs_indices.reserve(2*ngrid_active);
156 for (
unsigned igrd = 0; igrd < grid.size(); igrd++) {
157 if (grid[igrd] != -1) {
158 inputs.push_back(cs.
jets()[grid[igrd]]);
159 cs_indices.push_back(grid[igrd]);
163 const vector<ClusterSequence::history_element> & post_history = post_cs.
history();
164 const vector<PseudoJet> & post_jets = post_cs.
jets();
165 for (
unsigned ihist = ngrid_active; ihist < post_history.size(); ihist++) {
167 int post_ij1 = post_history[hist.parent1].
jetp_index;
168 int ij1 = cs_indices[post_ij1];
170 int post_ij2 = post_history[hist.
parent2].jetp_index;
171 int ij2 = cs_indices[post_ij2];
174 assert(
int(cs_indices.size()) == hist.
jetp_index);
175 cs_indices.push_back(k);
184 FASTJET_END_NAMESPACE
double rap() const
returns the rapidity or some large value when the rapidity is infinite
const std::vector< PseudoJet > & jets() const
allow the user to access the internally stored _jets() array, which contains both the initial particl...
the value for the jet algorithm in a JetDefinition for which no algorithm has yet been defined ...
JetAlgorithm jet_algorithm() const
return information about the definition...
virtual std::string description() const
return a textual description of the jet-definition implemented in this plugin
int jetp_index
index in _history where the current jet is recombined with another jet to form its child...
void plugin_record_ij_recombination(int jet_i, int jet_j, double dij, int &newjet_k)
record the fact that there has been a recombination between jets()[jet_i] and jets()[jet_k], with the specified dij, and return the index (newjet_k) allocated to the new jet, whose momentum is assumed to be the 4-vector sum of that of jet_i and jet_j
virtual double R() const
This returns the sqrt(dphi*dy/pi) – i.e.
int parent2
index in _history where first parent of this jet was created (InexistentParent if this jet is an orig...
double dij
index in the _jets vector where we will find the
void plugin_record_iB_recombination(int jet_i, double diB)
record the fact that there has been a recombination between jets()[jet_i] and the beam...
std::string description() const
return a textual description of the current jet definition
const std::vector< history_element > & history() const
allow the user to access the raw internal history.
a single element in the clustering history
double phi() const
returns phi (in the range 0..2pi)
virtual void run_clustering(ClusterSequence &) const
given a ClusterSequence that has been filled up with initial particles, the following function should...
Class to contain pseudojets, including minimal information of use to jet-clustering routines...
class that is intended to hold a full definition of the jet clusterer