32 #ifndef DROP_CGAL // in case we do not have the code for CGAL 
   33 #ifndef __FASTJET_DNN2PICYLINDER_HH__ 
   34 #define __FASTJET_DNN2PICYLINDER_HH__ 
   36 #include "fastjet/internal/DynamicNearestNeighbours.hh" 
   37 #include "fastjet/internal/DnnPlane.hh" 
   38 #include "fastjet/internal/numconsts.hh" 
   40 FASTJET_BEGIN_NAMESPACE      
 
   50 class Dnn2piCylinder : 
public DynamicNearestNeighbours {
 
   71   Dnn2piCylinder(
const std::vector<EtaPhi> &,
 
   72                  const bool & ignore_nearest_is_mirror = 
false,
 
   73                  const bool & verbose = 
false );
 
   77   int NearestNeighbourIndex(
const int ii) 
const ;
 
   81   double NearestNeighbourDistance(
const int ii) 
const ;
 
   86   bool Valid(
const int index) 
const;
 
   88   void RemoveAndAddPoints(
const std::vector<int> & indices_to_remove,
 
   89                           const std::vector<EtaPhi> & points_to_add,
 
   90                           std::vector<int> & indices_added,
 
   91                           std::vector<int> & indices_of_updated_neighbours);
 
   98   const static int INEXISTENT_VERTEX=-3;
 
  102   bool _ignore_nearest_is_mirror;
 
  142   struct MirrorVertexInfo {
 
  155   std::vector<MirrorVertexInfo> _mirror_info;
 
  159   std::vector<int> _cylinder_index_of_plane_vertex;
 
  170   inline EtaPhi _remap_phi(
const EtaPhi & point) {
 
  171     double phi = point.second;
 
  172     if (phi < pi) { phi += twopi ;} 
else {phi -= twopi;}
 
  173     return EtaPhi(point.first, phi);}
 
  183   void _RegisterCylinderPoint (
const EtaPhi & cylinder_point,
 
  184                                std::vector<EtaPhi> & plane_points);
 
  201   void _CreateNecessaryMirrorPoints(
 
  202                           const std::vector<int> & plane_indices,
 
  203                           std::vector<int> & updated_plane_points);
 
  220 inline int Dnn2piCylinder::NearestNeighbourIndex(
const int current)
 const {
 
  221   int main_index = _mirror_info[current].main_index;
 
  222   int mirror_index = _mirror_info[current].mirror_index;
 
  224   if (mirror_index == INEXISTENT_VERTEX ) {
 
  225     plane_index = _DNN->NearestNeighbourIndex(main_index);
 
  228         _DNN->NearestNeighbourDistance(main_index) < 
 
  229         _DNN->NearestNeighbourDistance(mirror_index)) ? 
 
  230       _DNN->NearestNeighbourIndex(main_index) : 
 
  231       _DNN->NearestNeighbourIndex(mirror_index) ; 
 
  233   int this_cylinder_index = _cylinder_index_of_plane_vertex[plane_index];
 
  237   assert(_ignore_nearest_is_mirror || this_cylinder_index != current);
 
  242   return this_cylinder_index;
 
  245 inline double Dnn2piCylinder::NearestNeighbourDistance(
const int current)
 const {
 
  246   int main_index = _mirror_info[current].main_index;
 
  247   int mirror_index = _mirror_info[current].mirror_index;
 
  248   if (mirror_index == INEXISTENT_VERTEX ) {
 
  249     return _DNN->NearestNeighbourDistance(main_index);
 
  252         _DNN->NearestNeighbourDistance(main_index) < 
 
  253         _DNN->NearestNeighbourDistance(mirror_index)) ? 
 
  254       _DNN->NearestNeighbourDistance(main_index) : 
 
  255       _DNN->NearestNeighbourDistance(mirror_index) ; 
 
  260 inline bool Dnn2piCylinder::Valid(
const int index)
 const {
 
  261   return (_DNN->Valid(_mirror_info[index].main_index));
 
  265 inline Dnn2piCylinder::~Dnn2piCylinder() {
 
  270 FASTJET_END_NAMESPACE
 
  272 #endif //  __FASTJET_DNN2PICYLINDER_HH__