File indexing completed on 2025-01-18 09:57:15
0001 #ifndef __FASTJET_LAZYTILING9ALT_HH__
0002 #define __FASTJET_LAZYTILING9ALT_HH__
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #include "fastjet/internal/MinHeap.hh"
0036 #include "fastjet/ClusterSequence.hh"
0037
0038 FASTJET_BEGIN_NAMESPACE
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071 const double tile_edge_security_margin=1.0e-7;
0072
0073
0074
0075 class TiledJet {
0076 public:
0077 double eta, phi, kt2, NN_dist;
0078 TiledJet * NN, *previous, * next;
0079 int _jets_index, tile_index;
0080 bool _minheap_update_needed;
0081
0082
0083
0084 inline void label_minheap_update_needed() {_minheap_update_needed = true;}
0085 inline void label_minheap_update_done() {_minheap_update_needed = false;}
0086 inline bool minheap_update_needed() const {return _minheap_update_needed;}
0087 };
0088
0089 const int n_tile_neighbours = 9;
0090
0091 class Tile {
0092 public:
0093 typedef double (Tile::*DistToTileFn)(const TiledJet*) const;
0094 typedef std::pair<Tile *, DistToTileFn> TileFnPair;
0095
0096 TileFnPair begin_tiles[n_tile_neighbours];
0097
0098 TileFnPair * surrounding_tiles;
0099
0100 TileFnPair * RH_tiles;
0101
0102 TileFnPair * end_tiles;
0103
0104 TiledJet * head;
0105
0106 bool tagged;
0107
0108
0109 bool use_periodic_delta_phi;
0110
0111
0112 double max_NN_dist;
0113 double eta_min, eta_max, phi_min, phi_max;
0114
0115 double distance_to_centre(const TiledJet *) const {return 0;}
0116 double distance_to_left(const TiledJet * jet) const {
0117 double deta = jet->eta - eta_min;
0118 return deta*deta;
0119 }
0120 double distance_to_right(const TiledJet * jet) const {
0121 double deta = jet->eta - eta_max;
0122 return deta*deta;
0123 }
0124 double distance_to_bottom(const TiledJet * jet) const {
0125 double dphi = jet->phi - phi_min;
0126 return dphi*dphi;
0127 }
0128 double distance_to_top(const TiledJet * jet) const {
0129 double dphi = jet->phi - phi_max;
0130 return dphi*dphi;
0131 }
0132
0133 double distance_to_left_top(const TiledJet * jet) const {
0134 double deta = jet->eta - eta_min;
0135 double dphi = jet->phi - phi_max;
0136 return deta*deta + dphi*dphi;
0137 }
0138 double distance_to_left_bottom(const TiledJet * jet) const {
0139 double deta = jet->eta - eta_min;
0140 double dphi = jet->phi - phi_min;
0141 return deta*deta + dphi*dphi;
0142 }
0143 double distance_to_right_top(const TiledJet * jet) const {
0144 double deta = jet->eta - eta_max;
0145 double dphi = jet->phi - phi_max;
0146 return deta*deta + dphi*dphi;
0147 }
0148 double distance_to_right_bottom(const TiledJet * jet) const {
0149 double deta = jet->eta - eta_max;
0150 double dphi = jet->phi - phi_min;
0151 return deta*deta + dphi*dphi;
0152 }
0153
0154
0155 };
0156
0157
0158 class LazyTiling9Alt {
0159 public:
0160 LazyTiling9Alt(ClusterSequence & cs);
0161
0162 void run();
0163
0164
0165
0166
0167 protected:
0168 ClusterSequence & _cs;
0169 const std::vector<PseudoJet> & _jets;
0170 std::vector<Tile> _tiles;
0171
0172
0173 double _Rparam, _R2, _invR2;
0174 double _tiles_eta_min, _tiles_eta_max;
0175 double _tile_size_eta, _tile_size_phi;
0176 double _tile_half_size_eta, _tile_half_size_phi;
0177 int _n_tiles_phi,_tiles_ieta_min,_tiles_ieta_max;
0178
0179 std::vector<TiledJet *> _jets_for_minheap;
0180
0181
0182
0183 void _initialise_tiles();
0184
0185
0186
0187 inline int _tile_index (int ieta, int iphi) const {
0188
0189
0190 return (ieta-_tiles_ieta_min)*_n_tiles_phi
0191 + (iphi+_n_tiles_phi) % _n_tiles_phi;
0192 }
0193
0194 void _bj_remove_from_tiles(TiledJet * const jet);
0195
0196
0197 int _tile_index(const double eta, const double phi) const;
0198
0199
0200 void _tj_set_jetinfo(TiledJet * const jet, const int _jets_index);
0201
0202 void _print_tiles(TiledJet * briefjets ) const;
0203 void _add_neighbours_to_tile_union(const int tile_index,
0204 std::vector<int> & tile_union, int & n_near_tiles) const;
0205 void _add_untagged_neighbours_to_tile_union(const int tile_index,
0206 std::vector<int> & tile_union, int & n_near_tiles);
0207 void _add_untagged_neighbours_to_tile_union_using_max_info(const TiledJet * const jet,
0208 std::vector<int> & tile_union, int & n_near_tiles);
0209
0210 void _update_jetX_jetI_NN(TiledJet * jetX, TiledJet * jetI, std::vector<TiledJet *> & jets_for_minheap);
0211
0212 void _set_NN(TiledJet * jetI, std::vector<TiledJet *> & jets_for_minheap);
0213
0214
0215
0216 template <class J> double _bj_diJ(const J * const jet) const {
0217 double kt2 = jet->kt2;
0218 if (jet->NN != NULL) {if (jet->NN->kt2 < kt2) {kt2 = jet->NN->kt2;}}
0219 return jet->NN_dist * kt2;
0220 }
0221
0222
0223
0224 template <class J> inline void _bj_set_jetinfo(
0225 J * const jetA, const int _jets_index) const {
0226 jetA->eta = _jets[_jets_index].rap();
0227 jetA->phi = _jets[_jets_index].phi_02pi();
0228 jetA->kt2 = _cs.jet_scale_for_algorithm(_jets[_jets_index]);
0229 jetA->_jets_index = _jets_index;
0230
0231 jetA->NN_dist = _R2;
0232 jetA->NN = NULL;
0233 }
0234
0235
0236
0237 template <class J> inline double _bj_dist(
0238 const J * const jetA, const J * const jetB) const {
0239 double dphi = std::abs(jetA->phi - jetB->phi);
0240 double deta = (jetA->eta - jetB->eta);
0241 if (dphi > pi) {dphi = twopi - dphi;}
0242 return dphi*dphi + deta*deta;
0243 }
0244
0245
0246
0247 template <class J> inline double _bj_dist_not_periodic(
0248 const J * const jetA, const J * const jetB) const {
0249 double dphi = jetA->phi - jetB->phi;
0250 double deta = (jetA->eta - jetB->eta);
0251 return dphi*dphi + deta*deta;
0252 }
0253
0254 };
0255
0256
0257 FASTJET_END_NAMESPACE
0258
0259 #endif