Fork me on GitHub

source: git/external/fastjet/internal/LazyTiling9.hh@ ededa33

ImprovedOutputFile Timing
Last change on this file since ededa33 was b7b836a, checked in by Pavel Demin <pavel-demin@…>, 6 years ago

update FastJet library to 3.3.1 and FastJet Contrib library to 1.036

  • Property mode set to 100644
File size: 7.6 KB
Line 
1#ifndef __FASTJET_LAZYTILING9_HH__
2#define __FASTJET_LAZYTILING9_HH__
3
4//#define INSTRUMENT2 1
5
6//FJSTARTHEADER
7// $Id: LazyTiling9.hh 4354 2018-04-22 07:12:37Z salam $
8//
9// Copyright (c) 2005-2018, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
10//
11//----------------------------------------------------------------------
12// This file is part of FastJet.
13//
14// FastJet is free software; you can redistribute it and/or modify
15// it under the terms of the GNU General Public License as published by
16// the Free Software Foundation; either version 2 of the License, or
17// (at your option) any later version.
18//
19// The algorithms that underlie FastJet have required considerable
20// development. They are described in the original FastJet paper,
21// hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
22// FastJet as part of work towards a scientific publication, please
23// quote the version you use and include a citation to the manual and
24// optionally also to hep-ph/0512210.
25//
26// FastJet is distributed in the hope that it will be useful,
27// but WITHOUT ANY WARRANTY; without even the implied warranty of
28// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29// GNU General Public License for more details.
30//
31// You should have received a copy of the GNU General Public License
32// along with FastJet. If not, see <http://www.gnu.org/licenses/>.
33//----------------------------------------------------------------------
34//FJENDHEADER
35
36//#include "fastjet/PseudoJet.hh"
37#include "fastjet/internal/MinHeap.hh"
38#include "fastjet/ClusterSequence.hh"
39#include "fastjet/internal/LazyTiling9Alt.hh"
40
41
42FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh
43template<int NN>
44class Tile2Base {
45public:
46 /// pointers to neighbouring tiles, including self
47 Tile2Base * begin_tiles[NN];
48 /// neighbouring tiles, excluding self
49 Tile2Base ** surrounding_tiles;
50 /// half of neighbouring tiles, no self
51 Tile2Base ** RH_tiles;
52 /// just beyond end of tiles
53 Tile2Base ** end_tiles;
54 /// start of list of BriefJets contained in this tile
55 TiledJet * head;
56 /// sometimes useful to be able to tag a tile
57 bool tagged;
58 /// true for tiles where the delta phi calculation needs
59 /// potentially to account for periodicity in phi
60 bool use_periodic_delta_phi;
61 /// for all particles in the tile, this stores the largest of the
62 /// (squared) nearest-neighbour distances.
63 double max_NN_dist;
64 double eta_centre, phi_centre;
65
66 /// returns the number of jets in the tile; useful principally for
67 /// diagnostics
68 int jet_count() const {
69 int count = 0;
70 const TiledJet * jet = head;
71 while (jet != 0) {
72 count++;
73 jet = jet->next;
74 }
75 return count;
76 }
77};
78
79
80typedef Tile2Base<9> Tile2;
81
82// class Tile2 : public Tile2Base {
83// public:
84// /// pointers to neighbouring tiles, including self
85// Tile2 * begin_tiles[n_tile_neighbours];
86// bool is_near_zero_phi(double tile_size_phi) const {
87// return phi_centre < tile_size_phi || (twopi-phi_centre) < tile_size_phi;
88// }
89// };
90
91// class Tile2 {
92// public:
93// /// pointers to neighbouring tiles, including self
94// Tile2 * begin_tiles[n_tile_neighbours];
95// /// neighbouring tiles, excluding self
96// Tile2 ** surrounding_tiles;
97// /// half of neighbouring tiles, no self
98// Tile2 ** RH_tiles;
99// /// just beyond end of tiles
100// Tile2 ** end_tiles;
101// /// start of list of BriefJets contained in this tile
102// TiledJet * head;
103// /// sometimes useful to be able to tag a tile
104// bool tagged;
105// /// for all particles in the tile, this stores the largest of the
106// /// (squared) nearest-neighbour distances.
107// double max_NN_dist;
108// double eta_centre, phi_centre;
109// bool is_near_zero_phi(double tile_size_phi) const {
110// return phi_centre < tile_size_phi || (twopi-phi_centre) < tile_size_phi;
111// }
112// };
113
114
115
116//----------------------------------------------------------------------
117class LazyTiling9 {
118public:
119 LazyTiling9(ClusterSequence & cs);
120
121 void run();
122
123 //void get_next_clustering(int & jetA_index, int & jetB_index, double & dij);
124
125
126protected:
127 ClusterSequence & _cs;
128 const std::vector<PseudoJet> & _jets;
129 std::vector<Tile2> _tiles;
130
131#ifdef INSTRUMENT2
132 int _ncall; // GPS tmp
133 int _ncall_dtt; // GPS tmp
134#endif // INSTRUMENT2
135
136 double _Rparam, _R2, _invR2;
137 double _tiles_eta_min, _tiles_eta_max;
138 double _tile_size_eta, _tile_size_phi;
139 double _tile_half_size_eta, _tile_half_size_phi;
140 int _n_tiles_phi,_tiles_ieta_min,_tiles_ieta_max;
141
142 std::vector<TiledJet *> _jets_for_minheap;
143
144 //MinHeap _minheap;
145
146 void _initialise_tiles();
147
148 // reasonably robust return of tile index given ieta and iphi, in particular
149 // it works even if iphi is negative
150 inline int _tile_index (int ieta, int iphi) const {
151 // note that (-1)%n = -1 so that we have to add _n_tiles_phi
152 // before performing modulo operation
153 return (ieta-_tiles_ieta_min)*_n_tiles_phi
154 + (iphi+_n_tiles_phi) % _n_tiles_phi;
155 }
156
157 void _bj_remove_from_tiles(TiledJet * const jet);
158
159 /// returns the tile index given the eta and phi values of a jet
160 int _tile_index(const double eta, const double phi) const;
161
162 // sets up information regarding the tiling of the given jet
163 void _tj_set_jetinfo(TiledJet * const jet, const int _jets_index);
164
165 void _print_tiles(TiledJet * briefjets ) const;
166 void _add_neighbours_to_tile_union(const int tile_index,
167 std::vector<int> & tile_union, int & n_near_tiles) const;
168 void _add_untagged_neighbours_to_tile_union(const int tile_index,
169 std::vector<int> & tile_union, int & n_near_tiles);
170 void _add_untagged_neighbours_to_tile_union_using_max_info(const TiledJet * const jet,
171 std::vector<int> & tile_union, int & n_near_tiles);
172 double _distance_to_tile(const TiledJet * bj, const Tile2 *)
173#ifdef INSTRUMENT2
174 ;
175#else
176 const;
177#endif
178 void _update_jetX_jetI_NN(TiledJet * jetX, TiledJet * jetI, std::vector<TiledJet *> & jets_for_minheap);
179
180 void _set_NN(TiledJet * jetI, std::vector<TiledJet *> & jets_for_minheap);
181
182 // return the diJ (multiplied by _R2) for this jet assuming its NN
183 // info is correct
184 template <class J> double _bj_diJ(const J * const jet) const {
185 double kt2 = jet->kt2;
186 if (jet->NN != NULL) {if (jet->NN->kt2 < kt2) {kt2 = jet->NN->kt2;}}
187 return jet->NN_dist * kt2;
188 }
189
190
191 //----------------------------------------------------------------------
192 template <class J> inline void _bj_set_jetinfo(
193 J * const jetA, const int _jets_index) const {
194 jetA->eta = _jets[_jets_index].rap();
195 jetA->phi = _jets[_jets_index].phi_02pi();
196 jetA->kt2 = _cs.jet_scale_for_algorithm(_jets[_jets_index]);
197 jetA->_jets_index = _jets_index;
198 // initialise NN info as well
199 jetA->NN_dist = _R2;
200 jetA->NN = NULL;
201 }
202
203
204 //----------------------------------------------------------------------
205 template <class J> inline double _bj_dist(
206 const J * const jetA, const J * const jetB)
207#ifdef INSTRUMENT2
208 {
209 _ncall++; // GPS tmp
210#else
211 const {
212#endif
213 double dphi = std::abs(jetA->phi - jetB->phi);
214 double deta = (jetA->eta - jetB->eta);
215 if (dphi > pi) {dphi = twopi - dphi;}
216 return dphi*dphi + deta*deta;
217 }
218
219
220 //----------------------------------------------------------------------
221 template <class J> inline double _bj_dist_not_periodic(
222 const J * const jetA, const J * const jetB)
223#ifdef INSTRUMENT2
224 {
225 _ncall++; // GPS tmp
226#else
227 const {
228#endif
229 //_ncall++; // GPS tmp
230 double dphi = jetA->phi - jetB->phi;
231 double deta = (jetA->eta - jetB->eta);
232 return dphi*dphi + deta*deta;
233 }
234
235};
236
237
238FASTJET_END_NAMESPACE
239
240#endif // __FASTJET_LAZYTILING9_HH__
Note: See TracBrowser for help on using the repository browser.