#include <DnnPlane.hh>
Inheritance diagram for fastjet::DnnPlane:
Public Member Functions | |
DnnPlane () | |
empty initaliser | |
DnnPlane (const std::vector< EtaPhi > &, const bool &verbose=false) | |
Initialiser from a set of points on an Eta-Phi plane, where both eta and phi can have arbitrary ranges. | |
int | NearestNeighbourIndex (const int &ii) const |
Returns the index of the nearest neighbour of point labelled by ii (assumes ii is valid). | |
double | NearestNeighbourDistance (const int &ii) const |
Returns the distance to the nearest neighbour of point labelled by index ii (assumes ii is valid). | |
bool | Valid (const int &index) const |
Returns true iff the given index corresponds to a point that exists in the DNN structure (meaning that it has been added, and not removed in the meantime). | |
void | RemoveAndAddPoints (const std::vector< int > &indices_to_remove, const std::vector< EtaPhi > &points_to_add, std::vector< int > &indices_added, std::vector< int > &indices_of_updated_neighbours) |
remove the points labelled by the std::vector indices_to_remove, and add the points specified by the std::vector points_to_add (corresponding indices will be calculated automatically); the idea behind this routine is that the points to be added will somehow be close to the one or other of the points being removed and this can be used by the implementation to provide hints for inserting the new points in whatever structure it is using. | |
EtaPhi | etaphi (const int i) const |
returns the EtaPhi of point with index i. | |
double | eta (const int i) const |
returns the eta point with index i. | |
double | phi (const int i) const |
returns the phi point with index i. | |
Private Member Functions | |
double | _euclid_distance (const Point &p1, const Point &p2) const |
calculates and returns the euclidean distance between points p1 and p2 | |
void | _SetNearest (const int &j) |
Determines the index and distance of the nearest neighbour to point j and puts the information into the _supervertex entry for j. | |
void | _SetAndUpdateNearest (const int &j, std::vector< int > &indices_of_updated_neighbours) |
Determines and stores the nearest neighbour of j. | |
void | _CrashIfVertexPresent (const Vertex_handle &vertex, const int &its_index) |
Crashes if the given vertex handle already exists. | |
Private Attributes | |
std::vector< SuperVertex > | _supervertex |
bool | _verbose |
Triangulation | _TR |
Static Private Attributes | |
static const bool | _crash_on_coincidence = true |
Classes | |
struct | SuperVertex |
Structure containing a vertex_handle and cached information on the nearest neighbour. More... |
Definition at line 45 of file DnnPlane.hh.
fastjet::DnnPlane::DnnPlane | ( | ) | [inline] |
fastjet::DnnPlane::DnnPlane | ( | const std::vector< EtaPhi > & | , | |
const bool & | verbose = false | |||
) |
Initialiser from a set of points on an Eta-Phi plane, where both eta and phi can have arbitrary ranges.
int fastjet::DnnPlane::NearestNeighbourIndex | ( | const int & | ii | ) | const [inline, virtual] |
Returns the index of the nearest neighbour of point labelled by ii (assumes ii is valid).
Implements fastjet::DynamicNearestNeighbours.
Definition at line 138 of file DnnPlane.hh.
References _supervertex.
Referenced by fastjet::Dnn4piCylinder::NearestNeighbourIndex(), fastjet::Dnn3piCylinder::NearestNeighbourIndex(), and fastjet::Dnn2piCylinder::NearestNeighbourIndex().
00138 { 00139 return _supervertex[ii].NNindex;}
double fastjet::DnnPlane::NearestNeighbourDistance | ( | const int & | ii | ) | const [inline, virtual] |
Returns the distance to the nearest neighbour of point labelled by index ii (assumes ii is valid).
Implements fastjet::DynamicNearestNeighbours.
Definition at line 141 of file DnnPlane.hh.
References _supervertex.
Referenced by fastjet::Dnn4piCylinder::NearestNeighbourDistance(), fastjet::Dnn3piCylinder::NearestNeighbourDistance(), fastjet::Dnn2piCylinder::NearestNeighbourDistance(), fastjet::Dnn4piCylinder::NearestNeighbourIndex(), fastjet::Dnn3piCylinder::NearestNeighbourIndex(), and fastjet::Dnn2piCylinder::NearestNeighbourIndex().
00141 { 00142 return _supervertex[ii].NNdistance;}
bool fastjet::DnnPlane::Valid | ( | const int & | index | ) | const [inline, virtual] |
Returns true iff the given index corresponds to a point that exists in the DNN structure (meaning that it has been added, and not removed in the meantime).
Implements fastjet::DynamicNearestNeighbours.
Definition at line 144 of file DnnPlane.hh.
References _supervertex.
Referenced by fastjet::Dnn4piCylinder::Valid(), fastjet::Dnn3piCylinder::Valid(), and fastjet::Dnn2piCylinder::Valid().
00144 { 00145 if (index >= 0 && index < static_cast<int>(_supervertex.size())) { 00146 return (_supervertex[index].vertex != NULL);} else {return false;} }
void fastjet::DnnPlane::RemoveAndAddPoints | ( | const std::vector< int > & | indices_to_remove, | |
const std::vector< EtaPhi > & | points_to_add, | |||
std::vector< int > & | indices_added, | |||
std::vector< int > & | indices_of_updated_neighbours | |||
) | [virtual] |
remove the points labelled by the std::vector indices_to_remove, and add the points specified by the std::vector points_to_add (corresponding indices will be calculated automatically); the idea behind this routine is that the points to be added will somehow be close to the one or other of the points being removed and this can be used by the implementation to provide hints for inserting the new points in whatever structure it is using.
In a kt-algorithm the points being added will be a result of a combination of the points to be removed -- hence the proximity is (more or less) guaranteed.
Implements fastjet::DynamicNearestNeighbours.
EtaPhi fastjet::DnnPlane::etaphi | ( | const int | i | ) | const [inline] |
returns the EtaPhi of point with index i.
Definition at line 148 of file DnnPlane.hh.
References _supervertex, fastjet::Point::x, and fastjet::Point::y.
00148 { 00149 Point * p = & (_supervertex[i].vertex->point()); 00150 return EtaPhi(p->x(),p->y()); }
double fastjet::DnnPlane::eta | ( | const int | i | ) | const [inline] |
returns the eta point with index i.
Definition at line 152 of file DnnPlane.hh.
References _supervertex.
00152 { 00153 return _supervertex[i].vertex->point().x(); }
double fastjet::DnnPlane::phi | ( | const int | i | ) | const [inline] |
returns the phi point with index i.
Definition at line 155 of file DnnPlane.hh.
References _supervertex.
00155 { 00156 return _supervertex[i].vertex->point().y(); }
double fastjet::DnnPlane::_euclid_distance | ( | const Point & | p1, | |
const Point & | p2 | |||
) | const [inline, private] |
calculates and returns the euclidean distance between points p1 and p2
Definition at line 102 of file DnnPlane.hh.
References fastjet::Point::x, and fastjet::Point::y.
Referenced by _SetNearest().
00102 { 00103 double distx= p1.x()-p2.x(); 00104 double disty= p1.y()-p2.y(); 00105 return distx*distx+disty*disty; 00106 }
void fastjet::DnnPlane::_SetNearest | ( | const int & | j | ) | [private] |
Determines the index and distance of the nearest neighbour to point j and puts the information into the _supervertex entry for j.
Definition at line 261 of file DnnPlane.cc.
References _euclid_distance(), _supervertex, _TR, _verbose, fastjet::HUGE_DOUBLE, and fastjet::INFINITE_VERTEX.
00261 { 00262 Vertex_handle current = _supervertex[j].vertex; 00263 Vertex_circulator vc = _TR.incident_vertices(current); 00264 Vertex_circulator done = vc; 00265 double dist; 00266 double mindist = HUGE_DOUBLE; // change this to "HUGE" or max_double? 00267 Vertex_handle nearest = _TR.infinite_vertex(); 00268 00269 // when there is only one finite point left in the triangulation, 00270 // there are no triangles. Presumably this is why voronoi returns 00271 // NULL for the incident vertex circulator. Check if this is 00272 // happening before circulating over it... (Otherwise it crashes 00273 // when looking for neighbours of last point) 00274 if (vc != NULL) do { 00275 if ( vc->info().val() != INFINITE_VERTEX) { 00276 // find distance between j and its Voronoi neighbour (vc) 00277 if (_verbose) cout << current->info().val() << " " << vc->info().val() << endl; 00278 dist = _euclid_distance(current->point(), vc->point()); 00279 // check if j is closer to vc than vc's currently registered 00280 // nearest neighbour (and update things if it is) 00281 if (dist < mindist) { 00282 mindist = dist; nearest = vc; 00283 if (_verbose) cout << "nearer "; 00284 } 00285 if (_verbose) cout << vc->point() << "; "<< dist << endl; 00286 } 00287 } while (++vc != done); // move on to next Voronoi neighbour 00288 // set j's supervertex info about nearest neighbour 00289 _supervertex[j].NNindex = nearest->info().val(); 00290 _supervertex[j].NNdistance = mindist; 00291 }
void fastjet::DnnPlane::_SetAndUpdateNearest | ( | const int & | j, | |
std::vector< int > & | indices_of_updated_neighbours | |||
) | [private] |
Determines and stores the nearest neighbour of j.
For each voronoi neighbour D of j if the distance between j and D is less than D's own nearest neighbour, then update the nearest-neighbour info in D; push D's index onto indices_of_updated_neighbours
Note that j is NOT pushed onto indices_of_updated_neighbours -- if you want it there, put it there yourself.
void fastjet::DnnPlane::_CrashIfVertexPresent | ( | const Vertex_handle & | vertex, | |
const int & | its_index | |||
) | [private] |
Crashes if the given vertex handle already exists.
Otherwise it does the bookkeeping for future such tests
Definition at line 80 of file DnnPlane.cc.
References _crash_on_coincidence, and fastjet::NEW_VERTEX.
00081 { 00082 if (!_crash_on_coincidence) return; 00083 00084 // vertices that do not have the same geometric position as any 00085 // other vertex so far added have info().val() == NEW_VERTEX -- this 00086 // is ensured by the InitialisedInt class, which forms the "info" 00087 // part of our 00088 // CGAL::Triangulation_vertex_base_with_info_2<InitialisedInt,K> 00089 // 00090 // If the vertex coincides with one that already exists, then 00091 // info().val() it's info().val() will have been updated (in 00092 // DNN:DNN) to be equal to a vertex "index". 00093 if (vertex->info().val() != NEW_VERTEX) { 00094 ostringstream err; 00095 err << "ERROR in DnnPlane::_CrashIfVertexPresent" 00096 <<endl << "Point "<<its_index<<" coincides with point " 00097 <<vertex->info().val() << endl; 00098 throw DnnError(err.str()); 00099 } 00100 }
std::vector<SuperVertex> fastjet::DnnPlane::_supervertex [private] |
Definition at line 91 of file DnnPlane.hh.
Referenced by _SetNearest(), eta(), etaphi(), NearestNeighbourDistance(), NearestNeighbourIndex(), phi(), and Valid().
bool fastjet::DnnPlane::_verbose [private] |
const bool fastjet::DnnPlane::_crash_on_coincidence = true [static, private] |
Triangulation fastjet::DnnPlane::_TR [private] |