FastJet 3.4.1
RectangularGrid.hh
1#ifndef __FASTJET_RECTANGULARGRID_HH__
2#define __FASTJET_RECTANGULARGRID_HH__
3
4//FJSTARTHEADER
5// $Id$
6//
7// Copyright (c) 2005-2023, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
8//
9//----------------------------------------------------------------------
10// This file is part of FastJet.
11//
12// FastJet is free software; you can redistribute it and/or modify
13// it under the terms of the GNU General Public License as published by
14// the Free Software Foundation; either version 2 of the License, or
15// (at your option) any later version.
16//
17// The algorithms that underlie FastJet have required considerable
18// development. They are described in the original FastJet paper,
19// hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
20// FastJet as part of work towards a scientific publication, please
21// quote the version you use and include a citation to the manual and
22// optionally also to hep-ph/0512210.
23//
24// FastJet is distributed in the hope that it will be useful,
25// but WITHOUT ANY WARRANTY; without even the implied warranty of
26// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27// GNU General Public License for more details.
28//
29// You should have received a copy of the GNU General Public License
30// along with FastJet. If not, see <http://www.gnu.org/licenses/>.
31//----------------------------------------------------------------------
32//FJENDHEADER
33
34#include "fastjet/PseudoJet.hh"
35#include "fastjet/Selector.hh"
36
37FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
38
39
40//----------------------------------------------------------------------
41/// Class to indicate generic structure of tilings
43public:
44 /// returns the index of the tile in which p is located, or -1 if p
45 /// is outside the tiling region
46 virtual int tile_index(const PseudoJet & p) const = 0;
47
48 /// returns the total number of tiles in the tiling; valid tile
49 /// indices run from 0 ... n_tiles()-1;
50 virtual int n_tiles() const = 0;
51
52 /// returns the number of tiles that are "good"; i.e. there is scope
53 /// for having tiles that, for whatever reason, should be ignored;
54 /// there are situations in which having "non-good" tiles may be the
55 /// simplest mechanism to obtain a tiling with holes in it
56 virtual int n_good_tiles() const {return n_tiles();}
57
58 /// returns whether a given tile is good
59 virtual bool tile_is_good(int /* itile */) const {return true;}
60
61 /// returns whether all tiles are good
62 virtual bool all_tiles_good() const {return n_good_tiles() == n_tiles();}
63
64 /// returns true if all tiles have the same area
65 virtual bool all_tiles_equal_area() const {return true;}
66
67 /// returns the area of tile itile. Here with a default
68 /// implementation to return mean_tile_area(), consistent with the
69 /// fact that all_tiles_equal_area() returns true.
70 virtual double tile_area(int /* itile */) const {return mean_tile_area();}
71
72 /// returns the mean area of the tiles.
73 virtual double mean_tile_area() const = 0;
74
75 /// returns a string to describe the tiling
76 virtual std::string description() const = 0;
77
78 /// returns true if the Tiling structure is in a suitably initialised state
79 virtual bool is_initialised() const = 0;
80 bool is_initialized() const {return is_initialised();}
81
82 /// virtual destructor
83 virtual ~TilingBase() {}
84};
85
86//----------------------------------------------------------------------
87/// Class that holds a generic rectangular tiling
89public:
90 /// ctor with simple initialisation
91 /// \param rapmax the maximal absolute rapidity extent of the grid
92 /// \param cell_size the grid spacing (equivalently, cell size)
93 RectangularGrid(double rapmax_in, double cell_size) :
94 _ymax(rapmax_in), _ymin(-rapmax_in),
95 _requested_drap(cell_size), _requested_dphi(cell_size) {
96 _setup_grid();
97 }
98
99 /// ctor with more control over initialisation
100 /// \param rapmin the minimum rapidity extent of the grid
101 /// \param rapmax the maximum rapidity extent of the grid
102 /// \param drap the grid spacing in rapidity
103 /// \param dphi the grid spacing in azimuth
104 /// \param tile_selector optional (geometric) selector to specify
105 /// which tiles are good; a tile is good if
106 /// a massless 4-vector at the center of the tile passes
107 /// the selection
108 RectangularGrid(double rapmin_in, double rapmax_in, double drap_in, double dphi_in,
109 Selector tile_selector = Selector())
110 : _ymax(rapmax_in), _ymin(rapmin_in),
111 _requested_drap(drap_in), _requested_dphi(dphi_in),
112 _tile_selector(tile_selector)
113 {
114 _setup_grid();
115 }
116
117 /// dummy ctor (will give an unusable grid)
119
120 virtual int n_tiles() const FASTJET_OVERRIDE {return _ntotal;}
121
122 virtual int n_good_tiles() const FASTJET_OVERRIDE {return _ngood;}
123
124 // this was being kept inline, but it seems to make little
125 // difference whether it is or not (at least on Gavin's mac)
126 virtual int tile_index(const PseudoJet & p) const FASTJET_OVERRIDE;
127
128 /// returns whether a given tile is good
129 // tested in "issue" 2014-08-08-testing-rect-grid
130 virtual bool tile_is_good(int itile) const FASTJET_OVERRIDE{
131 return _tile_selector.worker() ? _is_good[itile] : true;
132 }
133
134 /// returns the area of tile itile.
135 virtual double tile_area(int /* itile */) const FASTJET_OVERRIDE{
136 return mean_tile_area();
137 }
138
139 /// returns the mean area of tiles.
140 virtual double mean_tile_area() const FASTJET_OVERRIDE { return _dphi*_dy; }
141
142 /// returns a textual description of the grid
143 virtual std::string description() const FASTJET_OVERRIDE;
144
145 /// returns the minimum rapidity extent of the grid
146 double rapmin() const {return _ymin;}
147 /// returns the maxmium rapidity extent of the grid
148 double rapmax() const {return _ymax;}
149 /// returns the spacing of the grid in rapidity
150 double drap() const {return _dy;}
151 /// returns the spacing of the grid in azimuth
152 double dphi() const {return _dphi;}
153
154 /// returns true if the grid is in a suitably initialised state
155 virtual bool is_initialised() const FASTJET_OVERRIDE { return _ntotal > 0; }
156
157private:
158 void _setup_grid();
159
160 // information about the requested grid
161 double _ymax, _ymin; ///< maximal and minimal rapidity coverage of the grid
162 double _requested_drap; ///< requested rapidity spacing
163 double _requested_dphi; ///< requested phi spacing
164
165 // information about the actual grid
166 double _dy, _dphi, _cell_area, _inverse_dy, _inverse_dphi;
167 int _ny, _nphi, _ntotal;
168 int _ngood;
169
170 // a tile selector
171 Selector _tile_selector;
172 // if there's a tile selector, then for each tile, this caches the
173 // information about whether it is "good" i.e. it passes the tile
174 // selector
175 std::vector<bool> _is_good;
176
177};
178
179FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
180
181#endif // __FASTJET_RECTANGULARGRID_HH__
Class to contain pseudojets, including minimal information of use to jet-clustering routines.
Definition: PseudoJet.hh:68
Class that holds a generic rectangular tiling.
virtual double mean_tile_area() const override
returns the mean area of tiles.
double drap() const
returns the spacing of the grid in rapidity
double dphi() const
returns the spacing of the grid in azimuth
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 double tile_area(int) const override
returns the area of tile itile.
RectangularGrid(double rapmin_in, double rapmax_in, double drap_in, double dphi_in, Selector tile_selector=Selector())
ctor with more control over initialisation
double rapmax() const
returns the maxmium rapidity extent of the grid
virtual bool is_initialised() const override
returns true if the grid is in a suitably initialised state
virtual int n_good_tiles() const override
returns the number of tiles that are "good"; i.e.
RectangularGrid(double rapmax_in, double cell_size)
ctor with simple initialisation
Class that encodes information about cuts and other selection criteria that can be applied to PseudoJ...
Definition: Selector.hh:149
Class to indicate generic structure of tilings.
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
virtual bool tile_is_good(int) const
returns whether a given tile is good
virtual int n_tiles() const =0
returns the total number of tiles in the tiling; valid tile indices run from 0 ......
virtual double tile_area(int) const
returns the area of tile itile.
virtual std::string description() const =0
returns a string to describe the tiling
virtual ~TilingBase()
virtual destructor
virtual double mean_tile_area() const =0
returns the mean area of the tiles.
virtual bool is_initialised() const =0
returns true if the Tiling structure is in a suitably initialised state
virtual bool all_tiles_good() const
returns whether all tiles are good
virtual int n_good_tiles() const
returns the number of tiles that are "good"; i.e.
virtual bool all_tiles_equal_area() const
returns true if all tiles have the same area