fastjet 2.4.5
|
Abstract base class for quick location of nearest neighbours in a set of points, with facilities for adding and removing points from the set after initialisation. More...
#include <DynamicNearestNeighbours.hh>
Public Member Functions | |
virtual int | NearestNeighbourIndex (const int &ii) const =0 |
Dummy initialiser --- does nothing! | |
virtual double | NearestNeighbourDistance (const int &ii) const =0 |
Returns the distance to the nearest neighbour of point labelled by index ii (assumes ii is valid) | |
virtual bool | Valid (const int &index) const =0 |
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) | |
virtual 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)=0 |
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. | |
void | RemovePoint (const int &index, std::vector< int > &indices_of_updated_neighbours) |
Remove the point labelled by index and return the list of points whose nearest neighbours have changed in the process. | |
void | RemoveCombinedAddCombination (const int &index1, const int &index2, const EtaPhi &newpoint, int &index3, std::vector< int > &indices_of_updated_neighbours) |
Removes the two points labelled by index1, index2 and adds in the a point with coordinates newpoint; it returns an index for the new point (index 3) and a std::vector of indices of neighbours whose nearest neighbour has changed (the list includes index3, i.e. | |
virtual | ~DynamicNearestNeighbours () |
destructor -- here it is now implemented |
Abstract base class for quick location of nearest neighbours in a set of points, with facilities for adding and removing points from the set after initialisation.
Derived classes will be named according to the convention DnnSomeName (e.g. DnnPlane).
The main purpose of this abstract base class is to define the general interface of a whole set of classes that deal with nearest-neighbour location on different 2-d geometries and with various underlying data structures and algorithms.
Definition at line 89 of file DynamicNearestNeighbours.hh.
virtual fastjet::DynamicNearestNeighbours::~DynamicNearestNeighbours | ( | ) | [inline, virtual] |
destructor -- here it is now implemented
Definition at line 165 of file DynamicNearestNeighbours.hh.
{}
virtual double fastjet::DynamicNearestNeighbours::NearestNeighbourDistance | ( | const int & | ii | ) | const [pure virtual] |
Returns the distance to the nearest neighbour of point labelled by index ii (assumes ii is valid)
Implemented in fastjet::Dnn2piCylinder, fastjet::Dnn3piCylinder, fastjet::Dnn4piCylinder, and fastjet::DnnPlane.
Referenced by fastjet::ClusterSequence::_add_ktdistance_to_map().
virtual int fastjet::DynamicNearestNeighbours::NearestNeighbourIndex | ( | const int & | ii | ) | const [pure virtual] |
Dummy initialiser --- does nothing!
Initialiser --- sets up the necessary structures to allow efficient nearest-neighbour finding on the std::vector<EtaPhi> of input points Returns the index of the nearest neighbour of point labelled by ii (assumes ii is valid)
Implemented in fastjet::Dnn2piCylinder, fastjet::Dnn3piCylinder, fastjet::Dnn4piCylinder, and fastjet::DnnPlane.
Referenced by fastjet::ClusterSequence::_add_ktdistance_to_map().
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 | ||
) | [pure 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.
remove the points labelled by the vector indices_to_remove, and add the points specified by the 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.
insertion and removal of points
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.
Implemented in fastjet::Dnn2piCylinder, fastjet::Dnn3piCylinder, fastjet::Dnn4piCylinder, and fastjet::DnnPlane.
Definition at line 183 of file Dnn2piCylinder.cc.
{ // translate from "cylinder" indices of points to remove to the // plane indices of points to remove, bearing in mind that sometimes // there are multple plane points to remove. vector<int> plane_indices_to_remove; for (unsigned int i=0; i < indices_to_remove.size(); i++) { MirrorVertexInfo * mvi; mvi = & _mirror_info[indices_to_remove[i]]; plane_indices_to_remove.push_back(mvi->main_index); if (mvi->mirror_index != INEXISTENT_VERTEX) { plane_indices_to_remove.push_back(mvi->mirror_index); } } // given "cylinder" points to add get hold of the list of // plane-points to add. vector<EtaPhi> plane_points_to_add; indices_added.clear(); for (unsigned int i=0; i < points_to_add.size(); i++) { indices_added.push_back(_mirror_info.size()); _RegisterCylinderPoint(points_to_add[i], plane_points_to_add); } // now get the hard work done (note that we need to supply the // plane_indices_added vector but that we will not actually check // its contents in any way -- the indices_added that is actually // returned has been calculated above). vector<int> updated_plane_neighbours, plane_indices_added; _DNN->RemoveAndAddPoints(plane_indices_to_remove, plane_points_to_add, plane_indices_added, updated_plane_neighbours); vector<int> extra_updated_plane_neighbours; _CreateNecessaryMirrorPoints(updated_plane_neighbours, extra_updated_plane_neighbours); // extract, from the updated_plane_neighbours, and // extra_updated_plane_neighbours, the set of cylinder neighbours // that have changed set<int> index_set; unsigned int i; for (i=0; i < updated_plane_neighbours.size(); i++) { index_set.insert( _cylinder_index_of_plane_vertex[updated_plane_neighbours[i]]);} for (i=0; i < extra_updated_plane_neighbours.size(); i++) { index_set.insert( _cylinder_index_of_plane_vertex[extra_updated_plane_neighbours[i]]);} // decant the set into the vector that needs to be returned indices_of_updated_neighbours.clear(); for (set<int>::iterator iter = index_set.begin(); iter != index_set.end(); iter++) { indices_of_updated_neighbours.push_back(*iter); } }
void fastjet::DynamicNearestNeighbours::RemoveCombinedAddCombination | ( | const int & | index1, |
const int & | index2, | ||
const EtaPhi & | newpoint, | ||
int & | index3, | ||
std::vector< int > & | indices_of_updated_neighbours | ||
) | [inline] |
Removes the two points labelled by index1, index2 and adds in the a point with coordinates newpoint; it returns an index for the new point (index 3) and a std::vector of indices of neighbours whose nearest neighbour has changed (the list includes index3, i.e.
the new point).
Definition at line 147 of file DynamicNearestNeighbours.hh.
Referenced by fastjet::ClusterSequence::_delaunay_cluster().
{ std::vector<int> indices_added(1); std::vector<EtaPhi> points_to_add(1); std::vector<int> indices_to_remove(2); indices_to_remove[0] = index1; indices_to_remove[1] = index2; points_to_add[0] = newpoint; RemoveAndAddPoints(indices_to_remove, points_to_add, indices_added, indices_of_updated_neighbours ); index3 = indices_added[0]; };
void fastjet::DynamicNearestNeighbours::RemovePoint | ( | const int & | index, |
std::vector< int > & | indices_of_updated_neighbours | ||
) | [inline] |
Remove the point labelled by index and return the list of points whose nearest neighbours have changed in the process.
Definition at line 131 of file DynamicNearestNeighbours.hh.
Referenced by fastjet::ClusterSequence::_delaunay_cluster().
{ std::vector<int> indices_added; std::vector<EtaPhi> points_to_add; std::vector<int> indices_to_remove(1); indices_to_remove[0] = index; RemoveAndAddPoints(indices_to_remove, points_to_add, indices_added, indices_of_updated_neighbours );};
virtual bool fastjet::DynamicNearestNeighbours::Valid | ( | const int & | index | ) | const [pure 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)
Implemented in fastjet::Dnn2piCylinder, fastjet::Dnn3piCylinder, fastjet::Dnn4piCylinder, and fastjet::DnnPlane.
Referenced by fastjet::ClusterSequence::_delaunay_cluster().