Fork me on GitHub

source: git/external/fastjet/RectangularGrid.hh@ 273e668

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 273e668 was 273e668, checked in by Pavel Demin <pavel.demin@…>, 10 years ago

upgrade FastJet to version 3.1.0

  • Property mode set to 100644
File size: 6.5 KB
RevLine 
[35cdc46]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
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();}
81};
82
83//----------------------------------------------------------------------
84/// Class that holds a generic rectangular tiling
85class RectangularGrid : public TilingBase {
86public:
87 /// ctor with simple initialisation
88 /// \param rapmax the maximal absolute rapidity extent of the grid
89 /// \param cell_size the grid spacing (equivalently, cell size)
[273e668]90 RectangularGrid(double rapmax_in, double cell_size) :
91 _ymax(rapmax_in), _ymin(-rapmax_in),
[35cdc46]92 _requested_drap(cell_size), _requested_dphi(cell_size) {
93 _setup_grid();
94 }
95
96 /// ctor with more control over initialisation
97 /// \param rapmin the minimum rapidity extent of the grid
98 /// \param rapmax the maximum rapidity extent of the grid
99 /// \param drap the grid spacing in rapidity
100 /// \param dphi the grid spacing in azimuth
101 /// \param tile_selector optional (geometric) selector to specify
102 /// which tiles are good; a tile is good if
103 /// a massless 4-vector at the center of the tile passes
104 /// the selection
[273e668]105 RectangularGrid(double rapmin_in, double rapmax_in, double drap_in, double dphi_in,
[35cdc46]106 Selector tile_selector = Selector())
[273e668]107 : _ymax(rapmax_in), _ymin(rapmin_in),
108 _requested_drap(drap_in), _requested_dphi(dphi_in),
[35cdc46]109 _tile_selector(tile_selector)
110 {
111 _setup_grid();
112 }
113
114 /// dummy ctor (will give an unusable grid)
115 RectangularGrid();
116
117 virtual int n_tiles() const {return _ntotal;}
118
119 virtual int n_good_tiles() const {return _ngood;}
120
121 // this was being kept inline, but it seems to make little
122 // difference whether it is or not (at least on Gavin's mac)
123 virtual int tile_index(const PseudoJet & p) const;
124
125 /// returns whether a given tile is good
126 // tested in "issue" 2014-08-08-testing-rect-grid
127 virtual bool tile_is_good(int itile) const {return _tile_selector.worker() ? _is_good[itile] : true;}
128
129 /// returns the area of tile itile.
130 virtual double tile_area(int /* itile */) const {return mean_tile_area();}
131
132 /// returns the mean area of tiles.
133 virtual double mean_tile_area() const {return _dphi*_dy;};
134
135 /// returns a textual description of the grid
136 virtual std::string description() const;
137
138 /// returns the minimum rapidity extent of the grid
139 double rapmin() const {return _ymin;}
140 /// returns the maxmium rapidity extent of the grid
141 double rapmax() const {return _ymax;}
142 /// returns the spacing of the grid in rapidity
143 double drap() const {return _dy;}
144 /// returns the spacing of the grid in azimuth
145 double dphi() const {return _dphi;}
146
147 /// returns true if the grid is in a suitably initialised state
148 virtual bool is_initialised() const {return _ntotal > 0;}
149
150private:
151 void _setup_grid();
152
153 // information about the requested grid
154 double _ymax, _ymin; ///< maximal and minimal rapidity coverage of the grid
155 double _requested_drap; ///< requested rapidity spacing
156 double _requested_dphi; ///< requested phi spacing
157
158 // information about the actual grid
159 double _dy, _dphi, _cell_area, _inverse_dy, _inverse_dphi;
160 int _ny, _nphi, _ntotal;
161 int _ngood;
162
163 // a tile selector
164 Selector _tile_selector;
165 // a cached
166 std::vector<bool> _is_good;
167
168};
169
170FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
171
172#endif // __FASTJET_RECTANGULARGRID_HH__
Note: See TracBrowser for help on using the repository browser.