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
00049 class DnnPlane : public DynamicNearestNeighbours {
00050 public:
00052 DnnPlane() {}
00053
00056 DnnPlane(const std::vector<EtaPhi> &, const bool & verbose = false );
00057
00058
00061 int NearestNeighbourIndex(const int & ii) const ;
00062
00065 double NearestNeighbourDistance(const int & ii) const ;
00066
00070 bool Valid(const int & index) const;
00071
00072 void RemoveAndAddPoints(const std::vector<int> & indices_to_remove,
00073 const std::vector<EtaPhi> & points_to_add,
00074 std::vector<int> & indices_added,
00075 std::vector<int> & indices_of_updated_neighbours);
00076
00078 EtaPhi etaphi(const int i) const;
00080 double eta(const int i) const;
00082 double phi(const int i) const;
00083
00084 private:
00085
00088 struct SuperVertex {
00089 Vertex_handle vertex;
00090 double NNdistance;
00091 int NNindex;
00092
00093 };
00094
00095 std::vector<SuperVertex> _supervertex;
00096
00097 bool _verbose;
00098
00099 static const bool _crash_on_coincidence = true;
00100
00101
00102 Triangulation _TR;
00103
00106 inline double _euclid_distance(const Point& p1, const Point& p2) const {
00107 double distx= p1.x()-p2.x();
00108 double disty= p1.y()-p2.y();
00109 return distx*distx+disty*disty;
00110 }
00111
00112
00115 void _SetNearest(const int & j);
00116
00117
00127 void _SetAndUpdateNearest(const int & j,
00128 std::vector<int> & indices_of_updated_neighbours);
00129
00133 void _CrashIfVertexPresent(const Vertex_handle & vertex,
00134 const int & its_index);
00135
00136 };
00137
00138
00139
00140
00141
00142 inline int DnnPlane::NearestNeighbourIndex(const int & ii) const {
00143 return _supervertex[ii].NNindex;}
00144
00145 inline double DnnPlane::NearestNeighbourDistance(const int & ii) const {
00146 return _supervertex[ii].NNdistance;}
00147
00148 inline bool DnnPlane::Valid(const int & index) const {
00149 if (index >= 0 && index < static_cast<int>(_supervertex.size())) {
00150 return (_supervertex[index].vertex != NULL);} else {return false;} }
00151
00152 inline EtaPhi DnnPlane::etaphi(const int i) const {
00153 Point * p = & (_supervertex[i].vertex->point());
00154 return EtaPhi(p->x(),p->y()); }
00155
00156 inline double DnnPlane::eta(const int i) const {
00157 return _supervertex[i].vertex->point().x(); }
00158
00159 inline double DnnPlane::phi(const int i) const {
00160 return _supervertex[i].vertex->point().y(); }
00161
00162
00163 FASTJET_END_NAMESPACE
00164
00165 #endif // __FASTJET_DNNPLANE_HH__
00166
00167 #endif // DROP_CGAL