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
00034 #ifndef __FASTJET_DNNPLANE_HH__
00035 #define __FASTJET_DNNPLANE_HH__
00036
00037 #include "fastjet/internal/Triangulation.hh"
00038 #include "fastjet/internal/DynamicNearestNeighbours.hh"
00039
00040 FASTJET_BEGIN_NAMESPACE
00041
00042
00045 class DnnPlane : public DynamicNearestNeighbours {
00046 public:
00048 DnnPlane() {}
00049
00052 DnnPlane(const std::vector<EtaPhi> &, const bool & verbose = false );
00053
00054
00057 int NearestNeighbourIndex(const int & ii) const ;
00058
00061 double NearestNeighbourDistance(const int & ii) const ;
00062
00066 bool Valid(const int & index) const;
00067
00068 void RemoveAndAddPoints(const std::vector<int> & indices_to_remove,
00069 const std::vector<EtaPhi> & points_to_add,
00070 std::vector<int> & indices_added,
00071 std::vector<int> & indices_of_updated_neighbours);
00072
00074 EtaPhi etaphi(const int i) const;
00076 double eta(const int i) const;
00078 double phi(const int i) const;
00079
00080 private:
00081
00084 struct SuperVertex {
00085 Vertex_handle vertex;
00086 double NNdistance;
00087 int NNindex;
00088
00089 };
00090
00091 std::vector<SuperVertex> _supervertex;
00092
00093 bool _verbose;
00094
00095 static const bool _crash_on_coincidence = true;
00096
00097
00098 Triangulation _TR;
00099
00102 inline double _euclid_distance(const Point& p1, const Point& p2) const {
00103 double distx= p1.x()-p2.x();
00104 double disty= p1.y()-p2.y();
00105 return distx*distx+disty*disty;
00106 }
00107
00108
00111 void _SetNearest(const int & j);
00112
00113
00123 void _SetAndUpdateNearest(const int & j,
00124 std::vector<int> & indices_of_updated_neighbours);
00125
00129 void _CrashIfVertexPresent(const Vertex_handle & vertex,
00130 const int & its_index);
00131
00132 };
00133
00134
00135
00136
00137
00138 inline int DnnPlane::NearestNeighbourIndex(const int & ii) const {
00139 return _supervertex[ii].NNindex;}
00140
00141 inline double DnnPlane::NearestNeighbourDistance(const int & ii) const {
00142 return _supervertex[ii].NNdistance;}
00143
00144 inline bool DnnPlane::Valid(const int & index) const {
00145 if (index >= 0 && index < static_cast<int>(_supervertex.size())) {
00146 return (_supervertex[index].vertex != NULL);} else {return false;} }
00147
00148 inline EtaPhi DnnPlane::etaphi(const int i) const {
00149 Point * p = & (_supervertex[i].vertex->point());
00150 return EtaPhi(p->x(),p->y()); }
00151
00152 inline double DnnPlane::eta(const int i) const {
00153 return _supervertex[i].vertex->point().x(); }
00154
00155 inline double DnnPlane::phi(const int i) const {
00156 return _supervertex[i].vertex->point().y(); }
00157
00158
00159 FASTJET_END_NAMESPACE
00160
00161 #endif // __FASTJET_DNNPLANE_HH__
00162
00163 #endif // DROP_CGAL