00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef DROP_CGAL // in case we do not have the code for CGAL
00033 #ifndef __FASTJET_DNN3PICYLINDER_HH__
00034 #define __FASTJET_DNN3PICYLINDER_HH__
00035
00036 #include "fastjet/internal/DynamicNearestNeighbours.hh"
00037 #include "fastjet/internal/DnnPlane.hh"
00038 #include "fastjet/internal/numconsts.hh"
00039
00040 FASTJET_BEGIN_NAMESPACE
00041
00049 class Dnn3piCylinder : public DynamicNearestNeighbours {
00050 public:
00052 Dnn3piCylinder() {}
00053
00068 Dnn3piCylinder(const std::vector<EtaPhi> &,
00069 const bool & ignore_nearest_is_mirror = false,
00070 const bool & verbose = false );
00071
00074 int NearestNeighbourIndex(const int & ii) const ;
00075
00078 double NearestNeighbourDistance(const int & ii) const ;
00079
00083 bool Valid(const int & index) const;
00084
00085 void RemoveAndAddPoints(const std::vector<int> & indices_to_remove,
00086 const std::vector<EtaPhi> & points_to_add,
00087 std::vector<int> & indices_added,
00088 std::vector<int> & indices_of_updated_neighbours);
00089
00090 ~Dnn3piCylinder();
00091
00092 private:
00093
00094
00095 const static int INEXISTENT_VERTEX=-3;
00096
00097 bool _verbose;
00098
00099 bool _ignore_nearest_is_mirror;
00100
00137
00139 struct MirrorVertexInfo {
00144 int main_index;
00147 int mirror_index;
00148 };
00149
00150
00151
00152 std::vector<MirrorVertexInfo> _mirror_info;
00153
00154
00155
00156 std::vector<int> _cylinder_index_of_plane_vertex;
00157
00158
00159
00160
00161
00162 DnnPlane * _DNN;
00163
00166 inline EtaPhi _remap_phi(const EtaPhi & point) {
00167 double phi = point.second;
00168 if (phi < pi) { phi += twopi ;}
00169 return EtaPhi(point.first, phi);}
00170
00171
00172
00191 void _RegisterCylinderPoint (const EtaPhi & cylinder_point,
00192 std::vector<EtaPhi> & plane_points);
00193 };
00194
00195
00196
00197
00198
00199
00208 inline int Dnn3piCylinder::NearestNeighbourIndex(const int & current) const {
00209 int main_index = _mirror_info[current].main_index;
00210 int mirror_index = _mirror_info[current].mirror_index;
00211 int plane_index;
00212 if (mirror_index == INEXISTENT_VERTEX ) {
00213 plane_index = _DNN->NearestNeighbourIndex(main_index);
00214 } else {
00215 plane_index = (
00216 _DNN->NearestNeighbourDistance(main_index) <
00217 _DNN->NearestNeighbourDistance(mirror_index)) ?
00218 _DNN->NearestNeighbourIndex(main_index) :
00219 _DNN->NearestNeighbourIndex(mirror_index) ;
00220 }
00221 int this_cylinder_index = _cylinder_index_of_plane_vertex[plane_index];
00222
00223
00224
00225 assert(_ignore_nearest_is_mirror || this_cylinder_index != current);
00226
00227
00228
00229
00230 return this_cylinder_index;
00231 }
00232
00233 inline double Dnn3piCylinder::NearestNeighbourDistance(const int & current) const {
00234 int main_index = _mirror_info[current].main_index;
00235 int mirror_index = _mirror_info[current].mirror_index;
00236 if (mirror_index == INEXISTENT_VERTEX ) {
00237 return _DNN->NearestNeighbourDistance(main_index);
00238 } else {
00239 return (
00240 _DNN->NearestNeighbourDistance(main_index) <
00241 _DNN->NearestNeighbourDistance(mirror_index)) ?
00242 _DNN->NearestNeighbourDistance(main_index) :
00243 _DNN->NearestNeighbourDistance(mirror_index) ;
00244 }
00245
00246 }
00247
00248 inline bool Dnn3piCylinder::Valid(const int & index) const {
00249 return (_DNN->Valid(_mirror_info[index].main_index));
00250 }
00251
00252
00253 inline Dnn3piCylinder::~Dnn3piCylinder() {
00254 delete _DNN;
00255 }
00256
00257
00258 FASTJET_END_NAMESPACE
00259
00260 #endif // __FASTJET_DNN3PICYLINDER_HH__
00261 #endif // DROP_CGAL