Fork me on GitHub

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

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

upgrade FastJet to version 3.1.1

  • Property mode set to 100644
File size: 6.8 KB
Line 
1#ifndef __FASTJET_RECTANGULARGRID_HH__
2#define __FASTJET_RECTANGULARGRID_HH__
3
4//FJSTARTHEADER
5// $Id: RectangularGrid.hh 3771 2014-12-22 21:13:22Z salam $
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 /// virtual destructor
83 virtual ~TilingBase() {}
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)
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)
118 RectangularGrid();
119
120 virtual int n_tiles() const {return _ntotal;}
121
122 virtual int n_good_tiles() const {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;
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 {return _tile_selector.worker() ? _is_good[itile] : true;}
131
132 /// returns the area of tile itile.
133 virtual double tile_area(int /* itile */) const {return mean_tile_area();}
134
135 /// returns the mean area of tiles.
136 virtual double mean_tile_area() const {return _dphi*_dy;};
137
138 /// returns a textual description of the grid
139 virtual std::string description() const;
140
141 /// returns the minimum rapidity extent of the grid
142 double rapmin() const {return _ymin;}
143 /// returns the maxmium rapidity extent of the grid
144 double rapmax() const {return _ymax;}
145 /// returns the spacing of the grid in rapidity
146 double drap() const {return _dy;}
147 /// returns the spacing of the grid in azimuth
148 double dphi() const {return _dphi;}
149
150 /// returns true if the grid is in a suitably initialised state
151 virtual bool is_initialised() const {return _ntotal > 0;}
152
153private:
154 void _setup_grid();
155
156 // information about the requested grid
157 double _ymax, _ymin; ///< maximal and minimal rapidity coverage of the grid
158 double _requested_drap; ///< requested rapidity spacing
159 double _requested_dphi; ///< requested phi spacing
160
161 // information about the actual grid
162 double _dy, _dphi, _cell_area, _inverse_dy, _inverse_dphi;
163 int _ny, _nphi, _ntotal;
164 int _ngood;
165
166 // a tile selector
167 Selector _tile_selector;
168 // if there's a tile selector, then for each tile, this caches the
169 // information about whether it is "good" i.e. it passes the tile
170 // selector
171 std::vector<bool> _is_good;
172
173};
174
175FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh
176
177#endif // __FASTJET_RECTANGULARGRID_HH__
Note: See TracBrowser for help on using the repository browser.