1 | #ifndef __FASTJET_RECTANGULARGRID_HH__
|
---|
2 | #define __FASTJET_RECTANGULARGRID_HH__
|
---|
3 |
|
---|
4 | //FJSTARTHEADER
|
---|
5 | // $Id$
|
---|
6 | //
|
---|
7 | // Copyright (c) 2005-2014, 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 |
|
---|
37 | FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
|
---|
38 |
|
---|
39 |
|
---|
40 | //----------------------------------------------------------------------
|
---|
41 | /// Class to indicate generic structure of tilings
|
---|
42 | class TilingBase {
|
---|
43 | public:
|
---|
44 | virtual ~TilingBase() {}
|
---|
45 |
|
---|
46 | /// returns the index of the tile in which p is located, or -1 if p
|
---|
47 | /// is outside the tiling region
|
---|
48 | virtual int tile_index(const PseudoJet & p) const = 0;
|
---|
49 |
|
---|
50 | /// returns the total number of tiles in the tiling; valid tile
|
---|
51 | /// indices run from 0 ... n_tiles()-1;
|
---|
52 | virtual int n_tiles() const = 0;
|
---|
53 |
|
---|
54 | /// returns the number of tiles that are "good"; i.e. there is scope
|
---|
55 | /// for having tiles that, for whatever reason, should be ignored;
|
---|
56 | /// there are situations in which having "non-good" tiles may be the
|
---|
57 | /// simplest mechanism to obtain a tiling with holes in it
|
---|
58 | virtual int n_good_tiles() const {return n_tiles();}
|
---|
59 |
|
---|
60 | /// returns whether a given tile is good
|
---|
61 | virtual bool tile_is_good(int /* itile */) const {return true;}
|
---|
62 |
|
---|
63 | /// returns whether all tiles are good
|
---|
64 | virtual bool all_tiles_good() const {return n_good_tiles() == n_tiles();}
|
---|
65 |
|
---|
66 | /// returns true if all tiles have the same area
|
---|
67 | virtual bool all_tiles_equal_area() const {return true;}
|
---|
68 |
|
---|
69 | /// returns the area of tile itile. Here with a default
|
---|
70 | /// implementation to return mean_tile_area(), consistent with the
|
---|
71 | /// fact that all_tiles_equal_area() returns true.
|
---|
72 | virtual double tile_area(int /* itile */) const {return mean_tile_area();}
|
---|
73 |
|
---|
74 | /// returns the mean area of the tiles.
|
---|
75 | virtual double mean_tile_area() const = 0;
|
---|
76 |
|
---|
77 | /// returns a string to describe the tiling
|
---|
78 | virtual std::string description() const = 0;
|
---|
79 |
|
---|
80 | /// returns true if the Tiling structure is in a suitably initialised state
|
---|
81 | virtual bool is_initialised() const = 0;
|
---|
82 | bool is_initialized() const {return is_initialised();}
|
---|
83 | };
|
---|
84 |
|
---|
85 | //----------------------------------------------------------------------
|
---|
86 | /// Class that holds a generic rectangular tiling
|
---|
87 | class RectangularGrid : public TilingBase {
|
---|
88 | public:
|
---|
89 | /// ctor with simple initialisation
|
---|
90 | /// \param rapmax the maximal absolute rapidity extent of the grid
|
---|
91 | /// \param cell_size the grid spacing (equivalently, cell size)
|
---|
92 | RectangularGrid(double rapmax_in, double cell_size) :
|
---|
93 | _ymax(rapmax_in), _ymin(-rapmax_in),
|
---|
94 | _requested_drap(cell_size), _requested_dphi(cell_size) {
|
---|
95 | _setup_grid();
|
---|
96 | }
|
---|
97 |
|
---|
98 | /// ctor with more control over initialisation
|
---|
99 | /// \param rapmin the minimum rapidity extent of the grid
|
---|
100 | /// \param rapmax the maximum rapidity extent of the grid
|
---|
101 | /// \param drap the grid spacing in rapidity
|
---|
102 | /// \param dphi the grid spacing in azimuth
|
---|
103 | /// \param tile_selector optional (geometric) selector to specify
|
---|
104 | /// which tiles are good; a tile is good if
|
---|
105 | /// a massless 4-vector at the center of the tile passes
|
---|
106 | /// the selection
|
---|
107 | RectangularGrid(double rapmin_in, double rapmax_in, double drap_in, double dphi_in,
|
---|
108 | Selector tile_selector = Selector())
|
---|
109 | : _ymax(rapmax_in), _ymin(rapmin_in),
|
---|
110 | _requested_drap(drap_in), _requested_dphi(dphi_in),
|
---|
111 | _tile_selector(tile_selector)
|
---|
112 | {
|
---|
113 | _setup_grid();
|
---|
114 | }
|
---|
115 |
|
---|
116 | /// dummy ctor (will give an unusable grid)
|
---|
117 | RectangularGrid();
|
---|
118 |
|
---|
119 | virtual int n_tiles() const {return _ntotal;}
|
---|
120 |
|
---|
121 | virtual int n_good_tiles() const {return _ngood;}
|
---|
122 |
|
---|
123 | // this was being kept inline, but it seems to make little
|
---|
124 | // difference whether it is or not (at least on Gavin's mac)
|
---|
125 | virtual int tile_index(const PseudoJet & p) const;
|
---|
126 |
|
---|
127 | /// returns whether a given tile is good
|
---|
128 | // tested in "issue" 2014-08-08-testing-rect-grid
|
---|
129 | virtual bool tile_is_good(int itile) const {return _tile_selector.worker() ? _is_good[itile] : true;}
|
---|
130 |
|
---|
131 | /// returns the area of tile itile.
|
---|
132 | virtual double tile_area(int /* itile */) const {return mean_tile_area();}
|
---|
133 |
|
---|
134 | /// returns the mean area of tiles.
|
---|
135 | virtual double mean_tile_area() const {return _dphi*_dy;};
|
---|
136 |
|
---|
137 | /// returns a textual description of the grid
|
---|
138 | virtual std::string description() const;
|
---|
139 |
|
---|
140 | /// returns the minimum rapidity extent of the grid
|
---|
141 | double rapmin() const {return _ymin;}
|
---|
142 | /// returns the maxmium rapidity extent of the grid
|
---|
143 | double rapmax() const {return _ymax;}
|
---|
144 | /// returns the spacing of the grid in rapidity
|
---|
145 | double drap() const {return _dy;}
|
---|
146 | /// returns the spacing of the grid in azimuth
|
---|
147 | double dphi() const {return _dphi;}
|
---|
148 |
|
---|
149 | /// returns true if the grid is in a suitably initialised state
|
---|
150 | virtual bool is_initialised() const {return _ntotal > 0;}
|
---|
151 |
|
---|
152 | private:
|
---|
153 | void _setup_grid();
|
---|
154 |
|
---|
155 | // information about the requested grid
|
---|
156 | double _ymax, _ymin; ///< maximal and minimal rapidity coverage of the grid
|
---|
157 | double _requested_drap; ///< requested rapidity spacing
|
---|
158 | double _requested_dphi; ///< requested phi spacing
|
---|
159 |
|
---|
160 | // information about the actual grid
|
---|
161 | double _dy, _dphi, _cell_area, _inverse_dy, _inverse_dphi;
|
---|
162 | int _ny, _nphi, _ntotal;
|
---|
163 | int _ngood;
|
---|
164 |
|
---|
165 | // a tile selector
|
---|
166 | Selector _tile_selector;
|
---|
167 | // a cached
|
---|
168 | std::vector<bool> _is_good;
|
---|
169 |
|
---|
170 | };
|
---|
171 |
|
---|
172 | FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
|
---|
173 |
|
---|
174 | #endif // __FASTJET_RECTANGULARGRID_HH__
|
---|