Changes in external/fastjet/internal/DnnPlane.hh [d7d2da3:35cdc46] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
external/fastjet/internal/DnnPlane.hh
rd7d2da3 r35cdc46 1 // STARTHEADER2 // $Id: DnnPlane.hh 2577 2011-09-13 15:11:38Z salam $3 // 4 // Copyright (c) 2005-201 1, Matteo Cacciari, Gavin P. Salam and Gregory Soyez1 //FJSTARTHEADER 2 // $Id: DnnPlane.hh 3442 2014-07-24 07:20:49Z salam $ 3 // 4 // Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez 5 5 // 6 6 //---------------------------------------------------------------------- … … 13 13 // 14 14 // The algorithms that underlie FastJet have required considerable 15 // development and are described in hep-ph/0512210. If you use 15 // development. They are described in the original FastJet paper, 16 // hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use 16 17 // FastJet as part of work towards a scientific publication, please 17 // include a citation to the FastJet paper. 18 // quote the version you use and include a citation to the manual and 19 // optionally also to hep-ph/0512210. 18 20 // 19 21 // FastJet is distributed in the hope that it will be useful, … … 25 27 // along with FastJet. If not, see <http://www.gnu.org/licenses/>. 26 28 //---------------------------------------------------------------------- 27 // ENDHEADER29 //FJENDHEADER 28 30 29 31 … … 44 46 /// class derived from DynamicNearestNeighbours that provides an 45 47 /// implementation for the Euclidean plane 48 /// 49 /// This class that uses CGAL Delaunay triangulation for most of the 50 /// work (it allows for easy and efficient removal and addition of 51 /// points and circulation over a point's neighbours). The treatment 52 /// of coincident points is not supported by CGAL and is implemented 53 /// according to the method specified in 54 /// issue-tracker/2012-02-CGAL-coincident/METHOD 46 55 /// \endif 47 56 class DnnPlane : public DynamicNearestNeighbours { … … 57 66 /// Returns the index of the nearest neighbour of point labelled 58 67 /// by ii (assumes ii is valid) 59 int NearestNeighbourIndex(const int &ii) const ;68 int NearestNeighbourIndex(const int ii) const ; 60 69 61 70 /// Returns the distance to the nearest neighbour of point labelled 62 71 /// by index ii (assumes ii is valid) 63 double NearestNeighbourDistance(const int &ii) const ;72 double NearestNeighbourDistance(const int ii) const ; 64 73 65 74 /// Returns true iff the given index corresponds to a point that 66 75 /// exists in the DNN structure (meaning that it has been added, and 67 76 /// not removed in the meantime) 68 bool Valid(const int &index) const;77 bool Valid(const int index) const; 69 78 70 79 void RemoveAndAddPoints(const std::vector<int> & indices_to_remove, … … 80 89 double phi(const int i) const; 81 90 82 91 private: 83 92 84 93 /// Structure containing a vertex_handle and cached information on … … 88 97 double NNdistance; 89 98 int NNindex; 99 int coincidence; // ==vertex->info.val() if no coincidence 100 // points to the coinciding SV in case of coincidence 90 101 // later on for cylinder put a second vertex? 91 102 }; … … 95 106 bool _verbose; 96 107 97 static const bool _crash_on_coincidence = true;98 //static const bool _crash_on_coincidence = false;108 //static const bool _crash_on_coincidence = true; 109 static const bool _crash_on_coincidence = false; 99 110 100 111 Triangulation _TR; /// CGAL object for dealing with triangulations … … 111 122 /// Determines the index and distance of the nearest neighbour to 112 123 /// point j and puts the information into the _supervertex entry for j 113 void _SetNearest(const int &j);124 void _SetNearest(const int j); 114 125 115 126 //---------------------------------------------------------------------- … … 123 134 /// Note that j is NOT pushed onto indices_of_updated_neighbours -- 124 135 /// if you want it there, put it there yourself. 125 void _SetAndUpdateNearest(const int &j,136 void _SetAndUpdateNearest(const int j, 126 137 std::vector<int> & indices_of_updated_neighbours); 127 138 128 139 /// given a vertex_handle returned by CGAL on insertion of a new 129 /// points, crash if it turns out that it corresponds to a vertex 130 /// that we already knew about (usually because two points coincide) 131 void _CrashIfVertexPresent(const Vertex_handle & vertex, 132 const int & its_index); 133 140 /// points, returns the coinciding vertex's value if it turns out 141 /// that it corresponds to a vertex that we already knew about 142 /// (usually because two points coincide) 143 int _CheckIfVertexPresent(const Vertex_handle & vertex, 144 const int its_index); 145 146 //---------------------------------------------------------------------- 147 /// if the distance between 'pref' and 'candidate' is smaller (or 148 /// equal) than the one between 'pref' and 'near', return true and 149 /// set 'mindist' to that distance. Note that it is assumed that 150 /// 'mindist' is the euclidian distance between 'pref' and 'near' 151 /// 152 /// Note that the 'near' point is passed through its vertex rather 153 /// than as a point. This allows us to handle cases where we have no min 154 /// yet (near is the infinite vertex) 155 inline bool _is_closer_to(const Point &pref, 156 const Point &candidate, 157 const Vertex_handle &near, 158 double & dist, 159 double & mindist){ 160 dist = _euclid_distance(pref, candidate); 161 return _is_closer_to_with_hint(pref, candidate, near, dist, mindist); 162 } 163 164 /// same as '_is_closer_to' except that 'dist' already contains the 165 /// distance between 'pref' and 'candidate' 166 inline bool _is_closer_to_with_hint(const Point &pref, 167 const Point &candidate, 168 const Vertex_handle &near, 169 const double & dist, 170 double & mindist){ 171 172 // check if 'dist', the pre-computed distance between 'candidate' 173 // and 'pref' is smaller than the distance between 'pref' and its 174 // currently registered nearest neighbour 'near' (and update 175 // things if it is) 176 // 177 // Interestingly enough, it has to be pointed out that the use of 178 // 'abs' instead of 'std::abs' returns wrong results (apparently 179 // ints without any compiler warning) 180 // 181 // The (near != NULL) test is there for one single reason: when 182 // checking that a newly inserted point is not closer than a 183 // previous NN, if that distance comparison involves a "nearly 184 // degenerate" distance we need to access near->point. But 185 // sometimes, in the course of RemoveAndAddPoints, its previous NN 186 // has been deleted and its vertex (corresponding to 'near') set 187 // to NULL. This is not a problem as all points having a deleted 188 // point as NN will have their NN explicitly recomputed at the end 189 // of RemoveAndAddPoints so here we should just make sure there is 190 // no crash... that's done by checking (near != NULL) 191 if ((std::abs(dist-mindist)<DISTANCE_FOR_CGAL_CHECKS) && 192 (near != NULL) && 193 (_euclid_distance(candidate, near->point())<DISTANCE_FOR_CGAL_CHECKS)){ 194 // we're in a situation where there might be a rounding issue, 195 // use CGAL's distance computation to get it right 196 // 197 // Note that in the test right above, 198 // (abs(dist-mindist)<1e-12) guarantees that the current 199 // nearest point is not the infinite vertex and thus 200 // nearest->point() is not ill-defined 201 if (_verbose) std::cout << "using CGAL's distance ordering" << std::endl; 202 if (CGAL::compare_distance_to_point(pref, candidate, near->point())!=CGAL::LARGER){ 203 mindist = dist; 204 return true; 205 } 206 } else if (dist <= mindist) { 207 // Note that the use of a <= in the above expression (instead of 208 // a strict ordering <) is important in one case: when checking 209 // if a new point is the new NN of one of the points in its 210 // neighbourhood, in case of distances being ==, we are sure 211 // that 'candidate' is in a cell adjacent to 'pref' while it may 212 // no longer be the case for 'near' 213 mindist = dist; 214 return true; 215 } 216 217 return false; 218 } 219 220 /// if a distance between a point and 2 others is smaller than this 221 /// and the distance between the two points is also smaller than this 222 /// then use CGAL to compare the distances. 223 static const double DISTANCE_FOR_CGAL_CHECKS; 224 134 225 }; 135 226 … … 138 229 // functions defined above 139 230 140 inline int DnnPlane::NearestNeighbourIndex(const int &ii) const {231 inline int DnnPlane::NearestNeighbourIndex(const int ii) const { 141 232 return _supervertex[ii].NNindex;} 142 233 143 inline double DnnPlane::NearestNeighbourDistance(const int &ii) const {234 inline double DnnPlane::NearestNeighbourDistance(const int ii) const { 144 235 return _supervertex[ii].NNdistance;} 145 236 146 inline bool DnnPlane::Valid(const int &index) const {237 inline bool DnnPlane::Valid(const int index) const { 147 238 if (index >= 0 && index < static_cast<int>(_supervertex.size())) { 148 239 return (_supervertex[index].vertex != NULL);} else {return false;} }
Note:
See TracChangeset
for help on using the changeset viewer.