1 #ifndef __FASTJET_LAZYTILING9ALT_HH__
2 #define __FASTJET_LAZYTILING9ALT_HH__
35 #include "fastjet/internal/MinHeap.hh"
36 #include "fastjet/ClusterSequence.hh"
38 FASTJET_BEGIN_NAMESPACE
77 double eta, phi, kt2, NN_dist;
79 int _jets_index, tile_index;
80 bool _minheap_update_needed;
84 inline void label_minheap_update_needed() {_minheap_update_needed =
true;}
85 inline void label_minheap_update_done() {_minheap_update_needed =
false;}
86 inline bool minheap_update_needed()
const {
return _minheap_update_needed;}
89 const int n_tile_neighbours = 9;
93 typedef double (Tile::*DistToTileFn)(
const TiledJet*)
const;
94 typedef std::pair<Tile *, DistToTileFn> TileFnPair;
96 TileFnPair begin_tiles[n_tile_neighbours];
98 TileFnPair * surrounding_tiles;
100 TileFnPair * RH_tiles;
102 TileFnPair * end_tiles;
109 bool use_periodic_delta_phi;
113 double eta_min, eta_max, phi_min, phi_max;
115 double distance_to_centre(
const TiledJet *)
const {
return 0;}
116 double distance_to_left(
const TiledJet * jet)
const {
117 double deta = jet->eta - eta_min;
120 double distance_to_right(
const TiledJet * jet)
const {
121 double deta = jet->eta - eta_max;
124 double distance_to_bottom(
const TiledJet * jet)
const {
125 double dphi = jet->phi - phi_min;
128 double distance_to_top(
const TiledJet * jet)
const {
129 double dphi = jet->phi - phi_max;
133 double distance_to_left_top(
const TiledJet * jet)
const {
134 double deta = jet->eta - eta_min;
135 double dphi = jet->phi - phi_max;
136 return deta*deta + dphi*dphi;
138 double distance_to_left_bottom(
const TiledJet * jet)
const {
139 double deta = jet->eta - eta_min;
140 double dphi = jet->phi - phi_min;
141 return deta*deta + dphi*dphi;
143 double distance_to_right_top(
const TiledJet * jet)
const {
144 double deta = jet->eta - eta_max;
145 double dphi = jet->phi - phi_max;
146 return deta*deta + dphi*dphi;
148 double distance_to_right_bottom(
const TiledJet * jet)
const {
149 double deta = jet->eta - eta_max;
150 double dphi = jet->phi - phi_min;
151 return deta*deta + dphi*dphi;
158 class LazyTiling9Alt {
160 LazyTiling9Alt(ClusterSequence & cs);
168 ClusterSequence & _cs;
169 const std::vector<PseudoJet> & _jets;
170 std::vector<Tile> _tiles;
173 double _Rparam, _R2, _invR2;
174 double _tiles_eta_min, _tiles_eta_max;
175 double _tile_size_eta, _tile_size_phi;
176 double _tile_half_size_eta, _tile_half_size_phi;
177 int _n_tiles_phi,_tiles_ieta_min,_tiles_ieta_max;
179 std::vector<TiledJet *> _jets_for_minheap;
183 void _initialise_tiles();
187 inline int _tile_index (
int ieta,
int iphi)
const {
190 return (ieta-_tiles_ieta_min)*_n_tiles_phi
191 + (iphi+_n_tiles_phi) % _n_tiles_phi;
194 void _bj_remove_from_tiles(TiledJet *
const jet);
197 int _tile_index(
const double eta,
const double phi)
const;
200 void _tj_set_jetinfo(TiledJet *
const jet,
const int _jets_index);
202 void _print_tiles(TiledJet * briefjets )
const;
203 void _add_neighbours_to_tile_union(
const int tile_index,
204 std::vector<int> & tile_union,
int & n_near_tiles)
const;
205 void _add_untagged_neighbours_to_tile_union(
const int tile_index,
206 std::vector<int> & tile_union,
int & n_near_tiles);
207 void _add_untagged_neighbours_to_tile_union_using_max_info(
const TiledJet *
const jet,
208 std::vector<int> & tile_union,
int & n_near_tiles);
210 void _update_jetX_jetI_NN(TiledJet * jetX, TiledJet * jetI, std::vector<TiledJet *> & jets_for_minheap);
212 void _set_NN(TiledJet * jetI, std::vector<TiledJet *> & jets_for_minheap);
216 template <
class J>
double _bj_diJ(
const J *
const jet)
const {
217 double kt2 = jet->kt2;
218 if (jet->NN != NULL) {
if (jet->NN->kt2 < kt2) {kt2 = jet->NN->kt2;}}
219 return jet->NN_dist * kt2;
224 template <
class J>
inline void _bj_set_jetinfo(
225 J *
const jetA,
const int _jets_index)
const {
226 jetA->eta = _jets[_jets_index].rap();
227 jetA->phi = _jets[_jets_index].phi_02pi();
228 jetA->kt2 = _cs.jet_scale_for_algorithm(_jets[_jets_index]);
229 jetA->_jets_index = _jets_index;
237 template <
class J>
inline double _bj_dist(
238 const J *
const jetA,
const J *
const jetB)
const {
239 double dphi = std::abs(jetA->phi - jetB->phi);
240 double deta = (jetA->eta - jetB->eta);
241 if (dphi > pi) {dphi = twopi - dphi;}
242 return dphi*dphi + deta*deta;
247 template <
class J>
inline double _bj_dist_not_periodic(
248 const J *
const jetA,
const J *
const jetB)
const {
249 double dphi = jetA->phi - jetB->phi;
250 double deta = (jetA->eta - jetB->eta);
251 return dphi*dphi + deta*deta;
257 FASTJET_END_NAMESPACE
structure analogous to BriefJet, but with the extra information needed for dealing with tiles
const double tile_edge_security_margin
Rounding errors in the Lazy strategies may cause the following problem: when browsing tiles in the vi...