32#include "fastjet/ClusterSequence.hh"
33#include "fastjet/GridJetPlugin.hh"
39FASTJET_BEGIN_NAMESPACE
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");
68#ifndef FASTJET_GRIDJET_USEFJGRID
69void 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);
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);
const std::vector< history_element > & history() const
allow the user to access the raw internal history.
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,...
const std::vector< PseudoJet > & jets() const
allow the user to access the internally stored _jets() array, which contains both the initial particl...
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],...
base class corresponding to errors that can be thrown by FastJet
virtual std::string description() const
return a textual description of the jet-definition implemented in this plugin
GridJetPlugin(double ymax, double requested_grid_spacing, const JetDefinition &post_jet_def=JetDefinition())
Basic constructor for the GridJetPlugin Plugin class.
virtual void run_clustering(ClusterSequence &) const
given a ClusterSequence that has been filled up with initial particles, the following function should...
virtual double R() const
This returns the sqrt(dphi*dy/pi) – i.e.
class that is intended to hold a full definition of the jet clusterer
double drap() const
returns the spacing of the grid in rapidity
double dphi() const
returns the spacing of the grid in azimuth
virtual int tile_index(const PseudoJet &p) const override
returns the index of the tile in which p is located, or -1 if p is outside the tiling region
virtual bool tile_is_good(int itile) const override
returns whether a given tile is good
virtual int n_tiles() const override
returns the total number of tiles in the tiling; valid tile indices run from 0 ......
virtual std::string description() const override
returns a textual description of the grid
virtual bool is_initialised() const override
returns true if the grid is in a suitably initialised state
RectangularGrid(double rapmax_in, double cell_size)
ctor with simple initialisation
virtual int tile_index(const PseudoJet &p) const =0
returns the index of the tile in which p is located, or -1 if p is outside the tiling region
@ undefined_jet_algorithm
the value for the jet algorithm in a JetDefinition for which no algorithm has yet been defined
a single element in the clustering history
int jetp_index
index in _history where the current jet is recombined with another jet to form its child.
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