fastjet 2.4.5
|
class derived from DynamicNearestNeighbours that provides an implementation for the surface of cylinder (using one DnnPlane object spanning 0--2pi). More...
#include <Dnn2piCylinder.hh>
Classes | |
struct | MirrorVertexInfo |
Picture of how things will work... More... | |
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 |
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. | |
~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 |
class derived from DynamicNearestNeighbours that provides an implementation for the surface of cylinder (using one DnnPlane object spanning 0--2pi).
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.
{ delete _DNN; }
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)
Definition at line 107 of file Dnn2piCylinder.cc.
References fastjet::d0::inline_maths::phi(), fastjet::EtaPhi::second, and twopi.
{ vector<EtaPhi> new_plane_points; for (size_t i = 0; i < plane_indices.size(); i++) { int ip = plane_indices[i]; // plane index EtaPhi position = _DNN->etaphi(ip); double phi = position.second; //BAD // require phi < pi //BAD if (phi >= pi) {continue;} // require absence of mirror int ic = _cylinder_index_of_plane_vertex[ip]; if (_mirror_info[ic].mirror_index != INEXISTENT_VERTEX) {continue;} //printf("%3d %3d %10.5f %10.5f %3d\n",ic, ip, phi, // _DNN->NearestNeighbourDistance(ip),_DNN->NearestNeighbourIndex(ip)); // check that we are sufficiently close to the border -- // i.e. closer than nearest neighbour distance. But RECALL: // nearest neighbourDistance actually returns a squared distance // (this was really stupid on our part -- caused considerable loss // of time ... ) double nndist = _DNN->NearestNeighbourDistance(ip); if (phi*phi >= nndist && (twopi-phi)*(twopi-phi) >= nndist) {continue;} // now proceed to prepare the point for addition new_plane_points.push_back(_remap_phi(position)); _mirror_info[ic].mirror_index = _cylinder_index_of_plane_vertex.size(); _cylinder_index_of_plane_vertex.push_back(ic); } vector<int> indices_to_remove; // empty vector<int> indices_added; // will be filled as result of call _DNN->RemoveAndAddPoints(indices_to_remove,new_plane_points,indices_added, updated_plane_points); // occasionally, addition of points might cause a change in the // nearest neighbour of a point in the 0--pi range? (But should be // impossible -- we add points beyond 2pi, so they can only be // nearest neighbours of points in the range pi--2pi; there is one // exception -- the nearest neighbour of one's self -- but in that // case this will already have been discovered, so there should be // nothing left to do). // To be on the safe side, check to see if we have updated points // with phi<pi and no current mirror point. BUT: this check, as // written, only makes sense when the mirror image was created only // beyond 2pi, which is no longer the case. Only apparent // alternative is to run separate insertions for beyond 2pi and // below phi=0, with separate checks in the two cases. But, given // that across a large number of recombinations and events in the // old method (single mirror), we never ran into this problem, it's // probably safe to assume that the arguments given above are OK! So // comment out the check... //NOTNEEDED for (size_t i = 0; i < updated_plane_points.size(); i++) { //NOTNEEDED int ip = updated_plane_points[i]; //NOTNEEDED double phi = _DNN->phi(ip); //NOTNEEDED int ic = _cylinder_index_of_plane_vertex[ip]; //NOTNEEDED assert (!(phi < pi && _mirror_info[ic].mirror_index == INEXISTENT_VERTEX)); //NOTNEEDED } // alternative recursive code //vector<int> extra_updated_plane_points; //_CreateNecessaryMirrorPoints(updated_plane_points,extra_updated_plane_points) //updated_plane_points.push_back(extra_updated_plane_points); }
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.
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::d0::inline_maths::phi(), fastjet::pi, fastjet::EtaPhi::second, and twopi.
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.
{ int main_index = _mirror_info[current].main_index; int mirror_index = _mirror_info[current].mirror_index; if (mirror_index == INEXISTENT_VERTEX ) { return _DNN->NearestNeighbourDistance(main_index); } else { return ( _DNN->NearestNeighbourDistance(main_index) < _DNN->NearestNeighbourDistance(mirror_index)) ? _DNN->NearestNeighbourDistance(main_index) : _DNN->NearestNeighbourDistance(mirror_index) ; } }
int fastjet::Dnn2piCylinder::NearestNeighbourIndex | ( | const int & | current | ) | const [inline, virtual] |
Returns the index of the nearest neighbour of point labelled by ii (assumes ii is valid)
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.
{ int main_index = _mirror_info[current].main_index; int mirror_index = _mirror_info[current].mirror_index; int plane_index; if (mirror_index == INEXISTENT_VERTEX ) { plane_index = _DNN->NearestNeighbourIndex(main_index); } else { plane_index = ( _DNN->NearestNeighbourDistance(main_index) < _DNN->NearestNeighbourDistance(mirror_index)) ? _DNN->NearestNeighbourIndex(main_index) : _DNN->NearestNeighbourIndex(mirror_index) ; } int this_cylinder_index = _cylinder_index_of_plane_vertex[plane_index]; // either the user has acknowledged the fact that they may get the // mirror copy as the closest point, or crash if it should occur // that mirror copy is the closest point. assert(_ignore_nearest_is_mirror || this_cylinder_index != current); //if (this_cylinder_index == current) { // cerr << "WARNING point "<<current<< // " has its mirror copy as its own nearest neighbour"<<endl; //} return this_cylinder_index; }
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.
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.
Implements fastjet::DynamicNearestNeighbours.
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.
{ return (_DNN->Valid(_mirror_info[index].main_index)); }
std::vector<int> fastjet::Dnn2piCylinder::_cylinder_index_of_plane_vertex [private] |
Definition at line 153 of file Dnn2piCylinder.hh.
DnnPlane* fastjet::Dnn2piCylinder::_DNN [private] |
Definition at line 159 of file Dnn2piCylinder.hh.
bool fastjet::Dnn2piCylinder::_ignore_nearest_is_mirror [private] |
Definition at line 96 of file Dnn2piCylinder.hh.
std::vector<MirrorVertexInfo> fastjet::Dnn2piCylinder::_mirror_info [private] |
Definition at line 149 of file Dnn2piCylinder.hh.
bool fastjet::Dnn2piCylinder::_verbose [private] |
Definition at line 94 of file Dnn2piCylinder.hh.
const int fastjet::Dnn2piCylinder::INEXISTENT_VERTEX = -3 [static, private] |
Definition at line 92 of file Dnn2piCylinder.hh.