30 #ifndef DROP_CGAL // in case we do not have the code for CGAL
31 #ifndef __FASTJET_DNN2PICYLINDER_HH__
32 #define __FASTJET_DNN2PICYLINDER_HH__
34 #include "fastjet/internal/DynamicNearestNeighbours.hh"
35 #include "fastjet/internal/DnnPlane.hh"
36 #include "fastjet/internal/numconsts.hh"
38 FASTJET_BEGIN_NAMESPACE
48 class Dnn2piCylinder :
public DynamicNearestNeighbours {
69 Dnn2piCylinder(
const std::vector<EtaPhi> &,
70 const bool & ignore_nearest_is_mirror =
false,
71 const bool & verbose =
false );
75 int NearestNeighbourIndex(
const int & ii)
const ;
79 double NearestNeighbourDistance(
const int & ii)
const ;
84 bool Valid(
const int & index)
const;
86 void RemoveAndAddPoints(
const std::vector<int> & indices_to_remove,
87 const std::vector<EtaPhi> & points_to_add,
88 std::vector<int> & indices_added,
89 std::vector<int> & indices_of_updated_neighbours);
96 const static int INEXISTENT_VERTEX=-3;
100 bool _ignore_nearest_is_mirror;
140 struct MirrorVertexInfo {
153 std::vector<MirrorVertexInfo> _mirror_info;
157 std::vector<int> _cylinder_index_of_plane_vertex;
168 inline EtaPhi _remap_phi(
const EtaPhi & point) {
169 double phi = point.second;
170 if (phi < pi) { phi += twopi ;}
else {phi -= twopi;}
171 return EtaPhi(point.first, phi);}
181 void _RegisterCylinderPoint (
const EtaPhi & cylinder_point,
182 std::vector<EtaPhi> & plane_points);
199 void _CreateNecessaryMirrorPoints(
200 const std::vector<int> & plane_indices,
201 std::vector<int> & updated_plane_points);
218 inline int Dnn2piCylinder::NearestNeighbourIndex(
const int & current)
const {
219 int main_index = _mirror_info[current].main_index;
220 int mirror_index = _mirror_info[current].mirror_index;
222 if (mirror_index == INEXISTENT_VERTEX ) {
223 plane_index = _DNN->NearestNeighbourIndex(main_index);
226 _DNN->NearestNeighbourDistance(main_index) <
227 _DNN->NearestNeighbourDistance(mirror_index)) ?
228 _DNN->NearestNeighbourIndex(main_index) :
229 _DNN->NearestNeighbourIndex(mirror_index) ;
231 int this_cylinder_index = _cylinder_index_of_plane_vertex[plane_index];
235 assert(_ignore_nearest_is_mirror || this_cylinder_index != current);
240 return this_cylinder_index;
243 inline double Dnn2piCylinder::NearestNeighbourDistance(
const int & current)
const {
244 int main_index = _mirror_info[current].main_index;
245 int mirror_index = _mirror_info[current].mirror_index;
246 if (mirror_index == INEXISTENT_VERTEX ) {
247 return _DNN->NearestNeighbourDistance(main_index);
250 _DNN->NearestNeighbourDistance(main_index) <
251 _DNN->NearestNeighbourDistance(mirror_index)) ?
252 _DNN->NearestNeighbourDistance(main_index) :
253 _DNN->NearestNeighbourDistance(mirror_index) ;
258 inline bool Dnn2piCylinder::Valid(
const int & index)
const {
259 return (_DNN->Valid(_mirror_info[index].main_index));
263 inline Dnn2piCylinder::~Dnn2piCylinder() {
268 FASTJET_END_NAMESPACE
270 #endif // __FASTJET_DNN2PICYLINDER_HH__