Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

fastjet::Dnn3piCylinder Class Reference

class derived from DynamicNearestNeighbours that provides an implementation for the surface of cylinder (using one DnnPlane object spanning 0--3pi). More...

#include <Dnn3piCylinder.hh>

Inheritance diagram for fastjet::Dnn3piCylinder:

Inheritance graph
[legend]
Collaboration diagram for fastjet::Dnn3piCylinder:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Dnn3piCylinder ()
 empty initaliser
 Dnn3piCylinder (const std::vector< EtaPhi > &, const bool &ignore_nearest_is_mirror=false, const bool &verbose=false)
 initialiser...
int NearestNeighbourIndex (const int &ii) const
 Note: one of the difficulties of the 0--3pi 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)
 insertion and removal of points
 ~Dnn3piCylinder ()

Private Member Functions

EtaPhi _remap_phi (const EtaPhi &point)
 given a phi value in the 0--2pi range return one in the pi--3pi range.
void _RegisterCylinderPoint (const EtaPhi &cylinder_point, std::vector< EtaPhi > &plane_points)
 What on earth does this do?

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

Detailed Description

class derived from DynamicNearestNeighbours that provides an implementation for the surface of cylinder (using one DnnPlane object spanning 0--3pi).

Definition at line 45 of file Dnn3piCylinder.hh.


Constructor & Destructor Documentation

fastjet::Dnn3piCylinder::Dnn3piCylinder  )  [inline]
 

empty initaliser

Definition at line 48 of file Dnn3piCylinder.hh.

00048 {}

fastjet::Dnn3piCylinder::Dnn3piCylinder const std::vector< EtaPhi > &  ,
const bool &  ignore_nearest_is_mirror = false,
const bool &  verbose = false
 

initialiser...

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).

Definition at line 41 of file Dnn3piCylinder.cc.

References _DNN, _ignore_nearest_is_mirror, _RegisterCylinderPoint(), and _verbose.

00044                               {
00045   
00046   _verbose = verbose;
00047   _ignore_nearest_is_mirror = ignore_nearest_is_mirror;
00048   vector<EtaPhi> plane_points;
00049   //plane_points.reserve(2*input_points.size());
00050 
00051   for (unsigned int i=0; i < input_points.size(); i++) {
00052     _RegisterCylinderPoint(input_points[i], plane_points);
00053   }
00054 
00055   if (_verbose) cout << "============== Preparing _DNN" << endl;
00056   _DNN = new DnnPlane(plane_points, verbose);
00057 }

fastjet::Dnn3piCylinder::~Dnn3piCylinder  )  [inline]
 

Definition at line 249 of file Dnn3piCylinder.hh.

References _DNN.

00249                                        {
00250   delete _DNN; 
00251 }


Member Function Documentation

void fastjet::Dnn3piCylinder::_RegisterCylinderPoint const EtaPhi cylinder_point,
std::vector< EtaPhi > &  plane_points
[private]
 

What on earth does this do?

Example: last true "cylinder" index was 15 last plane index was 23

Then: _cylinder_index_of_plane_vertex.size() = 24 and _mirror_info.size() = 16

IF cylinder_point's phi < pi then create: _mirror_info[16] = (main_index = 24, mirror_index=25) _cylinder_index_of_plane_vertex[24] = 16 _cylinder_index_of_plane_vertex[25] = 16 ELSE create: _mirror_info[16] = (main_index = 24, mirror_index=INEXISTENT..) _cylinder_index_of_plane_vertex[24] = 16

ADDITIONALLY push the cylinder_point (and if it exists the mirror copy) onto the vector plane_points.

Definition at line 79 of file Dnn3piCylinder.cc.

References _cylinder_index_of_plane_vertex, _mirror_info, _remap_phi(), INEXISTENT_VERTEX, fastjet::Dnn3piCylinder::MirrorVertexInfo::main_index, fastjet::Dnn3piCylinder::MirrorVertexInfo::mirror_index, fastjet::pi, and fastjet::EtaPhi::second.

Referenced by Dnn3piCylinder(), and RemoveAndAddPoints().

00080                                                                             {
00081   double phi = cylinder_point.second;
00082   assert(phi >= 0.0 && phi < 2*pi);
00083   
00084   // do main point
00085   MirrorVertexInfo mvi;
00086   mvi.main_index = _cylinder_index_of_plane_vertex.size();
00087   _cylinder_index_of_plane_vertex.push_back(_mirror_info.size());
00088   plane_points.push_back(cylinder_point);
00089   
00090   // do mirror point if need be
00091   if (phi < pi) {
00092     mvi.mirror_index = _cylinder_index_of_plane_vertex.size();
00093     _cylinder_index_of_plane_vertex.push_back(_mirror_info.size());
00094     plane_points.push_back(_remap_phi(cylinder_point));
00095   } else {
00096     mvi.mirror_index = INEXISTENT_VERTEX;
00097   }
00098   
00099   // 
00100   _mirror_info.push_back(mvi);
00101 }

EtaPhi fastjet::Dnn3piCylinder::_remap_phi const EtaPhi point  )  [inline, private]
 

given a phi value in the 0--2pi range return one in the pi--3pi range.

Definition at line 162 of file Dnn3piCylinder.hh.

References fastjet::EtaPhi::first, fastjet::pi, fastjet::EtaPhi::second, and twopi.

Referenced by _RegisterCylinderPoint().

00162                                                  {
00163     double phi = point.second;
00164     if (phi < pi) { phi += twopi ;}
00165     return EtaPhi(point.first, phi);}

double fastjet::Dnn3piCylinder::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 229 of file Dnn3piCylinder.hh.

References _DNN, _mirror_info, INEXISTENT_VERTEX, and fastjet::DnnPlane::NearestNeighbourDistance().

00229                                                                                 {
00230   int main_index = _mirror_info[current].main_index;
00231   int mirror_index = _mirror_info[current].mirror_index;
00232   if (mirror_index == INEXISTENT_VERTEX ) {
00233     return _DNN->NearestNeighbourDistance(main_index);
00234   } else {
00235     return (
00236         _DNN->NearestNeighbourDistance(main_index) < 
00237         _DNN->NearestNeighbourDistance(mirror_index)) ? 
00238       _DNN->NearestNeighbourDistance(main_index) : 
00239       _DNN->NearestNeighbourDistance(mirror_index) ; 
00240   }
00241  
00242 }

int fastjet::Dnn3piCylinder::NearestNeighbourIndex const int &  current  )  const [inline, virtual]
 

Note: one of the difficulties of the 0--3pi 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 204 of file Dnn3piCylinder.hh.

References _cylinder_index_of_plane_vertex, _DNN, _ignore_nearest_is_mirror, _mirror_info, INEXISTENT_VERTEX, fastjet::DnnPlane::NearestNeighbourDistance(), and fastjet::DnnPlane::NearestNeighbourIndex().

00204                                                                           {
00205   int main_index = _mirror_info[current].main_index;
00206   int mirror_index = _mirror_info[current].mirror_index;
00207   int plane_index;
00208   if (mirror_index == INEXISTENT_VERTEX ) {
00209     plane_index = _DNN->NearestNeighbourIndex(main_index);
00210   } else {
00211     plane_index = (
00212         _DNN->NearestNeighbourDistance(main_index) < 
00213         _DNN->NearestNeighbourDistance(mirror_index)) ? 
00214       _DNN->NearestNeighbourIndex(main_index) : 
00215       _DNN->NearestNeighbourIndex(mirror_index) ; 
00216   }
00217   int this_cylinder_index = _cylinder_index_of_plane_vertex[plane_index];
00218   // either the user has acknowledged the fact that they may get the
00219   // mirror copy as the closest point, or crash if it should occur
00220   // that mirror copy is the closest point.
00221   assert(_ignore_nearest_is_mirror || this_cylinder_index != current);
00222   //if (this_cylinder_index == current) {
00223   //  std::cerr << "WARNING point "<<current<<
00224   //    " has its mirror copy as its own nearest neighbour"<<endl;
00225   //}
00226   return this_cylinder_index;
00227 }

void fastjet::Dnn3piCylinder::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]
 

insertion and removal of points

Implements fastjet::DynamicNearestNeighbours.

Definition at line 106 of file Dnn3piCylinder.cc.

References _cylinder_index_of_plane_vertex, _DNN, _mirror_info, _RegisterCylinderPoint(), INEXISTENT_VERTEX, fastjet::Dnn3piCylinder::MirrorVertexInfo::main_index, fastjet::Dnn3piCylinder::MirrorVertexInfo::mirror_index, and fastjet::DnnPlane::RemoveAndAddPoints().

00109                                                                              {
00110 
00111   // translate from "cylinder" indices of points to remove to the
00112   // plane indices of points to remove, bearing in mind that sometimes
00113   // there are multple plane points to remove.
00114   vector<int> plane_indices_to_remove;
00115   for (unsigned int i=0; i < indices_to_remove.size(); i++) {
00116     MirrorVertexInfo * mvi;
00117     mvi = & _mirror_info[indices_to_remove[i]];
00118     plane_indices_to_remove.push_back(mvi->main_index);
00119     if (mvi->mirror_index != INEXISTENT_VERTEX) {
00120       plane_indices_to_remove.push_back(mvi->mirror_index);
00121     }
00122   }
00123 
00124   // given "cylinder" points to add get hold of the list of
00125   // plane-points to add.
00126   vector<EtaPhi> plane_points_to_add;
00127   indices_added.clear();
00128   for (unsigned int i=0; i < points_to_add.size(); i++) {
00129     indices_added.push_back(_mirror_info.size());
00130     _RegisterCylinderPoint(points_to_add[i], plane_points_to_add);
00131   }
00132 
00133   // now get the hard work done (note that we need to supply the
00134   // plane_indices_added vector but that we will not actually check
00135   // its contents in any way -- the indices_added that is actually
00136   // returned has been calculated above).
00137   vector<int> updated_plane_neighbours, plane_indices_added;
00138   _DNN->RemoveAndAddPoints(plane_indices_to_remove, plane_points_to_add,
00139                              plane_indices_added, updated_plane_neighbours);
00140 
00141   // extract, from the updated_plane_neighbours, the set of cylinder
00142   // neighbours that have changed
00143   set<int> index_set;
00144   unsigned int i;
00145   for (i=0; i < updated_plane_neighbours.size(); i++) {
00146     index_set.insert(
00147        _cylinder_index_of_plane_vertex[updated_plane_neighbours[i]]);}
00148 
00149   // decant the set into the vector that needs to be returned
00150   indices_of_updated_neighbours.clear();
00151   for (set<int>::iterator iter = index_set.begin(); 
00152        iter != index_set.end(); iter++) {
00153     indices_of_updated_neighbours.push_back(*iter);
00154   }
00155 }

bool fastjet::Dnn3piCylinder::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 244 of file Dnn3piCylinder.hh.

References _DNN, _mirror_info, and fastjet::DnnPlane::Valid().

00244                                                          {
00245   return (_DNN->Valid(_mirror_info[index].main_index));
00246 }


Member Data Documentation

std::vector<int> fastjet::Dnn3piCylinder::_cylinder_index_of_plane_vertex [private]
 

Definition at line 152 of file Dnn3piCylinder.hh.

Referenced by _RegisterCylinderPoint(), NearestNeighbourIndex(), and RemoveAndAddPoints().

DnnPlane* fastjet::Dnn3piCylinder::_DNN [private]
 

Definition at line 158 of file Dnn3piCylinder.hh.

Referenced by Dnn3piCylinder(), NearestNeighbourDistance(), NearestNeighbourIndex(), RemoveAndAddPoints(), Valid(), and ~Dnn3piCylinder().

bool fastjet::Dnn3piCylinder::_ignore_nearest_is_mirror [private]
 

Definition at line 95 of file Dnn3piCylinder.hh.

Referenced by Dnn3piCylinder(), and NearestNeighbourIndex().

std::vector<MirrorVertexInfo> fastjet::Dnn3piCylinder::_mirror_info [private]
 

Definition at line 148 of file Dnn3piCylinder.hh.

Referenced by _RegisterCylinderPoint(), NearestNeighbourDistance(), NearestNeighbourIndex(), RemoveAndAddPoints(), and Valid().

bool fastjet::Dnn3piCylinder::_verbose [private]
 

Definition at line 93 of file Dnn3piCylinder.hh.

Referenced by Dnn3piCylinder().

const int fastjet::Dnn3piCylinder::INEXISTENT_VERTEX = -3 [static, private]
 

Definition at line 91 of file Dnn3piCylinder.hh.

Referenced by _RegisterCylinderPoint(), NearestNeighbourDistance(), NearestNeighbourIndex(), and RemoveAndAddPoints().


The documentation for this class was generated from the following files:
Generated on Mon Apr 2 20:58:22 2007 for fastjet by  doxygen 1.4.2