#include <Dnn2piCylinder.hh>
Inheritance diagram for fastjet::Dnn2piCylinder:
Public Member Functions | |
Dnn2piCylinder () | |
empty initaliser | |
Dnn2piCylinder (const std::vector< EtaPhi > &, const bool &ignore_nearest_is_mirror=false, const bool &verbose=false) | |
Initialiser from a set of points on an Eta-Phi plane, where eta can have an arbitrary ranges and phi must be in range 0 <= phi < 2pi;. | |
int | NearestNeighbourIndex (const int &ii) const |
Note: one of the difficulties of the 0--2pi mapping is that a point may have its mirror copy as its own nearest neighbour (if no other point is within a distance of 2pi). | |
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. | |
~Dnn2piCylinder () | |
Private Member Functions | |
EtaPhi | _remap_phi (const EtaPhi &point) |
given a phi value in the 0--pi range return one in the 2pi--3pi range; whereas if it is in the pi-2pi range then remap it to be inthe range (-pi)--0. | |
void | _RegisterCylinderPoint (const EtaPhi &cylinder_point, std::vector< EtaPhi > &plane_points) |
Actions here are similar to those in the Dnn3piCylinder::_RegisterCylinderPoint case, however here we do NOT create the mirror point -- instead we initialise the structure as if there were no need for the mirror point. | |
void | _CreateNecessaryMirrorPoints (const std::vector< int > &plane_indices, std::vector< int > &updated_plane_points) |
For each plane point specified in the vector plane_indices, establish whether there is a need to create a mirror point according to the following criteria:. | |
Private Attributes | |
bool | _verbose |
bool | _ignore_nearest_is_mirror |
std::vector< MirrorVertexInfo > | _mirror_info |
std::vector< int > | _cylinder_index_of_plane_vertex |
DnnPlane * | _DNN |
Static Private Attributes | |
static const int | INEXISTENT_VERTEX = -3 |
Classes | |
struct | MirrorVertexInfo |
Definition at line 46 of file Dnn2piCylinder.hh.
fastjet::Dnn2piCylinder::Dnn2piCylinder | ( | ) | [inline] |
fastjet::Dnn2piCylinder::Dnn2piCylinder | ( | const std::vector< EtaPhi > & | , | |
const bool & | ignore_nearest_is_mirror = false , |
|||
const bool & | verbose = false | |||
) |
Initialiser from a set of points on an Eta-Phi plane, where eta can have an arbitrary ranges and phi must be in range 0 <= phi < 2pi;.
NB: this class is more efficient than the plain Dnn4piCylinder class, but can give wrong answers when the nearest neighbour is further away than 2pi (in this case a point's nearest neighbour becomes itself, because it is considered to be a distance 2pi away). For the kt-algorithm (e.g.) this is actually not a problem (the distance need only be accurate when it is less than R), so we can tell the routine to ignore this problem -- alternatively the routine will crash if it detects it occurring (only when finding the nearest neighbour index, not its distance).
fastjet::Dnn2piCylinder::~Dnn2piCylinder | ( | ) | [inline] |
Definition at line 259 of file Dnn2piCylinder.hh.
References _DNN.
00259 { 00260 delete _DNN; 00261 }
int fastjet::Dnn2piCylinder::NearestNeighbourIndex | ( | const int & | current | ) | const [inline, virtual] |
Note: one of the difficulties of the 0--2pi mapping is that a point may have its mirror copy as its own nearest neighbour (if no other point is within a distance of 2pi).
This does not matter for the kt_algorithm with reasonable values of radius, but might matter for a general use of this algorithm -- depending on whether or not the user has initialised the class with instructions to ignore this problem the program will detect and ignore it, or crash.
Implements fastjet::DynamicNearestNeighbours.
Definition at line 214 of file Dnn2piCylinder.hh.
References _cylinder_index_of_plane_vertex, _DNN, _ignore_nearest_is_mirror, _mirror_info, INEXISTENT_VERTEX, fastjet::DnnPlane::NearestNeighbourDistance(), and fastjet::DnnPlane::NearestNeighbourIndex().
00214 { 00215 int main_index = _mirror_info[current].main_index; 00216 int mirror_index = _mirror_info[current].mirror_index; 00217 int plane_index; 00218 if (mirror_index == INEXISTENT_VERTEX ) { 00219 plane_index = _DNN->NearestNeighbourIndex(main_index); 00220 } else { 00221 plane_index = ( 00222 _DNN->NearestNeighbourDistance(main_index) < 00223 _DNN->NearestNeighbourDistance(mirror_index)) ? 00224 _DNN->NearestNeighbourIndex(main_index) : 00225 _DNN->NearestNeighbourIndex(mirror_index) ; 00226 } 00227 int this_cylinder_index = _cylinder_index_of_plane_vertex[plane_index]; 00228 // either the user has acknowledged the fact that they may get the 00229 // mirror copy as the closest point, or crash if it should occur 00230 // that mirror copy is the closest point. 00231 assert(_ignore_nearest_is_mirror || this_cylinder_index != current); 00232 //if (this_cylinder_index == current) { 00233 // cerr << "WARNING point "<<current<< 00234 // " has its mirror copy as its own nearest neighbour"<<endl; 00235 //} 00236 return this_cylinder_index; 00237 }
double fastjet::Dnn2piCylinder::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 239 of file Dnn2piCylinder.hh.
References _DNN, _mirror_info, INEXISTENT_VERTEX, and fastjet::DnnPlane::NearestNeighbourDistance().
00239 { 00240 int main_index = _mirror_info[current].main_index; 00241 int mirror_index = _mirror_info[current].mirror_index; 00242 if (mirror_index == INEXISTENT_VERTEX ) { 00243 return _DNN->NearestNeighbourDistance(main_index); 00244 } else { 00245 return ( 00246 _DNN->NearestNeighbourDistance(main_index) < 00247 _DNN->NearestNeighbourDistance(mirror_index)) ? 00248 _DNN->NearestNeighbourDistance(main_index) : 00249 _DNN->NearestNeighbourDistance(mirror_index) ; 00250 } 00251 00252 }
bool fastjet::Dnn2piCylinder::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 254 of file Dnn2piCylinder.hh.
References _DNN, _mirror_info, and fastjet::DnnPlane::Valid().
00254 { 00255 return (_DNN->Valid(_mirror_info[index].main_index)); 00256 }
void fastjet::Dnn2piCylinder::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.
given a phi value in the 0--pi range return one in the 2pi--3pi range; whereas if it is in the pi-2pi range then remap it to be inthe range (-pi)--0.
Definition at line 164 of file Dnn2piCylinder.hh.
References fastjet::EtaPhi::first, fastjet::pi, fastjet::EtaPhi::second, and twopi.
00164 { 00165 double phi = point.second; 00166 if (phi < pi) { phi += twopi ;} else {phi -= twopi;} 00167 return EtaPhi(point.first, phi);}
void fastjet::Dnn2piCylinder::_RegisterCylinderPoint | ( | const EtaPhi & | cylinder_point, | |
std::vector< EtaPhi > & | plane_points | |||
) | [private] |
Actions here are similar to those in the Dnn3piCylinder::_RegisterCylinderPoint case, however here we do NOT create the mirror point -- instead we initialise the structure as if there were no need for the mirror point.
ADDITIONALLY push the cylinder_point onto the vector plane_points.
void fastjet::Dnn2piCylinder::_CreateNecessaryMirrorPoints | ( | const std::vector< int > & | plane_indices, | |
std::vector< int > & | updated_plane_points | |||
) | [private] |
For each plane point specified in the vector plane_indices, establish whether there is a need to create a mirror point according to the following criteria:.
. phi < pi . mirror does not already exist . phi < NearestNeighbourDistance (if this is not true then there is no way that its mirror point could have a nearer neighbour).
If conditions all hold, then create the mirror point, insert it into the _DNN structure, adjusting any nearest neighbours, and return the list of plane points whose nearest neighbours have changed (this will include the new neighbours that have just been added)
const int fastjet::Dnn2piCylinder::INEXISTENT_VERTEX = -3 [static, private] |
Definition at line 92 of file Dnn2piCylinder.hh.
Referenced by NearestNeighbourDistance(), and NearestNeighbourIndex().
bool fastjet::Dnn2piCylinder::_verbose [private] |
Definition at line 94 of file Dnn2piCylinder.hh.
bool fastjet::Dnn2piCylinder::_ignore_nearest_is_mirror [private] |
std::vector<MirrorVertexInfo> fastjet::Dnn2piCylinder::_mirror_info [private] |
Definition at line 149 of file Dnn2piCylinder.hh.
Referenced by NearestNeighbourDistance(), NearestNeighbourIndex(), and Valid().
std::vector<int> fastjet::Dnn2piCylinder::_cylinder_index_of_plane_vertex [private] |
DnnPlane* fastjet::Dnn2piCylinder::_DNN [private] |
Definition at line 159 of file Dnn2piCylinder.hh.
Referenced by NearestNeighbourDistance(), NearestNeighbourIndex(), Valid(), and ~Dnn2piCylinder().