|
||||
File indexing completed on 2025-01-18 09:57:18
0001 #ifndef __FASTJET_RECTANGULARGRID_HH__ 0002 #define __FASTJET_RECTANGULARGRID_HH__ 0003 0004 //FJSTARTHEADER 0005 // $Id$ 0006 // 0007 // Copyright (c) 2005-2021, Matteo Cacciari, Gavin P. Salam and Gregory Soyez 0008 // 0009 //---------------------------------------------------------------------- 0010 // This file is part of FastJet. 0011 // 0012 // FastJet is free software; you can redistribute it and/or modify 0013 // it under the terms of the GNU General Public License as published by 0014 // the Free Software Foundation; either version 2 of the License, or 0015 // (at your option) any later version. 0016 // 0017 // The algorithms that underlie FastJet have required considerable 0018 // development. They are described in the original FastJet paper, 0019 // hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use 0020 // FastJet as part of work towards a scientific publication, please 0021 // quote the version you use and include a citation to the manual and 0022 // optionally also to hep-ph/0512210. 0023 // 0024 // FastJet is distributed in the hope that it will be useful, 0025 // but WITHOUT ANY WARRANTY; without even the implied warranty of 0026 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0027 // GNU General Public License for more details. 0028 // 0029 // You should have received a copy of the GNU General Public License 0030 // along with FastJet. If not, see <http://www.gnu.org/licenses/>. 0031 //---------------------------------------------------------------------- 0032 //FJENDHEADER 0033 0034 #include "fastjet/PseudoJet.hh" 0035 #include "fastjet/Selector.hh" 0036 0037 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh 0038 0039 0040 //---------------------------------------------------------------------- 0041 /// Class to indicate generic structure of tilings 0042 class TilingBase { 0043 public: 0044 /// returns the index of the tile in which p is located, or -1 if p 0045 /// is outside the tiling region 0046 virtual int tile_index(const PseudoJet & p) const = 0; 0047 0048 /// returns the total number of tiles in the tiling; valid tile 0049 /// indices run from 0 ... n_tiles()-1; 0050 virtual int n_tiles() const = 0; 0051 0052 /// returns the number of tiles that are "good"; i.e. there is scope 0053 /// for having tiles that, for whatever reason, should be ignored; 0054 /// there are situations in which having "non-good" tiles may be the 0055 /// simplest mechanism to obtain a tiling with holes in it 0056 virtual int n_good_tiles() const {return n_tiles();} 0057 0058 /// returns whether a given tile is good 0059 virtual bool tile_is_good(int /* itile */) const {return true;} 0060 0061 /// returns whether all tiles are good 0062 virtual bool all_tiles_good() const {return n_good_tiles() == n_tiles();} 0063 0064 /// returns true if all tiles have the same area 0065 virtual bool all_tiles_equal_area() const {return true;} 0066 0067 /// returns the area of tile itile. Here with a default 0068 /// implementation to return mean_tile_area(), consistent with the 0069 /// fact that all_tiles_equal_area() returns true. 0070 virtual double tile_area(int /* itile */) const {return mean_tile_area();} 0071 0072 /// returns the mean area of the tiles. 0073 virtual double mean_tile_area() const = 0; 0074 0075 /// returns a string to describe the tiling 0076 virtual std::string description() const = 0; 0077 0078 /// returns true if the Tiling structure is in a suitably initialised state 0079 virtual bool is_initialised() const = 0; 0080 bool is_initialized() const {return is_initialised();} 0081 0082 /// virtual destructor 0083 virtual ~TilingBase() {} 0084 }; 0085 0086 //---------------------------------------------------------------------- 0087 /// Class that holds a generic rectangular tiling 0088 class RectangularGrid : public TilingBase { 0089 public: 0090 /// ctor with simple initialisation 0091 /// \param rapmax the maximal absolute rapidity extent of the grid 0092 /// \param cell_size the grid spacing (equivalently, cell size) 0093 RectangularGrid(double rapmax_in, double cell_size) : 0094 _ymax(rapmax_in), _ymin(-rapmax_in), 0095 _requested_drap(cell_size), _requested_dphi(cell_size) { 0096 _setup_grid(); 0097 } 0098 0099 /// ctor with more control over initialisation 0100 /// \param rapmin the minimum rapidity extent of the grid 0101 /// \param rapmax the maximum rapidity extent of the grid 0102 /// \param drap the grid spacing in rapidity 0103 /// \param dphi the grid spacing in azimuth 0104 /// \param tile_selector optional (geometric) selector to specify 0105 /// which tiles are good; a tile is good if 0106 /// a massless 4-vector at the center of the tile passes 0107 /// the selection 0108 RectangularGrid(double rapmin_in, double rapmax_in, double drap_in, double dphi_in, 0109 Selector tile_selector = Selector()) 0110 : _ymax(rapmax_in), _ymin(rapmin_in), 0111 _requested_drap(drap_in), _requested_dphi(dphi_in), 0112 _tile_selector(tile_selector) 0113 { 0114 _setup_grid(); 0115 } 0116 0117 /// dummy ctor (will give an unusable grid) 0118 RectangularGrid(); 0119 0120 virtual int n_tiles() const FASTJET_OVERRIDE {return _ntotal;} 0121 0122 virtual int n_good_tiles() const FASTJET_OVERRIDE {return _ngood;} 0123 0124 // this was being kept inline, but it seems to make little 0125 // difference whether it is or not (at least on Gavin's mac) 0126 virtual int tile_index(const PseudoJet & p) const FASTJET_OVERRIDE; 0127 0128 /// returns whether a given tile is good 0129 // tested in "issue" 2014-08-08-testing-rect-grid 0130 virtual bool tile_is_good(int itile) const FASTJET_OVERRIDE{ 0131 return _tile_selector.worker() ? _is_good[itile] : true; 0132 } 0133 0134 /// returns the area of tile itile. 0135 virtual double tile_area(int /* itile */) const FASTJET_OVERRIDE{ 0136 return mean_tile_area(); 0137 } 0138 0139 /// returns the mean area of tiles. 0140 virtual double mean_tile_area() const FASTJET_OVERRIDE { return _dphi*_dy; } 0141 0142 /// returns a textual description of the grid 0143 virtual std::string description() const FASTJET_OVERRIDE; 0144 0145 /// returns the minimum rapidity extent of the grid 0146 double rapmin() const {return _ymin;} 0147 /// returns the maxmium rapidity extent of the grid 0148 double rapmax() const {return _ymax;} 0149 /// returns the spacing of the grid in rapidity 0150 double drap() const {return _dy;} 0151 /// returns the spacing of the grid in azimuth 0152 double dphi() const {return _dphi;} 0153 0154 /// returns true if the grid is in a suitably initialised state 0155 virtual bool is_initialised() const FASTJET_OVERRIDE { return _ntotal > 0; } 0156 0157 private: 0158 void _setup_grid(); 0159 0160 // information about the requested grid 0161 double _ymax, _ymin; ///< maximal and minimal rapidity coverage of the grid 0162 double _requested_drap; ///< requested rapidity spacing 0163 double _requested_dphi; ///< requested phi spacing 0164 0165 // information about the actual grid 0166 double _dy, _dphi, _cell_area, _inverse_dy, _inverse_dphi; 0167 int _ny, _nphi, _ntotal; 0168 int _ngood; 0169 0170 // a tile selector 0171 Selector _tile_selector; 0172 // if there's a tile selector, then for each tile, this caches the 0173 // information about whether it is "good" i.e. it passes the tile 0174 // selector 0175 std::vector<bool> _is_good; 0176 0177 }; 0178 0179 FASTJET_END_NAMESPACE // defined in fastjet/internal/base.hh 0180 0181 #endif // __FASTJET_RECTANGULARGRID_HH__
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |