Fork me on GitHub

source: git/external/fastjet/RectangularGrid.hh@ f08474a

Last change on this file since f08474a was cb80e6f, checked in by Pavel Demin <pavel.demin@…>, 4 years ago

update FastJet library to 3.3.4 and FastJet Contrib library to 1.045

  • Property mode set to 100644
File size: 6.9 KB
RevLine 
[35cdc46]1#ifndef __FASTJET_RECTANGULARGRID_HH__
2#define __FASTJET_RECTANGULARGRID_HH__
3
4//FJSTARTHEADER
[cb80e6f]5// $Id: RectangularGrid.hh 4442 2020-05-05 07:50:11Z soyez $
[35cdc46]6//
[cb80e6f]7// Copyright (c) 2005-2020, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
[35cdc46]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
42class TilingBase {
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();}
[554babf]81
82 /// virtual destructor
83 virtual ~TilingBase() {}
[35cdc46]84};
85
86//----------------------------------------------------------------------
87/// Class that holds a generic rectangular tiling
88class RectangularGrid : public TilingBase {
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)
[273e668]93 RectangularGrid(double rapmax_in, double cell_size) :
94 _ymax(rapmax_in), _ymin(-rapmax_in),
[35cdc46]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
[273e668]108 RectangularGrid(double rapmin_in, double rapmax_in, double drap_in, double dphi_in,
[35cdc46]109 Selector tile_selector = Selector())
[273e668]110 : _ymax(rapmax_in), _ymin(rapmin_in),
111 _requested_drap(drap_in), _requested_dphi(dphi_in),
[35cdc46]112 _tile_selector(tile_selector)
113 {
114 _setup_grid();
115 }
116
117 /// dummy ctor (will give an unusable grid)
118 RectangularGrid();
119
[1d208a2]120 virtual int n_tiles() const FASTJET_OVERRIDE {return _ntotal;}
[35cdc46]121
[1d208a2]122 virtual int n_good_tiles() const FASTJET_OVERRIDE {return _ngood;}
[35cdc46]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)
[1d208a2]126 virtual int tile_index(const PseudoJet & p) const FASTJET_OVERRIDE;
[35cdc46]127
128 /// returns whether a given tile is good
129 // tested in "issue" 2014-08-08-testing-rect-grid
[1d208a2]130 virtual bool tile_is_good(int itile) const FASTJET_OVERRIDE {
131 return _tile_selector.worker() ? _is_good[itile] : true;
132 }
[35cdc46]133
134 /// returns the area of tile itile.
[1d208a2]135 virtual double tile_area(int /* itile */) const FASTJET_OVERRIDE {
136 return mean_tile_area();
137 }
[35cdc46]138
139 /// returns the mean area of tiles.
[1d208a2]140 virtual double mean_tile_area() const FASTJET_OVERRIDE {return _dphi*_dy;};
[35cdc46]141
142 /// returns a textual description of the grid
[1d208a2]143 virtual std::string description() const FASTJET_OVERRIDE;
[35cdc46]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
[1d208a2]155 virtual bool is_initialised() const FASTJET_OVERRIDE {return _ntotal > 0;}
[35cdc46]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;
[554babf]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
[35cdc46]175 std::vector<bool> _is_good;
176
177};
178
179FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
180
181#endif // __FASTJET_RECTANGULARGRID_HH__
Note: See TracBrowser for help on using the repository browser.