32 #include "fastjet/ClusterSequence.hh"
33 #include "fastjet/GridJetPlugin.hh"
39 FASTJET_BEGIN_NAMESPACE
44 GridJetPlugin::GridJetPlugin (
double ymax,
45 double requested_grid_spacing,
47 #ifdef FASTJET_GRIDJET_USEFJGRID
48 RectangularGrid(ymax, requested_grid_spacing), _post_jet_def(post_jet_def) {
51 _ymin(-ymax), _ymax(ymax),
52 _requested_grid_spacing(requested_grid_spacing) ,
53 _post_jet_def(post_jet_def)
59 #ifdef FASTJET_GRIDJET_USEFJGRID
64 throw Error(
"attempt to construct GridJetPlugin with uninitialised RectangularGrid");
66 #endif // FASTJET_GRIDJET_USEFJGRID
68 #ifndef FASTJET_GRIDJET_USEFJGRID
69 void GridJetPlugin::setup_grid() {
73 assert(_ymax>0 && _ymax - _ymin >= _requested_grid_spacing);
75 double ny_double = (_ymax-_ymin) / _requested_grid_spacing;
76 _ny = int(ny_double+0.49999);
77 _dy = (_ymax-_ymin) / _ny;
79 _nphi = int (twopi / _requested_grid_spacing + 0.5);
80 _dphi = twopi / _nphi;
83 assert(_ny >= 1 && _nphi >= 1);
85 _ntotal = _nphi * _ny;
100 int iy = int(floor( (p.rap() - _ymin) / _dy ));
101 if (iy < 0 || iy >= _ny)
return -1;
103 int iphi = int( p.phi()/_dphi );
104 assert(iphi >= 0 && iphi <= _nphi);
105 if (iphi == _nphi) iphi = 0;
107 int igrid_res = iy*_nphi + iphi;
108 assert (igrid_res >= 0 && igrid_res < _ny*_nphi);
111 #endif // not FASTJET_GRIDJET_USEFJGRID
117 desc <<
"GridJetPlugin plugin with ";
118 #ifndef FASTJET_GRIDJET_USEFJGRID
119 desc <<
"ymax = " << _ymax <<
", dy = " << _dy <<
", dphi = " << _dphi <<
" (requested grid spacing was " << _requested_grid_spacing <<
")";
124 desc <<
", followed by " << _post_jet_def.
description();
141 vector<int> grid(
n_tiles(), -1);
143 int nparticles = cs.
jets().size();
144 double dij_or_diB = 1.0;
146 int ngrid_active = 0;
149 for (
int i = 0; i < nparticles; i++) {
153 if (igrd < 0)
continue;
155 if (grid[igrd] == -1) {
168 for (
unsigned igrd = 0; igrd < grid.size(); igrd++) {
174 vector<PseudoJet> inputs;
175 vector<int> cs_indices;
176 inputs.reserve(ngrid_active);
177 cs_indices.reserve(2*ngrid_active);
178 for (
unsigned igrd = 0; igrd < grid.size(); igrd++) {
179 if (grid[igrd] != -1) {
180 inputs.push_back(cs.
jets()[grid[igrd]]);
181 cs_indices.push_back(grid[igrd]);
185 const vector<ClusterSequence::history_element> & post_history = post_cs.
history();
186 const vector<PseudoJet> & post_jets = post_cs.
jets();
187 for (
unsigned ihist = ngrid_active; ihist < post_history.size(); ihist++) {
189 int post_ij1 = post_history[hist.parent1].
jetp_index;
190 int ij1 = cs_indices[post_ij1];
192 int post_ij2 = post_history[hist.
parent2].jetp_index;
193 int ij2 = cs_indices[post_ij2];
196 assert(
int(cs_indices.size()) == hist.
jetp_index);
197 cs_indices.push_back(k);
206 FASTJET_END_NAMESPACE